diff --git a/pcbnew/dialog_layers_setup.cpp b/pcbnew/dialog_layers_setup.cpp new file mode 100644 index 0000000000..99e817b672 --- /dev/null +++ b/pcbnew/dialog_layers_setup.cpp @@ -0,0 +1,1027 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +/////////////////////////////////////////////////////////////////////////// + +#include "fctsys.h" +#include "common.h" +#include "class_drawpanel.h" + +#include "confirm.h" +#include "pcbnew.h" +#include "wxPcbStruct.h" + +#include "pcbnew_id.h" + +#include "dialog_layers_setup.h" + +/////////////////////////////////////////////////////////////////////////// + +//============================================================================== +// +// CHANGE HERE IF YOU WANT TO CHANGE THE DIALOG'S APEARANCE +// +//============================================================================== + +// Define as 1 to show the layers in Pcbnew's original order +#define ORIGINAL_KICAD_LAYER_ORDER 0 + +// Define as 1 to show colored rows backgrounds in the list panel +#define PANEL_BACKGROUND_COLORED 1 + +// Setting this to 1 gives insteresting (and odd) results, some may like +#define CONTROL_BACKGROUND_COLORED 0 + +// Works best when LIST_CONTROLS_FLAGS includes wxALL +#define HIGHLIGHT_BACKGROUND_OTHER_THAN_CHECBOXES 0 + +// Uncommenting wxSIMPLE_BORDER will create a visibled grid +#define LIST_PANELS_STYLE (wxTAB_TRAVERSAL/*|wxSIMPLE_BORDER*/) + +// Uncommenting wxALL will add a margin between rows, but waste some visual space +#define LIST_CONTROLS_FLAGS (wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL/*|wxALL*/) + +//============================================================================== +// IDs for the dialog controls + +enum +{ + ID_LAYERNAMES = ( wxID_HIGHEST + 1 ), + ID_CHECKBOXES = ( ID_LAYERNAMES + NB_LAYERS ), + ID_LAYERTYPES = ( ID_CHECKBOXES + NB_LAYERS ), +}; + +//============================================================================== +// We want our dialog to remember its previous screen position + +wxPoint DialogLayerSetup::m_DialogLastPosition( -1, -1 ); + +//============================================================================== +// Layer order on the list panel + +#if ORIGINAL_KICAD_LAYER_ORDER + +// Kicad's original order + +static const int LayerOrder[NB_LAYERS] = +{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28 }; + +#else + +// Real board order + +static const int LayerOrder[NB_LAYERS] = +{ 17, 19, 21, 23, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, + 3, 2, 1, 0, 22, 20, 18, 16, 28, 27, 26, 25, 24 }; + +#endif + +//============================================================================== +// Categories for coloring the rows backgrounds (0 means default dialog color). + +static const int LayerCategories[NB_LAYERS] = +{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 5, 5, 5, 5, 4 }; + +//============================================================================== +// Colors for the rows backgrounds in layer list + +static const wxColour LayerCategoriesColors[5] = +{ + wxColour( 236, 233, 236 ), // 1 + wxColour( 255, 252, 235 ), // 2 + wxColour( 236, 253, 216 ), // 3 + wxColour( 255, 253, 216 ), // 4 + wxColour( 236, 233, 255 ) // 5 +}; + +//============================================================================== +// Descriptive types for non-copper layers + +static const wxString LayerCategoriesNames[NB_LAYERS] = +{ + _( "Unknown" ), // Not used + _( "Off-board, manufacturing" ), // 1 + _( "On-board, non-copper" ), // 2 + _( "On-board, copper" ), // 3 + _( "Board contour" ), // 4 + _( "Auxiliary" ) // 5 +}; + +//============================================================================== +// Names for the presets + +static const wxString m_PresetsChoiceChoices[] = +{ + _("All Layers On"), + _("Single Side"), + _("Single Side, SMD on Back"), + _("Two Layers, Parts on Front"), + _("Two Layers, Parts on Both Faces"), + _("Four Layers, Parts on Front"), + _("Four Layers, Parts on Both Faces") +}; + +#define PRESETS_CHOICE_N_CHOICES ((int)(sizeof m_PresetsChoiceChoices/sizeof m_PresetsChoiceChoices[0])) + +//============================================================================== +// Bit masks (for all layers) for each defined preset + +static const int Presets[] = +{ + ALL_LAYERS, // 0x1fffffff + SILKSCREEN_LAYER_CMP | CUIVRE_LAYER | SOLDERMASK_LAYER_CU | EDGE_LAYER, // 0x10600001 + SILKSCREEN_LAYER_CMP | CUIVRE_LAYER | SOLDERMASK_LAYER_CU | + ADHESIVE_LAYER_CU | EDGE_LAYER, // 0x10610001 + SILKSCREEN_LAYER_CMP | SOLDERMASK_LAYER_CMP | CMP_LAYER | CUIVRE_LAYER | + SOLDERMASK_LAYER_CU | EDGE_LAYER, // 0x10e08001 + SILKSCREEN_LAYER_CMP | SOLDERMASK_LAYER_CMP | CMP_LAYER | CUIVRE_LAYER | + SOLDERMASK_LAYER_CU | SILKSCREEN_LAYER_CU | EDGE_LAYER, // 0x10f08001 + SILKSCREEN_LAYER_CMP | SOLDERMASK_LAYER_CMP | CMP_LAYER | LAYER_3 | + LAYER_2 | CUIVRE_LAYER | SOLDERMASK_LAYER_CU | EDGE_LAYER, // 0x10e08007 + SILKSCREEN_LAYER_CMP | SOLDERMASK_LAYER_CMP | CMP_LAYER | LAYER_3 | LAYER_2 | + CUIVRE_LAYER | SOLDERMASK_LAYER_CU | SILKSCREEN_LAYER_CU | EDGE_LAYER // 0x10f08007 +}; + +//============================================================================== +// Options to show in the copper layer choice widget + +static const wxString m_LayerNumberChoiceChoices[] = +{ + wxT("1"), + wxT("2"), + wxT("4"), + wxT("6"), + wxT("8"), + wxT("10"), + wxT("12"), + wxT("14"), + wxT("16") +}; + +#define LAYER_NUMBER_CHOICE_N_CHOICES ((int)(sizeof m_LayerNumberChoiceChoices/sizeof m_LayerNumberChoiceChoices[0])) + +//============================================================================== +// Bit masks for copper layers, one for each option in the copper layer choice widget + +static const int CopperMasks[] = +{ + 0x00000001, + 0x00008001, + 0x00008007, + 0x0000801f, + 0x0000807f, + 0x000081ff, + 0x000087ff, + 0x00009fff, + 0x0000ffff +}; + +//============================================================================== +// Names for the types of copper layers + +static const wxString m_LayerTypeChoiceChoices[] = +{ + wxT("Signal"), + wxT("Power"), + wxT("Mixed"), + wxT("Jumper") +}; + +#define LAYER_TYPE_CHOICE_N_CHOICES ( sizeof m_LayerTypeChoiceChoices / sizeof m_LayerTypeChoiceChoices[0] ) + +//============================================================================== +// Helper function, only needed if we are goint to color the rows + +#if PANEL_BACKGROUND_COLORED + +static wxColour GetRowColor( int Layer ) +{ + if( ! IsValidLayerIndex( Layer ) || LayerCategories[Layer] == 0 ) + return wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ); + else + return LayerCategoriesColors[LayerCategories[Layer]-1]; +} + +#endif // PANEL_BACKGROUND_COLORED + +//============================================================================== + +static wxString GetCategoryName( int Layer ) +{ + if( ! IsValidLayerIndex( Layer )) + return wxEmptyString; + + int Category = LayerCategories[Layer]; + + if( Category < 0 || Category >= (int)( sizeof LayerCategoriesNames / sizeof LayerCategoriesNames[0] )) + return wxEmptyString; + else + return LayerCategoriesNames[Category]; +} + +//============================================================================== +// We will get the names for all the layers here, it will ease things if in the +// future the non-copper layers names can be changed. + +wxString DialogLayerSetup::GetLayerName( int Layer ) +{ + return m_Pcb->GetLayerName( Layer ); +/* + if( Layer < 0 || Layer >= NB_LAYERS ) + return wxEmptyString; + else if( Layer < NB_COPPER_LAYERS ) + return m_Pcb->GetLayerName( Layer ); + else + return LayerNames[Layer]; +*/ +} + +//============================================================================== + +void DialogLayerSetup::SetLayerName( int Layer, wxString Name ) +{ + m_Pcb->SetLayerName( Layer, Name ); +} + +//============================================================================== + +int DialogLayerSetup::GetLayerType( int Layer ) +{ + return m_Pcb->GetLayerType( Layer ); +} + +//============================================================================== +void DialogLayerSetup::SetLayerType( int Layer, LAYER_T Type ) +{ + m_Pcb->SetLayerType( Layer, Type ); +} + +//============================================================================== +// The layer mask for non-copper layers is obtained from the new +// EDA_BoardDesignSettings::m*EnabledLayers, but for compatibility, the mask +// for the copper-layers is obtained from g_DesignSettings::m_CopperLayerCount + +// Hopefully in the future we may unify them, perhaps saving only the mask and +// at load time calculating the number, or dropping the number completely if +// possible. + +int DialogLayerSetup::GetLayersMask() +{ + int Aux = m_Pcb->m_BoardSettings->GetCopperLayerCount(); + + // Here we transform the number of copper layers in an index to the table + // CopperMasks, and also do some consistency check. + if( Aux <= 1 ) + Aux = 0; + else if( Aux > 16 ) + Aux = 8; + else + Aux /= 2; + + return CopperMasks[Aux] | m_Pcb->GetEnabledLayers() & ALL_NO_CU_LAYERS; +} + +//============================================================================== +// This function translates from the dialog's layer order to Kicad's layer order. + +static int GetLayerNumber( int Row ) +{ + return LayerOrder[Row]; +} + +//============================================================================== +DialogLayerSetup::DialogLayerSetup( WinEDA_PcbFrame* parent, const wxPoint& pos, wxWindowID id, const wxString& title, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + m_Parent = parent; + m_Pcb = m_Parent->GetBoard(); + + if( pos == wxDefaultPosition ) + SetPosition( m_DialogLastPosition ); + + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* m_MainSizer; + m_MainSizer = new wxBoxSizer( wxVERTICAL ); + + m_MainPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxRAISED_BORDER|wxTAB_TRAVERSAL ); + wxBoxSizer* m_MainPanelSizer; + m_MainPanelSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* m_ChoicesSizer; + m_ChoicesSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* m_PresetsSizer; + m_PresetsSizer = new wxBoxSizer( wxVERTICAL ); + + m_PresetsCaption = new wxStaticText( m_MainPanel, wxID_ANY, wxT("Presets"), wxDefaultPosition, wxDefaultSize, 0 ); + m_PresetsCaption->Wrap( -1 ); + m_PresetsSizer->Add( m_PresetsCaption, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + + m_PresetsChoice = new wxChoice( m_MainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, PRESETS_CHOICE_N_CHOICES, m_PresetsChoiceChoices, 0 ); + m_PresetsChoice->SetSelection( 0 ); + m_PresetsChoice->SetToolTip( wxT("Choose the type which better describes your board") ); + + m_PresetsSizer->Add( m_PresetsChoice, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + m_ChoicesSizer->Add( m_PresetsSizer, 1, wxEXPAND, 5 ); + + wxBoxSizer* m_LayerNumberSizer; + m_LayerNumberSizer = new wxBoxSizer( wxVERTICAL ); + + m_LayerNumberCaption = new wxStaticText( m_MainPanel, wxID_ANY, wxT("Copper Layers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayerNumberCaption->Wrap( -1 ); + m_LayerNumberSizer->Add( m_LayerNumberCaption, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_LayerNumberChoice = new wxChoice( m_MainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, LAYER_NUMBER_CHOICE_N_CHOICES, m_LayerNumberChoiceChoices, 0 ); + m_LayerNumberChoice->SetSelection( 8 ); + m_LayerNumberChoice->SetToolTip( wxT("Choose how many copper layers you need") ); + + m_LayerNumberSizer->Add( m_LayerNumberChoice, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_ChoicesSizer->Add( m_LayerNumberSizer, 0, wxEXPAND, 5 ); + + m_MainPanelSizer->Add( m_ChoicesSizer, 0, wxEXPAND, 5 ); + + m_Separator1 = new wxStaticLine( m_MainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + m_MainPanelSizer->Add( m_Separator1, 0, wxEXPAND | wxALL, 5 ); + + m_LayersCaptionText = new wxStaticText( m_MainPanel, wxID_ANY, wxT("Layers"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayersCaptionText->Wrap( -1 ); + m_MainPanelSizer->Add( m_LayersCaptionText, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_LayersPanel = new wxPanel( m_MainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); + wxBoxSizer* m_LayersPanelSizer; + m_LayersPanelSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* m_LayerCaptionsSizer; + m_LayerCaptionsSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* m_LayerNameCaptionSizer; + m_LayerNameCaptionSizer = new wxBoxSizer( wxVERTICAL ); + + m_LayerNameCaptionText = new wxStaticText( m_LayersPanel, wxID_ANY, wxT("Name"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayerNameCaptionText->Wrap( -1 ); + m_LayerNameCaptionText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + + m_LayerNameCaptionSizer->Add( m_LayerNameCaptionText, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_LayerCaptionsSizer->Add( m_LayerNameCaptionSizer, 0, wxEXPAND, 5 ); + + wxBoxSizer* m_LayerEnabledCaptionSizer; + m_LayerEnabledCaptionSizer = new wxBoxSizer( wxVERTICAL ); + + m_LayerEnabledCaptionText = new wxStaticText( m_LayersPanel, wxID_ANY, wxT("Enabled"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayerEnabledCaptionText->Wrap( -1 ); + m_LayerEnabledCaptionText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + + m_LayerEnabledCaptionSizer->Add( m_LayerEnabledCaptionText, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_LayerCaptionsSizer->Add( m_LayerEnabledCaptionSizer, 0, wxEXPAND, 5 ); + + wxBoxSizer* m_LayerTypeCaptionSizer; + m_LayerTypeCaptionSizer = new wxBoxSizer( wxVERTICAL ); + + m_LayerTypeCaptionText = new wxStaticText( m_LayersPanel, wxID_ANY, wxT("Type"), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayerTypeCaptionText->Wrap( -1 ); + m_LayerTypeCaptionText->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) ); + + m_LayerTypeCaptionSizer->Add( m_LayerTypeCaptionText, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_LayerCaptionsSizer->Add( m_LayerTypeCaptionSizer, 0, wxEXPAND, 5 ); + + m_LayersPanelSizer->Add( m_LayerCaptionsSizer, 0, wxEXPAND, 5 ); + + m_LayerListScroller = new wxScrolledWindow( m_LayersPanel, wxID_ANY, wxDefaultPosition, wxSize( -1, 300 )/* wxDefaultSize */, wxALWAYS_SHOW_SB|wxVSCROLL ); + m_LayerListScroller->SetMinSize( wxSize( -1, 300 ) ); + + wxBoxSizer* bSizer18; + bSizer18 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* m_LayerListSizer; + m_LayerListSizer = new wxBoxSizer( wxHORIZONTAL ); + + //-------------------------------------------------------------------------- + // Create the controls inside the scrolled window + + wxGridSizer* m_LayerNameListSizer; + m_LayerNameListSizer = new wxGridSizer( 32, 1, 0, 0 ); + + for( int Row = 0; Row < NB_LAYERS; Row++ ) + { + int Layer = GetLayerNumber( Row ); + + //---------------------------------------------------------------------- + // Create a panel and sizer for each layer name + + m_LayerNamePanel[Layer] = new wxPanel( m_LayerListScroller, wxID_ANY, wxDefaultPosition, wxDefaultSize, LIST_PANELS_STYLE ); + +#if PANEL_BACKGROUND_COLORED + m_LayerNamePanel[Layer]->SetBackgroundColour( GetRowColor( Layer )); +#endif // PANEL_BACKGROUND_COLORED + + wxBoxSizer* m_LayerNameSizer = new wxBoxSizer( wxHORIZONTAL ); + + if( Layer >= NB_COPPER_LAYERS ) + { + //---------------------------------------------------------------------- + // The non-copper layer names canot be changed, we use just a static text + + m_LayerNameStaticText[Layer-NB_COPPER_LAYERS] = new wxStaticText( m_LayerNamePanel[Layer], ID_LAYERNAMES + Layer, GetLayerName( Layer ), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayerNameStaticText[Layer-NB_COPPER_LAYERS]->Wrap( -1 ); + m_LayerNameStaticText[Layer-NB_COPPER_LAYERS]->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) ); + + m_LayerNameSizer->Add( m_LayerNameStaticText[Layer-NB_COPPER_LAYERS], 1, LIST_CONTROLS_FLAGS, 5 ); + + m_LayerNamePanel[Layer]->SetSizer( m_LayerNameSizer ); + m_LayerNamePanel[Layer]->Layout(); + m_LayerNameSizer->Fit( m_LayerNamePanel[Layer] ); + m_LayerNameListSizer->Add( m_LayerNamePanel[Layer], 0, wxEXPAND, 5 ); + + } + else + { + //---------------------------------------------------------------------- + // The copper layer names can be changed, we need a text control + + m_LayerNameTextCtrl[Layer] = new wxTextCtrl( m_LayerNamePanel[Layer], ID_LAYERNAMES + Layer, GetLayerName( Layer ), wxDefaultPosition, wxDefaultSize, 0 /*|wxNO_BORDER*/ ); + m_LayerNameTextCtrl[Layer]->SetMaxLength( 20 ); + +#if CONTROL_BACKGROUND_COLORED + m_LayerNameTextCtrl[Layer]->SetBackgroundColour( GetRowColor( Layer )); +#endif // CONTROL_BACKGROUND_COLORED + + m_LayerNameTextCtrl[Layer]->SetToolTip( wxT("Edit Copper Layer Name") ); + + m_LayerNameSizer->Add( m_LayerNameTextCtrl[Layer], 1, LIST_CONTROLS_FLAGS, 5 ); + + m_LayerNamePanel[Layer]->SetSizer( m_LayerNameSizer ); + m_LayerNamePanel[Layer]->Layout(); + m_LayerNameSizer->Fit( m_LayerNamePanel[Layer] ); + m_LayerNameListSizer->Add( m_LayerNamePanel[Layer], 0, wxEXPAND, 5 ); + } + } + + m_LayerListSizer->Add( m_LayerNameListSizer, 0, wxEXPAND, 5 ); + + //-------------------------------------------------------------------------- + // Create the controls inside the scrolled window + + wxGridSizer* m_LayerEnabledListSizer; + m_LayerEnabledListSizer = new wxGridSizer( 32, 1, 0, 0 ); + + for( int Row = 0; Row < NB_LAYERS; Row++ ) + { + int Layer = GetLayerNumber( Row ); + + //---------------------------------------------------------------------- + // Create a panel and sizer for each layer enable check-box + + m_LayerEnabledPanel[Layer] = new wxPanel( m_LayerListScroller, wxID_ANY, wxDefaultPosition, wxDefaultSize, LIST_PANELS_STYLE ); + +#if PANEL_BACKGROUND_COLORED + m_LayerEnabledPanel[Layer]->SetBackgroundColour( GetRowColor( Layer )); +#endif // PANEL_BACKGROUND_COLORED + + wxBoxSizer* m_LayerEnabledSizer; + m_LayerEnabledSizer = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* m_LayerEnabledSizerInt; + m_LayerEnabledSizerInt = new wxBoxSizer( wxHORIZONTAL ); + + m_LayerEnabledCheckBox[Layer] = new wxCheckBox( m_LayerEnabledPanel[Layer], ID_CHECKBOXES + Layer, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + + m_LayerEnabledCheckBox[Layer]->SetForegroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_LayerEnabledCheckBox[Layer]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DDKSHADOW ) ); + m_LayerEnabledCheckBox[Layer]->SetToolTip( wxT("Enable/Disable Layer") ); + + m_LayerEnabledSizerInt->Add( m_LayerEnabledCheckBox[Layer], 0, LIST_CONTROLS_FLAGS, 5 ); + m_LayerEnabledSizer->Add( m_LayerEnabledSizerInt, 1, wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_LayerEnabledPanel[Layer]->SetSizer( m_LayerEnabledSizer ); + m_LayerEnabledPanel[Layer]->Layout(); + m_LayerEnabledSizer->Fit( m_LayerEnabledPanel[Layer] ); + m_LayerEnabledListSizer->Add( m_LayerEnabledPanel[Layer], 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + } + + m_LayerListSizer->Add( m_LayerEnabledListSizer, 0, wxEXPAND, 5 ); + + //-------------------------------------------------------------------------- + // Create the controls inside the scrolled window + + wxGridSizer* m_LayerTypeListSizer; + m_LayerTypeListSizer = new wxGridSizer( 32, 1, 0, 0 ); + + for( int Row = 0; Row < NB_LAYERS; Row++ ) + { + int Layer = GetLayerNumber( Row ); + + //---------------------------------------------------------------------- + // Create a panel and sizer for each layer enable chack-box + + m_LayerTypePanel[Layer] = new wxPanel( m_LayerListScroller, wxID_ANY, wxDefaultPosition, wxDefaultSize, LIST_PANELS_STYLE ); + +#if PANEL_BACKGROUND_COLORED + m_LayerTypePanel[Layer]->SetBackgroundColour( GetRowColor( Layer )); +#endif // PANEL_BACKGROUND_COLORED + + wxBoxSizer* m_LayerTypeSizer; + m_LayerTypeSizer = new wxBoxSizer( wxHORIZONTAL ); + + if( Layer >= NB_COPPER_LAYERS ) + { + //---------------------------------------------------------------------- + // The non-copper layer types canot be changed, we use just a static text + + m_LayerTypeStaticText[Layer-NB_COPPER_LAYERS] = new wxStaticText( m_LayerTypePanel[Layer], ID_LAYERTYPES + Layer, GetCategoryName( Layer ), wxDefaultPosition, wxDefaultSize, 0 ); + m_LayerTypeStaticText[Layer-NB_COPPER_LAYERS]->Wrap( -1 ); + m_LayerTypeStaticText[Layer-NB_COPPER_LAYERS]->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) ); + + m_LayerTypeSizer->Add( m_LayerTypeStaticText[Layer-NB_COPPER_LAYERS], 1, LIST_CONTROLS_FLAGS, 5 ); + + m_LayerTypePanel[Layer]->SetSizer( m_LayerTypeSizer ); + m_LayerTypePanel[Layer]->Layout(); + m_LayerTypeSizer->Fit( m_LayerTypePanel[Layer] ); + m_LayerTypeListSizer->Add( m_LayerTypePanel[Layer], 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + } + else + { + //---------------------------------------------------------------------- + // The copper layer names can be changed, we need a choice control + + m_LayerTypeChoice[Layer] = new wxChoice( m_LayerTypePanel[Layer], ID_LAYERTYPES + Layer, wxDefaultPosition, wxDefaultSize, LAYER_TYPE_CHOICE_N_CHOICES, m_LayerTypeChoiceChoices, 0 ); + m_LayerTypeChoice[Layer]->SetSelection( GetLayerType( Layer )); + m_LayerTypeChoice[Layer]->SetToolTip( wxT("Choose Copper Layer Type") ); + +#if CONTROL_BACKGROUND_COLORED + m_LayerTypeChoice[Layer]->SetBackgroundColour( GetRowColor( Layer )); +#endif // CONTROL_BACKGROUND_COLORED + + m_LayerTypeSizer->Add( m_LayerTypeChoice[Layer], 1, LIST_CONTROLS_FLAGS, 5 ); + + m_LayerTypePanel[Layer]->SetSizer( m_LayerTypeSizer ); + m_LayerTypePanel[Layer]->Layout(); + m_LayerTypeSizer->Fit( m_LayerTypePanel[Layer] ); + m_LayerTypeListSizer->Add( m_LayerTypePanel[Layer], 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + } + } + + m_LayerListSizer->Add( m_LayerTypeListSizer, 0, wxEXPAND, 5 ); + + //-------------------------------------------------------------------------- + // Adjust the width of the columns and column captions + int w; + + w = max( m_LayerNameListSizer->CalcMin().x, m_LayerNameCaptionSizer->CalcMin().x ); + m_LayerNameListSizer->SetMinSize( w, -1 ); + m_LayerNameCaptionSizer->SetMinSize( w, -1 ); + + w = max( m_LayerEnabledListSizer->CalcMin().x, m_LayerEnabledCaptionSizer->CalcMin().x ); + m_LayerEnabledListSizer->SetMinSize( w, -1 ); + m_LayerEnabledCaptionSizer->SetMinSize( w, -1 ); + + w = max( m_LayerTypeListSizer->CalcMin().x, m_LayerTypeCaptionSizer->CalcMin().x ); + m_LayerTypeListSizer->SetMinSize( w, -1 ); + m_LayerTypeCaptionSizer->SetMinSize( w, -1 ); + + + //-------------------------------------------------------------------------- + // Make the scroll step be exactly one row + + wxSize s = m_LayerNamePanel[0]->GetSize(); + m_LayerListScroller->SetScrollRate( 0, s.y ); + + //-------------------------------------------------------------------------- + + bSizer18->Add( m_LayerListSizer, 1, 0, 5 ); + + m_LayerListScroller->SetSizer( bSizer18 ); + + m_LayerListScroller->Layout(); + bSizer18->Fit( m_LayerListScroller ); + m_LayersPanelSizer->Add( m_LayerListScroller, 1, wxEXPAND, 5 ); + + m_LayersPanel->SetSizer( m_LayersPanelSizer ); + m_LayersPanel->Layout(); + m_LayersPanelSizer->Fit( m_LayersPanel ); + m_MainPanelSizer->Add( m_LayersPanel, 1, /*wxEXPAND|*/ wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_Separator2 = new wxStaticLine( m_MainPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + m_MainPanelSizer->Add( m_Separator2, 0, wxEXPAND | wxALL, 5 ); + + m_StdButtonsSizer = new wxStdDialogButtonSizer(); + m_StdButtonsSizerOK = new wxButton( m_MainPanel, wxID_OK ); + m_StdButtonsSizer->AddButton( m_StdButtonsSizerOK ); + m_StdButtonsSizerCancel = new wxButton( m_MainPanel, wxID_CANCEL ); + m_StdButtonsSizer->AddButton( m_StdButtonsSizerCancel ); + m_StdButtonsSizer->Realize(); + m_MainPanelSizer->Add( m_StdButtonsSizer, 0, wxALL|wxEXPAND, 5 ); + + m_MainPanel->SetSizer( m_MainPanelSizer ); + m_MainPanel->Layout(); + m_MainPanelSizer->Fit( m_MainPanel ); + m_MainSizer->Add( m_MainPanel, 1, wxEXPAND | wxALL, 5 ); + + this->SetSizer( m_MainSizer ); + this->Layout(); + m_MainSizer->Fit( this ); + + + + + m_LayersMask = GetLayersMask(); + + UpdatePresetsChoice(); + UpdateCopperLayersChoice(); + UpdateCheckBoxes(); + + // Connect Events + m_StdButtonsSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLayerSetup::OnCancelClick ), NULL, this ); + m_StdButtonsSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLayerSetup::OnOKClick ), NULL, this ); + + m_PresetsChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogLayerSetup::OnPresetChoice ), NULL, this ); + m_LayerNumberChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogLayerSetup::OnCopperLayersChoice ), NULL, this ); + + for( int i = 0; i < NB_COPPER_LAYERS; i++ ) + { + m_LayerTypeChoice[i]->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogLayerSetup::OnLayerTypeChoice ), NULL, this ); +#if HIGHLIGHT_BACKGROUND_OTHER_THAN_CHECBOXES + m_LayerTypeChoice[i]->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerTypeKillFocus ), NULL, this ); + m_LayerTypeChoice[i]->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerTypeSetFocus ), NULL, this ); + m_LayerNameTextCtrl[i]->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerNameKillFocus ), NULL, this ); + m_LayerNameTextCtrl[i]->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerNameSetFocus ), NULL, this ); +#endif // HIGHLIGHT_BACKGROUND_OTHER_THAN_CHECBOXES + } + + for( int i = 0; i < NB_LAYERS; i++ ) + { + m_LayerEnabledCheckBox[i]->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DialogLayerSetup::OnLayerEnabledCheckBox ), NULL, this ); + m_LayerEnabledCheckBox[i]->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerEnabledKillFocus ), NULL, this ); + m_LayerEnabledCheckBox[i]->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerEnabledSetFocus ), NULL, this ); + } +} + +//============================================================================== + +DialogLayerSetup::~DialogLayerSetup() +{ + // Disconnect Events + m_StdButtonsSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLayerSetup::OnCancelClick ), NULL, this ); + m_StdButtonsSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DialogLayerSetup::OnOKClick ), NULL, this ); + + m_PresetsChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogLayerSetup::OnPresetChoice ), NULL, this ); + m_LayerNumberChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogLayerSetup::OnCopperLayersChoice ), NULL, this ); + + for( int i = 0; i < NB_COPPER_LAYERS; i++ ) + { + m_LayerTypeChoice[i]->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DialogLayerSetup::OnLayerTypeChoice ), NULL, this ); +#if HIGHLIGHT_BACKGROUND_OTHER_THAN_CHECBOXES + m_LayerTypeChoice[i]->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerTypeKillFocus ), NULL, this ); + m_LayerTypeChoice[i]->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerTypeSetFocus ), NULL, this ); + m_LayerNameTextCtrl[i]->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerNameKillFocus ), NULL, this ); + m_LayerNameTextCtrl[i]->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerNameSetFocus ), NULL, this ); +#endif // HIGHLIGHT_BACKGROUND_OTHER_THAN_CHECBOXES + } + + for( int i = 0; i < NB_LAYERS; i++ ) + { + m_LayerEnabledCheckBox[i]->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DialogLayerSetup::OnLayerEnabledCheckBox ), NULL, this ); + m_LayerEnabledCheckBox[i]->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerEnabledKillFocus ), NULL, this ); + m_LayerEnabledCheckBox[i]->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DialogLayerSetup::OnLayerEnabledSetFocus ), NULL, this ); + } +} + +//============================================================================== + +void DialogLayerSetup::UpdateCheckBoxes() +{ + int i; + + for( i = 0; i < NB_COPPER_LAYERS; i++ ) + { + m_LayerEnabledCheckBox[i]->Disable(); + + if( m_LayersMask >> i & 0x00000001 ) + { + m_LayerEnabledCheckBox[i]->SetValue( true ); + m_LayerNameTextCtrl[i]->Enable(); + m_LayerTypeChoice[i]->Enable(); + } + else + { + m_LayerEnabledCheckBox[i]->SetValue( false ); + m_LayerNameTextCtrl[i]->Disable(); + m_LayerTypeChoice[i]->Disable(); + } + m_LayerEnabledCheckBox[i]->Refresh(); + } + + for( ; i < NB_LAYERS; i++ ) + { + m_LayerEnabledCheckBox[i]->SetValue( m_LayersMask >> i & 0x00000001 ); + m_LayerEnabledCheckBox[i]->Refresh(); + } + + if( m_LayersMask & CUIVRE_LAYER ) + { + m_LayerNameStaticText[SOLDERPASTE_N_CU-NB_COPPER_LAYERS]->Enable(); + m_LayerEnabledCheckBox[SOLDERPASTE_N_CU]->Enable(); + m_LayerTypeStaticText[SOLDERPASTE_N_CU-NB_COPPER_LAYERS]->Enable(); + + m_LayerNameStaticText[SOLDERMASK_N_CU-NB_COPPER_LAYERS]->Enable(); + m_LayerEnabledCheckBox[SOLDERMASK_N_CU]->Enable(); + m_LayerTypeStaticText[SOLDERMASK_N_CU-NB_COPPER_LAYERS]->Enable(); + } + else + { + m_LayerEnabledCheckBox[SOLDERPASTE_N_CU]->SetValue( false ); + m_LayerEnabledCheckBox[SOLDERMASK_N_CU]->SetValue( false ); + + m_LayerNameStaticText[SOLDERPASTE_N_CU-NB_COPPER_LAYERS]->Disable(); + m_LayerEnabledCheckBox[SOLDERPASTE_N_CU]->Disable(); + m_LayerTypeStaticText[SOLDERPASTE_N_CU-NB_COPPER_LAYERS]->Disable(); + + m_LayerNameStaticText[SOLDERMASK_N_CU-NB_COPPER_LAYERS]->Disable(); + m_LayerEnabledCheckBox[SOLDERMASK_N_CU]->Disable(); + m_LayerTypeStaticText[SOLDERMASK_N_CU-NB_COPPER_LAYERS]->Disable(); + } + + if( m_LayersMask & CMP_LAYER ) + { + m_LayerNameStaticText[SOLDERPASTE_N_CMP-NB_COPPER_LAYERS]->Enable(); + m_LayerEnabledCheckBox[SOLDERPASTE_N_CMP]->Enable(); + m_LayerTypeStaticText[SOLDERPASTE_N_CMP-NB_COPPER_LAYERS]->Enable(); + + m_LayerNameStaticText[SOLDERMASK_N_CMP-NB_COPPER_LAYERS]->Enable(); + m_LayerEnabledCheckBox[SOLDERMASK_N_CMP]->Enable(); + m_LayerTypeStaticText[SOLDERMASK_N_CMP-NB_COPPER_LAYERS]->Enable(); + } + else + { + m_LayerEnabledCheckBox[SOLDERPASTE_N_CMP]->SetValue( false ); + m_LayerEnabledCheckBox[SOLDERMASK_N_CMP]->SetValue( false ); + + m_LayerNameStaticText[SOLDERPASTE_N_CMP-NB_COPPER_LAYERS]->Disable(); + m_LayerEnabledCheckBox[SOLDERPASTE_N_CMP]->Disable(); + m_LayerTypeStaticText[SOLDERPASTE_N_CMP-NB_COPPER_LAYERS]->Disable(); + + m_LayerNameStaticText[SOLDERMASK_N_CMP-NB_COPPER_LAYERS]->Disable(); + m_LayerEnabledCheckBox[SOLDERMASK_N_CMP]->Disable(); + m_LayerTypeStaticText[SOLDERMASK_N_CMP-NB_COPPER_LAYERS]->Disable(); + } +} + +//============================================================================== + +void DialogLayerSetup::UpdateCopperLayersChoice() +{ + int NumberOfCopperLayers = 0; + + // Count the copper layers + for( int i = 0; i < NB_COPPER_LAYERS; i++ ) + { + if( m_LayersMask >> i & 0x00000001 ) + NumberOfCopperLayers++; + } + + m_LayerNumberChoice->SetSelection( NumberOfCopperLayers / 2 ); +} + +//============================================================================== + +void DialogLayerSetup::UpdatePresetsChoice() +{ + int Selection = -1; + + for( int i = 0; i < NB_LAYERS; i++ ) + { + if( m_LayersMask == Presets[i] ) + { + Selection = i; + break; + } + } + + m_PresetsChoice->SetSelection( Selection ); + m_PresetsChoice->Refresh(); +} + +//============================================================================== + +void DialogLayerSetup::OnPresetChoice( wxCommandEvent& event ) +{ + int Selection = m_PresetsChoice->GetSelection(); + + if( Selection < 0 || Selection >= PRESETS_CHOICE_N_CHOICES ) + return; + + m_LayersMask = Presets[Selection]; + + UpdateCopperLayersChoice(); + UpdateCheckBoxes(); + +// event.Skip(); +} + +//============================================================================== + +void DialogLayerSetup::OnCopperLayersChoice( wxCommandEvent& event ) +{ + int Selection = m_LayerNumberChoice->GetSelection(); + + if( Selection < 0 || Selection >= LAYER_NUMBER_CHOICE_N_CHOICES ) + return; + + m_LayersMask = ( m_LayersMask & ALL_NO_CU_LAYERS ) | CopperMasks[Selection]; + + UpdatePresetsChoice(); + UpdateCheckBoxes(); + +// event.Skip(); +} + +//============================================================================== + +void DialogLayerSetup::OnLayerEnabledCheckBox( wxCommandEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_CHECKBOXES && Id < ID_CHECKBOXES + NB_LAYERS ) + { + int Index = Id - ID_CHECKBOXES; + if( m_LayerEnabledCheckBox[Index]->GetValue() ) + m_LayersMask |= 1 << Index; + else + m_LayersMask &= ~( 1 << Index ); + + UpdatePresetsChoice(); + UpdateCheckBoxes(); + } + +// event.Skip(); +} + +//============================================================================== +// Checkboxes without captions donīt show when they have focus, we will change the color +// of the panel where they reside to allow navigating the dialog by keyboard + +void DialogLayerSetup::OnLayerEnabledSetFocus( wxFocusEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_CHECKBOXES && Id < ID_CHECKBOXES + NB_LAYERS ) + { + int Index = Id - ID_CHECKBOXES; + m_LayerEnabledPanel[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_LayerEnabledPanel[Index]->Refresh(); + } + +// event.Skip(); +} +//============================================================================== +void DialogLayerSetup::OnLayerEnabledKillFocus( wxFocusEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_CHECKBOXES && Id < ID_CHECKBOXES + NB_LAYERS ) + { + int Index = Id - ID_CHECKBOXES; +#if PANEL_BACKGROUND_COLORED + m_LayerEnabledPanel[Index]->SetBackgroundColour( GetRowColor( Index )); +#else // PANEL_BACKGROUND_COLORED + m_LayerEnabledPanel[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE )); +#endif // PANEL_BACKGROUND_COLORED + m_LayerEnabledPanel[Index]->Refresh(); + } + +// event.Skip(); +} +//============================================================================== +void DialogLayerSetup::OnLayerNameSetFocus( wxFocusEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_LAYERNAMES && Id < ID_LAYERNAMES + NB_COPPER_LAYERS ) + { + int Index = Id - ID_LAYERNAMES; +#if CONTROL_BACKGROUND_COLORED + m_LayerNameTextCtrl[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); +#endif // CONTROL_BACKGROUND_COLORED + m_LayerNamePanel[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_LayerNamePanel[Index]->Refresh(); + } + +// event.Skip(); +} +//============================================================================== +void DialogLayerSetup::OnLayerNameKillFocus( wxFocusEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_LAYERNAMES && Id < ID_LAYERNAMES + NB_COPPER_LAYERS ) + { + int Index = Id - ID_LAYERNAMES; +#if CONTROL_BACKGROUND_COLORED + m_LayerNameTextCtrl[Index]->SetBackgroundColour( GetRowColor( Index )); +#endif // CONTROL_BACKGROUND_COLORED +#if PANEL_BACKGROUND_COLORED + m_LayerNamePanel[Index]->SetBackgroundColour( GetRowColor( Index )); +#else // PANEL_BACKGROUND_COLORED + m_LayerNamePanel[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE )); +#endif // PANEL_BACKGROUND_COLORED + m_LayerNamePanel[Index]->Refresh(); + } + +// event.Skip(); +} +//============================================================================== +void DialogLayerSetup::OnLayerTypeSetFocus( wxFocusEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_LAYERTYPES && Id < ID_LAYERTYPES + NB_COPPER_LAYERS ) + { + int Index = Id - ID_LAYERTYPES; +#if CONTROL_BACKGROUND_COLORED + m_LayerTypeChoice[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); +#endif // CONTROL_BACKGROUND_COLORED + m_LayerTypePanel[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT ) ); + m_LayerTypePanel[Index]->Refresh(); + } + +// event.Skip(); +} +//============================================================================== +void DialogLayerSetup::OnLayerTypeKillFocus( wxFocusEvent& event ) +{ + int Id = event.GetId(); + + if( Id >= ID_LAYERTYPES && Id < ID_LAYERTYPES + NB_COPPER_LAYERS ) + { + int Index = Id - ID_LAYERTYPES; +#if CONTROL_BACKGROUND_COLORED + m_LayerTypeChoice[Index]->SetBackgroundColour( GetRowColor( Index )); +#endif // CONTROL_BACKGROUND_COLORED +#if PANEL_BACKGROUND_COLORED + m_LayerTypePanel[Index]->SetBackgroundColour( GetRowColor( Index )); +#else // PANEL_BACKGROUND_COLORED + m_LayerTypePanel[Index]->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE )); +#endif // PANEL_BACKGROUND_COLORED + m_LayerTypePanel[Index]->Refresh(); + } + +// event.Skip(); +} + +//============================================================================== + +void DialogLayerSetup::OnCancelClick( wxCommandEvent& event ) +{ + // Save the dialog's position before finishing + m_DialogLastPosition = this->GetPosition(); + event.Skip(); +} + +//============================================================================== + +void DialogLayerSetup::OnOKClick( wxCommandEvent& event ) +{ + int NumberOfCopperLayers = 0; + + // Count the copper layers + for( int i = 0; i < NB_COPPER_LAYERS; i++ ) + { + if( m_LayersMask >> i & 0x00000001 ) + NumberOfCopperLayers++; + } + + m_Pcb->m_BoardSettings->m_CopperLayerCount = NumberOfCopperLayers; + + m_Pcb->SetEnabledLayers( m_LayersMask ); + + for( int i = 0; i < NB_COPPER_LAYERS; i++ ) + { + SetLayerName( i, m_LayerNameTextCtrl[i]->GetValue() ); + SetLayerType( i, (LAYER_T)m_LayerTypeChoice[i]->GetSelection() ); + } + + + m_Parent->ReCreateLayerBox( NULL ); + + // Save the dialog's position before finishing + m_DialogLastPosition = this->GetPosition(); + + event.Skip(); +} + +//============================================================================== +// Invoke the dialog. + +void DisplayDialogLayerSetup( WinEDA_PcbFrame* parent ) +{ + DialogLayerSetup* frame = new DialogLayerSetup( parent ); + frame->ShowModal(); + frame->Destroy(); +} + +//============================================================================== diff --git a/pcbnew/dialog_layers_setup.fbp b/pcbnew/dialog_layers_setup.fbp new file mode 100644 index 0000000000..3851f53068 --- /dev/null +++ b/pcbnew/dialog_layers_setup.fbp @@ -0,0 +1,1699 @@ + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_layers_setup + 1000 + none + 0 + dialog_layers_setup + + . + + 1 + 1 + 0 + 0 + + + + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + dialog_layers_setup + + 700,600 + wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU + + Layer Setup + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + m_MainSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_MainPanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxRAISED_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_MainPanelSizer + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + m_ChoicesSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + + m_PresetsSizer + wxVERTICAL + none + + 5 + wxLEFT|wxRIGHT|wxTOP + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Presets + + + m_PresetsCaption + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + "Single Side" "Double Side" + + 1 + 1 + + + 0 + wxID_ANY + + + m_PresetsChoice + protected + + 0 + + + Choose what type of board you will design + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + m_LayerNumberSizer + wxVERTICAL + none + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Copper Layers + + + m_LayerNumberCaption + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + + "1" "2" "4" "6" "8" "10" "12" "14" "16" + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerNumberChoice + protected + + 8 + + + Choose how many copper layers you need. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_Separator1 + protected + + + wxLI_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + Layers + + + m_LayersCaptionText + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayersPanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxSUNKEN_BORDER|wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayersPanelSizer + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + m_LayerCaptionsSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 0 + + + m_LayerNameCaptionSizer + wxVERTICAL + none + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 1 + 1 + + ,90,92,-1,70,0 + 0 + wxID_ANY + Name + + + m_LayerNameCaptionText + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + m_LayerEnabledCaptionSizer + wxVERTICAL + none + + 5 + wxALL|wxALIGN_CENTER_HORIZONTAL + 0 + + + + 1 + 1 + + ,90,92,-1,70,0 + 0 + wxID_ANY + Enabled + + + m_LayerEnabledCaptionText + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + m_LayerTypeCaptionSizer + wxVERTICAL + none + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + + + 1 + 1 + + ,90,92,-1,70,0 + 0 + wxID_ANY + Type + + + m_LayerTypeCaptionText + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerListScroller + protected + + 0 + 1 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxALWAYS_SHOW_SB|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer18 + wxHORIZONTAL + none + + 5 + + 1 + + + m_LayerListSizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + 1 + 0 + + m_LayerNameListSizer + none + 2 + 0 + + 5 + wxEXPAND + 1 + + wxSYS_COLOUR_INACTIVECAPTION + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerNamePanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayerNameSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + + + 1 + 1 + + ,90,90,-1,70,0 + 0 + wxID_ANY + Non Copper Layer 1 + + + m_LayerNameText + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerNamePanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayerTypeSizer1 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + wxSYS_COLOUR_BTNFACE + + 1 + 1 + + + 0 + wxID_ANY + + 0 + + m_LayerNameTextCtrl + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + Copper Layer 1 + + + wxNO_BORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 1 + 0 + + m_LayerEnabledListSizer + none + 2 + 0 + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 1 + + wxSYS_COLOUR_INACTIVECAPTION + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerEnabledPanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayerEnabledSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + + m_LayerEnabledSizerInt + wxVERTICAL + none + + 5 + wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL + 0 + + wxSYS_COLOUR_3DDKSHADOW + 0 + + 1 + 1 + wxSYS_COLOUR_HIGHLIGHT + + 0 + wxID_ANY + + + + m_LayerEnabledCheckBox + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerEnabledPanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayerEnabledSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + + m_LayerEnabledSizer + wxVERTICAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT|wxALIGN_CENTER_HORIZONTAL + 0 + + wxSYS_COLOUR_3DDKSHADOW + 0 + + 1 + 1 + wxSYS_COLOUR_HIGHLIGHT + + 0 + wxID_ANY + + + + m_LayerEnabledCheckBox + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + 1 + 0 + + m_LayerTypeListSizer + none + 2 + 0 + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 1 + + wxSYS_COLOUR_INACTIVECAPTION + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerTypePanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayerTypeSizer2 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 1 + + + + 1 + 1 + + ,90,90,-1,70,0 + 0 + wxID_ANY + Non Copper Layer 1 Type + + + m_LayerTypeStaticText + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND|wxALIGN_CENTER_VERTICAL + 1 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerTypePanel + protected + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + m_LayerTypeSizer + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT + 1 + + + "Signal" "Power" "Jumper" "Mixed" + + 1 + 1 + + + 0 + wxID_ANY + + + m_LayerTypeChoice + protected + + 0 + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND | wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + + m_Separator2 + protected + + + wxLI_HORIZONTAL + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_StdButtonsSizer + protected + + OnCancelClick + + + + OnOKClick + + + + + + + + + + + diff --git a/pcbnew/dialog_layers_setup.h b/pcbnew/dialog_layers_setup.h new file mode 100644 index 0000000000..168503000a --- /dev/null +++ b/pcbnew/dialog_layers_setup.h @@ -0,0 +1,120 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DialogLayerSetup__ +#define __DialogLayerSetup__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +/// Class DialogLayerSetup +/////////////////////////////////////////////////////////////////////////////// +class DialogLayerSetup : public wxDialog +{ + private: + + protected: + wxPanel* m_MainPanel; + + wxStaticText* m_PresetsCaption; + wxChoice* m_PresetsChoice; + + wxStaticText* m_LayerNumberCaption; + wxChoice* m_LayerNumberChoice; + + wxStaticLine* m_Separator1; + + wxStaticText* m_LayersCaptionText; + + wxPanel* m_LayersPanel; + + wxStaticText* m_LayerNameCaptionText; + wxStaticText* m_LayerEnabledCaptionText; + wxStaticText* m_LayerTypeCaptionText; + + wxScrolledWindow* m_LayerListScroller; + + wxPanel* m_LayerNamePanel[NB_LAYERS]; + wxStaticText* m_LayerNameStaticText[NB_LAYERS-NB_COPPER_LAYERS]; + wxTextCtrl* m_LayerNameTextCtrl[NB_COPPER_LAYERS]; + + wxPanel* m_LayerEnabledPanel[NB_LAYERS]; + wxCheckBox* m_LayerEnabledCheckBox[NB_LAYERS]; + + wxPanel* m_LayerTypePanel[NB_LAYERS]; + wxStaticText* m_LayerTypeStaticText[NB_LAYERS-NB_COPPER_LAYERS]; + wxChoice* m_LayerTypeChoice[NB_COPPER_LAYERS]; + + wxStaticLine* m_Separator2; + + wxStdDialogButtonSizer* m_StdButtonsSizer; + wxButton* m_StdButtonsSizerOK; + wxButton* m_StdButtonsSizerCancel; + + int m_LayersMask; + + static wxPoint m_DialogLastPosition; + + WinEDA_PcbFrame* m_Parent; + BOARD* m_Pcb; + + + wxString GetLayerName( int Layer ); + int GetLayerType( int Layer ); + void SetLayerName( int Layer, wxString Name ); + void SetLayerType( int Layer, LAYER_T Type ); + int GetLayersMask(); + + + // Virtual event handlers, overide them in your derived class + virtual void OnPresetChoice( wxCommandEvent& event ); + virtual void OnCopperLayersChoice( wxCommandEvent& event ); + + virtual void OnLayerNameKillFocus( wxFocusEvent& event ); + virtual void OnLayerNameSetFocus( wxFocusEvent& event ); + + virtual void OnLayerEnabledCheckBox( wxCommandEvent& event ); + + virtual void OnLayerEnabledSetFocus( wxFocusEvent& event ); + virtual void OnLayerEnabledKillFocus( wxFocusEvent& event ); + + virtual void OnLayerTypeChoice( wxCommandEvent& event ){ event.Skip(); } + + virtual void OnLayerTypeSetFocus( wxFocusEvent& event ); + virtual void OnLayerTypeKillFocus( wxFocusEvent& event ); + + virtual void OnCancelClick( wxCommandEvent& event ); + virtual void OnOKClick( wxCommandEvent& event ); + + void UpdateCheckBoxes(); + void UpdateCopperLayersChoice(); + void UpdatePresetsChoice(); + + public: + DialogLayerSetup( WinEDA_PcbFrame* parent, + const wxPoint& pos = wxDefaultPosition, + wxWindowID id = wxID_ANY, + const wxString& title = wxT("Layer Setup"), + const wxSize& size = wxSize( -1,-1 ), + long style = wxDEFAULT_DIALOG_STYLE ); + + ~DialogLayerSetup(); +}; + +#endif //__DialogLayerSetup__