Commit e295e8e0 authored by g_harland's avatar g_harland
Browse files

Enhance "EESchema Preferences" dialog box;

sizers and OK, Cancel, and Apply buttons now provided
parent a287b16f
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,15 @@ Please add newer entries at the top, list the date and your name with
email address.
email address.




2007-Oct-23 UPDATE   Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
+ eeschema
  * Sizers have now been provided for the "EESchema Preferences" dialog box,
    together with "OK", "Cancel", and "Apply" buttons. And an additional bitmap
    button and checkbox have also been provided for the purpose of editing the
    color and visibility of the grid.


2007-Oct-21 UPDATE   Geoff Harland <gharlandau@yahoo.com.au>
2007-Oct-21 UPDATE   Geoff Harland <gharlandau@yahoo.com.au>
================================================================================
================================================================================
+ all
+ all
+284 −353
Original line number Original line Diff line number Diff line
/* Set up color Layers */
/***************/
/* eelayer.cpp */
/***************/

/* Set up color Layers for EESchema
 */

#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "eelayer.h"
#endif

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif


#include "fctsys.h"
#include "fctsys.h"
#include "gr_basic.h"
#include "gr_basic.h"
@@ -12,319 +32,166 @@


#include "protos.h"
#include "protos.h"


#include "eelayer.h"


/* Variables locales */
// Local variables:

/* Fonctions locales: */

/* Macro utile : */
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])

#define BUTT_SIZE_X 30
#define BUTT_SIZE_Y 20



enum col_sel_id {
int CurrentColor[NB_BUTT]; // Holds color for each layer while dialog box open
    ID_COLOR_SETUP = 1800
};


/**********************************/
/* Liste des menus de Menu_Layers */
/**********************************/
struct ColorButton
{
    wxString        m_Name;
    int*            m_Color;
    int             m_Id;
    wxBitmapButton* m_Button;
    int             m_State;
};

static ColorButton Msg_General =
{
    _( "General" ),                    /* Title */
    NULL
};


static ColorButton Msg_Sheets =
IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetColorsFrame, wxDialog )
{
    _( "Sheets" ),                 /* Title */
    NULL
};

static ColorButton Layer_Wire_Item =
{
    _( "Wire" ),                    /* Title */
    ADR( LAYER_WIRE )               /* adr du parametre optionnel */
};


static ColorButton Layer_Bus_Item =
// Table of events for WinEDA_SetColorsFrame
{
BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog )
    _( "Bus" ),                     /* Title */
    EVT_COMMAND_RANGE( ID_COLOR_SETUP, ID_COLOR_SETUP + NB_BUTT - 1,
    ADR( LAYER_BUS )                /* adr du parametre optionnel */
                       wxEVT_COMMAND_BUTTON_CLICKED,
};
                       WinEDA_SetColorsFrame::SetColor )

    EVT_BUTTON( wxID_OK, WinEDA_SetColorsFrame::OnOkClick )
static ColorButton Layer_Jonction_Item =
    EVT_BUTTON( wxID_CANCEL, WinEDA_SetColorsFrame::OnCancelClick )
{
    EVT_BUTTON( wxID_APPLY, WinEDA_SetColorsFrame::OnApplyClick )
    _( "Junction" ),                /* Title */
END_EVENT_TABLE()
    ADR( LAYER_JUNCTION )           /* adr du parametre optionnel */
};


static ColorButton Layer_LocalLabel_Item =
{
    _( "Label" ),               /* Title */
    ADR( LAYER_LOCLABEL )       /* adr du parametre optionnel */
};


static ColorButton Layer_GlobLabel_Item =
/**************************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
                             const wxPoint&    framepos )
/**************************************************************/
{
{
    _( "GlobLabel" ),           /* Title */
    WinEDA_SetColorsFrame* frame =
    ADR( LAYER_GLOBLABEL )      /* adr du parametre optionnel */
        new WinEDA_SetColorsFrame( parent, framepos );
};


static ColorButton Layer_PinNum_Item =
    frame->ShowModal();
{
    frame->Destroy();
    _( "PinNum" ),              /* Title */
}
    ADR( LAYER_PINNUM )         /* adr du parametre optionnel */
};


