diff --git a/3d-viewer/3d_canvas.cpp b/3d-viewer/3d_canvas.cpp index 3b029caa05..e362e33839 100644 --- a/3d-viewer/3d_canvas.cpp +++ b/3d-viewer/3d_canvas.cpp @@ -66,7 +66,7 @@ EVT_MENU_RANGE( ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, END_EVENT_TABLE() /*************************************************************************/ -Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, wxWindowID id, +Pcb3D_GLCanvas::Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent, const wxWindowID id, int* gl_attrib ) : wxGLCanvas( parent, id, wxPoint( -1, -1 ), wxSize( -1, -1 ), 0, wxT( "Pcb3D_glcanvas" ), gl_attrib ) diff --git a/change_log.txt b/change_log.txt index 452e43e672..5d392076f8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,19 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-Nov-09 UPDATE Geoff Harland +================================================================================ ++ 3d-viewer + * The 3d_canvas.cpp file has been updated to use a const parameter, as suggested + within (Bug) Request ID 1828487. ++ pcbnew + * Sizers have now been provided for the "Pcbnew Layer Colors:" dialog box (previously + identified as the "Colors:" dialog box), and tool tips have been provided for the + "Show All" and "Show None" buttons. + * The reglage.cpp file (which is not currently used) has been removed, and replaced + with reglage.cpp.notused. + + 2007-Nov-02 UPDATE Jean-Pierre Charras ================================================================================ + all diff --git a/pcbnew/reglage.cpp b/pcbnew/reglage.cpp.notused similarity index 100% rename from pcbnew/reglage.cpp rename to pcbnew/reglage.cpp.notused diff --git a/pcbnew/set_color.cpp b/pcbnew/set_color.cpp index 5608f70c73..330625c9ed 100644 --- a/pcbnew/set_color.cpp +++ b/pcbnew/set_color.cpp @@ -1,4 +1,24 @@ -/* Set up the items and layer colors and show/no show options */ +/*****************/ +/* set_color.cpp */ +/*****************/ + +/*Set up the items and layer colors and show/no show options + */ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma implementation "set_color.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 "gr_basic.h" @@ -8,128 +28,28 @@ #include "protos.h" +#include "set_color.h" // Header file associated with this file -/* Variables locales */ -const int BUTT_SIZE_X = 25; -const int BUTT_SIZE_Y = 15; - -const int COLOR_COUNT = 43; // 43 = 29 (layers) + 11 (others) + 3 (headings) - // Is there a better way to determine how many elements CurrentColor requires? +// Local variables: +const int COLOR_COUNT = 40; // 40 = 29 (layers) + 11 (others) int CurrentColor[COLOR_COUNT]; // Holds color for each layer while dialog box open -/* Fonctions locales: */ -/* Macro utile : */ -#define ADR( numlayer ) &g_DesignSettings.m_LayerColor[(numlayer)] +IMPLEMENT_DYNAMIC_CLASS( WinEDA_SetColorsFrame, wxDialog ) -enum col_sel_id { - ID_COLOR_RESET_SHOW_LAYER_ON = 1800, - ID_COLOR_RESET_SHOW_LAYER_OFF, - ID_COLOR_CHECKBOX_ONOFF, - ID_COLOR_SETUP -}; - -/**********************************/ -/* Liste des menus de Menu_Layers */ -/**********************************/ -struct ColorButton -{ - const wxString m_Title; - int m_LayerNumber; - int* m_Color; ///< pointer to color variable to manipulate - bool m_NoDisplayIsColor; ///< TRUE if bit ITEM_NOT_SHOW of the color variable should be manipulated - bool* m_NoDisplay; ///< pointer to the on/off display control variable, if it is not the color variable - - int m_Id; - wxBitmapButton* m_Button; - int m_State; - wxCheckBox* m_CheckBox; ///< Display ON/OFF toggle -}; - -#include "set_color.h" // Include description and list of tools and buttons - - -/*************************************************************/ -/* classe derivee pour la frame de Configuration des couleurs*/ -/*************************************************************/ - -class WinEDA_SetColorsFrame : public wxDialog -{ -private: - WinEDA_DrawFrame* m_Parent; - -public: - - // Constructor and destructor - WinEDA_SetColorsFrame( WinEDA_DrawFrame * parent, const wxPoint &framepos ); - ~WinEDA_SetColorsFrame() { }; - -private: - void SetColor( wxCommandEvent& event ); - void OnOkClick( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ); - void OnApplyClick( wxCommandEvent& event ); - void UpdateLayerSettings(); - void ResetDisplayLayersCu( wxCommandEvent& event ); - - DECLARE_EVENT_TABLE() -}; - - -/* Table des evenements pour WinEDA_SetColorsFrame */ +// Table of events for WinEDA_SetColorsFrame BEGIN_EVENT_TABLE( WinEDA_SetColorsFrame, wxDialog ) EVT_BUTTON( ID_COLOR_RESET_SHOW_LAYER_OFF, WinEDA_SetColorsFrame::ResetDisplayLayersCu ) EVT_BUTTON( ID_COLOR_RESET_SHOW_LAYER_ON, WinEDA_SetColorsFrame::ResetDisplayLayersCu ) + EVT_COMMAND_RANGE( ID_COLOR_SETUP, ID_COLOR_SETUP + NB_BUTT - 1, + wxEVT_COMMAND_BUTTON_CLICKED, + WinEDA_SetColorsFrame::SetColor ) EVT_BUTTON( wxID_OK, WinEDA_SetColorsFrame::OnOkClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_SetColorsFrame::OnCancelClick ) EVT_BUTTON( wxID_APPLY, WinEDA_SetColorsFrame::OnApplyClick ) - EVT_BUTTON( ID_COLOR_SETUP, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 1, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 2, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 3, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 4, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 5, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 6, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 7, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 8, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 9, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 10, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 11, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 12, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 13, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 14, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 15, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 16, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 17, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 18, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 19, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 20, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 21, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 22, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 23, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 24, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 25, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 26, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 27, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 28, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 29, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 30, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 31, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 32, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 33, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 34, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 35, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 36, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 37, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 38, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 39, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 40, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 41, WinEDA_SetColorsFrame::SetColor ) - EVT_BUTTON( ID_COLOR_SETUP + 42, WinEDA_SetColorsFrame::SetColor ) -// EVT_BUTTON( ID_COLOR_SETUP + 43, WinEDA_SetColorsFrame::SetColor ) -// EVT_BUTTON( ID_COLOR_SETUP + 44, WinEDA_SetColorsFrame::SetColor ) END_EVENT_TABLE() + /*****************************************************/ void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos ) @@ -143,81 +63,136 @@ void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, } -/**********************************************************************/ -WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( - WinEDA_DrawFrame* parent, const wxPoint& framepos ) : - wxDialog( parent, -1, _( "Colors:" ), framepos, wxSize( -1, -1 ), DIALOG_STYLE ) -/**********************************************************************/ +// Default Constructor (whose provision is mandated by the inclusion +// of DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame ) within set_color.h) +WinEDA_SetColorsFrame::WinEDA_SetColorsFrame() { -#define START_Y 25 - wxBitmapButton* ButtonB; - int ii, yy, xx, butt_ID, buttcolor; - wxPoint pos; - wxSize winsize; - wxString msg; + Init(); +} + +// Standard Constructor +WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, + const wxPoint& framepos ) +{ m_Parent = parent; + Init(); + Create( parent, + SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME, + SYMBOL_WINEDA_SETCOLORSFRAME_TITLE, + framepos, + wxDefaultSize, + SYMBOL_WINEDA_SETCOLORSFRAME_STYLE ); +} + + +// Destructor +WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame() { } + + +/**********************************************************/ +bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id, + const wxString& caption, const wxPoint& pos, + const wxSize& size, long style ) +/**********************************************************/ +{ + SetExtraStyle(wxWS_EX_BLOCK_EVENTS); + wxDialog::Create( parent, id, caption, pos, size, style ); + + CreateControls(); + if (GetSizer()) + { + GetSizer()->SetSizeHints(this); + } + return true; +} + + +/**********************************************************/ +void WinEDA_SetColorsFrame::Init() +/**********************************************************/ +{ + OuterBoxSizer = NULL; + MainBoxSizer = NULL; + FlexColumnBoxSizer = NULL; + Label = NULL; + RowBoxSizer = NULL; + BitmapButton = NULL; + CheckBox = NULL; + Button = NULL; + Line = NULL; + StdDialogButtonSizer = NULL; +} + + +/**********************************************************/ +void WinEDA_SetColorsFrame::CreateControls() +/**********************************************************/ +{ + int lyr, cln, butt_ID, buttcolor; + wxString msg; + wxSize CorrectRowSize; // Used while specifying height of various spacers + int ButtonHeight; // Used while specifying height of other spacers + SetFont( *g_DialogFont ); - pos.x = 5; - pos.y = START_Y; + OuterBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(OuterBoxSizer); - for( ii = 0; laytool_list[ii] != NULL; ii++ ) + MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5); + + // Add various items to the dialog box, as determined by the + // details of each element contained within laytool_list[] + for( lyr = 0, cln = 0; lyr < NB_BUTT; lyr++ ) { - if( !laytool_list[ii]->m_Color && !laytool_list[ii]->m_NoDisplay ) + // Look for the first set of controls within each column. + if( lyr == 0 || lyr == laytool_index[cln]->m_Index + 1 ) { - if( pos.y != START_Y ) + if( lyr != 0 ) + cln++; + + // Specify a FlexGrid sizer with nineteen rows and one column. + FlexColumnBoxSizer = new wxFlexGridSizer(19, 1, 0, 0); + + // Specify that all of the rows can be expanded. + for( int ii = 0; ii < 19; ii++ ) { - pos.x += BUTT_SIZE_X + 120; - pos.y = START_Y; + FlexColumnBoxSizer->AddGrowableRow(ii); } - if( laytool_list[ii]->m_LayerNumber >= 0 ) - { - if( laytool_list[ii]->m_Title == wxT( "*" ) ) - { - msg = g_ViaType_Name[laytool_list[ii]->m_LayerNumber]; - } - else - msg = ReturnPcbLayerName( laytool_list[ii]->m_LayerNumber ); - } - else - msg = wxGetTranslation( laytool_list[ii]->m_Title.GetData() ); + // Specify that the column can also be expanded. + FlexColumnBoxSizer->AddGrowableCol(0); - new wxStaticText( this, -1, msg, - wxPoint( pos.x + 10, pos.y - 18 ), wxSize( -1, -1 ), 0 ); + MainBoxSizer->Add(FlexColumnBoxSizer, 1, wxGROW|wxLEFT|wxBOTTOM, 5); - continue; + // Add a text string to identify the controls within this column. + Label = new wxStaticText( this, wxID_STATIC, laytool_index[cln]->m_Name, + wxDefaultPosition, wxDefaultSize, 0 ); + + // Make this text string bold (so that it stands out better). + Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(), + wxNORMAL, wxBOLD, false, wxNORMAL_FONT->GetFaceName() ) ); + + FlexColumnBoxSizer->Add(Label, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); } - if( laytool_list[ii]->m_Id == 0 ) - laytool_list[ii]->m_Id = ID_COLOR_SETUP + ii; + // Provide a sizer to accomodate the (bitmap button and) checkbox associated with the + // current layer (while providing a spacer instead a button, when appropriate). + RowBoxSizer = new wxBoxSizer(wxHORIZONTAL); + FlexColumnBoxSizer->Add(RowBoxSizer, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5); - butt_ID = laytool_list[ii]->m_Id; + butt_ID = ID_COLOR_SETUP + lyr; + laytool_list[lyr]->m_Id = butt_ID; - laytool_list[ii]->m_CheckBox = new wxCheckBox( this, - ID_COLOR_CHECKBOX_ONOFF, wxEmptyString, - pos ); - - if( laytool_list[ii]->m_NoDisplayIsColor ) - { - if( *laytool_list[ii]->m_Color & ITEM_NOT_SHOW ) - laytool_list[ii]->m_CheckBox->SetValue( FALSE ); - else - laytool_list[ii]->m_CheckBox->SetValue( TRUE ); - } - else if( laytool_list[ii]->m_NoDisplay ) - laytool_list[ii]->m_CheckBox->SetValue( *laytool_list[ii]->m_NoDisplay ); - - xx = laytool_list[ii]->m_CheckBox->GetSize().x + 3; - - if( laytool_list[ii]->m_Color ) + if( laytool_list[lyr]->m_Color ) { + // Provide a bitmap button, and "paint" this with the appropriate color. wxMemoryDC iconDC; wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); iconDC.SelectObject( ButtBitmap ); - buttcolor = *laytool_list[ii]->m_Color & MASKCOLOR; - CurrentColor[ii] = buttcolor; + buttcolor = *laytool_list[lyr]->m_Color & MASKCOLOR; + CurrentColor[lyr] = buttcolor; wxBrush Brush; iconDC.SelectObject( ButtBitmap ); iconDC.SetPen( *wxBLACK_PEN ); @@ -231,62 +206,190 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( iconDC.SetBrush( Brush ); iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); - ButtonB = new wxBitmapButton( this, butt_ID, - ButtBitmap, - wxPoint(pos.x + xx, pos.y), - wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) ); - laytool_list[ii]->m_Button = ButtonB; - xx += BUTT_SIZE_X + 3; - } + BitmapButton = new wxBitmapButton( this, butt_ID, + ButtBitmap, + wxDefaultPosition, + wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) ); + laytool_list[lyr]->m_Button = BitmapButton; - if( laytool_list[ii]->m_LayerNumber >= 0 ) - { - if( laytool_list[ii]->m_Title == wxT( "*" ) ) - msg = g_ViaType_Name[laytool_list[ii]->m_LayerNumber]; - else - msg = ReturnPcbLayerName( laytool_list[ii]->m_LayerNumber ); + RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5); } else - msg = wxGetTranslation( laytool_list[ii]->m_Title.GetData() ); + { + // Provide a spacer instead (rather than a bitmap button). + RowBoxSizer->Add(BUTT_SIZE_X, BUTT_SIZE_Y, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5); + } - new wxStaticText( this, -1, msg, - wxPoint( pos.x + xx, pos.y + 1 ), - wxSize( -1, -1 ), 0 ); + if( laytool_list[lyr]->m_LayerNumber >= 0 ) + { + if( laytool_list[lyr]->m_Title == wxT( "*" ) ) + msg = g_ViaType_Name[laytool_list[lyr]->m_LayerNumber]; + else + msg = ReturnPcbLayerName( laytool_list[lyr]->m_LayerNumber ); + } + else + msg = wxGetTranslation( laytool_list[lyr]->m_Title.GetData() ); - yy = BUTT_SIZE_Y + 5; - pos.y += yy; + CheckBox = new wxCheckBox( this, ID_COLOR_CHECKBOX_ONOFF, msg, + wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + + laytool_list[lyr]->m_CheckBox = CheckBox; + + if( laytool_list[lyr]->m_NoDisplayIsColor ) + { + if( *laytool_list[lyr]->m_Color & ITEM_NOT_SHOW ) + CheckBox->SetValue( FALSE ); + else + CheckBox->SetValue( TRUE ); + } + else if( laytool_list[lyr]->m_NoDisplay ) + CheckBox->SetValue( *laytool_list[lyr]->m_NoDisplay ); + + RowBoxSizer->Add(CheckBox, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5); + + // Check whether the last (bitmap button and) checkbox has been provided for this column. + if( lyr == laytool_index[cln]->m_Index ) + { + // What happens now depends upon which column is currently being created. Another + // two (standard/non-bitmap) buttons are provided within the first column, while + // assorted spacers are added to each of the other two columns (so that if the + // dialog box is resized by the user, each of the controls within each of the + // columns will be repositioned in an aesthetically-acceptable manner). + if( cln == 0 ) + { + // Provide another two buttons; for aesthetic reasons, these will both be + // made equally wide. + + int GoodWidth, width0; + + // Specify the relevent details for the first button, but in the first instance, + // specify the caption which will be used by the second of these buttons (with + // the objective being to determine how wide those buttons would need to be to + // be able to accomodate the caption provided for either of them). + Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_ON, _("Show None"), + wxDefaultPosition, wxDefaultSize, 0 ); + + // Note the height of this button, so that the same height can also be specified for + // the spacers occupying the corresponding cells within each of the other two columns. + // Also note the width of the button required for the initially specified caption. + Button->GetSize( &width0, &ButtonHeight ); + + // Now change the caption of this button to what is really wanted for it. + Button->SetLabel( _("Show All") ); + + // Also note the width of the button required for the updated caption. + Button->GetSize( &GoodWidth, &ButtonHeight ); + + // Upate the value of GoodWidth if required (as that variable will subsequently + // be used to specify the (minimum) width for both of these buttons). + if( GoodWidth < width0 ) + GoodWidth = width0; + + // Complete the steps necessary for providing the first button. + if (WinEDA_SetColorsFrame::ShowToolTips()) + Button->SetToolTip( _("Switch on all of the copper layers") ); + Button->SetMinSize( wxSize( GoodWidth, ButtonHeight ) ); + Button->SetForegroundColour( wxColor( 0, 100, 0 ) ); + FlexColumnBoxSizer->Add(Button, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5); + + // Now do everything required for providing the second button. + Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_OFF, _("Show None"), + wxDefaultPosition, wxDefaultSize, 0 ); + if (WinEDA_SetColorsFrame::ShowToolTips()) + Button->SetToolTip( _("Switch off all of the copper layers") ); + Button->SetMinSize( wxSize( GoodWidth, ButtonHeight ) ); + Button->SetForegroundColour( wxColor( 100, 0, 0 ) ); + FlexColumnBoxSizer->Add(Button, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5); + } + else + { + // Provide additional spacers within each other column to occupy any cells + // that would otherwise remain unoccupied. + // + // Provide a spacer, of appropriate height, for each row that + // would otherwise contain a (bitmap button and) checkbox. + // + // First determine what height is required for those spacers; i.e. the + // larger of each bitmap button's height and each checkbox'es height. + // (That only needs to be determined once, so do so after the last + // bitmap button and checkbox have been provided for the second column.) + if( cln == 1 ) + { + CorrectRowSize = CheckBox->GetSize(); + if( CorrectRowSize.y < BUTT_SIZE_Y ) + CorrectRowSize.y = BUTT_SIZE_Y; + } + + // The first column contains 16 checkboxes, while each of the other two columns + // contains a smaller number. Determine how many checkboxes have actually been + // provided within each of the other columns, then provide an appropriate number + // of sizers (to take the total count of checkboxes and substitute sizers to 16). + for( int ii = lyr; ii < 16 + laytool_index[cln - 1]->m_Index + + lyr - laytool_index[cln]->m_Index; ii++ ) + { + FlexColumnBoxSizer->Add(5, CorrectRowSize.y, 1, wxBOTTOM, 5); + } + + // As the first column also contains two (standard/non-bitmap) buttons, while each of + // the other two columns doesn't, also provide yet another two spacers, each of button + // height, within each of the other two columns. + FlexColumnBoxSizer->Add(5, ButtonHeight, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP, 5); + FlexColumnBoxSizer->Add(5, ButtonHeight, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP, 5); + } + } } - pos.x = 5; - pos.y = 355; + // Provide a line to separate the controls which have been provided so far from + // the OK, Cancel, and Apply buttons (which will be provided after this line) + Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + OuterBoxSizer->Add(Line, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5); - wxButton* Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_ON, - _( "Show All" ), pos ); - Button->SetForegroundColour( wxColor( 0, 100, 0 ) ); + // Provide a StdDialogButtonSizer to accommodate the OK, Cancel, and Apply + // buttons; using that type of sizer results in those buttons being + // automatically located in positions appropriate for each (OS) version of KiCad. + StdDialogButtonSizer = new wxStdDialogButtonSizer; + OuterBoxSizer->Add(StdDialogButtonSizer, 0, wxGROW|wxALL, 10); - pos.x += Button->GetSize().x + 10; - - Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_OFF, - _( "Show None" ), pos ); - Button->SetForegroundColour( wxColor( 100, 0, 0 ) ); - - pos.x = MAX( pos.x + 20, 480 - 3 * Button->GetSize().x ); - - Button = new wxButton( this, wxID_OK, _("OK"), pos ); + Button = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); Button->SetForegroundColour( *wxRED ); + StdDialogButtonSizer->AddButton(Button); - pos.x += Button->GetSize().x + 10; - - Button = new wxButton( this, wxID_CANCEL, _("Cancel"), pos ); + Button = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); Button->SetForegroundColour( *wxBLUE ); + StdDialogButtonSizer->AddButton(Button); - pos.x += Button->GetSize().x + 10; + Button = new wxButton( this, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 ); + StdDialogButtonSizer->AddButton(Button); - Button = new wxButton( this, wxID_APPLY, _("Apply"), pos ); + StdDialogButtonSizer->Realize(); - winsize.x = MAX( 500, pos.x + Button->GetSize().x + 10 ); - winsize.y = pos.y + Button->GetSize().y + 5; - SetClientSize( winsize ); + // (Dialog now needs to be resized, but the associated command is provided elsewhere.) +} + + +/**********************************************************/ +bool WinEDA_SetColorsFrame::ShowToolTips() +/**********************************************************/ +{ + return true; +} + + +/**********************************************************/ +wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name ) +/**********************************************************/ +{ + wxUnusedVar(name); + return wxNullBitmap; +} + + +/**********************************************************/ +wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name ) +/**********************************************************/ +{ + wxUnusedVar(name); + return wxNullIcon; } @@ -321,47 +424,41 @@ void WinEDA_SetColorsFrame::OnApplyClick(wxCommandEvent& WXUNUSED(event)) void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event ) /**********************************************************/ { - int ii; int id = event.GetId(); int color; - color = DisplayColorFrame( this, CurrentColor[id - ID_COLOR_SETUP] ); + wxBitmapButton* Button; + + color = DisplayColorFrame( this, + CurrentColor[id - ID_COLOR_SETUP] ); + if( color < 0 ) return; - for( ii = 0; laytool_list[ii] != NULL; ii++ ) - { - if( laytool_list[ii]->m_Id != id ) - continue; + if( CurrentColor[id - ID_COLOR_SETUP] == color ) + return; - if( laytool_list[ii]->m_Color == NULL ) - continue; + CurrentColor[id - ID_COLOR_SETUP] = color; + wxMemoryDC iconDC; - if( CurrentColor[ii] == color ) - break; + Button = laytool_list[id - ID_COLOR_SETUP]->m_Button; - CurrentColor[ii] = color; - wxMemoryDC iconDC; + wxBitmap ButtBitmap = Button->GetBitmapLabel(); + iconDC.SelectObject( ButtBitmap ); + wxBrush Brush; + iconDC.SetPen( *wxBLACK_PEN ); + Brush.SetColour( + ColorRefs[color].m_Red, + ColorRefs[color].m_Green, + ColorRefs[color].m_Blue + ); + Brush.SetStyle( wxSOLID ); - wxBitmapButton* Button = laytool_list[ii]->m_Button; + iconDC.SetBrush( Brush ); + iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); + Button->SetBitmapLabel( ButtBitmap ); + Button->Refresh(); - wxBitmap ButtBitmap = Button->GetBitmapLabel(); - iconDC.SelectObject( ButtBitmap ); - int buttcolor = CurrentColor[ii]; - wxBrush Brush; - iconDC.SetPen( *wxBLACK_PEN ); - Brush.SetColour( - ColorRefs[buttcolor].m_Red, - ColorRefs[buttcolor].m_Green, - ColorRefs[buttcolor].m_Blue - ); - Brush.SetStyle( wxSOLID ); - - iconDC.SetBrush( Brush ); - iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); - Button->SetBitmapLabel( ButtBitmap ); - Button->Refresh(); - } Refresh( FALSE ); } @@ -370,40 +467,21 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event ) void WinEDA_SetColorsFrame::UpdateLayerSettings() /******************************************************************/ { - for( int ii = 0; laytool_list[ii] != NULL; ii++ ) + for( int lyr = 0; lyr < NB_BUTT; lyr++ ) { -// if( laytool_list[ii]->m_CheckBox == NULL ) -// continue; - - // Although some of the items listed within laytool_list[] - // do not have any checkboxes associated with them, the - // previous command is still not necessary (as those items - // are processed satisfactorily by the following command). - - if( !laytool_list[ii]->m_NoDisplayIsColor - && (laytool_list[ii]->m_NoDisplay == NULL) ) - continue; - - if( laytool_list[ii]->m_NoDisplayIsColor ) + if( laytool_list[lyr]->m_NoDisplayIsColor ) { - if( laytool_list[ii]->m_CheckBox->GetValue() ) - *laytool_list[ii]->m_Color = CurrentColor[ii] & ~ITEM_NOT_SHOW; + if( laytool_list[lyr]->m_CheckBox->GetValue() ) + *laytool_list[lyr]->m_Color = CurrentColor[lyr] & ~ITEM_NOT_SHOW; else - *laytool_list[ii]->m_Color = CurrentColor[ii] | ITEM_NOT_SHOW; + *laytool_list[lyr]->m_Color = CurrentColor[lyr] | ITEM_NOT_SHOW; } else { - if( laytool_list[ii]->m_Color ) - *laytool_list[ii]->m_Color = CurrentColor[ii]; + if( laytool_list[lyr]->m_Color ) + *laytool_list[lyr]->m_Color = CurrentColor[lyr]; -// if( laytool_list[ii]->m_CheckBox ) -// *laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue(); - - // As there is a checkbox associated with every layer listed - // within this particular dialog box, the previous command can - // be replaced with this following command. - - *laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue(); + *laytool_list[lyr]->m_NoDisplay = laytool_list[lyr]->m_CheckBox->GetValue(); } } // Additional command required for updating visibility of grid. @@ -415,12 +493,17 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() void WinEDA_SetColorsFrame::ResetDisplayLayersCu( wxCommandEvent& event ) /**********************************************************************/ { - bool NewState = (event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON) ? TRUE : FALSE; + bool NewState = ( event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON ) + ? TRUE + : FALSE; - for( int ii = 1; ii < 17; ii++ ) + for( int lyr = 0; lyr < 16; lyr++ ) { - if( laytool_list[ii]->m_CheckBox == NULL ) - continue; - laytool_list[ii]->m_CheckBox->SetValue( NewState ); +// if( laytool_list[lyr]->m_CheckBox ) +// laytool_list[lyr]->m_CheckBox->SetValue( NewState ); + + // (As checkboxes are actually provided for *all* of these layers, + // the following (simpler) command can be used instead.) + laytool_list[lyr]->m_CheckBox->SetValue( NewState ); } } diff --git a/pcbnew/set_color.h b/pcbnew/set_color.h index 6b5c4e3c20..cef1454b20 100644 --- a/pcbnew/set_color.h +++ b/pcbnew/set_color.h @@ -1,8 +1,85 @@ -/* Set up the button list for the color selection for pcbnew layers */ +/***************/ +/* set_color.h */ +/***************/ -static ColorButton Msg_Layers_Cu = +#ifndef SET_COLOR_H +#define SET_COLOR_H + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "set_color.cpp" +#endif + +#include "wx/statline.h" + +class wxBoxSizer; +class wxFlexGridSizer; +class wxStaticLine; +class wxStdDialogButtonSizer; + + +// Specify how many elements are contained within laytool_list[] +const int NB_BUTT = 44; + +// Specify how many elements are contained within laytool_index[] +const int BUTTON_GROUPS = 3; + +// Specify the numbers associated with assorted controls +enum col_sel_id { + ID_DIALOG = 1800, + ID_COLOR_RESET_SHOW_LAYER_ON, + ID_COLOR_RESET_SHOW_LAYER_OFF, + ID_COLOR_CHECKBOX_ONOFF, + ID_COLOR_SETUP +}; + +// Control identifiers +// #define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER +#define SYMBOL_WINEDA_SETCOLORSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER +#define SYMBOL_WINEDA_SETCOLORSFRAME_TITLE _("Pcbnew Layer Colors:") +#define SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME ID_DIALOG +// #define SYMBOL_WINEDA_SETCOLORSFRAME_SIZE wxSize(400, 300) +// #define SYMBOL_WINEDA_SETCOLORSFRAME_POSITION wxDefaultPosition + +#ifndef wxCLOSE_BOX +#define wxCLOSE_BOX 0x1000 +#endif + +// Specify the width and height of every (color-displaying / bitmap) button +const int BUTT_SIZE_X = 25; +const int BUTT_SIZE_Y = 15; + +/* Macro utile : */ +#define ADR( numlayer ) &g_DesignSettings.m_LayerColor[(numlayer)] + + +/**********************************/ +/* Liste des menus de Menu_Layers */ +/**********************************/ +struct ColorButton { - _( "Copper Layers" ), -1 // Title + const wxString m_Title; + int m_LayerNumber; + int* m_Color; ///< pointer to color variable to manipulate + bool m_NoDisplayIsColor; ///< TRUE if bit ITEM_NOT_SHOW of the color variable should be manipulated + bool* m_NoDisplay; ///< pointer to the on/off display control variable, if it is not the color variable + + int m_Id; + wxBitmapButton* m_Button; +// int m_State; // (Commented out until when it is actually used.) + wxCheckBox* m_CheckBox; ///< Display ON/OFF toggle +}; + +struct ButtonIndex +{ + wxString m_Name; // Title + int m_Index; // Index to last bitmap button in group +}; + + +static ButtonIndex Msg_Layers_Cu = +{ + _( "Copper Layers" ), // Title + 15 // Index to last bitmap button in group }; static ColorButton Layer_1_Butt = @@ -134,9 +211,10 @@ static ColorButton Layer_16_Butt = }; -static ColorButton Msg_Layers_Tech = +static ButtonIndex Msg_Layers_Tech = { - _( "Tech Layers" ), -1 // Title + _( "Tech Layers" ), // Title + 28 // Index to last bitmap button in group }; static ColorButton Layer_17_Butt = @@ -244,9 +322,10 @@ static ColorButton Layer_29_Butt = }; -static ColorButton Msg_Others_Items = +static ButtonIndex Msg_Others_Items = { - wxT( "Others" ), -1 // Title + wxT( "Others" ), // Title + 43 // Index to last bitmap button in group }; static ColorButton VIA_THROUGH_Butt = @@ -377,7 +456,6 @@ static ColorButton Show_Modules_Cu_Butt = static ColorButton* laytool_list[] = { - &Msg_Layers_Cu, &Layer_1_Butt, &Layer_2_Butt, &Layer_3_Butt, @@ -395,7 +473,6 @@ static ColorButton* laytool_list[] = { &Layer_15_Butt, &Layer_16_Butt, - &Msg_Layers_Tech, &Layer_17_Butt, &Layer_18_Butt, &Layer_19_Butt, @@ -413,7 +490,6 @@ static ColorButton* laytool_list[] = { // &Layer_31_Butt, // &Layer_32_Butt, - &Msg_Others_Items, &VIA_THROUGH_Butt, &Via_Aveugle_Butt, &BLIND_VIA_Butt, @@ -430,6 +506,69 @@ static ColorButton* laytool_list[] = { &Show_Pads_Noconnect_Butt, &Show_Modules_Cmp_Butt, &Show_Modules_Cu_Butt, - - NULL }; + + +static ButtonIndex* laytool_index[BUTTON_GROUPS] = { + &Msg_Layers_Cu, + &Msg_Layers_Tech, + &Msg_Others_Items +}; + + +/**************************************************************/ +/* classe derivee pour la frame de Configuration des couleurs */ +/**************************************************************/ + +class WinEDA_SetColorsFrame: public wxDialog +{ +private: + DECLARE_DYNAMIC_CLASS( WinEDA_SetColorsFrame ) + DECLARE_EVENT_TABLE() + + WinEDA_DrawFrame* m_Parent; + wxBoxSizer* OuterBoxSizer; + wxBoxSizer* MainBoxSizer; + wxFlexGridSizer* FlexColumnBoxSizer; + wxStaticText* Label; + wxBoxSizer* RowBoxSizer; + wxBitmapButton* BitmapButton; + wxCheckBox* CheckBox; + wxButton* Button; + wxStaticLine* Line; + wxStdDialogButtonSizer* StdDialogButtonSizer; + + // Creation + bool Create( wxWindow* parent, + wxWindowID id = SYMBOL_WINEDA_SETCOLORSFRAME_IDNAME, + const wxString& caption = SYMBOL_WINEDA_SETCOLORSFRAME_TITLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE ); + + // Initialises member variables + void Init(); + + // Creates the controls and sizers + void CreateControls(); + + wxBitmap GetBitmapResource( const wxString& name ); + wxIcon GetIconResource( const wxString& name ); + static bool ShowToolTips(); + + void SetColor( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnApplyClick( wxCommandEvent& event ); + void UpdateLayerSettings(); + void ResetDisplayLayersCu( wxCommandEvent& event ); + +public: + // Constructors and destructor + WinEDA_SetColorsFrame(); + WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, const wxPoint& framepos ); + ~WinEDA_SetColorsFrame(); +}; + +#endif + // SET_COLOR_H