diff --git a/change_log.txt b/change_log.txt index 0ed628cf6e..409e98c536 100644 --- a/change_log.txt +++ b/change_log.txt @@ -4,6 +4,54 @@ Started 2007-June-11 Please add newer entries at the top, list the date and your name with email address. +2007-Oct-07 UPDATE Geoff Harland +================================================================================ ++ all + * Various dialog boxes can now (otherwise) be cancelled by pressing the "Esc" key. + (Some dialog boxes still require attention in that regard though, so that task + is not yet complete.) And the captions of the "OK" button within various dialog + boxes have been fully capitalised (meaning that an icon is now provided within + each of those buttons within the Linux version of KiCad). + * DIALOG_STYLE (defined within include/wxstruct.h) now includes MAYBE_RESIZE_BORDER + field. (Refer to 2007-Oct-2 UPDATE notes for the relevance of this.) + * Beautification and house keeping. ++ eeschema + * The editpart.cpp and editpart.cpp files (which are no longer used) have been + removed, and replaced with editpart.cpp.notused and editpart.cpp.notused ++ cvpcb + * Additional "OK", "Cancel", and "Apply" buttons have now been provided for the + "Options" dialog box which lists various display options for footprints. ++ pcbnew + * Invoking the "Select Layer Pair:" dialog box is no longer possible whenever only + one (copper) layer is currently enabled. And it is no longer possible to select + the same layer to be both the Top Layer and Bottom Layer (for any Layer Pair). + * Deselecting layers during the "Swap layers" command is now more user-friendly, + due to the provision of an additional "(Deselect)" radiobutton within the (child) + "Select Layer:" dialog box (which is always invoked whenever a different + radiobutton within the "Swap Layers:" dialog box is clicked on). (It had + previously been necessary to cancel the "Select Layer:" dialog box before being + able to click on the "Deselect" button within the "Swap Layers:" dialog box.) + * Definition for NB_LAYERS changed from (EDGE_N + 1) to (LAST_NO_COPPER_LAYER + 1) + (Although EDGE_N is currently the "last" layer, that wouldn't necessarily still + be true if any additional layers are ever defined in the future.) And comparisons + to 29 (or 28) have been replaced with comparisons to NB_LAYERS (when appropriate). ++ gerbview + * The previously provided "Exit" button within the "GerbView Layer Colors" dialog + box has been replaced with "OK", "Cancel", and "Apply" buttons; and both the + visibility and color of the Grid layer can now be edited from the same dialog. + * Deselecting (Gerber) layers during the "Export to Pcbnew" command is now more + user-friendly, due to the provision of an additional "(Deselect)" radiobutton + within the (child) "Select Layer:" dialog box (which is always invoked whenever + a different radiobutton within the "Layer selection:" dialog box is clicked on). + (It had previously been necessary to cancel the "Select Layer:" dialog box before + being able to click on the "Deselect" button within the "Layer selection:" dialog + box.) + * The "Export to Pcbnew" command now requires at least one Gerber file to have been + already loaded. And Gerber files can now be loaded into any of the 32 (Gerber) + layers provided. (It had previously been necessary to avoid having any gaps within + the sequence of used Gerber layers.) + + 2007-Oct-6 UPDATE Jean-Pierre Charras ================================================================================ + pcbnew @@ -11,7 +59,6 @@ email address. move RemoteCommand() and SendMessageToEESCHEMA() to cross-probing.cpp - 2007-Oct-3 UPDATE Dick Hollenbeck ================================================================================ + pcbnew diff --git a/common/displlst.cpp b/common/displlst.cpp index 2a9c256a4d..2f12a31d33 100644 --- a/common/displlst.cpp +++ b/common/displlst.cpp @@ -16,14 +16,12 @@ /***********************/ enum listbox { - ID_LISTBOX_CANCEL = 8000, - ID_LISTBOX_LIST, - ID_LISTBOX_OK + ID_LISTBOX_LIST = 8000 }; BEGIN_EVENT_TABLE(WinEDAListBox, wxDialog) - EVT_BUTTON(ID_LISTBOX_OK, WinEDAListBox::Ok) - EVT_BUTTON(ID_LISTBOX_CANCEL, WinEDAListBox::Cancel) + EVT_BUTTON(wxID_OK, WinEDAListBox::OnOkClick) + EVT_BUTTON(wxID_CANCEL, WinEDAListBox::OnCancelClick) EVT_LISTBOX(ID_LISTBOX_LIST, WinEDAListBox::ClickOnList) EVT_LISTBOX_DCLICK(ID_LISTBOX_LIST, WinEDAListBox::D_ClickOnList) EVT_CHAR(WinEDAListBox::OnKeyEvent) @@ -98,11 +96,11 @@ int ii; m_List->Append(*names); } - wxButton * butt = new wxButton(this, ID_LISTBOX_OK, _("Ok")); + wxButton * butt = new wxButton(this, wxID_OK, _("OK")); RightBoxSizer->Add(butt, 0, wxGROW|wxALL, 5); butt->SetDefault(); - butt = new wxButton(this, ID_LISTBOX_CANCEL, _("Cancel")); + butt = new wxButton(this, wxID_CANCEL, _("Cancel")); RightBoxSizer->Add(butt, 0, wxGROW|wxALL, 5); if (m_MoveFct ) @@ -110,7 +108,7 @@ int ii; size.x = -1; size.y = 60; m_WinMsg = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, size, wxTE_READONLY|wxTE_MULTILINE); - GeneralBoxSizer->Add(m_WinMsg, 0, wxGROW|wxALL, 5); + GeneralBoxSizer->Add(m_WinMsg, 0, wxGROW|wxALL, 5); } GetSizer()->Fit(this); @@ -174,7 +172,7 @@ void WinEDAListBox::InsertItems(const wxArrayString & itemlist, int position) } /************************************************/ -void WinEDAListBox::Cancel(wxCommandEvent& event) +void WinEDAListBox::OnCancelClick(wxCommandEvent& event) /************************************************/ { EndModal(-1); @@ -205,7 +203,7 @@ int ii = m_List->GetSelection(); /***********************************************/ -void WinEDAListBox::Ok(wxCommandEvent& event) +void WinEDAListBox::OnOkClick(wxCommandEvent& event) /***********************************************/ { int ii = m_List->GetSelection(); @@ -224,8 +222,8 @@ void WinEDAListBox::OnClose(wxCloseEvent& event) static int SortItems( const wxString ** ptr1, const wxString ** ptr2 ) /********************************************************************/ /* Routines de comparaison pour le tri tri alphabetique, - avec traitement des nombres en tant que valeur numerique -*/ + * avec traitement des nombres en tant que valeur numerique + */ { return StrNumICmp( (*ptr1)->GetData(), (*ptr2)->GetData() ); } diff --git a/cvpcb/dialog_display_options.cpp b/cvpcb/dialog_display_options.cpp index 727f4ebcbe..9767dde9f1 100644 --- a/cvpcb/dialog_display_options.cpp +++ b/cvpcb/dialog_display_options.cpp @@ -47,7 +47,8 @@ void WinEDA_DisplayFrame::InstallOptionsDisplay(wxCommandEvent& event) /* Creation de la fenetre d'options de la fenetre de visu */ { KiDisplayOptionsFrame * OptionWindow = new KiDisplayOptionsFrame(this); - OptionWindow->ShowModal(); OptionWindow->Destroy(); + OptionWindow->ShowModal(); + OptionWindow->Destroy(); } @@ -65,15 +66,13 @@ IMPLEMENT_DYNAMIC_CLASS( KiDisplayOptionsFrame, wxDialog ) BEGIN_EVENT_TABLE( KiDisplayOptionsFrame, wxDialog ) ////@begin KiDisplayOptionsFrame event table entries - EVT_CHECKBOX( PADNUM_OPT, KiDisplayOptionsFrame::OnPadnumOptClick ) - EVT_BUTTON( ID_SAVE_CONFIG, KiDisplayOptionsFrame::OnSaveConfigClick ) - EVT_CHECKBOX( PADFILL_OPT, KiDisplayOptionsFrame::OnPadfillOptClick ) + EVT_BUTTON( wxID_OK, KiDisplayOptionsFrame::OnOkClick ) - EVT_RADIOBOX( EDGE_SELECT, KiDisplayOptionsFrame::OnEdgeSelectSelected ) + EVT_BUTTON( wxID_CANCEL, KiDisplayOptionsFrame::OnCancelClick ) - EVT_RADIOBOX( TEXT_SELECT, KiDisplayOptionsFrame::OnTextSelectSelected ) + EVT_BUTTON( wxID_APPLY, KiDisplayOptionsFrame::OnApplyClick ) ////@end KiDisplayOptionsFrame event table entries @@ -101,10 +100,10 @@ KiDisplayOptionsFrame::KiDisplayOptionsFrame( WinEDA_BasePcbFrame* parent, wxWin bool KiDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin KiDisplayOptionsFrame member initialisation - m_IsShowPadNum = NULL; - m_IsShowPadFill = NULL; m_EdgesDisplayOption = NULL; m_TextDisplayOption = NULL; + m_IsShowPadNum = NULL; + m_IsShowPadFill = NULL; ////@end KiDisplayOptionsFrame member initialisation ////@begin KiDisplayOptionsFrame creation @@ -132,24 +131,16 @@ void KiDisplayOptionsFrame::CreateControls() KiDisplayOptionsFrame* itemDialog1 = this; - wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemDialog1->SetSizer(itemBoxSizer2); - wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(3, 2, 0, 0); - itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); +// itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_TOP|wxALL, 5); - m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - m_IsShowPadNum->SetValue(false); - itemFlexGridSizer3->Add(m_IsShowPadNum, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - wxButton* itemButton5 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 ); - itemFlexGridSizer3->Add(itemButton5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Fill"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - m_IsShowPadFill->SetValue(false); - itemFlexGridSizer3->Add(m_IsShowPadFill, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); - - itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5); + wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); +// itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); + itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxALIGN_TOP|wxALL, 5); wxString m_EdgesDisplayOptionStrings[] = { _("&Filaire"), @@ -157,7 +148,8 @@ void KiDisplayOptionsFrame::CreateControls() _("&Sketch") }; m_EdgesDisplayOption = new wxRadioBox( itemDialog1, EDGE_SELECT, _("Edges:"), wxDefaultPosition, wxDefaultSize, 3, m_EdgesDisplayOptionStrings, 1, wxRA_SPECIFY_COLS ); - itemFlexGridSizer3->Add(m_EdgesDisplayOption, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5); +// itemBoxSizer3->Add(m_EdgesDisplayOption, 0, wxGROW|wxALL, 5); + itemBoxSizer3->Add(m_EdgesDisplayOption, 0, wxALIGN_LEFT|wxALL, 5); wxString m_TextDisplayOptionStrings[] = { _("&Filaire"), @@ -165,13 +157,54 @@ void KiDisplayOptionsFrame::CreateControls() _("&Sketch") }; m_TextDisplayOption = new wxRadioBox( itemDialog1, TEXT_SELECT, _("Texts:"), wxDefaultPosition, wxDefaultSize, 3, m_TextDisplayOptionStrings, 1, wxRA_SPECIFY_COLS ); - itemFlexGridSizer3->Add(m_TextDisplayOption, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); +// itemBoxSizer3->Add(m_TextDisplayOption, 0, wxGROW|wxALL, 5); + itemBoxSizer3->Add(m_TextDisplayOption, 0, wxALIGN_LEFT|wxALL, 5); + + wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL); +// itemBoxSizer3->Add(itemBoxSizer5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5); + itemBoxSizer3->Add(itemBoxSizer5, 0, wxGROW|wxALL, 0); + + // Provide a spacer to improve appearance of dialog box + itemBoxSizer5->AddSpacer(5); + + m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_IsShowPadNum->SetValue(false); +// itemBoxSizer5->Add(m_IsShowPadNum, 0, wxGROW|wxALL, 5); + itemBoxSizer5->Add(m_IsShowPadNum, 0, wxALIGN_TOP|wxALL, 5); + + m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Fill"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); + m_IsShowPadFill->SetValue(false); +// itemBoxSizer5->Add(m_IsShowPadFill, 0, wxGROW|wxALL, 5); + itemBoxSizer5->Add(m_IsShowPadFill, 0, wxALIGN_TOP|wxALL, 5); + + // Provide a stretch spacer to improve appearance of dialog box + itemBoxSizer5->AddStretchSpacer(); + + wxButton* itemButton6 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg..."), wxDefaultPosition, wxDefaultSize, 0 ); +// itemBoxSizer5->Add(itemButton6, 0, wxGROW|wxALL, 5); + itemBoxSizer5->Add(itemButton6, 0, wxALIGN_BOTTOM|wxALL, 5); + +// itemBoxSizer4->AddStretchSpacer(); + + wxButton* itemButton7 = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton7->SetForegroundColour(*wxRED); +// itemBoxSizer4->Add(itemButton7, 0, wxGROW|wxALL, 5); + itemBoxSizer4->Add(itemButton7, 0, wxALIGN_RIGHT|wxALL, 5); + + wxButton* itemButton8 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + itemButton8->SetForegroundColour(*wxBLUE); +// itemBoxSizer4->Add(itemButton8, 0, wxGROW|wxALL, 5); + itemBoxSizer4->Add(itemButton8, 0, wxALIGN_RIGHT|wxALL, 5); + + wxButton* itemButton9 = new wxButton( itemDialog1, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 ); +// itemBoxSizer4->Add(itemButton9, 0, wxGROW|wxALL, 5); + itemBoxSizer4->Add(itemButton9, 0, wxALIGN_RIGHT|wxALL, 5); // Set validators - m_IsShowPadNum->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNum) ); - m_IsShowPadFill->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadFill) ); m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) ); m_TextDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModText) ); + m_IsShowPadNum->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadNum) ); + m_IsShowPadFill->SetValidator( wxGenericValidator(& DisplayOpt.DisplayPadFill) ); ////@end KiDisplayOptionsFrame content construction } @@ -210,37 +243,28 @@ wxIcon KiDisplayOptionsFrame::GetIconResource( const wxString& name ) ////@end KiDisplayOptionsFrame icon retrieval } - /*! - * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADFILL_OPT + * Update settings related to edges, text strings, and pads */ -void KiDisplayOptionsFrame::OnPadfillOptClick( wxCommandEvent& event ) -{ - DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill = - m_IsShowPadFill->GetValue(); - m_Parent->ReDrawPanel(); -} - -/*! - * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADNUM_OPT - */ - -void KiDisplayOptionsFrame::OnPadnumOptClick( wxCommandEvent& event ) -{ - DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum = m_IsShowPadNum->GetValue(); - m_Parent->ReDrawPanel(); -} - -/*! - * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for EDGE_SELECT - */ - -void KiDisplayOptionsFrame::OnEdgeSelectSelected( wxCommandEvent& event ) +void KiDisplayOptionsFrame::UpdateObjectSettings() { + // Update settings +////@begin KiDisplayOptionsFrame update settings DisplayOpt.DisplayModEdge = m_Parent->m_DisplayModEdge = m_EdgesDisplayOption->GetSelection(); + + DisplayOpt.DisplayModText = m_Parent->m_DisplayModText = + m_TextDisplayOption->GetSelection(); + + DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum = + m_IsShowPadNum->GetValue(); + + DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill = + m_IsShowPadFill->GetValue(); + m_Parent->ReDrawPanel(); +////@end KiDisplayOptionsFrame update settings } /*! @@ -253,14 +277,31 @@ void KiDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event ) } /*! - * wxEVT_COMMAND_RADIOBOX_SELECTED event handler for TEXT_SELECT + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK */ -void KiDisplayOptionsFrame::OnTextSelectSelected( wxCommandEvent& event ) +void KiDisplayOptionsFrame::OnOkClick( wxCommandEvent& event ) { - DisplayOpt.DisplayModText = m_Parent->m_DisplayModText = - m_TextDisplayOption->GetSelection(); - m_Parent->ReDrawPanel(); + UpdateObjectSettings(); + EndModal( 1 ); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + */ + +void KiDisplayOptionsFrame::OnCancelClick( wxCommandEvent& event ) +{ + EndModal( -1 ); +} + +/*! + * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY + */ + +void KiDisplayOptionsFrame::OnApplyClick( wxCommandEvent& event ) +{ + UpdateObjectSettings(); } diff --git a/cvpcb/dialog_display_options.h b/cvpcb/dialog_display_options.h index 50ef6d9fa1..e28fd22fc1 100644 --- a/cvpcb/dialog_display_options.h +++ b/cvpcb/dialog_display_options.h @@ -81,20 +81,17 @@ public: ////@begin KiDisplayOptionsFrame event handler declarations - /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADNUM_OPT - void OnPadnumOptClick( wxCommandEvent& event ); - /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG void OnSaveConfigClick( wxCommandEvent& event ); - /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for PADFILL_OPT - void OnPadfillOptClick( wxCommandEvent& event ); + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK + void OnOkClick( wxCommandEvent& event ); - /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for EDGE_SELECT - void OnEdgeSelectSelected( wxCommandEvent& event ); + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL + void OnCancelClick( wxCommandEvent& event ); - /// wxEVT_COMMAND_RADIOBOX_SELECTED event handler for TEXT_SELECT - void OnTextSelectSelected( wxCommandEvent& event ); + /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_APPLY + void OnApplyClick( wxCommandEvent& event ); ////@end KiDisplayOptionsFrame event handler declarations @@ -105,16 +102,19 @@ public: /// Retrieves icon resources wxIcon GetIconResource( const wxString& name ); + + /// Updates settings related to edges, text strings, and pads + void UpdateObjectSettings(); ////@end KiDisplayOptionsFrame member function declarations /// Should we show tooltips? static bool ShowToolTips(); ////@begin KiDisplayOptionsFrame member variables - wxCheckBox* m_IsShowPadNum; - wxCheckBox* m_IsShowPadFill; wxRadioBox* m_EdgesDisplayOption; wxRadioBox* m_TextDisplayOption; + wxCheckBox* m_IsShowPadNum; + wxCheckBox* m_IsShowPadFill; ////@end KiDisplayOptionsFrame member variables WinEDA_BasePcbFrame * m_Parent; diff --git a/eeschema/editpart.cpp b/eeschema/editpart.cpp.notused similarity index 99% rename from eeschema/editpart.cpp rename to eeschema/editpart.cpp.notused index 1a282267e6..34aa383d81 100644 --- a/eeschema/editpart.cpp +++ b/eeschema/editpart.cpp.notused @@ -194,7 +194,7 @@ WinEDA_ComponentPropertiesFrame::WinEDA_ComponentPropertiesFrame( pos.x += MButton->GetDefaultSize().x + 10; wxButton* Button = new wxButton( this, ID_ACCEPT_CMP_PROPERTIES, - _( "Ok" ), pos ); + _( "OK" ), pos ); Button->SetForegroundColour( *wxBLUE ); c = new wxLayoutConstraints; c->left.SameAs( MButton, wxRight, 20 ); diff --git a/eeschema/libedpart.cpp b/eeschema/libedpart.cpp.notused similarity index 99% rename from eeschema/libedpart.cpp rename to eeschema/libedpart.cpp.notused index c4e7ab7006..2f045f9638 100644 --- a/eeschema/libedpart.cpp +++ b/eeschema/libedpart.cpp.notused @@ -232,7 +232,7 @@ WinEDA_PartPropertiesFrame::WinEDA_PartPropertiesFrame( WinEDA_LibeditFrame* par pos.x += Button->GetDefaultSize().x + 70; Button = new wxButton( this, ID_ACCEPT_PART_PROPERTIES, - _( "Ok" ), pos ); + _( "OK" ), pos ); Button->SetForegroundColour( *wxRED ); c = new wxLayoutConstraints; diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index b0668e4f72..4542b53f23 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -30,11 +30,6 @@ static wxString shape_list[NBSHAPES] = wxT( "Input" ), wxT( "Output" ), wxT( "Bidi" ), wxT( "TriState" ), wxT( "Passive" ) }; -enum id_Textdit { - ID_ACCEPT_PINSHEET_PROPERTIES = 1970, - ID_CANCEL_PINSHEET_PROPERTIES -}; - /*****************************************************/ class WinEDA_PinSheetPropertiesFrame : public wxDialog @@ -57,16 +52,15 @@ public: ~WinEDA_PinSheetPropertiesFrame() { }; private: - void PinSheetPropertiesAccept( wxCommandEvent& event ); - void OnQuit( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE( WinEDA_PinSheetPropertiesFrame, wxDialog ) -EVT_BUTTON( ID_ACCEPT_PINSHEET_PROPERTIES, - WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept ) -EVT_BUTTON( ID_CANCEL_PINSHEET_PROPERTIES, WinEDA_PinSheetPropertiesFrame::OnQuit ) +EVT_BUTTON( wxID_OK, WinEDA_PinSheetPropertiesFrame::OnOkClick ) +EVT_BUTTON( wxID_CANCEL, WinEDA_PinSheetPropertiesFrame::OnCancelClick ) END_EVENT_TABLE() @@ -96,13 +90,11 @@ WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame( m_CurrentPinSheet = curr_pinsheet; /* Creation des boutons de commande */ - Button = new wxButton( this, ID_ACCEPT_PINSHEET_PROPERTIES, - _( "Ok" ) ); + Button = new wxButton( this, wxID_OK, _( "OK" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton( this, ID_CANCEL_PINSHEET_PROPERTIES, - _( "Cancel" ) ); + Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); Button->SetForegroundColour( *wxBLUE ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); @@ -123,23 +115,22 @@ WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame( /************************************************************************/ -void WinEDA_PinSheetPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) +void WinEDA_PinSheetPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) /************************************************************************/ { - // true is to force the frame to close - Close( true ); + EndModal( -1 ); } /***********************************************************************************/ -void WinEDA_PinSheetPropertiesFrame::PinSheetPropertiesAccept( wxCommandEvent& event ) +void WinEDA_PinSheetPropertiesFrame::OnOkClick( wxCommandEvent& event ) /***********************************************************************************/ { m_CurrentPinSheet->m_Text = m_TextWin->GetText(); m_CurrentPinSheet->m_Size.x = m_CurrentPinSheet->m_Size.y = m_TextWin->GetTextSize(); m_CurrentPinSheet->m_Shape = m_PinSheetShape->GetSelection(); - Close( TRUE ); + EndModal( 0 ); } diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index a6862cf2d0..0eafb7833a 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -25,6 +25,23 @@ void WinEDA_GerberFrame::ExportDataInPcbnewFormat( wxCommandEvent& event ) /* Export data in pcbnew format */ { + int ii = 0; + bool no_used_layers = true; // Changed to false if any used layer found + + // Check whether any of the Gerber layers are actually currently used + while( no_used_layers && ii < 32 ) + { + if( g_GERBER_Descr_List[ii] != NULL ) + no_used_layers = false; + ii++; + } + + if( no_used_layers ) + { + DisplayInfo( this, _( "None of the Gerber layers contain any data" ) ); + return; + } + wxString FullFileName, msg; wxString PcbExt( wxT( ".brd" ) ); diff --git a/gerbview/options.cpp b/gerbview/options.cpp index de125863ce..104d97eb66 100644 --- a/gerbview/options.cpp +++ b/gerbview/options.cpp @@ -211,7 +211,7 @@ wxString list_scales[2] = { _("format: 2.3"), _("format 3.4") }; void WinEDA_GerberGeneralOptionsFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event)) /************************************************************************/ { - EndModal(0); + EndModal( -1 ); } @@ -227,7 +227,7 @@ void WinEDA_GerberGeneralOptionsFrame::OnOkClick(wxCommandEvent& event) g_Default_GERBER_Format = (m_GerberDefaultScale->GetSelection() == 0) ? 23 : 34; - EndModal(1); + EndModal( 1 ); } @@ -334,7 +334,7 @@ wxString list_opt3[3] = { _("Sketch"), _("Filled"), _("Line") }; void WinEDA_LookFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event)) /**************************************************************/ { - EndModal(0); + EndModal( -1 ); } @@ -363,7 +363,7 @@ void WinEDA_LookFrame::OnOkClick(wxCommandEvent& event) m_Parent->GetScreen()->SetRefreshReq(); - EndModal(1); + EndModal( 1 ); } @@ -395,4 +395,3 @@ void WinEDA_GerberFrame::InstallPcbOptionsFrame(const wxPoint & pos, int id) break; } } - diff --git a/gerbview/reglage.cpp b/gerbview/reglage.cpp index c1866ba489..05e522922c 100644 --- a/gerbview/reglage.cpp +++ b/gerbview/reglage.cpp @@ -154,7 +154,7 @@ void WinEDA_ConfigFrame::OnOkClick(wxCommandEvent& WXUNUSED(event)) g_PhotoFilenameExt = TextPhotoExt->GetValue(); g_PenFilenameExt = TextPenExt->GetValue(); - EndModal(1); + EndModal( 1 ); } @@ -162,7 +162,7 @@ void WinEDA_ConfigFrame::OnOkClick(wxCommandEvent& WXUNUSED(event)) void WinEDA_ConfigFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event)) /******************************************************************/ { - EndModal(0); + EndModal( -1 ); } @@ -172,4 +172,3 @@ void WinEDA_ConfigFrame::SaveCfg(wxCommandEvent& event) { m_Parent->Update_config(); } - diff --git a/gerbview/select_layers_to_pcb.cpp b/gerbview/select_layers_to_pcb.cpp index c81224d785..c1d8adf51e 100644 --- a/gerbview/select_layers_to_pcb.cpp +++ b/gerbview/select_layers_to_pcb.cpp @@ -12,14 +12,13 @@ /* Variables locales */ -static int LayerLookUpTable[32]; +static int RadioButtonTable[32]; // Indexes radiobuttons to Gerber layers +static int LayerLookUpTable[32]; // Indexes Gerber layers to PCB file layers enum swap_layer_id { - ID_SWAP_LAYER_EXECUTE = 1800, - ID_SWAP_LAYER_CANCEL, - ID_SWAP_LAYER_BUTTON_SELECT, - ID_SWAP_LAYER_DESELECT, - ID_SWAP_LAYER_SELECT + ID_SWAP_LAYER_BUTTON_SELECT = 1800, + ID_SWAP_LAYER_DESELECT, + ID_SWAP_LAYER_SELECT }; @@ -40,19 +39,21 @@ public: ~WinEDA_SwapLayerFrame() {}; private: - void Sel_Layer(wxCommandEvent& event); - void Cancel(wxCommandEvent& event); - void Execute(wxCommandEvent& event); - DECLARE_EVENT_TABLE() + void Sel_Layer(wxCommandEvent& event); + void OnOkClick(wxCommandEvent& event); + void OnCancelClick(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() }; + /* Table des evenements pour WinEDA_SwapLayerFrame */ BEGIN_EVENT_TABLE(WinEDA_SwapLayerFrame, wxDialog) - EVT_BUTTON(ID_SWAP_LAYER_EXECUTE, WinEDA_SwapLayerFrame::Execute) - EVT_BUTTON(ID_SWAP_LAYER_CANCEL, WinEDA_SwapLayerFrame::Cancel) - EVT_BUTTON(ID_SWAP_LAYER_DESELECT, WinEDA_SwapLayerFrame::Sel_Layer) - EVT_BUTTON(ID_SWAP_LAYER_BUTTON_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) - EVT_RADIOBOX(ID_SWAP_LAYER_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) + EVT_BUTTON(wxID_OK, WinEDA_SwapLayerFrame::OnOkClick) + EVT_BUTTON(wxID_CANCEL, WinEDA_SwapLayerFrame::OnCancelClick) + EVT_BUTTON(ID_SWAP_LAYER_DESELECT, WinEDA_SwapLayerFrame::Sel_Layer) + EVT_BUTTON(ID_SWAP_LAYER_BUTTON_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) + EVT_RADIOBOX(ID_SWAP_LAYER_SELECT, WinEDA_SwapLayerFrame::Sel_Layer) END_EVENT_TABLE() @@ -60,90 +61,133 @@ END_EVENT_TABLE() int * InstallDialogLayerPairChoice(WinEDA_GerberFrame * parent) /*************************************************************/ /* Install a dialog frame to choose the equivalence - between gerber layers and pcbnew layers - return the "lookup table" if ok, or NULL -*/ + * between gerber layers and pcbnew layers + * return the "lookup table" if ok, or NULL + */ { WinEDA_SwapLayerFrame * frame = new WinEDA_SwapLayerFrame(parent); - int ii = frame->ShowModal(); frame->Destroy(); - if ( ii >= 0 ) return LayerLookUpTable; - else return NULL; + int ii = frame->ShowModal(); + frame->Destroy(); + if( ii >= 0 ) + return LayerLookUpTable; + else + return NULL; } + /*************************************************************************/ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame(WinEDA_GerberFrame *parent): - wxDialog(parent, -1, _("Layer selection:"),wxPoint(-1,-1), + wxDialog( parent, -1, _("Layer selection:"), wxPoint(-1, -1), wxDefaultSize, DIALOG_STYLE ) /*************************************************************************/ { wxButton * Button; int ii, nb_items; wxString g_Layer_Name_Pair[32]; - + m_Parent = parent; SetFont(*g_DialogFont); - /* Compute a resonnable number of copper layers */ + // Compute a reasonable number of copper layers g_DesignSettings.m_CopperLayerCount = 0; - for ( ii = 0; ii < NB_LAYERS; ii++ ) + for( ii = 0; ii < 32; ii++ ) { - if ( g_GERBER_Descr_List[ii] != NULL) + if( g_GERBER_Descr_List[ii] != NULL ) g_DesignSettings.m_CopperLayerCount++; + + // Specify the default value for each member of these arrays. + RadioButtonTable[ii] = -1; + LayerLookUpTable[ii] = NB_LAYERS; // Value associated with deselected Gerber layer } int pcb_layer_number = 0; - for ( nb_items = 0, ii = 0; ii < NB_LAYERS; ii++ ) + for( nb_items = 0, ii = 0; ii < 32; ii++ ) { - if ( g_GERBER_Descr_List[ii] == NULL ) - { - LayerLookUpTable[ii] = -1; + if( g_GERBER_Descr_List[ii] == NULL ) continue; - } - if ( (pcb_layer_number == g_DesignSettings.m_CopperLayerCount-1) + + if( (pcb_layer_number == g_DesignSettings.m_CopperLayerCount - 1) && (g_DesignSettings.m_CopperLayerCount > 1) ) pcb_layer_number = CMP_N; + + RadioButtonTable[nb_items] = ii; LayerLookUpTable[ii] = pcb_layer_number; - g_Layer_Name_Pair[ii] = _("Gerber layer "); - g_Layer_Name_Pair[ii] << ii+1 - << wxT(" -> ") << ReturnPcbLayerName(pcb_layer_number); + + // Specify initial (temporary) caption for associated radiobutton, + // which will be appropriately updated after dialog box has been sized. + // (If the radiobuttons' captions are not changed in this way, some of + // each radiobutton's caption could be truncated if the associated + // (Gerber) layer is ever subsequently deselected by the user.) + g_Layer_Name_Pair[nb_items] = _("Gerber layer "); + g_Layer_Name_Pair[nb_items] << ii + 1 << wxT(" -> ") << _("Do not export"); + nb_items++; pcb_layer_number++; } - - wxBoxSizer* FrameBoxSizer = new wxBoxSizer(wxHORIZONTAL); + + wxBoxSizer* FrameBoxSizer = new wxBoxSizer(wxVERTICAL); SetSizer(FrameBoxSizer); - wxBoxSizer* LeftBoxSizer = new wxBoxSizer(wxVERTICAL); - FrameBoxSizer->Add(LeftBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); - wxBoxSizer* RightBoxSizer = new wxBoxSizer(wxVERTICAL); - FrameBoxSizer->Add(RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); + + wxBoxSizer* MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); + FrameBoxSizer->Add(MainBoxSizer, 0, wxGROW|wxALIGN_LEFT|wxALL, 5); m_LayerList = new wxRadioBox(this, ID_SWAP_LAYER_SELECT, _("Layers"), wxDefaultPosition, wxDefaultSize, nb_items, g_Layer_Name_Pair, - nb_items < 16 ? nb_items :16, + nb_items < 16 ? nb_items : 16, wxRA_SPECIFY_ROWS); - LeftBoxSizer->Add(m_LayerList, 0, wxGROW|wxALL, 5); - Button = new wxButton(this,ID_SWAP_LAYER_CANCEL, _("Cancel")); - Button->SetForegroundColour(*wxRED); + // Specify a minimum size for this radiobox (with the objective + // of attempting to prevent any radiobutton's caption from being + // truncated if any of the layers are subsequently deselected) + m_LayerList->SetMinSize( m_LayerList->GetSize() ); + + MainBoxSizer->Add(m_LayerList, 0, wxALIGN_TOP|wxALL, 5); + + wxBoxSizer* RightBoxSizer = new wxBoxSizer(wxVERTICAL); + MainBoxSizer->Add(RightBoxSizer, 0, wxALIGN_TOP|wxALL, 0); + + RightBoxSizer->AddSpacer(10); + + Button = new wxButton(this, ID_SWAP_LAYER_BUTTON_SELECT, _("Select...")); + Button->SetForegroundColour(wxColour(0,100,100)); RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - Button = new wxButton(this,ID_SWAP_LAYER_EXECUTE, _("OK")); - Button->SetForegroundColour(*wxBLUE); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - - Button = new wxButton(this,ID_SWAP_LAYER_DESELECT, _("Deselect")); + Button = new wxButton(this, ID_SWAP_LAYER_DESELECT, _("Deselect")); Button->SetForegroundColour(wxColour(0,100,0)); RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - Button = new wxButton(this,ID_SWAP_LAYER_BUTTON_SELECT, _("Select")); - Button->SetForegroundColour(wxColour(0,100,100)); - RightBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + wxBoxSizer* BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL); + FrameBoxSizer->Add(BottomBoxSizer, 0, wxGROW|wxALIGN_RIGHT|wxALL, 5); + + // The following stretch spacer ensures that the "OK" and "Cancel" buttons + // will be positioned at the lower right corner of the dialog box. + BottomBoxSizer->AddStretchSpacer(); + + Button = new wxButton(this, wxID_OK, _("OK")); + Button->SetForegroundColour(*wxRED); + BottomBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - if (GetSizer()) + Button = new wxButton(this, wxID_CANCEL, _("Cancel")); + Button->SetForegroundColour(*wxBLUE); + BottomBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + if( GetSizer() ) { GetSizer()->SetSizeHints(this); } + + // Now specify the correct caption for each radiobutton. + // (Regrettably though there are still problems with the Windows + // version; captions for each radiobutton can still be truncated.) :-( + for( ii = 0; ii < nb_items; ii++ ) + { + g_Layer_Name_Pair[ii] = _("Gerber layer "); + g_Layer_Name_Pair[ii] << RadioButtonTable[ii] + 1 << wxT(" -> ") + << ReturnPcbLayerName(LayerLookUpTable[RadioButtonTable[ii]]); + + m_LayerList->SetString( ii, g_Layer_Name_Pair[ii] ); + } } @@ -152,82 +196,87 @@ void WinEDA_SwapLayerFrame::Sel_Layer(wxCommandEvent& event) /***************************************************************/ { int ii, jj; -int gerber_layer_number; +// int gerber_layer_number; wxString msg; ii = m_LayerList->GetSelection(); - if ( ii < 0 ) return; - /* Search the gerber layer number correspondint to the selection */ - for ( jj = 0, gerber_layer_number = 0; gerber_layer_number < 32; gerber_layer_number++ ) + if( ii < 0 ) + return; + + switch ( event.GetId() ) { - if ( g_GERBER_Descr_List[gerber_layer_number] == NULL) continue; - if (jj == ii ) break; - jj++; - } - + case ID_SWAP_LAYER_DESELECT: + if( LayerLookUpTable[RadioButtonTable[ii]] != NB_LAYERS ) + { + LayerLookUpTable[RadioButtonTable[ii]] = NB_LAYERS; + msg = _("Gerber layer "); + msg << RadioButtonTable[ii] + 1 + << wxT(" -> ") << _("Do not export"); + m_LayerList->SetString( ii, msg ); + } + break; - switch ( event.GetId()) - { - case ID_SWAP_LAYER_DESELECT: - if ( LayerLookUpTable[gerber_layer_number] != -1 ) - { - LayerLookUpTable[gerber_layer_number] = -1; - msg = _("Gerber layer "); - msg << gerber_layer_number+1 << wxT(" -> ") << _("Do not export"); - m_LayerList->SetString(ii, msg ); - } - break; + case ID_SWAP_LAYER_BUTTON_SELECT: + case ID_SWAP_LAYER_SELECT: + jj = LayerLookUpTable[RadioButtonTable[ii]]; + if( (jj < 0) || (jj > NB_LAYERS) ) + jj = 0; // (Defaults to "Copper" layer.) + jj = m_Parent->SelectLayer(jj, -1, -1, true); + if( (jj < 0) || (jj > NB_LAYERS) ) + return; - case ID_SWAP_LAYER_BUTTON_SELECT: - case ID_SWAP_LAYER_SELECT: - jj = m_Parent->SelectLayer(ii, -1, -1); - if ( (jj < 0) || (jj >= 29) ) return; - - if ( ii != jj ) - { - LayerLookUpTable[gerber_layer_number] = jj; - msg = _("Gerber layer "); - msg << gerber_layer_number+1 << wxT(" -> ") << ReturnPcbLayerName(jj); - m_LayerList->SetString(ii, msg ); - } - break; + if( jj != LayerLookUpTable[RadioButtonTable[ii]] ) + { + LayerLookUpTable[RadioButtonTable[ii]] = jj; + msg = _("Gerber layer "); + msg << RadioButtonTable[ii] + 1 << wxT(" -> "); + if( jj == NB_LAYERS ) + msg << _("Do not export"); + else + msg << ReturnPcbLayerName(jj); + m_LayerList->SetString( ii, msg ); + } + break; } } + /*********************************************************/ -void WinEDA_SwapLayerFrame::Cancel(wxCommandEvent& event) +void WinEDA_SwapLayerFrame::OnCancelClick(wxCommandEvent& event) /*********************************************************/ { - EndModal(-1); + EndModal( -1 ); } + /*********************************************************/ -void WinEDA_SwapLayerFrame::Execute(wxCommandEvent& event) +void WinEDA_SwapLayerFrame::OnOkClick(wxCommandEvent& event) /*********************************************************/ { int ii; bool AsCmpLayer = false; - + /* Compute the number of copper layers - this is the max layer number + 1 (if some internal layers exists) - */ + * this is the max layer number + 1 (if some internal layers exist) + */ g_DesignSettings.m_CopperLayerCount = 1; - for ( ii = 0; ii < 32; ii++ ) + for( ii = 0; ii < 32; ii++ ) { - if ( LayerLookUpTable[ii] == CMP_N ) AsCmpLayer = true; + if( LayerLookUpTable[ii] == CMP_N ) + AsCmpLayer = true; else { - if ( LayerLookUpTable[ii] >= CMP_N ) continue; // not a copper layer - if ( LayerLookUpTable[ii] >= g_DesignSettings.m_CopperLayerCount ) + if( LayerLookUpTable[ii] >= CMP_N ) + continue; // not a copper layer + if( LayerLookUpTable[ii] >= g_DesignSettings.m_CopperLayerCount ) g_DesignSettings.m_CopperLayerCount++; } } - - if ( AsCmpLayer ) g_DesignSettings.m_CopperLayerCount++; - if ( g_DesignSettings.m_CopperLayerCount > CMP_N+1 ) // should not occur. - g_DesignSettings.m_CopperLayerCount = CMP_N+1; - EndModal(1); + if( AsCmpLayer ) + g_DesignSettings.m_CopperLayerCount++; + if( g_DesignSettings.m_CopperLayerCount > CMP_N + 1 ) // should not occur. + g_DesignSettings.m_CopperLayerCount = CMP_N + 1; + + EndModal( 1 ); } - - diff --git a/gerbview/set_color.cpp b/gerbview/set_color.cpp index 1075405316..0f528d26fe 100644 --- a/gerbview/set_color.cpp +++ b/gerbview/set_color.cpp @@ -9,11 +9,13 @@ #include "protos.h" -#define BUTT_SIZE_X 20 -#define BUTT_SIZE_Y 16 - /* Variables locales */ -int CurrentColor; +const int BUTT_SIZE_X = 20; +const int BUTT_SIZE_Y = 16; + +const int COLOR_COUNT = 37; // 37 = 32 (layers) + 2 (others) + 3 (headings) + // Is there a better way to determine how many elements CurrentColor requires? +int CurrentColor[COLOR_COUNT]; // Holds color for each layer while dialog box open /* Fonctions locales: */ @@ -23,7 +25,6 @@ int CurrentColor; enum col_sel_id { ID_COLOR_RESET_SHOW_LAYER_ON = 1800, ID_COLOR_RESET_SHOW_LAYER_OFF, - ID_COLOR_EXIT, ID_COLOR_CHECKBOX_ONOFF, ID_COLOR_SETUP }; @@ -35,12 +36,12 @@ enum col_sel_id { struct ColorButton { wxString m_Name; - int * m_Color; // Pointeur sur la variable couleur + int * m_Color; // Pointeur sur la variable couleur bool m_NoDisplayIsColor; // TRUE si bit ITEM_NON_VISIBLE de la variable Color - bool * m_NoDisplay; // Pointeur sur la variable Display on/off si ce n'est pas la var - // Color + bool * m_NoDisplay; // Pointeur sur la variable Display on/off si ce + // n'est pas la var Color int m_Id; - wxBitmapButton * m_Button; + wxBitmapButton * m_Button; // Button to display/change color assigned to this layer int m_State; wxCheckBox * m_CheckBox; // Option Display ON/OFF }; @@ -65,8 +66,10 @@ public: private: void SetColor(wxCommandEvent& event); - void OnQuit(wxCommandEvent& event); - void SetDisplayOnOff(wxCommandEvent& event); + void OnOkClick(wxCommandEvent& event); + void OnCancelClick(wxCommandEvent& event); + void OnApplyClick(wxCommandEvent& event); + void UpdateLayerSettings(); void ResetDisplayLayersCu(wxCommandEvent& event); DECLARE_EVENT_TABLE() @@ -75,8 +78,9 @@ private: 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_BUTTON(ID_COLOR_EXIT, WinEDA_SetColorsFrame::OnQuit) - EVT_CHECKBOX(ID_COLOR_CHECKBOX_ONOFF, WinEDA_SetColorsFrame::SetDisplayOnOff) + 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) @@ -114,18 +118,18 @@ BEGIN_EVENT_TABLE(WinEDA_SetColorsFrame, wxDialog) 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) +// 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, */ +/* void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, */ /* const wxPoint & pos) */ /**************************************************************/ @@ -142,9 +146,10 @@ void DisplayColorSetupFrame(WinEDA_DrawFrame * parent, /**********************************************************************/ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame(WinEDA_DrawFrame *parent, const wxPoint& framepos): - wxDialog(parent, -1, _("Gerbview Layer Colors:"), framepos, + wxDialog(parent, -1, _("GerbView Layer Colors:"), framepos, wxSize(390, 380), - wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT ) + wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT| + MAYBE_RESIZE_BORDER ) /**********************************************************************/ { wxBitmapButton * ButtonB; @@ -152,7 +157,7 @@ int ii, butt_ID, buttcolor; wxString msg; wxStaticText * text; wxBoxSizer * CurrBoxSizer = NULL; - + m_Parent = parent; SetFont(*g_DialogFont); @@ -166,7 +171,7 @@ wxBoxSizer * CurrBoxSizer = NULL; CurrBoxSizer = new wxBoxSizer(wxVERTICAL); MainBoxSizer->Add(CurrBoxSizer, 0, wxGROW|wxALL, 5); msg = wxGetTranslation(laytool_list[ii]->m_Name.GetData()); - text = new wxStaticText(this,-1, msg ); + text = new wxStaticText( this, -1, msg ); CurrBoxSizer->Add(text, 0, wxGROW|wxALL, 5); continue; } @@ -178,7 +183,7 @@ wxBoxSizer * CurrBoxSizer = NULL; wxBoxSizer * LineBoxSizer = new wxBoxSizer(wxHORIZONTAL); wxCheckBox * Checkb; CurrBoxSizer->Add(LineBoxSizer, 0, wxGROW|wxALL, 0); - laytool_list[ii]->m_CheckBox = Checkb = new wxCheckBox(this, + laytool_list[ii]->m_CheckBox = Checkb = new wxCheckBox( this, ID_COLOR_CHECKBOX_ONOFF, wxEmptyString ); LineBoxSizer->Add(Checkb, 0, wxGROW|wxALL, 1); @@ -189,16 +194,16 @@ wxBoxSizer * CurrBoxSizer = NULL; 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); if( laytool_list[ii]->m_Color ) { - wxMemoryDC iconDC; int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; - wxBitmap ButtBitmap(w,h); + wxMemoryDC iconDC; + wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); iconDC.SelectObject( ButtBitmap ); buttcolor = *laytool_list[ii]->m_Color & MASKCOLOR; + CurrentColor[ii] = buttcolor; wxBrush Brush; iconDC.SelectObject( ButtBitmap ); iconDC.SetPen(*wxBLACK_PEN); @@ -210,47 +215,75 @@ wxBoxSizer * CurrBoxSizer = NULL; Brush.SetStyle(wxSOLID); iconDC.SetBrush(Brush); - iconDC.DrawRectangle(0,0, w, h); + iconDC.DrawRectangle(0, 0, BUTT_SIZE_X, BUTT_SIZE_Y); - ButtonB = new wxBitmapButton(this, butt_ID, + ButtonB = new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition, - wxSize(w,h) ); + wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) ); laytool_list[ii]->m_Button = ButtonB; LineBoxSizer->Add(ButtonB, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1); } msg = wxGetTranslation(laytool_list[ii]->m_Name.GetData()); - text = new wxStaticText(this,-1, msg); + text = new wxStaticText( this, -1, msg ); LineBoxSizer->Add(text, 0, wxGROW|wxALL, 1); } CurrBoxSizer->AddSpacer(20); - wxButton * Button = new wxButton(this,ID_COLOR_RESET_SHOW_LAYER_ON, - _("Show All")); + wxButton * Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_ON, + _("Show All") ); Button->SetForegroundColour(*wxBLUE); - CurrBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + CurrBoxSizer->Add(Button, 0, wxALIGN_TOP|wxGROW|wxALL, 5); - Button = new wxButton(this,ID_COLOR_RESET_SHOW_LAYER_OFF, - _("Show None")); + Button = new wxButton( this, ID_COLOR_RESET_SHOW_LAYER_OFF, + _("Show None") ); Button->SetForegroundColour(*wxRED); - CurrBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + CurrBoxSizer->Add(Button, 0, wxALIGN_TOP|wxGROW|wxALL, 5); - Button = new wxButton(this,ID_COLOR_EXIT, - _("Exit")); - Button->SetForegroundColour(*wxBLACK); - CurrBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + // Following stretch spacer ensures "OK", "Cancel", and "Apply" + // buttons will be located at lower right corner of dialog box + CurrBoxSizer->AddStretchSpacer(); - GetSizer()->Fit(this); + Button = new wxButton( this, wxID_OK, _("OK") ); + Button->SetForegroundColour(*wxRED); + CurrBoxSizer->Add(Button, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5); + + Button = new wxButton( this, wxID_CANCEL, _("Cancel") ); + Button->SetForegroundColour(*wxBLUE); + CurrBoxSizer->Add(Button, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5); + + Button = new wxButton( this, wxID_APPLY, _("Apply") ); + CurrBoxSizer->Add(Button, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5); + + GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); } /*******************************************************************/ -void WinEDA_SetColorsFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +void WinEDA_SetColorsFrame::OnOkClick(wxCommandEvent& WXUNUSED(event)) /*******************************************************************/ { - // true is to force the frame to close - Close(true); + UpdateLayerSettings(); + m_Parent->GetScreen()->SetRefreshReq(); + EndModal( 1 ); +} + + +/*******************************************************************/ +void WinEDA_SetColorsFrame::OnCancelClick(wxCommandEvent& WXUNUSED(event)) +/*******************************************************************/ +{ + EndModal( -1 ); +} + + +/*******************************************************************/ +void WinEDA_SetColorsFrame::OnApplyClick(wxCommandEvent& WXUNUSED(event)) +/*******************************************************************/ +{ + UpdateLayerSettings(); + m_Parent->ReDrawPanel(); } @@ -261,10 +294,9 @@ void WinEDA_SetColorsFrame::SetColor(wxCommandEvent& event) int ii; int id = event.GetId(); int color; -int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; color = DisplayColorFrame( this, - *laytool_list[id - ID_COLOR_SETUP]->m_Color ); + CurrentColor[id - ID_COLOR_SETUP] ); if ( color < 0 ) return; @@ -276,17 +308,17 @@ int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; if( laytool_list[ii]->m_Color == NULL ) continue; - if( *laytool_list[ii]->m_Color == color ) + if( CurrentColor[ii] == color ) break; - *laytool_list[ii]->m_Color = color; + CurrentColor[ii] = color; wxMemoryDC iconDC; wxBitmapButton * Button = laytool_list[ii]->m_Button; wxBitmap ButtBitmap = Button->GetBitmapLabel(); iconDC.SelectObject( ButtBitmap ); - int buttcolor = *laytool_list[ii]->m_Color; + int buttcolor = CurrentColor[ii]; wxBrush Brush; iconDC.SelectObject( ButtBitmap ); iconDC.SetPen(*wxBLACK_PEN); @@ -298,23 +330,19 @@ int w = BUTT_SIZE_X, h = BUTT_SIZE_Y; Brush.SetStyle(wxSOLID); iconDC.SetBrush(Brush); - iconDC.DrawRectangle(0,0, w, h); + iconDC.DrawRectangle(0, 0, BUTT_SIZE_X, BUTT_SIZE_Y); Button->SetBitmapLabel(ButtBitmap); - SetDisplayOnOff(event); - m_Parent->GetScreen()->SetRefreshReq(); } - Refresh(FALSE); + Refresh( FALSE ); } /******************************************************************/ -void WinEDA_SetColorsFrame::SetDisplayOnOff(wxCommandEvent& event) +void WinEDA_SetColorsFrame::UpdateLayerSettings() /******************************************************************/ { - for ( int ii = 0; laytool_list[ii] != NULL; ii++ ) + for( int ii = 0; laytool_list[ii] != NULL; ii++ ) { - if ( laytool_list[ii]->m_CheckBox == NULL ) - continue; if ( ! laytool_list[ii]->m_NoDisplayIsColor && (laytool_list[ii]->m_NoDisplay == NULL) ) continue; @@ -322,16 +350,21 @@ void WinEDA_SetColorsFrame::SetDisplayOnOff(wxCommandEvent& event) if ( laytool_list[ii]->m_NoDisplayIsColor ) { if ( laytool_list[ii]->m_CheckBox->GetValue() ) - *laytool_list[ii]->m_Color &= ~ITEM_NOT_SHOW; + *laytool_list[ii]->m_Color = CurrentColor[ii] & ~ITEM_NOT_SHOW; else - *laytool_list[ii]->m_Color |= ITEM_NOT_SHOW; + *laytool_list[ii]->m_Color = CurrentColor[ii] | ITEM_NOT_SHOW; } else { + *laytool_list[ii]->m_Color = CurrentColor[ii]; *laytool_list[ii]->m_NoDisplay = laytool_list[ii]->m_CheckBox->GetValue(); + + // A hack, we have both g_DrawGrid and m_Parent->m_Draw_Grid. + // A better way preferred, please. + if( laytool_list[ii]->m_NoDisplay == &g_ShowGrid ) + m_Parent->m_Draw_Grid = g_ShowGrid; } } - m_Parent->GetScreen()->SetRefreshReq(); } @@ -347,7 +380,4 @@ bool NewState = (event.GetId() == ID_COLOR_RESET_SHOW_LAYER_ON) ? TRUE : FALSE; continue; laytool_list[ii]->m_CheckBox->SetValue(NewState); } - - SetDisplayOnOff(event); } - diff --git a/gerbview/set_color.h b/gerbview/set_color.h index b582767f11..f78e8152ed 100644 --- a/gerbview/set_color.h +++ b/gerbview/set_color.h @@ -2,236 +2,236 @@ static ColorButton Msg_Layers_Cu= { - _("Layers 1-16") /* Title */ -}; - -static ColorButton Msg_Layers_Tech= -{ - _("Layers 17-32") /* Title */ + _("Layers 1-16") /* Title */ }; static ColorButton Layer_1_Butt= { _("Layer 1"), /* Title */ - ADR(0), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + ADR(0), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_2_Butt= { - _("Layer 2"), /* Title */ - ADR(1), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 2"), /* Title */ + ADR(1), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_3_Butt= { - _("Layer 3"), /* Title */ - ADR(2), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 3"), /* Title */ + ADR(2), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_4_Butt= { - _("Layer 4"), /* Title */ - ADR(3), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 4"), /* Title */ + ADR(3), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_5_Butt= { - _("Layer 5"), /* Title */ - ADR(4), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 5"), /* Title */ + ADR(4), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_6_Butt= { - _("Layer 6"), /* Title */ - ADR(5), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 6"), /* Title */ + ADR(5), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_7_Butt= { - _("Layer 7"), /* Title */ - ADR(6), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 7"), /* Title */ + ADR(6), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_8_Butt= { - _("Layer 8"), /* Title */ - ADR(7), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 8"), /* Title */ + ADR(7), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_9_Butt= { - _("Layer 9"), /* Title */ - ADR(8), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 9"), /* Title */ + ADR(8), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_10_Butt= { _("Layer 10"), /* Title */ - ADR(9), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + ADR(9), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_11_Butt= { _("Layer 11"), /* Title */ - ADR(10), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + ADR(10), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_12_Butt= { - _("Layer 12"), /* Title */ - ADR(11), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 12"), /* Title */ + ADR(11), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_13_Butt= { - _("Layer 13"), /* Title */ + _("Layer 13"), /* Title */ ADR(12), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_14_Butt= { - _("Layer 14"), /* Title */ + _("Layer 14"), /* Title */ ADR(13), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_15_Butt= { - _("Layer 15"), /* Title */ - ADR(14), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 15"), /* Title */ + ADR(14), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_16_Butt= { _("Layer 16"), /* Title */ ADR(15), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ +}; + +static ColorButton Msg_Layers_Tech= +{ + _("Layers 17-32") /* Title */ }; static ColorButton Layer_17_Butt= { - _("Layer 17"), /* Title */ - ADR(16), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 17"), /* Title */ + ADR(16), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_18_Butt= { - _("Layer 18"), /* Title */ - ADR(17), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 18"), /* Title */ + ADR(17), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_19_Butt= { - _("Layer 19"), /* Title */ - ADR(18), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 19"), /* Title */ + ADR(18), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_20_Butt= { - _("Layer 20"), /* Title */ - ADR(19), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 20"), /* Title */ + ADR(19), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_21_Butt= { - _("Layer 21"), /* Title */ - ADR(20), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 21"), /* Title */ + ADR(20), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_22_Butt= { - _("Layer 22"), /* Title */ - ADR(21), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 22"), /* Title */ + ADR(21), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_23_Butt= { - _("Layer 23"), /* Title */ - ADR(22), /* adr du parametre optionnel */ - TRUE /* adr du parametre display on/off */ + _("Layer 23"), /* Title */ + ADR(22), /* adr du parametre optionnel */ + TRUE /* adr du parametre display on/off */ }; static ColorButton Layer_24_Butt= { - _("Layer 24"), /* Title */ - ADR(23), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 24"), /* Title */ + ADR(23), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_25_Butt= { - _("Layer 25"), /* Title */ - ADR(24), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 25"), /* Title */ + ADR(24), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_26_Butt= { - _("Layer 26"), /* Title */ - ADR(25), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 26"), /* Title */ + ADR(25), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_27_Butt= { - _("Layer 27"), /* Title */ - ADR(26), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 27"), /* Title */ + ADR(26), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_28_Butt= { - _("Layer 28"), /* Title */ - ADR(27), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 28"), /* Title */ + ADR(27), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_29_Butt= { - _("Layer 29"), /* Title */ - ADR(28), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 29"), /* Title */ + ADR(28), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_30_Butt= { - _("Layer 30"), /* Title */ - ADR(29), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 30"), /* Title */ + ADR(29), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_31_Butt= { - _("Layer 31"), /* Title */ - ADR(30), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 31"), /* Title */ + ADR(30), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; static ColorButton Layer_32_Butt= { - _("Layer 32"), /* Title */ - ADR(31), /* adr du parametre optionnel */ - TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ + _("Layer 32"), /* Title */ + ADR(31), /* adr du parametre optionnel */ + TRUE /* parametre display on/off = bit ITEM_NON_VISIBLE */ }; @@ -243,18 +243,18 @@ static ColorButton Msg_Others_Items= static ColorButton Grid_Butt= { - _("Grid"), /* Title */ - &g_DesignSettings.m_PcbGridColor, /* adr du parametre optionnel */ + _("Grid"), /* Title */ + &g_GridColor, /* adr du parametre optionnel */ FALSE, - &g_ShowGrid /* parametre display on/off = bool */ + &g_ShowGrid /* parametre display on/off = bool */ }; static ColorButton Show_DCodes_Butt= { - _("D codes id."), /* Title */ + _("D codes id."), /* Title */ &g_DCodesColor, /* adr du parametre optionnel */ FALSE, - &DisplayOpt.DisplayPadNum /* parametre display on/off = bool*/ + &DisplayOpt.DisplayPadNum /* parametre display on/off = bool */ }; static ColorButton * laytool_list[] = { diff --git a/include/pcbstruct.h b/include/pcbstruct.h index 50cbdce3de..ee0f050b6d 100644 --- a/include/pcbstruct.h +++ b/include/pcbstruct.h @@ -71,7 +71,7 @@ #define ECO2_N 27 #define EDGE_N 28 #define LAST_NO_COPPER_LAYER 28 -#define NB_LAYERS (EDGE_N + 1) +#define NB_LAYERS (LAST_NO_COPPER_LAYER + 1) #define LAYER_COUNT 32 diff --git a/include/wxstruct.h b/include/wxstruct.h index c16c6745f2..4f4be5e77d 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -30,8 +30,8 @@ #endif // Option d'affichage des fenetres de dialogue -//#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT|wxSTAY_ON_TOP -#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT +// #define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE|wxFRAME_FLOAT_ON_PARENT|wxSTAY_ON_TOP +#define DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | wxFRAME_FLOAT_ON_PARENT | MAYBE_RESIZE_BORDER #define EDA_DRAW_PANEL wxScrolledWindow @@ -274,8 +274,8 @@ public: void OnPanning( int direction ); void OnGrid( int grid_type ); void Recadre_Trace( bool ToMouse ); - void PutOnGrid( wxPoint* coord );/* corrige la valeur de la coordonnee coord - * pour etre sur le point de grille le plus proche */ + void PutOnGrid( wxPoint* coord ); /* corrige la valeur de la coordonnee coord + * pour etre sur le point de grille le plus proche */ void Zoom_Automatique( bool move_mouse_cursor ); /* Affiche le schema au meilleur zoom au meilleur centrage pour le dessin @@ -303,7 +303,7 @@ public: virtual void OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) = 0; virtual void ToolOnRightClick( wxCommandEvent& event ); void AdjustScrollBars(); - void Affiche_Status_Box();/* Affichage des coord curseur, zoom .. */ + void Affiche_Status_Box(); /* Affichage des coord curseur, zoom .. */ void DisplayUnitsMsg(); /* Gestion generale des operations sur block */ @@ -494,7 +494,7 @@ public: MODULE* Load_Module_From_Library( const wxString& library, wxDC* DC ); // Gestion des chevelus (ratsnest) - void Compile_Ratsnest( wxDC* DC, bool affiche );/* Recalcul complet du chevelu */ + void Compile_Ratsnest( wxDC* DC, bool affiche ); /* Recalcul complet du chevelu */ void ReCompile_Ratsnest_After_Changes( wxDC* DC ); int Test_1_Net_Ratsnest( wxDC* DC, int net_code ); char* build_ratsnest_module( wxDC* DC, MODULE* Module ); @@ -502,8 +502,8 @@ public: void Build_Board_Ratsnest( wxDC* DC ); void DrawGeneralRatsnest( wxDC* DC, int net_code = 0 ); void trace_ratsnest_pad( wxDC* DC ); - void recalcule_pad_net_code();/* Routine de - * calcul et de mise a jour des net_codes des PADS */ + void recalcule_pad_net_code(); /* Routine de + * calcul et de mise a jour des net_codes des PADS */ void build_liste_pads(); int* build_ratsnest_pad( EDA_BaseStruct* ref, const wxPoint& refpos, bool init ); @@ -539,7 +539,9 @@ public: void DelLimitesZone( wxDC* DC, bool Redraw ); // Gestion des layers: - int SelectLayer( int default_layer, int min_layer, int max_layer ); + // (See pcbnew/sel_layer.cpp for description of why null_layer parameter is provided) + int SelectLayer( int default_layer, int min_layer, int max_layer, + bool null_layer = false ); void SelectLayerPair(); virtual void SwitchLayer( wxDC* DC, int layer ); @@ -1620,8 +1622,8 @@ public: private: void OnClose( wxCloseEvent& event ); - void Cancel( wxCommandEvent& event ); - void Ok( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); void ClickOnList( wxCommandEvent& event ); void D_ClickOnList( wxCommandEvent& event ); void OnKeyEvent( wxKeyEvent& event ); diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index d23816d4da..dfa17fd8c0 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -153,7 +153,7 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent, m_button2 = new wxButton( this, wxID_CANCEL, _( "Cancel" ), wxDefaultPosition, wxDefaultSize, 0 ); m_button2->SetForegroundColour( *wxBLUE ); fgSizer2->Add( m_button2, 0, wxALL, 5 ); - m_button1 = new wxButton( this, wxID_OK, _( "Ok" ), wxDefaultPosition, wxDefaultSize, 0 ); + m_button1 = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition, wxDefaultSize, 0 ); m_button1->SetForegroundColour( *wxRED ); m_button1->SetDefault(); fgSizer2->Add( m_button1, 0, wxALL, 5 ); @@ -169,7 +169,7 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent, void WinEDA_ExecBlockCmdFrame::Cancel( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - EndModal( 1 ); + EndModal( -1 ); } diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 38e8b4f0fb..ce6b6dbc2a 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -343,7 +343,7 @@ void TEXTE_MODULE::Display_Infos( WinEDA_DrawFrame* frame ) Affiche_1_Parametre( frame, -1, wxEmptyString, _( "Yes" ), DARKGREEN ); ii = m_Layer; - if( ii <= 28 ) + if( ii < NB_LAYERS ) Affiche_1_Parametre( frame, 28, _( "Layer" ), ReturnPcbLayerName( ii ), DARKGREEN ); else { diff --git a/pcbnew/cotation.cpp b/pcbnew/cotation.cpp index 7a703e3e81..ea16456955 100644 --- a/pcbnew/cotation.cpp +++ b/pcbnew/cotation.cpp @@ -36,9 +36,7 @@ static int status_cotation; /* = 0 : pas de cotation en cours enum id_Cotation_properties { - ID_ACCEPT_COTATION_PROPERTIES = 1900, - ID_CLOSE_COTATION_PROPERTIES, - ID_TEXTPCB_SELECT_LAYER + ID_TEXTPCB_SELECT_LAYER = 1900 }; /************************************/ @@ -69,17 +67,15 @@ public: private: - void OnQuit( wxCommandEvent& event ); - void CotationPropertiesAccept( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE( WinEDA_CotationPropertiesFrame, wxDialog ) -EVT_BUTTON( ID_ACCEPT_COTATION_PROPERTIES, - WinEDA_CotationPropertiesFrame::CotationPropertiesAccept ) -EVT_BUTTON( ID_CLOSE_COTATION_PROPERTIES, - WinEDA_CotationPropertiesFrame::OnQuit ) +EVT_BUTTON( wxID_OK, WinEDA_CotationPropertiesFrame::OnOkClick ) +EVT_BUTTON( wxID_CANCEL, WinEDA_CotationPropertiesFrame::OnCancelClick ) END_EVENT_TABLE() @@ -106,13 +102,11 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); /* Creation des boutons de commande */ - Button = new wxButton( this, ID_ACCEPT_COTATION_PROPERTIES, - _( "Ok" ) ); + Button = new wxButton( this, wxID_OK, _( "OK" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton( this, ID_CLOSE_COTATION_PROPERTIES, - _( "Cancel" ) ); + Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); Button->SetForegroundColour( *wxBLUE ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); @@ -142,7 +136,7 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* wxDefaultPosition, wxDefaultSize ); LeftBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); int ii; - for( ii = CMP_N + 1; ii < 29; ii++ ) + for( ii = CMP_N + 1; ii < NB_LAYERS; ii++ ) { m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); } @@ -155,15 +149,15 @@ WinEDA_CotationPropertiesFrame::WinEDA_CotationPropertiesFrame( WinEDA_PcbFrame* /**********************************************************************/ -void WinEDA_CotationPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) +void WinEDA_CotationPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - Close( true ); // true is to force the frame to close + EndModal( -1 ); } /***********************************************************************************/ -void WinEDA_CotationPropertiesFrame::CotationPropertiesAccept( wxCommandEvent& event ) +void WinEDA_CotationPropertiesFrame::OnOkClick( wxCommandEvent& event ) /***********************************************************************************/ { if( m_DC ) // Effacement ancien texte @@ -193,7 +187,7 @@ void WinEDA_CotationPropertiesFrame::CotationPropertiesAccept( wxCommandEvent& e } m_Parent->m_CurrentScreen->SetModify(); - Close( TRUE ); + EndModal( 1 ); } @@ -208,7 +202,7 @@ static void Exit_EditCotation( WinEDA_DrawPanel* Panel, wxDC* DC ) if( Cotation->m_Flags & IS_NEW ) { Cotation->Draw( Panel, DC, wxPoint( 0, 0 ), GR_XOR ); - Cotation ->DeleteStructure(); + Cotation->DeleteStructure(); } else { @@ -365,7 +359,8 @@ void WinEDA_PcbFrame::Install_Edit_Cotation( COTATION* Cotation, WinEDA_CotationPropertiesFrame* frame = new WinEDA_CotationPropertiesFrame( this, Cotation, DC, pos ); - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); + frame->Destroy(); } @@ -378,7 +373,7 @@ void WinEDA_PcbFrame::Delete_Cotation( COTATION* Cotation, wxDC* DC ) if( DC ) Cotation->Draw( DrawPanel, DC, wxPoint( 0, 0 ), GR_XOR ); - Cotation ->DeleteStructure(); + Cotation->DeleteStructure(); m_CurrentScreen->SetModify(); } diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index 7715dcce1c..2d7907157a 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -11,9 +11,8 @@ /**************************************/ BEGIN_EVENT_TABLE( WinEDA_ModulePropertiesFrame, wxDialog ) - EVT_BUTTON( ID_ACCEPT_MODULE_PROPERTIES, - WinEDA_ModulePropertiesFrame::ModulePropertiesAccept ) - EVT_BUTTON( ID_CLOSE_MODULE_PROPERTIES, WinEDA_ModulePropertiesFrame::OnQuit ) + EVT_BUTTON( wxID_OK, WinEDA_ModulePropertiesFrame::OnOkClick ) + EVT_BUTTON( wxID_CANCEL, WinEDA_ModulePropertiesFrame::OnCancelClick ) EVT_BUTTON( ID_MODULE_EDIT_ADD_TEXT, WinEDA_ModulePropertiesFrame::CreateTextModule ) EVT_BUTTON( ID_MODULE_EDIT_EDIT_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule ) EVT_BUTTON( ID_MODULE_EDIT_DELETE_TEXT, WinEDA_ModulePropertiesFrame::EditOrDelTextModule ) @@ -115,13 +114,11 @@ void WinEDA_ModulePropertiesFrame::CreateControls() wxBoxSizer* ButtonsBoxSizer = new wxBoxSizer( wxHORIZONTAL ); m_GeneralBoxSizer->Add( ButtonsBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 ); - Button = new wxButton( this, ID_ACCEPT_MODULE_PROPERTIES, - _( "Ok" ) ); + Button = new wxButton( this, wxID_OK, _( "OK" ) ); Button->SetForegroundColour( *wxRED ); ButtonsBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - Button = new wxButton( this, ID_CLOSE_MODULE_PROPERTIES, - _( "Cancel" ) ); + Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); Button->SetForegroundColour( *wxBLUE ); ButtonsBoxSizer->Add( Button, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); } @@ -486,15 +483,15 @@ void Panel3D_Ctrl::Browse3DLib( wxCommandEvent& event ) /**********************************************************************/ -void WinEDA_ModulePropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) +void WinEDA_ModulePropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - Close( true ); // true is to force the frame to close + EndModal( -1 ); } /******************************************************************************/ -void WinEDA_ModulePropertiesFrame::ModulePropertiesAccept( wxCommandEvent& event ) +void WinEDA_ModulePropertiesFrame::OnOkClick( wxCommandEvent& event ) /******************************************************************************/ { bool change_layer = FALSE; @@ -590,7 +587,7 @@ void WinEDA_ModulePropertiesFrame::ModulePropertiesAccept( wxCommandEvent& event m_Parent->GetScreen()->SetModify(); - Close( TRUE ); + EndModal( 1 ); if( m_DC ) m_CurrentModule->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); diff --git a/pcbnew/dialog_edit_module.h b/pcbnew/dialog_edit_module.h index 660182fda7..e21d278f0d 100644 --- a/pcbnew/dialog_edit_module.h +++ b/pcbnew/dialog_edit_module.h @@ -5,9 +5,7 @@ enum id_Module_properties { - ID_ACCEPT_MODULE_PROPERTIES = 1900, - ID_CLOSE_MODULE_PROPERTIES, - ID_GOTO_MODULE_EDITOR, + ID_GOTO_MODULE_EDITOR =1900, ID_MODULE_PROPERTIES_EXCHANGE, ID_MODULE_EDIT_ADD_TEXT, ID_MODULE_EDIT_EDIT_TEXT, @@ -59,8 +57,8 @@ public: private: void CreateControls(); - void OnQuit(wxCommandEvent& event); - void ModulePropertiesAccept(wxCommandEvent& event); + void OnCancelClick(wxCommandEvent& event); + void OnOkClick(wxCommandEvent& event); void CreateTextModule(wxCommandEvent& event); void EditOrDelTextModule(wxCommandEvent& event); void SelectTextListBox(wxCommandEvent& event); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 96df042c3a..d22d6783fe 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -284,10 +284,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( wxDC* DC, int shape_type ) /**************** Polygon Shapes ***********************/ enum id_mw_cmd { - ID_ACCEPT_OPT = 1000, - ID_CANCEL_OPT, - ID_READ_SHAPE_FILE - + ID_READ_SHAPE_FILE = 1000 }; /*************************************************/ @@ -309,8 +306,8 @@ public: ~WinEDA_SetParamShapeFrame() { }; private: - void OnCloseWindow( wxCloseEvent& event ); - void OnCancel( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); void ReadDataShapeDescr( wxCommandEvent& event ); void AcceptOptions( wxCommandEvent& event ); @@ -318,8 +315,8 @@ private: }; /* Construction de la table des evenements pour WinEDA_SetParamShapeFrame */ BEGIN_EVENT_TABLE( WinEDA_SetParamShapeFrame, wxDialog ) -EVT_BUTTON( ID_ACCEPT_OPT, WinEDA_SetParamShapeFrame::AcceptOptions ) -EVT_BUTTON( ID_CANCEL_OPT, WinEDA_SetParamShapeFrame::OnCancel ) +EVT_BUTTON( wxID_OK, WinEDA_SetParamShapeFrame::OnOkClick ) +EVT_BUTTON( wxID_CANCEL, WinEDA_SetParamShapeFrame::OnCancelClick ) EVT_BUTTON( ID_READ_SHAPE_FILE, WinEDA_SetParamShapeFrame::ReadDataShapeDescr ) END_EVENT_TABLE() @@ -348,21 +345,21 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent, MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 ); MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); - wxButton* Button = new wxButton( this, ID_ACCEPT_OPT, _( "Ok" ) ); + wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton( this, ID_CANCEL_OPT, _( "Cancel" ) ); + Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); Button->SetForegroundColour( *wxBLUE ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - Button = new wxButton( this, ID_READ_SHAPE_FILE, _( "Read Shape Descr File" ) ); + Button = new wxButton( this, ID_READ_SHAPE_FILE, _( "Read Shape Descr File..." ) ); Button->SetForegroundColour( wxColor( 0, 100, 0 ) ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); - wxString shapelist[3] = { _( "Normal" ), _( "Symmetrical" ), _( "mirrored" ) }; + wxString shapelist[3] = { _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" ) }; m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( - "ShapeOption" ), + "Shape Option" ), wxDefaultPosition, wxDefaultSize, 3, shapelist, 1, wxRA_SPECIFY_COLS ); LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 ); @@ -371,26 +368,25 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent, ShapeSize, g_UnitMetric, LeftBoxSizer, PCB_INTERNAL_UNIT ); - GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); } /**********************************************************************/ -void WinEDA_SetParamShapeFrame::OnCancel( wxCommandEvent& WXUNUSED (event) ) +void WinEDA_SetParamShapeFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { if( PolyEdges ) free( PolyEdges ); PolyEdges = NULL; PolyEdgesCount = 0; - EndModal( 0 ); + EndModal( -1 ); } /*******************************************************************/ -void WinEDA_SetParamShapeFrame::AcceptOptions( wxCommandEvent& event ) +void WinEDA_SetParamShapeFrame::OnOkClick( wxCommandEvent& event ) /*******************************************************************/ { ShapeSize = m_SizeCtrl->GetValue(); diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index d6d8025079..62b5e88c09 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -577,7 +577,7 @@ wxString ext; int mask = 1; s_SelectedLayers = 0; - for( layer_to_plot = 0; layer_to_plot < 29; layer_to_plot++, mask <<= 1 ) + for( layer_to_plot = 0; layer_to_plot < NB_LAYERS; layer_to_plot++, mask <<= 1 ) { if( m_BoxSelecLayer[layer_to_plot]->GetValue() ) { diff --git a/pcbnew/pcbtexte.cpp b/pcbnew/pcbtexte.cpp index 23e0a47e47..b6dea71e91 100644 --- a/pcbnew/pcbtexte.cpp +++ b/pcbnew/pcbtexte.cpp @@ -21,9 +21,7 @@ static wxPoint old_pos; // position originelle du texte selecte enum id_TextPCB_properties { - ID_ACCEPT_TEXTE_PCB_PROPERTIES = 1900, - ID_CLOSE_TEXTE_PCB_PROPERTIES, - ID_TEXTPCB_SELECT_LAYER + ID_TEXTPCB_SELECT_LAYER = 1900 }; /************************************/ @@ -56,17 +54,15 @@ public: private: - void TextPCBPropertiesAccept( wxCommandEvent& event ); - void OnQuit( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE( WinEDA_TextPCBPropertiesFrame, wxDialog ) -EVT_BUTTON( ID_ACCEPT_TEXTE_PCB_PROPERTIES, - WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept ) -EVT_BUTTON( ID_CLOSE_TEXTE_PCB_PROPERTIES, - WinEDA_TextPCBPropertiesFrame::OnQuit ) +EVT_BUTTON( wxID_OK, WinEDA_TextPCBPropertiesFrame::OnOkClick ) +EVT_BUTTON( wxID_CANCEL, WinEDA_TextPCBPropertiesFrame::OnCancelClick ) END_EVENT_TABLE() @@ -78,7 +74,8 @@ void WinEDA_PcbFrame::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, DrawPanel->m_IgnoreMouseEvents = TRUE; WinEDA_TextPCBPropertiesFrame* frame = new WinEDA_TextPCBPropertiesFrame( this, TextPCB, DC, pos ); - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); + frame->Destroy(); DrawPanel->MouseToCursorSchema(); DrawPanel->m_IgnoreMouseEvents = FALSE; } @@ -111,12 +108,12 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 ); /* Creation des boutons de commande */ - Button = new wxButton( this, ID_ACCEPT_TEXTE_PCB_PROPERTIES, _( "Ok" ) ); + Button = new wxButton( this, wxID_OK, _( "OK" ) ); Button->SetForegroundColour( *wxRED ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); Button->SetDefault(); - Button = new wxButton( this, ID_CLOSE_TEXTE_PCB_PROPERTIES, _( "Cancel" ) ); + Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) ); Button->SetForegroundColour( *wxBLUE ); RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 ); @@ -143,7 +140,7 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p MiddleBoxSizer->Add( m_SelLayerBox, 0, wxGROW | wxALL, 5 ); int ii; - for( ii = 0; ii < 29; ii++ ) + for( ii = 0; ii < NB_LAYERS; ii++ ) { m_SelLayerBox->Append( ReturnPcbLayerName( ii ) ); } @@ -181,7 +178,7 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p wxDefaultPosition, wxSize( -1, -1 ), 2, display_msg, 1, wxRA_SPECIFY_COLS ); if( !TextPCB->m_Miroir ) - m_Mirror->SetSelection( 1 );; + m_Mirror->SetSelection( 1 ); MiddleBoxSizer->Add( m_Mirror, 0, wxGROW | wxALL, 5 ); GetSizer()->Fit( this ); @@ -190,16 +187,15 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p /**********************************************************************/ -void WinEDA_TextPCBPropertiesFrame::OnQuit( wxCommandEvent& WXUNUSED (event) ) +void WinEDA_TextPCBPropertiesFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) ) /**********************************************************************/ { - // true is to force the frame to close - Close( true ); + EndModal( -1 ); } /**************************************************************************************/ -void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept( wxCommandEvent& event ) +void WinEDA_TextPCBPropertiesFrame::OnOkClick( wxCommandEvent& event ) /**************************************************************************************/ { if( m_DC ) // Effacement ancien texte @@ -224,7 +220,7 @@ void WinEDA_TextPCBPropertiesFrame::TextPCBPropertiesAccept( wxCommandEvent& eve CurrentTextPCB->Draw( m_Parent->DrawPanel, m_DC, wxPoint( 0, 0 ), GR_OR ); } m_Parent->m_CurrentScreen->SetModify(); - Close( TRUE ); + EndModal( 1 ); } diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index eca890d27d..8ca019363a 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -14,12 +14,9 @@ /* Fonctions locales: */ enum layer_sel_id { - ID_LAYER_OK = 1800, - ID_LAYER_CANCEL, - ID_LAYER_SELECT_TOP, + ID_LAYER_SELECT_TOP = 1800, ID_LAYER_SELECT_BOTTOM, ID_LAYER_SELECT - }; @@ -32,64 +29,82 @@ class WinEDA_SelLayerFrame : public wxDialog private: WinEDA_BasePcbFrame* m_Parent; wxRadioBox* m_LayerList; - int m_LayerId[NB_LAYERS]; + int m_LayerId[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton public: // Constructor and destructor WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, int default_layer, - int min_layer, int max_layer ); + int min_layer, int max_layer, bool null_layer ); ~WinEDA_SelLayerFrame() { }; private: void Sel_Layer( wxCommandEvent& event ); - void Cancel( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; /* Table des evenements pour WinEDA_SelLayerFrame */ BEGIN_EVENT_TABLE( WinEDA_SelLayerFrame, wxDialog ) -EVT_BUTTON( ID_LAYER_OK, WinEDA_SelLayerFrame::Sel_Layer ) -EVT_BUTTON( ID_LAYER_CANCEL, WinEDA_SelLayerFrame::Cancel ) -EVT_RADIOBOX( ID_LAYER_SELECT, WinEDA_SelLayerFrame::Sel_Layer ) + EVT_BUTTON( wxID_OK, WinEDA_SelLayerFrame::Sel_Layer ) + EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerFrame::OnCancelClick ) + EVT_RADIOBOX( ID_LAYER_SELECT, WinEDA_SelLayerFrame::Sel_Layer ) END_EVENT_TABLE() /****************************************************************************************/ -int WinEDA_BasePcbFrame::SelectLayer( int default_layer, int min_layer, int max_layer ) +int WinEDA_BasePcbFrame::SelectLayer( int default_layer, int min_layer, int max_layer, + bool null_layer ) /****************************************************************************************/ /* Install the dialog box for layer selection - * @param default_layer = Preselection + * @param default_layer = Preselection (NB_LAYERS for "(Deselect)" layer) * @param min_layer = min layer value (-1 if no min value) - * @param max_layer = max layer value (-1 si no max value) - * @return new layer value, or <0 if aborted + * @param max_layer = max layer value (-1 if no max value) + * @param null_layer = display a "(Deselect)" radiobutton (when set to true) + * @return new layer value (NB_LAYERS when "(Deselect)" radiobutton selected), + * or -1 if cancelled + * + * Providing the option to also display a "(Deselect)" radiobutton makes the + * "Swap Layers" command (and GerbView's "Export to Pcbnew" command) more "user + * friendly", by permitting any layer to be "deselected" immediately after its + * corresponding radiobutton has been clicked on. (It would otherwise be + * necessary to first cancel the "Select Layer:" dialog box (invoked after a + * different radiobutton is clicked on) prior to then clicking on the "Deselect" + * button provided within the "Swap Layers:" or "Layer selection:" dialog box). */ { int layer; WinEDA_SelLayerFrame* frame = - new WinEDA_SelLayerFrame( this, default_layer, min_layer, max_layer ); + new WinEDA_SelLayerFrame( this, default_layer, min_layer, max_layer, null_layer ); - layer = frame->ShowModal(); frame->Destroy(); + layer = frame->ShowModal(); + frame->Destroy(); return layer; } /***********************************************************************/ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, - int default_layer, int min_layer, int max_layer ) : - wxDialog( parent, -1, _( "Select Layer:" ), wxPoint( -1, -1 ), + int default_layer, int min_layer, + int max_layer, bool null_layer ) : + wxDialog( parent, -1, _("Select Layer:"), wxPoint( -1, -1 ), wxSize( 470, 250 ), DIALOG_STYLE ) /***********************************************************************/ + +/* + * The "OK" and "Cancel" buttons are positioned (in a horizontal line) + * beneath the "Layer" radiobox, unless that contains only one column of + * radiobuttons, in which case they are positioned (in a vertical line) + * to the right of that radiobox. + */ { wxButton* Button; - int ii, yy, xx; - wxPoint pos; - wxString LayerList[NB_LAYERS]; + int ii; + wxString LayerList[NB_LAYERS + 1]; // One extra element for "(Deselect)" radiobutton int LayerCount, LayerSelect = -1; - m_Parent = parent; SetFont( *g_DialogFont ); @@ -104,42 +119,54 @@ WinEDA_SelLayerFrame::WinEDA_SelLayerFrame( WinEDA_BasePcbFrame* parent, { if( min_layer > ii ) continue; - + if( (max_layer >= 0) && (max_layer < ii) ) break; - + LayerList[LayerCount] = ReturnPcbLayerName( ii ); if( ii == default_layer ) LayerSelect = LayerCount; - + m_LayerId[LayerCount] = ii; LayerCount++; } } + // When appropriate, also provide a "(Deselect)" radiobutton + if( null_layer ) + { + LayerList[LayerCount] = _( "(Deselect)" ); + if( NB_LAYERS == default_layer ) + LayerSelect = LayerCount; - pos.x = 5; pos.y = 5; + m_LayerId[LayerCount] = NB_LAYERS; + LayerCount++; + } - m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _( "Layer" ), - pos, wxSize( -1, -1 ), LayerCount, LayerList, + m_LayerList = new wxRadioBox( this, ID_LAYER_SELECT, _("Layer"), + wxPoint( -1, -1 ), wxSize( -1, -1 ), LayerCount, LayerList, (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS ); if( LayerSelect >= 0 ) m_LayerList->SetSelection( LayerSelect ); - m_LayerList->GetSize( &xx, &yy ); - pos.x += xx + 12; - Button = new wxButton( this, ID_LAYER_OK, - _( "OK" ), pos ); - Button->SetForegroundColour( *wxBLUE ); + wxBoxSizer* FrameBoxSizer = new wxBoxSizer(wxHORIZONTAL); + SetSizer(FrameBoxSizer); + FrameBoxSizer->Add(m_LayerList, 0, wxALIGN_TOP|wxALL, 5); + wxBoxSizer* ButtonBoxSizer = new wxBoxSizer(wxVERTICAL); + FrameBoxSizer->Add(ButtonBoxSizer, 0, wxALIGN_BOTTOM|wxALL, 0); - pos.y += Button->GetSize().y + 5; - Button = new wxButton( this, ID_LAYER_CANCEL, - _( "Cancel" ), pos ); + Button = new wxButton( this, wxID_OK, _("OK") ); Button->SetForegroundColour( *wxRED ); + ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - /* Redimensionnement de la boite de dialogue: */ - pos.x += Button->GetSize().x + 10; - SetSize( -1, -1, pos.x, yy + 35 ); + Button = new wxButton( this, wxID_CANCEL, _("Cancel") ); + Button->SetForegroundColour( *wxBLUE ); + ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + if( GetSizer() ) + { + GetSizer()->SetSizeHints(this); + } } @@ -154,7 +181,7 @@ void WinEDA_SelLayerFrame::Sel_Layer( wxCommandEvent& event ) /***************************************************************/ -void WinEDA_SelLayerFrame::Cancel( wxCommandEvent& event ) +void WinEDA_SelLayerFrame::OnCancelClick( wxCommandEvent& event ) /***************************************************************/ { EndModal( -1 ); @@ -180,8 +207,8 @@ public: ~WinEDA_SelLayerPairFrame() { }; private: - void Sel_Layer( wxCommandEvent& event ); - void Cancel( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; @@ -189,11 +216,11 @@ private: /* Table des evenements pour WinEDA_SelLayerPairFrame */ BEGIN_EVENT_TABLE( WinEDA_SelLayerPairFrame, wxDialog ) -EVT_BUTTON( ID_LAYER_OK, WinEDA_SelLayerPairFrame::Sel_Layer ) -EVT_BUTTON( ID_LAYER_CANCEL, WinEDA_SelLayerPairFrame::Cancel ) -EVT_RADIOBOX( ID_LAYER_SELECT, WinEDA_SelLayerPairFrame::Sel_Layer ) + EVT_BUTTON( wxID_OK, WinEDA_SelLayerPairFrame::OnOkClick ) + EVT_BUTTON( wxID_CANCEL, WinEDA_SelLayerPairFrame::OnCancelClick ) END_EVENT_TABLE() + /***********************************************/ void WinEDA_BasePcbFrame::SelectLayerPair() /***********************************************/ @@ -202,10 +229,23 @@ void WinEDA_BasePcbFrame::SelectLayerPair() * pour autorutage, vias... */ { + // Check whether more than one copper layer has been enabled for the + // current PCB file, as Layer Pairs can only meaningfully be defined + // within PCB files which contain at least two copper layers. + if( m_Pcb->m_BoardSettings->m_CopperLayerCount < 2 ) + { + wxString InfoMsg; + InfoMsg = _( "Less than two copper layers are being used." ); + InfoMsg << wxT( "\n" ) << _( "Hence Layer Pairs cannot be specified." ); + DisplayInfo( this, InfoMsg ); + return; + } + WinEDA_SelLayerPairFrame* frame = new WinEDA_SelLayerPairFrame( this ); - frame->ShowModal(); frame->Destroy(); + frame->ShowModal(); + frame->Destroy(); DrawPanel->MouseToCursorSchema(); SetToolbars(); } @@ -213,14 +253,12 @@ void WinEDA_BasePcbFrame::SelectLayerPair() /*******************************************************************************/ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent ) : - wxDialog( parent, -1, _( "Select Layer Pair:" ), wxPoint( -1, -1 ), + wxDialog( parent, -1, _("Select Layer Pair:"), wxPoint( -1, -1 ), wxSize( 470, 250 ), DIALOG_STYLE ) /*******************************************************************************/ { wxButton* Button; int ii, LayerCount; - int yy, xx; - wxPoint pos; wxString LayerList[NB_COPPER_LAYERS]; int LayerTopSelect = 0, LayerBottomSelect = 0; @@ -246,48 +284,85 @@ WinEDA_SelLayerPairFrame::WinEDA_SelLayerPairFrame( WinEDA_BasePcbFrame* parent } } - pos.x = 5; pos.y = 5; - m_LayerListTOP = new wxRadioBox( this, ID_LAYER_SELECT_TOP, _( "Top Layer" ), - pos, wxSize( -1, -1 ), LayerCount, LayerList, + m_LayerListTOP = new wxRadioBox( this, ID_LAYER_SELECT_TOP, _("Top Layer"), + wxPoint( -1, -1 ), wxSize( -1, -1 ), LayerCount, LayerList, (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS ); m_LayerListTOP->SetSelection( LayerTopSelect ); - m_LayerListTOP->GetSize( &xx, &yy ); - pos.x += xx + 12; - m_LayerListBOTTOM = new wxRadioBox( this, ID_LAYER_SELECT_BOTTOM, _( "Bottom Layer" ), - pos, wxSize( -1, -1 ), LayerCount, LayerList, + m_LayerListBOTTOM = new wxRadioBox( this, ID_LAYER_SELECT_BOTTOM, _("Bottom Layer"), + wxPoint( -1, -1 ), wxSize( -1, -1 ), LayerCount, LayerList, (LayerCount < 8) ? LayerCount : 8, wxRA_SPECIFY_ROWS ); m_LayerListBOTTOM->SetSelection( LayerBottomSelect ); - m_LayerListBOTTOM->GetSize( &xx, &yy ); - pos.x += xx + 12; - Button = new wxButton( this, ID_LAYER_OK, _( "OK" ), pos ); - Button->SetForegroundColour( *wxBLUE ); + wxBoxSizer* FrameBoxSizer = new wxBoxSizer(wxVERTICAL); + SetSizer(FrameBoxSizer); - pos.y += Button->GetSize().y + 5; - Button = new wxButton( this, ID_LAYER_CANCEL, _( "Cancel" ), pos ); + wxBoxSizer* RadioBoxSizer = new wxBoxSizer(wxHORIZONTAL); + FrameBoxSizer->Add(RadioBoxSizer, 0, wxALIGN_LEFT|wxALL, 0); + + wxBoxSizer* ButtonBoxSizer = new wxBoxSizer(wxHORIZONTAL); + FrameBoxSizer->Add(ButtonBoxSizer, 0, wxALIGN_RIGHT|wxALL, 0); + + RadioBoxSizer->Add(m_LayerListTOP, 0, wxALIGN_TOP|wxALL, 5); + RadioBoxSizer->Add(m_LayerListBOTTOM, 0, wxALIGN_TOP|wxALL, 5); + + Button = new wxButton( this, wxID_OK, _("OK") ); Button->SetForegroundColour( *wxRED ); + ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); - /* Redimensionnement de la boite de dialogue: */ - pos.x += Button->GetSize().x + 10; - SetSize( -1, -1, pos.x, yy + 35 ); + Button = new wxButton( this, wxID_CANCEL, _("Cancel") ); + Button->SetForegroundColour( *wxBLUE ); + ButtonBoxSizer->Add(Button, 0, wxGROW|wxALL, 5); + + if( GetSizer() ) + { + GetSizer()->SetSizeHints(this); + } } /***************************************************************/ -void WinEDA_SelLayerPairFrame::Sel_Layer( wxCommandEvent& event ) +void WinEDA_SelLayerPairFrame::OnOkClick( wxCommandEvent& event ) /***************************************************************/ { + // Check whether whichever layer has been specified as the "Top" + // layer is really "above" whichever layer has been specified as + // the "Bottom" layer; those values will only be updated (and the + // dialog box subsequently closed) when that condition is met. +// if( m_LayerId[m_LayerListTOP->GetSelection()] +// <= m_LayerId[m_LayerListBOTTOM->GetSelection()] ) +// { +// DisplayError( this, _( "The Top Layer must be above the Bottom Layer" ) ); +// return; +// } + + // Code for previous test commented out because other code now + // transposes the assignment of the Top and Bottom layers if + // the former layer is actually "below" the latter. However, + // it is still desirable to check that those layers differ. + + // Check whether whichever layer has been specified as the "Top" + // layer differs from whichever layer has been specified as the + // "Bottom" layer; those values will only be updated (and the + // dialog box subsequently closed) when that condition is met. + if( m_LayerId[m_LayerListTOP->GetSelection()] + == m_LayerId[m_LayerListBOTTOM->GetSelection()] ) + { + DisplayError( this, _( "The Top Layer and Bottom Layer must differ" ) ); + return; + } + PCB_SCREEN* screen = (PCB_SCREEN*) m_Parent->m_CurrentScreen; screen->m_Route_Layer_TOP = m_LayerId[m_LayerListTOP->GetSelection()]; screen->m_Route_Layer_BOTTOM = m_LayerId[m_LayerListBOTTOM->GetSelection()]; + EndModal( 0 ); } /***************************************************************/ -void WinEDA_SelLayerPairFrame::Cancel( wxCommandEvent& event ) +void WinEDA_SelLayerPairFrame::OnCancelClick( wxCommandEvent& event ) /***************************************************************/ { EndModal( -1 ); diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index d4211d9ba5..c0b32600df 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -11,12 +11,10 @@ #include "protos.h" /* Variables locales */ -static int New_Layer[32]; +static int New_Layer[NB_LAYERS]; enum swap_layer_id { - ID_SWAP_LAYER_EXECUTE = 1800, - ID_SWAP_LAYER_CANCEL, - ID_SWAP_LAYER_BUTTON_SELECT, + ID_SWAP_LAYER_BUTTON_SELECT = 1800, ID_SWAP_LAYER_DESELECT, ID_SWAP_LAYER_SELECT }; @@ -40,15 +38,16 @@ public: private: void Sel_Layer( wxCommandEvent& event ); - void Cancel( wxCommandEvent& event ); - void Execute( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; + /* Table des evenements pour WinEDA_SwapLayerFrame */ BEGIN_EVENT_TABLE( WinEDA_SwapLayerFrame, wxDialog ) -EVT_BUTTON( ID_SWAP_LAYER_EXECUTE, WinEDA_SwapLayerFrame::Execute ) -EVT_BUTTON( ID_SWAP_LAYER_CANCEL, WinEDA_SwapLayerFrame::Cancel ) +EVT_BUTTON( wxID_OK, WinEDA_SwapLayerFrame::OnOkClick ) +EVT_BUTTON( wxID_CANCEL, WinEDA_SwapLayerFrame::OnCancelClick ) EVT_BUTTON( ID_SWAP_LAYER_DESELECT, WinEDA_SwapLayerFrame::Sel_Layer ) EVT_BUTTON( ID_SWAP_LAYER_BUTTON_SELECT, WinEDA_SwapLayerFrame::Sel_Layer ) EVT_RADIOBOX( ID_SWAP_LAYER_SELECT, WinEDA_SwapLayerFrame::Sel_Layer ) @@ -65,7 +64,7 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) : wxButton* Button; int ii; wxPoint pos; - wxString g_Layer_Name_Pair[32]; + wxString g_Layer_Name_Pair[NB_LAYERS]; wxSize winsize; m_Parent = parent; @@ -76,42 +75,38 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( WinEDA_BasePcbFrame* parent ) : g_Layer_Name_Pair[ii] = ReturnPcbLayerName( ii ) + wxT( " -> " ) + _( "No Change" ); } - pos.x = 5; pos.y = START_Y; + pos.x = 5; + pos.y = START_Y; m_LayerList = new wxRadioBox( this, ID_SWAP_LAYER_SELECT, _( "Layers" ), - pos, - wxSize( -1, -1 ), 29, g_Layer_Name_Pair, 16, wxRA_SPECIFY_ROWS ); + pos, wxSize( -1, -1 ), + NB_LAYERS, g_Layer_Name_Pair, 16, wxRA_SPECIFY_ROWS ); winsize.y = m_LayerList->GetRect().GetBottom(); - pos.x = m_LayerList->GetRect().GetRight() + 12; - Button = new wxButton( this, ID_SWAP_LAYER_CANCEL, - _( "Cancel" ), pos ); + pos.x = m_LayerList->GetRect().GetRight() + 12; + + Button = new wxButton(this, ID_SWAP_LAYER_BUTTON_SELECT, _("Select..."), pos ); + Button->SetForegroundColour(wxColour(0,100,100)); + + pos.y += Button->GetSize().y + 10; + + Button = new wxButton(this, ID_SWAP_LAYER_DESELECT, _("Deselect"), pos ); + Button->SetForegroundColour(wxColour(0,100,0)); + + pos.y = winsize.y - 2 * Button->GetSize().y - 10; + + Button = new wxButton(this, wxID_OK, _("OK"), pos ); + Button->SetForegroundColour(*wxRED); + + pos.y += Button->GetSize().y + 10; + + Button = new wxButton(this, wxID_CANCEL, _("Cancel"), pos ); + Button->SetForegroundColour(*wxBLUE); - Button->SetForegroundColour( *wxRED ); winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); - - pos.y += Button->GetSize().y + 5; - Button = new wxButton( this, ID_SWAP_LAYER_EXECUTE, - _( "OK" ), pos ); - - Button->SetForegroundColour( *wxBLUE ); - winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); - - pos.y += Button->GetSize().y + 15; - Button = new wxButton( this, ID_SWAP_LAYER_DESELECT, - _( "Deselect" ), pos ); - - Button->SetForegroundColour( wxColour( 0, 100, 0 ) ); - winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); - - pos.y += Button->GetSize().y + 5; - Button = new wxButton( this, ID_SWAP_LAYER_BUTTON_SELECT, - _( "Select" ), pos ); - - Button->SetForegroundColour( wxColour( 0, 100, 100 ) ); - winsize.x = MAX( winsize.x, Button->GetRect().GetRight() ); - - winsize.x += 10; winsize.y += 10; + winsize.y = MAX( winsize.y, Button->GetRect().GetBottom() ); + winsize.x += 10; + winsize.y += 10; SetClientSize( winsize ); } @@ -127,26 +122,49 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event ) switch( event.GetId() ) { case ID_SWAP_LAYER_DESELECT: - if( New_Layer[ii] != -1 ) + if( New_Layer[ii] != NB_LAYERS ) { - New_Layer[ii] = -1; - m_LayerList->SetString( ii, ReturnPcbLayerName( ii ) + + New_Layer[ii] = NB_LAYERS; + m_LayerList->SetString( ii, ReturnPcbLayerName( ii ) + wxT( " -> " ) + _( "No Change" ) ); } break; case ID_SWAP_LAYER_BUTTON_SELECT: case ID_SWAP_LAYER_SELECT: - jj = m_Parent->SelectLayer( ii, -1, -1 ); - if( (jj < 0) || (jj >= 29) ) + jj = New_Layer[ii]; + if( (jj < 0) || (jj > NB_LAYERS) ) + jj = NB_LAYERS; // (Defaults to "No Change".) + jj = m_Parent->SelectLayer( jj, -1, -1, true ); + + if( (jj < 0) || (jj > NB_LAYERS) ) return; - if( ii != jj ) + // No change if the selected layer matches the layer being edited. + // (Hence the only way to restore a layer to the "No Change" + // state is by specifically deselecting it; any attempt + // to select the same layer (instead) will be ignored.) + if( jj == ii ) + { + wxString msg; + msg = _( "Deselect this layer to restore its No Change state" ); + DisplayInfo( this, msg ); + return; + } + + if( jj != New_Layer[ii] ) { New_Layer[ii] = jj; - m_LayerList->SetString( ii, - ReturnPcbLayerName( ii ) + wxT( " -> " ) + - ReturnPcbLayerName( jj ) ); + if( jj == NB_LAYERS ) + m_LayerList->SetString( ii, + ReturnPcbLayerName( ii ) + + wxT( " -> " ) + + _( "No Change" ) ); + else + m_LayerList->SetString( ii, + ReturnPcbLayerName( ii ) + + wxT( " -> " ) + + ReturnPcbLayerName( jj ) ); } break; } @@ -154,7 +172,7 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event ) /*********************************************************/ -void WinEDA_SwapLayerFrame::Cancel( wxCommandEvent& event ) +void WinEDA_SwapLayerFrame::OnCancelClick( wxCommandEvent& event ) /*********************************************************/ { EndModal( -1 ); @@ -162,7 +180,7 @@ void WinEDA_SwapLayerFrame::Cancel( wxCommandEvent& event ) /*********************************************************/ -void WinEDA_SwapLayerFrame::Execute( wxCommandEvent& event ) +void WinEDA_SwapLayerFrame::OnOkClick( wxCommandEvent& event ) /*********************************************************/ { EndModal( 1 ); @@ -181,15 +199,16 @@ void WinEDA_PcbFrame::Swap_Layers( wxCommandEvent& event ) /* Init default values */ - for( ii = 0; ii < 32; ii++ ) - New_Layer[ii] = -1; + for( ii = 0; ii < NB_LAYERS; ii++ ) + New_Layer[ii] = NB_LAYERS; WinEDA_SwapLayerFrame* frame = new WinEDA_SwapLayerFrame( this ); - ii = frame->ShowModal(); frame->Destroy(); + ii = frame->ShowModal(); + frame->Destroy(); if( ii != 1 ) - return; + return; // (Cancelled dialog box returns -1 instead) /* Modifications des pistes */ pt_segm = (TRACK*) m_Pcb->m_Track; diff --git a/pcbnew/tool_modedit.cpp b/pcbnew/tool_modedit.cpp index ffc5893b16..e9a5aa6450 100644 --- a/pcbnew/tool_modedit.cpp +++ b/pcbnew/tool_modedit.cpp @@ -1,5 +1,5 @@ /*****************************************************************/ -/* too_modeit.cpp: construction du menu de l'editeur de modules */ +/* tool_modeit.cpp: construction du menu de l'editeur de modules */ /*****************************************************************/ #include "fctsys.h"