static ColorButton Layer_PinNam_Item =
{
    _( "PinNam" ),              /* Title */
    ADR( LAYER_PINNAM )         /* adr du parametre optionnel */
};


static ColorButton Layer_Reference_Item =
// Default Constructor (whose provision is mandated by the inclusion
// of DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame ) within eelayer.h)
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
{
{
    _( "Reference" ),               /* Title */
    Init();
    ADR( LAYER_REFERENCEPART )      /* adr du parametre optionnel */
}
};


static ColorButton Layer_Value_Item =
{
    _( "Value" ),               /* Title */
    ADR( LAYER_VALUEPART )      /* adr du parametre optionnel */
};


static ColorButton Layer_Fields_Item =
// Standard Constructor
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
                                              const wxPoint& framepos )
{
{
    _( "Fields" ),              /* Title */
    m_Parent = parent;
    ADR( LAYER_FIELDS )         /* adr du parametre optionnel */
    Init();
};
    Create( parent,
            SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME,
            SYMBOL_WINEDA_SETCOLORSFRAME_TITLE,
            framepos,
            wxDefaultSize,
            SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
}


static ColorButton Layer_BodyDevice_Item =
{
    _( "Body" ),                    /* Title */
    ADR( LAYER_DEVICE )             /* adr du parametre optionnel */
};


static ColorButton Layer_BodyBackgroundDevice_Item =
// Destructor
{
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame() { }
    _( "Body Bg" ),                         /* Title */
    ADR( LAYER_DEVICE_BACKGROUND )          /* adr du parametre optionnel */
};


static ColorButton MsgDevice_Item =
{
    _( "Device" ),                 /* Title */
    NULL
};


static ColorButton Layer_Notes_Item =
/**********************************************************/
bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id,
                              const wxString& caption, const wxPoint& pos,
                              const wxSize& size, long style )
/**********************************************************/
{
{
    _( "Notes" ),               /* Title */
    SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
    ADR( LAYER_NOTES )          /* adr du parametre optionnel */
    wxDialog::Create( parent, id, caption, pos, size, style );
};


static ColorButton Layer_NetNam_Item =
    CreateControls();
    if (GetSizer())
    {
    {
    _( "Netname" ),                 /* Title */
        GetSizer()->SetSizeHints(this);
    ADR( LAYER_NETNAM )             /* adr du parametre optionnel */
    }
};
    return true;
}


static ColorButton Layer_Pin_Item =
{
    _( "Pin" ),                     /* Title */
    ADR( LAYER_PIN )                /* adr du parametre optionnel */
};


static ColorButton Layer_Sheet_Item =
/**********************************************************/
{
void WinEDA_SetColorsFrame::Init()
    _( "Sheet" ),               /* Title */
/**********************************************************/
    ADR( LAYER_SHEET )          /* adr du parametre optionnel */
{
};
    OuterBoxSizer   = NULL;
    MainBoxSizer    = NULL;
    ColumnBoxSizer  = NULL;
    RowBoxSizer     = NULL;
    BitmapButton    = NULL;
    text            = NULL;
    m_ShowGrid      = NULL;
    m_SelBgColor    = NULL;
    Line            = NULL;
    BottomBoxSizer  = NULL;
    Button          = NULL;
}


static ColorButton Layer_SheetName_Item =
{
    _( "SheetName" ),           /* Title */
    ADR( LAYER_SHEETNAME )      /* adr du parametre optionnel */
};


static ColorButton Layer_SheetFileName_Item =
/**********************************************************/
void WinEDA_SetColorsFrame::CreateControls()
/**********************************************************/
{
{
    _( "Sheetfile" ),           /* Title */
    int ii, jj, butt_ID, buttcolor;
    ADR( LAYER_SHEETFILENAME )  /* adr du parametre optionnel */
};


static ColorButton Layer_SheetLabel_Item =
    SetFont( *g_DialogFont );
{
    _( "SheetLabel" ),          /* Title */
    ADR( LAYER_SHEETLABEL )     /* adr du parametre optionnel */
};


static ColorButton Layer_NoConnect_Item =
    OuterBoxSizer = new wxBoxSizer(wxVERTICAL);
{
    SetSizer(OuterBoxSizer);
    _( "NoConn" ),              /* Title */
    ADR( LAYER_NOCONNECT )      /* adr du parametre optionnel */
};


    MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
    OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5);


static ColorButton Msg_ErcMarck =
    // Add various items to the dialog box, as determined by the
    // details of each element contained within laytool_list[]
    for( ii = 0, jj = 0; ii < NB_BUTT; ii++ )
    {
    {
    _( "Erc Mark" ),                   /* Title */
        // Look for the initial button of each group of controls.
    NULL
        if( ii == laytool_index[jj]->m_Index )
};

static ColorButton Layer_Erc_Warning_Item =
        {
        {
    _( "Erc Warning" ),             /* Title */
            // Add another column spacer, unless the current value of
    ADR( LAYER_ERC_WARN )           /* adr du parametre optionnel */
            // jj is BUTTON_GROUPS - 1. (The very last group of controls
};
            // differs from the previous groups in that its associated

            // controls are located in the same column as the controls
static ColorButton Layer_Erc_Error_Item =
            // associated with the preceeding group.)
            if( jj < BUTTON_GROUPS - 1 )
            {
            {
    _( "Erc Error" ),               /* Title */
                ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
    ADR( LAYER_ERC_ERR )            /* adr du parametre optionnel */
                MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxTOP, 5);
};
            }

            else
#define NB_BUTT 26
static ColorButton* laytool_list[NB_BUTT + 1] = {
    &Msg_General,
    &Layer_Wire_Item,
    &Layer_Bus_Item,
    &Layer_Jonction_Item,
    &Layer_LocalLabel_Item,
    &Layer_GlobLabel_Item,
    &Layer_NetNam_Item,
    &Layer_Notes_Item,
    &Layer_NoConnect_Item,

    &MsgDevice_Item,
    &Layer_BodyDevice_Item,
    &Layer_BodyBackgroundDevice_Item,
    &Layer_Pin_Item,
    &Layer_PinNum_Item,
    &Layer_PinNam_Item,
    &Layer_Reference_Item,
    &Layer_Value_Item,
    &Layer_Fields_Item,

    &Msg_Sheets,
    &Layer_Sheet_Item,
    &Layer_SheetFileName_Item,
    &Layer_SheetName_Item,
    &Layer_SheetLabel_Item,

    &Msg_ErcMarck,
    &Layer_Erc_Warning_Item,
    &Layer_Erc_Error_Item,

    NULL
};

/*************************************************************/
/* classe derivee pour la frame de Configuration des couleurs*/
/*************************************************************/

class WinEDA_SetColorsFrame : public wxDialog
            {
            {
private:
                // Add a spacer to better separate the text string (which is
    WinEDA_DrawFrame* m_Parent;
                // about to be added) from the items located above it.
    wxRadioBox*       m_SelBgColor;
                ColumnBoxSizer->AddSpacer(5);
            }


public:
            RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
            ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);


    // Constructor and destructor
            // Add a text string to identify the following set of controls
    WinEDA_SetColorsFrame( WinEDA_DrawFrame * parent, const wxPoint &framepos );
            text = new wxStaticText( this, -1, laytool_index[jj]->m_Name,
    ~WinEDA_SetColorsFrame() { };
                                     wxDefaultPosition, wxDefaultSize, 0 );
            // Make this text string bold (so that it stands out better)
            text->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(),
                           wxNORMAL, wxBOLD, false, wxNORMAL_FONT->GetFaceName() ) );


private:
            RowBoxSizer->Add(text, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
    void    SetColor( wxCommandEvent& event );
    void    BgColorChoice( wxCommandEvent& event );


    DECLARE_EVENT_TABLE()
            jj++;
};
/* Table des evenements pour WinEDA_SetColorsFrame */
BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog )
    EVT_RADIOBOX( ID_SEL_BG_COLOR, WinEDA_SetColorsFrame::BgColorChoice )
    EVT_COMMAND_RANGE( ID_COLOR_SETUP, ID_COLOR_SETUP + 26,
                       wxEVT_COMMAND_BUTTON_CLICKED,
                       WinEDA_SetColorsFrame::SetColor )
END_EVENT_TABLE()


/**************************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
                             const wxPoint&    framepos )
/**************************************************************/
{
    WinEDA_SetColorsFrame* frame =
        new WinEDA_SetColorsFrame( parent, framepos );

    frame->ShowModal();
    frame->Destroy();
        }
        }


        RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
        ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxALL, 0);


/**********************************************************************/
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
                                              const wxPoint&    framepos ) :
    wxDialog( parent, -1, _( "EESchema Preferences" ), framepos,
              wxSize( 500, 270 ), DIALOG_STYLE )
/**********************************************************************/
{
#define START_Y 15
    wxBitmapButton* Button;
    int             ii, yy, butt_ID, buttcolor;
    wxPoint         pos;
    int             w = BUTT_SIZE_X, h = BUTT_SIZE_Y;
    wxStaticText*   text;
    int             right, bottom, line_height;
    wxPoint         bg_color_pos;

    m_Parent = parent;
    SetFont( *g_DialogFont );

    pos.x = 10; pos.y = START_Y;
    right = pos.x; bottom = 0;
    line_height = h;
    for( ii = 0; laytool_list[ii] != NULL; ii++ )
    {
        if( laytool_list[ii]->m_Color == NULL )
        {
            if( pos.y != START_Y )
            {
                pos.x = right + 10;
                pos.y = START_Y;
                bg_color_pos = pos;
            }
            wxString msg = wxGetTranslation( laytool_list[ii]->m_Name );
            text = new wxStaticText( this, -1,
                                     msg,
                                     wxPoint ( pos.x, pos.y ),
                                     wxSize( -1, -1 ), 0 );

            line_height = MAX( line_height, text->GetRect().GetHeight() );
            pos.y += line_height;
            continue;
        }
        butt_ID = ID_COLOR_SETUP + ii;
        butt_ID = ID_COLOR_SETUP + ii;
        laytool_list[ii]->m_Id = butt_ID;
        laytool_list[ii]->m_Id = butt_ID;
        wxMemoryDC iconDC;
        wxMemoryDC iconDC;
        wxBitmap ButtBitmap( w, h );
        wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );


        iconDC.SelectObject( ButtBitmap );
        iconDC.SelectObject( ButtBitmap );
        buttcolor = *laytool_list[ii]->m_Color;
        buttcolor = *laytool_list[ii]->m_Color;
        CurrentColor[ii] = buttcolor;
        wxBrush Brush;
        wxBrush Brush;
        iconDC.SelectObject( ButtBitmap );
        iconDC.SelectObject( ButtBitmap );
        iconDC.SetPen( *wxBLACK_PEN );
        iconDC.SetPen( *wxBLACK_PEN );
@@ -336,119 +203,183 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
        Brush.SetStyle( wxSOLID );
        Brush.SetStyle( wxSOLID );


        iconDC.SetBrush( Brush );
        iconDC.SetBrush( Brush );
        iconDC.DrawRectangle( 0, 0, w, h );
        iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );

        Button = new wxBitmapButton( this, butt_ID,
                                    ButtBitmap,
                                    wxPoint ( pos.x, pos.y - (h - line_height) / 2 ),
                                    wxSize (w, h) );

        laytool_list[ii]->m_Button = Button;

        wxString msg = wxGetTranslation( laytool_list[ii]->m_Name );
        text = new wxStaticText( this, -1,
                                 msg,
                                 wxPoint (pos.x + 5 + w, pos.y ),
                                 wxSize( -1, -1 ), 0 );

        wxPoint lowpos;
        lowpos.x = text->GetRect().GetRight();
        lowpos.y = text->GetRect().GetBottom();
        right    = MAX( right, lowpos.x );
        bottom   = MAX( bottom, lowpos.y );
        bg_color_pos.y = lowpos.y;

        yy     = line_height + 5;
        pos.y += yy;
    }


    bg_color_pos.x += 5; bg_color_pos.y += 25;
        BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) );
        RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5);


    static const wxString bg_choice[2] = { _( "White Background" ), _( "Black Background" ) };
        laytool_list[ii]->m_Button = BitmapButton;


    m_SelBgColor = new wxRadioBox( this, ID_SEL_BG_COLOR,
        // Add a text string, unless the current value of ii is NB_BUTT - 1
                                   _( "Background Colour" ), bg_color_pos,
        if( ii < NB_BUTT - 1 )
                                   wxDefaultSize, 2, bg_choice, 1, wxRA_SPECIFY_COLS );
        {
            text = new wxStaticText( this, wxID_STATIC, wxGetTranslation( laytool_list[ii]->m_Name ),
                                     wxDefaultPosition, wxDefaultSize, 0 );
            RowBoxSizer->Add(text, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
        }
        else
        {
            // Special case; provide a checkbox instead (rather than a text string).
            m_ShowGrid = new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _("Grid"), wxDefaultPosition, wxDefaultSize, 0 );
            m_ShowGrid->SetValue( m_Parent->m_Draw_Grid );
            RowBoxSizer->Add(m_ShowGrid, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
        }
    }

    // Add a spacer to improve appearance.
    ColumnBoxSizer->AddSpacer(5);


    wxArrayString m_SelBgColorStrings;
    m_SelBgColorStrings.Add(_("White Background"));
    m_SelBgColorStrings.Add(_("Black Background"));
    m_SelBgColor = new wxRadioBox( this, ID_RADIOBOX_BACKGROUND_COLOR, _("Background Color"),
                                   wxDefaultPosition, wxDefaultSize, m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS );
    m_SelBgColor->SetSelection( ( g_DrawBgColor == BLACK ) ? 1 : 0 );
    m_SelBgColor->SetSelection( ( g_DrawBgColor == BLACK ) ? 1 : 0 );
    bottom = MAX( bottom, m_SelBgColor->GetRect().GetBottom() );
    ColumnBoxSizer->Add(m_SelBgColor, 1, wxGROW|wxRIGHT|wxTOP|wxBOTTOM, 5);
    right  = MAX( right, m_SelBgColor->GetRect().GetRight() );

    // Provide a line to separate all of the controls added so far from the
    // "OK", "Cancel", and "Apply" buttons (which will be added after that line).
    Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
    OuterBoxSizer->Add(Line, 0, wxGROW|wxALL, 5);

    BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL);
    OuterBoxSizer->Add(BottomBoxSizer, 0, wxALIGN_RIGHT|wxLEFT|wxRIGHT|wxBOTTOM, 5);

    Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 );
    Button->SetForegroundColour( *wxRED );
    BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
    Button->SetForegroundColour( *wxBLUE );
    BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    Button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition, wxDefaultSize, 0 );
    BottomBoxSizer->Add(Button, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

    // (Dialog now needs to be resized, but the associated command is found elsewhere.)
}


/**********************************************************/
bool WinEDA_SetColorsFrame::ShowToolTips()
/**********************************************************/
{
    return true;
}



    SetClientSize( wxSize( right + 10, bottom + 10 ) );
/**********************************************************/
wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name )
/**********************************************************/
{
    wxUnusedVar(name);
    return wxNullBitmap;
}


/**********************************************************/
wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name )
/**********************************************************/
{
    wxUnusedVar(name);
    return wxNullIcon;
}
}




/***************************************************************/
/**********************************************************/
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
/***************************************************************/
/**********************************************************/
{
{
    int ii;
    int id = event.GetId();
    int id = event.GetId();
    int color;
    int color;
    int w = BUTT_SIZE_X, h = BUTT_SIZE_Y;

    wxBitmapButton* Button;


    color = DisplayColorFrame( this,
    color = DisplayColorFrame( this,
                               *laytool_list[id - ID_COLOR_SETUP]->m_Color );
            CurrentColor[id - ID_COLOR_SETUP] );
    if( color < 0 )
    if( color < 0 )
        return;
        return;


    for( ii = 0; laytool_list[ii] != NULL; ii++ )
    if( CurrentColor[id - ID_COLOR_SETUP] == color )
    {
        return;
        if( laytool_list[ii]->m_Id != id )
            continue;

        if( *laytool_list[ii]->m_Color == color )
            break;


        *laytool_list[ii]->m_Color = color;
    CurrentColor[id - ID_COLOR_SETUP] = color;
    wxMemoryDC      iconDC;
    wxMemoryDC      iconDC;


        wxBitmapButton* Button = laytool_list[ii]->m_Button;
    Button = laytool_list[id - ID_COLOR_SETUP]->m_Button;


    wxBitmap        ButtBitmap = Button->GetBitmapLabel();
    wxBitmap        ButtBitmap = Button->GetBitmapLabel();
    iconDC.SelectObject( ButtBitmap );
    iconDC.SelectObject( ButtBitmap );
        int             buttcolor = *laytool_list[ii]->m_Color;
    wxBrush         Brush;
    wxBrush         Brush;
        iconDC.SelectObject( ButtBitmap );
    iconDC.SetPen( *wxBLACK_PEN );
    iconDC.SetPen( *wxBLACK_PEN );
    Brush.SetColour(
    Brush.SetColour(
            ColorRefs[buttcolor].m_Red,
        ColorRefs[color].m_Red,
            ColorRefs[buttcolor].m_Green,
        ColorRefs[color].m_Green,
            ColorRefs[buttcolor].m_Blue
        ColorRefs[color].m_Blue
        );
        );
    Brush.SetStyle( wxSOLID );
    Brush.SetStyle( wxSOLID );


    iconDC.SetBrush( Brush );
    iconDC.SetBrush( Brush );
        iconDC.DrawRectangle( 0, 0, w, h );
    iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
    Button->SetBitmapLabel( ButtBitmap );
    Button->SetBitmapLabel( ButtBitmap );
        if( m_Parent->GetScreen() )
    Button->Refresh();
            m_Parent->GetScreen()->SetRefreshReq();
    }


    Refresh( FALSE );
    Refresh( FALSE );
}
}




/***************************************************************/
/******************************************************************/
void WinEDA_SetColorsFrame::BgColorChoice( wxCommandEvent& event )
void WinEDA_SetColorsFrame::UpdateLayerSettings()
/***************************************************************/
/******************************************************************/
{
{
    int color;
    // Update colors for each layer
    for( int ii = 0; ii < NB_BUTT; ii++ )
    {
        if( laytool_list[ii]->m_Color )
            *laytool_list[ii]->m_Color = CurrentColor[ii];
    }


    // Update whether grid is actually displayed or otherwise
    m_Parent->m_Draw_Grid = g_ShowGrid = m_ShowGrid->GetValue();

    // Update color of background
    if( m_SelBgColor->GetSelection() == 0 )
    if( m_SelBgColor->GetSelection() == 0 )
        color = WHITE;
        g_DrawBgColor = WHITE;
    else
    else
        color = BLACK;
        g_DrawBgColor = BLACK;
    m_Parent->SetDrawBgColor( g_DrawBgColor );
}


    if( color != g_DrawBgColor )

/**********************************************************************/
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
{
{
        g_DrawBgColor = color;
    UpdateLayerSettings();
        m_Parent->SetDrawBgColor( g_DrawBgColor );
    m_Parent->ReDrawPanel();
    m_Parent->ReDrawPanel();
    EndModal( 1 );
}
}


/*******************************************************************/
void  WinEDA_SetColorsFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
{
    EndModal( -1 );
}


/*******************************************************************/
void  WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
{
    UpdateLayerSettings();
    m_Parent->ReDrawPanel();
}
}






/*************************/
/*************************/
void SeedLayers()
void SeedLayers()
/*************************/
/*************************/