diff --git a/common/dialogs/dialog_display_info_HTML_base.cpp b/common/dialogs/dialog_display_info_HTML_base.cpp index 5fd3e29a71..5c8ca9a5a7 100644 --- a/common/dialogs/dialog_display_info_HTML_base.cpp +++ b/common/dialogs/dialog_display_info_HTML_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -35,13 +35,11 @@ DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, // Connect Events m_htmlWindow->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this ); - m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnOKButtonClick ), NULL, this ); } DIALOG_DISPLAY_HTML_TEXT_BASE::~DIALOG_DISPLAY_HTML_TEXT_BASE() { // Disconnect Events m_htmlWindow->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnHTMLLinkClicked ), NULL, this ); - m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DISPLAY_HTML_TEXT_BASE::OnOKButtonClick ), NULL, this ); } diff --git a/common/dialogs/dialog_display_info_HTML_base.fbp b/common/dialogs/dialog_display_info_HTML_base.fbp index 64fb523c39..9333e16b1d 100644 --- a/common/dialogs/dialog_display_info_HTML_base.fbp +++ b/common/dialogs/dialog_display_info_HTML_base.fbp @@ -14,6 +14,7 @@ dialog_display_info_HTML_base 1000 none + 1 dialog_display_info_HTML @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -133,7 +135,6 @@ m_sdbSizer1 protected - OnOKButtonClick diff --git a/common/dialogs/dialog_display_info_HTML_base.h b/common/dialogs/dialog_display_info_HTML_base.h index 134c5c7569..d6b3ddd2d4 100644 --- a/common/dialogs/dialog_display_info_HTML_base.h +++ b/common/dialogs/dialog_display_info_HTML_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -37,7 +37,6 @@ class DIALOG_DISPLAY_HTML_TEXT_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnHTMLLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); } - virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/common/dialogs/dialog_locked_items_query.cpp b/common/dialogs/dialog_locked_items_query.cpp index 9d5adf6a9f..8b0765b6c1 100644 --- a/common/dialogs/dialog_locked_items_query.cpp +++ b/common/dialogs/dialog_locked_items_query.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,6 +24,7 @@ #include #include + DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, int aLockedItemCount ) : DIALOG_LOCKED_ITEMS_QUERY_BASE( aParent ) { @@ -46,19 +47,8 @@ DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, int aLo void DIALOG_LOCKED_ITEMS_QUERY::onOverrideLocks( wxCommandEvent& event ) { - EndModal( wxID_APPLY ); -} - - -void DIALOG_LOCKED_ITEMS_QUERY::onOkClick( wxCommandEvent& event ) -{ - EndModal( wxID_OK ); -} - - -void DIALOG_LOCKED_ITEMS_QUERY::onCancelClick( wxCommandEvent& event ) -{ - EndModal( wxID_CANCEL ); + // This will choose the correct way to end the dialog no matter how is was shown. + EndDialog( wxID_APPLY ); } diff --git a/common/dialogs/dialog_locked_items_query_base.cpp b/common/dialogs/dialog_locked_items_query_base.cpp index 4c3c27643b..c1a93fe66b 100644 --- a/common/dialogs/dialog_locked_items_query_base.cpp +++ b/common/dialogs/dialog_locked_items_query_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -55,7 +55,7 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent m_overrideBtn = new wxButton( this, wxID_ANY, _("Override Locks"), wxDefaultPosition, wxDefaultSize, 0 ); m_overrideBtn->SetToolTip( _("Override locks and apply the operation on all the items selected.\nAny locked items will remain locked after the operation is complete.") ); - bButtonSizer->Add( m_overrideBtn, 0, wxALL, 10 ); + bButtonSizer->Add( m_overrideBtn, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 10 ); m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); @@ -64,10 +64,10 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - bButtonSizer->Add( m_sdbSizer, 1, wxALL, 5 ); + bButtonSizer->Add( m_sdbSizer, 1, wxBOTTOM|wxTOP, 5 ); - bSizerMain->Add( bButtonSizer, 0, wxEXPAND|wxALL, 5 ); + bSizerMain->Add( bButtonSizer, 0, wxEXPAND, 5 ); this->SetSizer( bSizerMain ); @@ -77,8 +77,6 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::DIALOG_LOCKED_ITEMS_QUERY_BASE( wxWindow* parent // Connect Events this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::OnInitDlg ) ); m_overrideBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOverrideLocks ), NULL, this ); - m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onCancelClick ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOkClick ), NULL, this ); } DIALOG_LOCKED_ITEMS_QUERY_BASE::~DIALOG_LOCKED_ITEMS_QUERY_BASE() @@ -86,7 +84,5 @@ DIALOG_LOCKED_ITEMS_QUERY_BASE::~DIALOG_LOCKED_ITEMS_QUERY_BASE() // Disconnect Events this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::OnInitDlg ) ); m_overrideBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOverrideLocks ), NULL, this ); - m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onCancelClick ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LOCKED_ITEMS_QUERY_BASE::onOkClick ), NULL, this ); } diff --git a/common/dialogs/dialog_locked_items_query_base.fbp b/common/dialogs/dialog_locked_items_query_base.fbp index 2c39eb38a5..a9e0c70c65 100644 --- a/common/dialogs/dialog_locked_items_query_base.fbp +++ b/common/dialogs/dialog_locked_items_query_base.fbp @@ -14,6 +14,7 @@ dialog_locked_items_query_base 1000 none + 1 dialog_locked_items_query @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -344,7 +346,7 @@ 5 - wxEXPAND|wxALL + wxEXPAND 0 @@ -353,7 +355,7 @@ none 10 - wxALL + wxALIGN_CENTER_VERTICAL|wxLEFT 0 1 @@ -364,6 +366,7 @@ + 0 @@ -426,7 +429,7 @@ 5 - wxALL + wxBOTTOM|wxTOP 1 0 @@ -440,8 +443,6 @@ m_sdbSizer protected - onCancelClick - onOkClick diff --git a/common/dialogs/dialog_locked_items_query_base.h b/common/dialogs/dialog_locked_items_query_base.h index 8efe844d39..8b8e5a3623 100644 --- a/common/dialogs/dialog_locked_items_query_base.h +++ b/common/dialogs/dialog_locked_items_query_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -49,8 +49,6 @@ class DIALOG_LOCKED_ITEMS_QUERY_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); } virtual void onOverrideLocks( wxCommandEvent& event ) { event.Skip(); } - virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/common/dialogs/dialog_print_generic.cpp b/common/dialogs/dialog_print_generic.cpp index 58b6719262..007714ebac 100644 --- a/common/dialogs/dialog_print_generic.cpp +++ b/common/dialogs/dialog_print_generic.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2018 CERN - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * Author: Maciej Suminski * * This program is free software: you can redistribute it and/or modify it @@ -127,6 +127,7 @@ double DIALOG_PRINT_GENERIC::getScaleValue() wxString::Format( _( "Warning: Scale option set to a very small value.\n" " Clamped to %f" ), scale ) ); } + return scale; } @@ -268,17 +269,11 @@ void DIALOG_PRINT_GENERIC::onPrintButtonClick( wxCommandEvent& event ) } -void DIALOG_PRINT_GENERIC::onCloseButton( wxCommandEvent& event ) +void DIALOG_PRINT_GENERIC::onCancelButtonClick( wxCommandEvent& event ) { saveSettings(); - if( IsQuasiModal() ) - EndQuasiModal( wxID_CANCEL ); - - if( IsModal() ) - EndModal( wxID_CANCEL ); - - Close(); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) ); } diff --git a/common/dialogs/dialog_print_generic_base.cpp b/common/dialogs/dialog_print_generic_base.cpp index f57fe06ff9..fb382c22dc 100644 --- a/common/dialogs/dialog_print_generic_base.cpp +++ b/common/dialogs/dialog_print_generic_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -118,6 +118,7 @@ DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindow this->SetSizer( bMainSizer ); this->Layout(); + bMainSizer->Fit( this ); this->Centre( wxBOTH ); @@ -126,7 +127,7 @@ DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindow m_scaleCustomText->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onSetCustomScale ), NULL, this ); m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPageSetup ), NULL, this ); m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintPreview ), NULL, this ); - m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCloseButton ), NULL, this ); + m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCancelButtonClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintButtonClick ), NULL, this ); } @@ -137,7 +138,7 @@ DIALOG_PRINT_GENERIC_BASE::~DIALOG_PRINT_GENERIC_BASE() m_scaleCustomText->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onSetCustomScale ), NULL, this ); m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPageSetup ), NULL, this ); m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintPreview ), NULL, this ); - m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCloseButton ), NULL, this ); + m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onCancelButtonClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_GENERIC_BASE::onPrintButtonClick ), NULL, this ); } diff --git a/common/dialogs/dialog_print_generic_base.fbp b/common/dialogs/dialog_print_generic_base.fbp index 28d0e906dd..6adf0f8b26 100644 --- a/common/dialogs/dialog_print_generic_base.fbp +++ b/common/dialogs/dialog_print_generic_base.fbp @@ -14,6 +14,7 @@ dialog_print_generic_base 1000 none + 1 DIALOG_PRINT_GENERIC @@ -25,6 +26,7 @@ 1 1 UI + 0 1 0 @@ -45,7 +47,7 @@ -1,-1 DIALOG_PRINT_GENERIC_BASE - 410,476 + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Print @@ -692,6 +694,7 @@ + 0 @@ -769,7 +772,7 @@ m_sdbSizer1 protected onPrintPreview - onCloseButton + onCancelButtonClick onPrintButtonClick diff --git a/common/dialogs/dialog_print_generic_base.h b/common/dialogs/dialog_print_generic_base.h index c2489339d8..36f96292a4 100644 --- a/common/dialogs/dialog_print_generic_base.h +++ b/common/dialogs/dialog_print_generic_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 3 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -25,10 +25,10 @@ #include #include #include +#include #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -69,13 +69,13 @@ class DIALOG_PRINT_GENERIC_BASE : public DIALOG_SHIM virtual void onSetCustomScale( wxCommandEvent& event ) { event.Skip(); } virtual void onPageSetup( wxCommandEvent& event ) { event.Skip(); } virtual void onPrintPreview( wxCommandEvent& event ) { event.Skip(); } - virtual void onCloseButton( wxCommandEvent& event ) { event.Skip(); } + virtual void onCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void onPrintButtonClick( wxCommandEvent& event ) { event.Skip(); } public: - DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 410,476 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PRINT_GENERIC_BASE(); }; diff --git a/common/dialogs/eda_list_dialog.cpp b/common/dialogs/eda_list_dialog.cpp index 391025f44a..2377f92f2d 100644 --- a/common/dialogs/eda_list_dialog.cpp +++ b/common/dialogs/eda_list_dialog.cpp @@ -29,7 +29,7 @@ #include -// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or +// wxWidgets spends *far* too long calculating column widths (most of it, believe it or // not, in repeatedly creating/destroying a wxDC to do the measurement in). // Use default column widths instead. static int DEFAULT_SINGLE_COL_WIDTH = 260; @@ -215,11 +215,12 @@ void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList, void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event ) { - EndModal( wxID_OK ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } -/* Sort alphabetically, case insensitive. +/* + * Sort alphabetically, case insensitive. */ static int wxCALLBACK myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2, wxIntPtr WXUNUSED( aSortData ) ) diff --git a/common/dialogs/eda_view_switcher.cpp b/common/dialogs/eda_view_switcher.cpp index dba274c22e..ba42d7fca3 100644 --- a/common/dialogs/eda_view_switcher.cpp +++ b/common/dialogs/eda_view_switcher.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -131,7 +131,7 @@ bool EDA_VIEW_SWITCHER::TryBefore( wxEvent& aEvent ) // Check for control key trailing edge if( !wxGetKeyState( WXK_RAW_CONTROL ) ) { - EndModal( wxID_OK ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } return DIALOG_SHIM::TryBefore( aEvent ); diff --git a/common/dialogs/html_messagebox.cpp b/common/dialogs/html_messagebox.cpp index 7a96d34620..0fa42247e6 100644 --- a/common/dialogs/html_messagebox.cpp +++ b/common/dialogs/html_messagebox.cpp @@ -53,19 +53,6 @@ HTML_MESSAGE_BOX::~HTML_MESSAGE_BOX() } -void HTML_MESSAGE_BOX::OnOKButtonClick( wxCommandEvent& event ) -{ - // the dialog can be shown quasi-model, modal, or not modeless. - // therefore, use the right way to close it. - if( IsQuasiModal() ) - EndQuasiModal( wxID_OK ); - else if( IsModal() ) - EndModal( wxID_OK ); - else - Destroy(); -} - - void HTML_MESSAGE_BOX::ListClear() { m_htmlWindow->SetPage( wxEmptyString ); diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 49cde260ba..ec024e47b3 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Chris Pavlina - * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -69,8 +69,6 @@ public: */ class HK_PROMPT_DIALOG : public DIALOG_SHIM { - wxKeyEvent m_event; - public: HK_PROMPT_DIALOG( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, const wxString& aName, const wxString& aCurrentKey ) : @@ -136,17 +134,6 @@ public: SetInitialFocus( panel ); } - /** - * End the dialog whether modal or quasimodal - */ - void EndFlexible( int aRtnCode ) - { - if( IsQuasiModal() ) - EndQuasiModal( aRtnCode ); - else - EndModal( aRtnCode ); - } - static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName, const wxString& aCurrentKey ) { @@ -203,13 +190,16 @@ protected: void OnChar( wxKeyEvent& aEvent ) { m_event = aEvent; - EndFlexible( wxID_OK ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } + +private: + wxKeyEvent m_event; }; /** - * Class to manage logic for filtering hotkeys based on user input + * Manage logic for filtering hotkeys based on user input. */ class HOTKEY_FILTER { diff --git a/demos/simulation/sallen_key/sallen_key.kicad_pro b/demos/simulation/sallen_key/sallen_key.kicad_pro index cdf16f378a..01ebfe7120 100644 --- a/demos/simulation/sallen_key/sallen_key.kicad_pro +++ b/demos/simulation/sallen_key/sallen_key.kicad_pro @@ -355,7 +355,7 @@ } ], "meta": { - "version": 0 + "version": 1 }, "net_colors": null }, diff --git a/eeschema/dialogs/dialog_bus_manager.cpp b/eeschema/dialogs/dialog_bus_manager.cpp index f08100fae5..4c035449ec 100644 --- a/eeschema/dialogs/dialog_bus_manager.cpp +++ b/eeschema/dialogs/dialog_bus_manager.cpp @@ -33,22 +33,17 @@ -BEGIN_EVENT_TABLE( DIALOG_BUS_MANAGER, DIALOG_SHIM ) - EVT_BUTTON( wxID_OK, DIALOG_BUS_MANAGER::OnOkClick ) - EVT_BUTTON( wxID_CANCEL, DIALOG_BUS_MANAGER::OnCancelClick ) -END_EVENT_TABLE() - - DIALOG_BUS_MANAGER::DIALOG_BUS_MANAGER( SCH_EDIT_FRAME* aParent ) : DIALOG_SHIM( aParent, wxID_ANY, _( "Bus Definitions" ), - wxDefaultPosition, wxSize( 640, 480 ), + wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ), m_parent( aParent ) { auto sizer = new wxBoxSizer( wxVERTICAL ); auto buttons = new wxStdDialogButtonSizer(); + wxButton* okButton = new wxButton( this, wxID_OK ); - buttons->AddButton( new wxButton( this, wxID_OK ) ); + buttons->AddButton( okButton ); buttons->AddButton( new wxButton( this, wxID_CANCEL ) ); buttons->Realize(); @@ -186,6 +181,7 @@ DIALOG_BUS_MANAGER::DIALOG_BUS_MANAGER( SCH_EDIT_FRAME* aParent ) m_signal_edit->SetHint( _( "Net or Bus Name" ) ); finishDialogSettings(); + okButton->SetDefault(); } @@ -235,22 +231,6 @@ bool DIALOG_BUS_MANAGER::TransferDataToWindow() } -void DIALOG_BUS_MANAGER::OnOkClick( wxCommandEvent& aEvent ) -{ - if( TransferDataFromWindow() ) - { - ( ( SCH_EDIT_FRAME* )GetParent() )->OnModify(); - EndModal( wxID_OK ); - } -} - - -void DIALOG_BUS_MANAGER::OnCancelClick( wxCommandEvent& aEvent ) -{ - EndModal( wxID_CANCEL ); -} - - bool DIALOG_BUS_MANAGER::TransferDataFromWindow() { for( SCH_SCREEN* screen : m_screens ) @@ -259,6 +239,7 @@ bool DIALOG_BUS_MANAGER::TransferDataFromWindow() for( const std::shared_ptr& alias : m_aliases ) alias->GetParent()->AddBusAlias( alias ); + ( ( SCH_EDIT_FRAME* )GetParent() )->OnModify(); return true; } diff --git a/eeschema/dialogs/dialog_bus_manager.h b/eeschema/dialogs/dialog_bus_manager.h index 9b4ad60f86..2cff60af76 100644 --- a/eeschema/dialogs/dialog_bus_manager.h +++ b/eeschema/dialogs/dialog_bus_manager.h @@ -54,8 +54,6 @@ protected: void OnSelectSignal( wxListEvent& event ); private: - virtual void OnOkClick( wxCommandEvent& aEvent ); - virtual void OnCancelClick( wxCommandEvent& aEvent ); wxString getAliasDisplayText( std::shared_ptr< BUS_ALIAS > aAlias ); protected: @@ -78,8 +76,6 @@ private: std::vector< std::shared_ptr< BUS_ALIAS > > m_aliases; std::unordered_set m_screens; std::shared_ptr< BUS_ALIAS > m_active_alias; - - DECLARE_EVENT_TABLE() }; diff --git a/eeschema/dialogs/dialog_choose_symbol.cpp b/eeschema/dialogs/dialog_choose_symbol.cpp index d961df5796..cf589f480f 100644 --- a/eeschema/dialogs/dialog_choose_symbol.cpp +++ b/eeschema/dialogs/dialog_choose_symbol.cpp @@ -357,12 +357,7 @@ void DIALOG_CHOOSE_SYMBOL::OnUseBrowser( wxCommandEvent& aEvent ) { m_external_browser_requested = true; - if( IsQuasiModal() ) - EndQuasiModal( wxID_OK ); - else if( IsModal() ) - EndModal( wxID_OK ); - else - wxFAIL_MSG( "Dialog called with neither Modal nor QuasiModal" ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } @@ -382,12 +377,7 @@ void DIALOG_CHOOSE_SYMBOL::OnCloseTimer( wxTimerEvent& aEvent ) } else { - if( IsQuasiModal() ) - EndQuasiModal( wxID_OK ); - else if( IsModal() ) - EndModal( wxID_OK ); - else - wxFAIL_MSG( "Dialog called with neither Modal nor QuasiModal" ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } } diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index f01eb17e6e..f091c2c498 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -766,7 +766,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event ) if( IsQuasiModal() ) EndQuasiModal( retval ); else - EndModal( retval ); + EndDialog( retval ); return; } @@ -781,7 +781,7 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnClose( wxCloseEvent& event ) if( IsQuasiModal() ) EndQuasiModal( retval ); else - EndModal( retval ); + EndDialog( retval ); return; } diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index 0e3ad8704b..2710832dbc 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -181,12 +181,9 @@ public: const wxString GetGeneratorTitle() { return m_textCtrlName->GetValue(); } const wxString GetGeneratorTCommandLine() { return m_textCtrlCommand->GetValue(); } -private: - /** - * Validate info relative to a new netlist plugin - */ - void OnOKClick( wxCommandEvent& event ) override; + bool TransferDataFromWindow() override; +private: /* * Browse plugin files, and set m_CommandStringCtrl field */ @@ -210,7 +207,6 @@ BEGIN_EVENT_TABLE( NETLIST_DIALOG, NETLIST_DIALOG_BASE ) END_EVENT_TABLE() - NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& title, NETLIST_TYPE_ID id_NetType ) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ) @@ -243,7 +239,6 @@ NETLIST_PAGE_DIALOG::NETLIST_PAGE_DIALOG( wxNotebook* parent, const wxString& ti } - NETLIST_DIALOG::NETLIST_DIALOG( SCH_EDIT_FRAME* parent ) : NETLIST_DIALOG_BASE( parent ) { @@ -483,9 +478,9 @@ bool NETLIST_DIALOG::TransferDataFromWindow() fileExt = extRE.GetMatch( command, 1 ); title.Printf( _( "%s Export" ), currPage->m_TitleStringCtrl->GetValue().GetData() ); - } break; } + } fn.SetExt( fileExt ); @@ -603,7 +598,11 @@ void NETLIST_DIALOG::OnDelGenerator( wxCommandEvent& event ) m_DefaultNetFmtName = m_PanelNetType[PANELPCBNEW]->GetPageNetFmtName(); WriteCurrentNetlistSetup(); - EndModal( NET_PLUGIN_CHANGE ); + + if( IsQuasiModal() ) + EndQuasiModal( NET_PLUGIN_CHANGE ); + else + EndDialog( NET_PLUGIN_CHANGE ); } @@ -641,8 +640,10 @@ void NETLIST_DIALOG::OnAddGenerator( wxCommandEvent& event ) m_PanelNetType[netTypeId] = currPage; WriteCurrentNetlistSetup(); - // Close and reopen dialog to rebuild the dialog after changes - EndModal( NET_PLUGIN_CHANGE ); + if( IsQuasiModal() ) + EndQuasiModal( NET_PLUGIN_CHANGE ); + else + EndDialog( NET_PLUGIN_CHANGE ); } @@ -655,21 +656,24 @@ NETLIST_DIALOG_ADD_GENERATOR::NETLIST_DIALOG_ADD_GENERATOR( NETLIST_DIALOG* pare } -void NETLIST_DIALOG_ADD_GENERATOR::OnOKClick( wxCommandEvent& event ) +bool NETLIST_DIALOG_ADD_GENERATOR::TransferDataFromWindow() { + if( !wxDialog::TransferDataFromWindow() ) + return false; + if( m_textCtrlCommand->GetValue() == wxEmptyString ) { - wxMessageBox( _( "Error. You must provide a command String" ) ); - return; + wxMessageBox( _( "You must provide a netlist generator command string" ) ); + return false; } if( m_textCtrlName->GetValue() == wxEmptyString ) { - wxMessageBox( _( "Error. You must provide a Title" ) ); - return; + wxMessageBox( _( "You must provide a netlist generator title" ) ); + return false; } - EndModal( wxID_OK ); + return true; } @@ -694,14 +698,14 @@ void NETLIST_DIALOG_ADD_GENERATOR::OnBrowseGenerators( wxCommandEvent& event ) wxFileName fn( FullFileName ); wxString ext = fn.GetExt(); - if( ext == wxT("xsl" ) ) - cmdLine.Printf(wxT("xsltproc -o \"%%O\" \"%s\" \"%%I\""), FullFileName ); - else if( ext == wxT("exe" ) || ext.IsEmpty() ) - cmdLine.Printf(wxT("\"%s\" > \"%%O\" < \"%%I\""), FullFileName ); - else if( ext == wxT("py" ) || ext.IsEmpty() ) - cmdLine.Printf(wxT("python \"%s\" \"%%I\" \"%%O\""), FullFileName ); + if( ext == wxT( "xsl" ) ) + cmdLine.Printf( wxT( "xsltproc -o \"%%O\" \"%s\" \"%%I\"" ), FullFileName ); + else if( ext == wxT( "exe" ) || ext.IsEmpty() ) + cmdLine.Printf( wxT( "\"%s\" > \"%%O\" < \"%%I\"" ), FullFileName ); + else if( ext == wxT( "py" ) || ext.IsEmpty() ) + cmdLine.Printf( wxT( "python \"%s\" \"%%I\" \"%%O\"" ), FullFileName ); else - cmdLine.Printf(wxT("\"%s\""), FullFileName ); + cmdLine.Printf( wxT( "\"%s\"" ), FullFileName ); m_textCtrlCommand->SetValue( cmdLine ); diff --git a/eeschema/dialogs/dialog_netlist_base.cpp b/eeschema/dialogs/dialog_netlist_base.cpp index 3494a373b1..b2397f9d9f 100644 --- a/eeschema/dialogs/dialog_netlist_base.cpp +++ b/eeschema/dialogs/dialog_netlist_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -18,47 +18,47 @@ END_EVENT_TABLE() NETLIST_DIALOG_BASE::NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - + wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bUpperSizer; bUpperSizer = new wxBoxSizer( wxVERTICAL ); - + m_NoteBook = new wxNotebook( this, ID_CHANGE_NOTEBOOK_PAGE, wxDefaultPosition, wxDefaultSize, 0 ); m_NoteBook->SetMinSize( wxSize( 540,-1 ) ); - - + + bUpperSizer->Add( m_NoteBook, 1, wxEXPAND | wxALL, 5 ); - - + + bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); - + m_buttonSizer = new wxBoxSizer( wxHORIZONTAL ); - + m_buttonAddGenerator = new wxButton( this, ID_ADD_PLUGIN, _("Add Generator..."), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonSizer->Add( m_buttonAddGenerator, 0, wxALL|wxEXPAND, 5 ); - + m_buttonDelGenerator = new wxButton( this, ID_DEL_PLUGIN, _("Remove Generator"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonSizer->Add( m_buttonDelGenerator, 0, wxALL|wxEXPAND, 5 ); - + m_sdbSizer2 = new wxStdDialogButtonSizer(); m_sdbSizer2OK = new wxButton( this, wxID_OK ); m_sdbSizer2->AddButton( m_sdbSizer2OK ); m_sdbSizer2Cancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer2->AddButton( m_sdbSizer2Cancel ); m_sdbSizer2->Realize(); - + m_buttonSizer->Add( m_sdbSizer2, 1, wxEXPAND, 5 ); - - + + bMainSizer->Add( m_buttonSizer, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); - - + + this->SetSizer( bMainSizer ); this->Layout(); bMainSizer->Fit( this ); - + this->Centre( wxBOTH ); } @@ -68,62 +68,60 @@ NETLIST_DIALOG_BASE::~NETLIST_DIALOG_BASE() BEGIN_EVENT_TABLE( NETLIST_DIALOG_ADD_GENERATOR_BASE, DIALOG_SHIM ) EVT_BUTTON( wxID_BROWSE_PLUGINS, NETLIST_DIALOG_ADD_GENERATOR_BASE::_wxFB_OnBrowseGenerators ) - EVT_BUTTON( wxID_CANCEL, NETLIST_DIALOG_ADD_GENERATOR_BASE::_wxFB_OnCancelClick ) - EVT_BUTTON( wxID_OK, NETLIST_DIALOG_ADD_GENERATOR_BASE::_wxFB_OnOKClick ) END_EVENT_TABLE() NETLIST_DIALOG_ADD_GENERATOR_BASE::NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - + wxBoxSizer* bSizerMain; bSizerMain = new wxBoxSizer( wxVERTICAL ); - + wxBoxSizer* bSizerTop; bSizerTop = new wxBoxSizer( wxVERTICAL ); - + m_staticTextName = new wxStaticText( this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextName->Wrap( -1 ); bSizerTop->Add( m_staticTextName, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - + m_textCtrlName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizerTop->Add( m_textCtrlName, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - + m_staticTextCmd = new wxStaticText( this, wxID_ANY, _("Command line to run the generator:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextCmd->Wrap( -1 ); bSizerTop->Add( m_staticTextCmd, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - + m_textCtrlCommand = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_textCtrlCommand->SetMinSize( wxSize( 500,-1 ) ); - + bSizerTop->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - + + bSizerMain->Add( bSizerTop, 1, wxEXPAND|wxALL, 5 ); - + wxBoxSizer* bSizerBottom; bSizerBottom = new wxBoxSizer( wxHORIZONTAL ); - + m_buttonGenerator = new wxButton( this, wxID_BROWSE_PLUGINS, _("Browse Generators..."), wxDefaultPosition, wxDefaultSize, 0 ); bSizerBottom->Add( m_buttonGenerator, 0, wxALL|wxEXPAND, 5 ); - + m_sdbSizer = new wxStdDialogButtonSizer(); m_sdbSizerOK = new wxButton( this, wxID_OK ); m_sdbSizer->AddButton( m_sdbSizerOK ); m_sdbSizerCancel = new wxButton( this, wxID_CANCEL ); m_sdbSizer->AddButton( m_sdbSizerCancel ); m_sdbSizer->Realize(); - + bSizerBottom->Add( m_sdbSizer, 1, wxEXPAND, 5 ); - - + + bSizerMain->Add( bSizerBottom, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); - - + + this->SetSizer( bSizerMain ); this->Layout(); bSizerMain->Fit( this ); - + this->Centre( wxBOTH ); } diff --git a/eeschema/dialogs/dialog_netlist_base.fbp b/eeschema/dialogs/dialog_netlist_base.fbp index d454adcf83..73901c9d52 100644 --- a/eeschema/dialogs/dialog_netlist_base.fbp +++ b/eeschema/dialogs/dialog_netlist_base.fbp @@ -2,7 +2,7 @@ - + C++ 0 source_name @@ -14,82 +14,49 @@ dialog_netlist_base 1000 none + + 1 dialog_netlist_base - + . - + 1 1 1 1 UI + 0 1 0 0 wxAUI_MGR_DEFAULT - + wxBOTH - + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + NETLIST_DIALOG_BASE - + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Export Netlist - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + bMainSizer wxVERTICAL none @@ -98,7 +65,7 @@ wxEXPAND 1 - + bUpperSizer wxVERTICAL none @@ -111,79 +78,55 @@ 1 1 1 - - - - - - - - + + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 ID_CHANGE_NOTEBOOK_PAGE - + 0 - - + + 0 540,-1 1 m_NoteBook 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - - - - - - - - - - - - - - - - - + + + + OnNetlistTypeSelection - - - - - - - - @@ -193,7 +136,7 @@ wxEXPAND|wxTOP|wxBOTTOM|wxLEFT 0 - + m_buttonSizer wxHORIZONTAL protected @@ -206,83 +149,69 @@ 1 1 1 - - - - - - - + + + + + 0 + + + + 1 0 1 - + 1 + 0 0 + Dock 0 Left 1 - + 1 - + + 0 0 ID_ADD_PLUGIN Add Generator... - + + 0 + 0 - - + + 0 - + 1 m_buttonAddGenerator 1 - - + + protected 1 - + + + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnAddGenerator - - - - - - - - - - - - - - - - - - - - - - - @@ -294,83 +223,69 @@ 1 1 1 - - - - - - - + + + + + 0 + + + + 1 0 1 - + 1 + 0 0 + Dock 0 Left 1 - + 1 - + + 0 0 ID_DEL_PLUGIN Remove Generator - + + 0 + 0 - - + + 0 - + 1 m_buttonDelGenerator 1 - - + + protected 1 - + + + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnDelGenerator - - - - - - - - - - - - - - - - - - - - - - - @@ -386,17 +301,9 @@ 1 0 0 - + m_sdbSizer2 protected - - - - - - - - @@ -406,67 +313,31 @@ 0 wxAUI_MGR_DEFAULT - + wxBOTH - + 1 1 impl_virtual - - - + + + 0 wxID_ANY - - + + NETLIST_DIALOG_ADD_GENERATOR_BASE - + -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Script Generator Properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + bSizerMain wxVERTICAL none @@ -475,7 +346,7 @@ wxEXPAND|wxALL 1 - + bSizerTop wxVERTICAL none @@ -488,78 +359,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Name: - + 0 + 0 - - + + 0 - + 1 m_staticTextName 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -571,86 +420,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 0 - + 1 m_textCtrlName 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -662,78 +484,56 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY Command line to run the generator: - + 0 + 0 - - + + 0 - + 1 m_staticTextCmd 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - - - + + + + -1 - - - - - - - - - - - - - - - - - - - - - - - @@ -745,86 +545,59 @@ 1 1 1 - - - - - - - + + + + + + + 1 0 1 - + 1 0 Dock 0 Left 1 - + 1 - + 0 0 wxID_ANY - + 0 - + 0 - + 0 500,-1 1 m_textCtrlCommand 1 - - + + protected 1 - + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -834,7 +607,7 @@ wxEXPAND|wxTOP|wxBOTTOM|wxLEFT 0 - + bSizerBottom wxHORIZONTAL none @@ -847,83 +620,69 @@ 1 1 1 - - - - - - - + + + + + 0 + + + + 1 0 1 - + 1 + 0 0 + Dock 0 Left 1 - + 1 - + + 0 0 wxID_BROWSE_PLUGINS Browse Generators... - + + 0 + 0 - - + + 0 - + 1 m_buttonGenerator 1 - - + + protected 1 - + + + Resizable 1 - - - + + + 0 - - + + wxFILTER_NONE wxDefaultValidator - - - - + + + + OnBrowseGenerators - - - - - - - - - - - - - - - - - - - - - - - @@ -939,17 +698,9 @@ 1 0 0 - + m_sdbSizer protected - - OnCancelClick - - - - OnOKClick - - diff --git a/eeschema/dialogs/dialog_netlist_base.h b/eeschema/dialogs/dialog_netlist_base.h index 8c3e51e2e4..e4063dc2e5 100644 --- a/eeschema/dialogs/dialog_netlist_base.h +++ b/eeschema/dialogs/dialog_netlist_base.h @@ -1,12 +1,11 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __DIALOG_NETLIST_BASE_H__ -#define __DIALOG_NETLIST_BASE_H__ +#pragma once #include #include @@ -20,6 +19,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -33,13 +35,13 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM { DECLARE_EVENT_TABLE() private: - + // Private event handlers void _wxFB_OnNetlistTypeSelection( wxNotebookEvent& event ){ OnNetlistTypeSelection( event ); } void _wxFB_OnAddGenerator( wxCommandEvent& event ){ OnAddGenerator( event ); } void _wxFB_OnDelGenerator( wxCommandEvent& event ){ OnDelGenerator( event ); } - - + + protected: enum { @@ -47,7 +49,7 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM ID_ADD_PLUGIN, ID_DEL_PLUGIN }; - + wxNotebook* m_NoteBook; wxBoxSizer* m_buttonSizer; wxButton* m_buttonAddGenerator; @@ -55,18 +57,18 @@ class NETLIST_DIALOG_BASE : public DIALOG_SHIM wxStdDialogButtonSizer* m_sdbSizer2; wxButton* m_sdbSizer2OK; wxButton* m_sdbSizer2Cancel; - + // Virtual event handlers, overide them in your derived class virtual void OnNetlistTypeSelection( wxNotebookEvent& event ) { event.Skip(); } virtual void OnAddGenerator( wxCommandEvent& event ) { event.Skip(); } virtual void OnDelGenerator( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export Netlist"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + NETLIST_DIALOG_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Export Netlist"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~NETLIST_DIALOG_BASE(); - + }; /////////////////////////////////////////////////////////////////////////////// @@ -76,19 +78,17 @@ class NETLIST_DIALOG_ADD_GENERATOR_BASE : public DIALOG_SHIM { DECLARE_EVENT_TABLE() private: - + // Private event handlers void _wxFB_OnBrowseGenerators( wxCommandEvent& event ){ OnBrowseGenerators( event ); } - void _wxFB_OnCancelClick( wxCommandEvent& event ){ OnCancelClick( event ); } - void _wxFB_OnOKClick( wxCommandEvent& event ){ OnOKClick( event ); } - - + + protected: enum { wxID_BROWSE_PLUGINS = 1000 }; - + wxStaticText* m_staticTextName; wxTextCtrl* m_textCtrlName; wxStaticText* m_staticTextCmd; @@ -97,18 +97,15 @@ class NETLIST_DIALOG_ADD_GENERATOR_BASE : public DIALOG_SHIM wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel; - + // Virtual event handlers, overide them in your derived class virtual void OnBrowseGenerators( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } - - + + public: - - NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Script Generator Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + + NETLIST_DIALOG_ADD_GENERATOR_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Script Generator Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~NETLIST_DIALOG_ADD_GENERATOR_BASE(); - + }; -#endif //__DIALOG_NETLIST_BASE_H__ diff --git a/eeschema/dialogs/dialog_update_symbol_fields.cpp b/eeschema/dialogs/dialog_update_symbol_fields.cpp index 93a62f04a1..6fc685ee32 100644 --- a/eeschema/dialogs/dialog_update_symbol_fields.cpp +++ b/eeschema/dialogs/dialog_update_symbol_fields.cpp @@ -217,7 +217,7 @@ void DIALOG_UPDATE_SYMBOL_FIELDS::onOkButtonClicked( wxCommandEvent& aEvent ) m_editFrame->RebuildView(); m_editFrame->OnModify(); - EndModal( wxID_OK ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index ba75a4fb1e..3ad15bec86 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -221,7 +221,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_toolBar->Realize(); #ifndef wxHAS_NATIVE_TABART - // Non-native default tab art has ulgy gradients we don't want + // Non-native default tab art has ugly gradients we don't want m_workbook->SetArtProvider( new wxAuiSimpleTabArt() ); #endif @@ -368,7 +368,7 @@ void SIM_PLOT_FRAME::updateTitle() } -// A small helper struct to handle bitmaps initialisation in menus +// A small helper struct to handle bitmaps initialization in menus struct BM_MENU_INIT_ITEM { int m_MenuId; @@ -895,7 +895,7 @@ void SIM_PLOT_FRAME::applyTuners() { for( auto& tuner : m_tuners ) { - /// @todo no ngspice hardcoding + /// @todo no ngspice hard coding std::string command( "alter @" + tuner->GetSpiceName() + "=" + tuner->GetValue().ToSpiceString() ); @@ -997,7 +997,7 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath ) file.Close(); - // Successfully loading a workbook does not count as modyfying it. + // Successfully loading a workbook does not count as modifying it. m_workbook->ClrModified(); return true; } @@ -1512,7 +1512,7 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event ) void onClose( wxCloseEvent& evt ) { - EndModal( GetReturnCode() ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) ); } NETLIST_VIEW_DIALOG( wxWindow* parent, wxString source) : diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb.cpp b/gerbview/dialogs/dialog_layers_select_to_pcb.cpp index 3b244d54fb..011242cba8 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb.cpp +++ b/gerbview/dialogs/dialog_layers_select_to_pcb.cpp @@ -209,7 +209,6 @@ void LAYERS_MAP_DIALOG::initDialog() if( config->m_GerberToPcbLayerMapping.size() == 0 ) m_buttonRetrieve->Enable( false ); - std::vector gerber2KicadMapping; // See how many of the loaded Gerbers can be mapped to KiCad layers automatically @@ -269,7 +268,7 @@ void LAYERS_MAP_DIALOG::normalizeBrdLayersCount() void LAYERS_MAP_DIALOG::OnBrdLayersCountSelection( wxCommandEvent& event ) { int id = event.GetSelection(); - m_exportBoardCopperLayersCount = (id+1) * 2; + m_exportBoardCopperLayersCount = ( id + 1 ) * 2; } @@ -278,6 +277,7 @@ void LAYERS_MAP_DIALOG::OnResetClick( wxCommandEvent& event ) wxString msg; int ii; LAYER_NUM layer; + for( ii = 0, layer = 0; ii < m_gerberActiveLayersCount; ii++, ++layer ) { m_layersLookUpTable[ii] = UNSELECTED_LAYER; @@ -347,6 +347,7 @@ void LAYERS_MAP_DIALOG::OnGetSetup( wxCommandEvent& event ) } } + void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event ) { int ii; @@ -408,35 +409,35 @@ void LAYERS_MAP_DIALOG::OnSelectLayer( wxCommandEvent& event ) } -void LAYERS_MAP_DIALOG::OnOkClick( wxCommandEvent& event ) +bool LAYERS_MAP_DIALOG::TransferDataFromWindow() { - /* Make some test about copper layers: - * Board must have enough copper layers to handle selected internal layers - */ + if( !wxDialog::TransferDataFromWindow() ) + return false; + + // Board must have enough copper layers to handle selected internal layers. normalizeBrdLayersCount(); int inner_layer_max = 0; for( int ii = 0; ii < GERBER_DRAWLAYERS_COUNT; ++ii ) { - if( m_layersLookUpTable[ii] < F_Cu ) - { - if( m_layersLookUpTable[ii ] > inner_layer_max ) - inner_layer_max = m_layersLookUpTable[ii]; - } + if( m_layersLookUpTable[ii] < F_Cu ) + { + if( m_layersLookUpTable[ii ] > inner_layer_max ) + inner_layer_max = m_layersLookUpTable[ii]; + } } - // inner_layer_max must be less than (or equal to) the number of - // internal copper layers + // inner_layer_max must be less than (or equal to the number of internal copper layers // internal copper layers = m_exportBoardCopperLayersCount-2 if( inner_layer_max > m_exportBoardCopperLayersCount-2 ) { wxMessageBox( _("Exported board does not have enough copper layers to handle selected " "inner layers") ); - return; + return false; } - EndModal( wxID_OK ); + return true; } @@ -568,6 +569,7 @@ int LAYERS_MAP_DIALOG::findNumAltiumGerbersLoaded( std::vector& aGerber2Kic return numAltiumMatches; } + int LAYERS_MAP_DIALOG::findNumKiCadGerbersLoaded( std::vector& aGerber2KicadMapping ) { // The next comment preserves initializer formatting below it @@ -689,6 +691,7 @@ int LAYERS_MAP_DIALOG::findNumKiCadGerbersLoaded( std::vector& aGerber2Kica return numKicadMatches; } + int LAYERS_MAP_DIALOG::findNumX2GerbersLoaded( std::vector& aGerber2KicadMapping ) { // The next comment preserves initializer formatting below it diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb.h b/gerbview/dialogs/dialog_layers_select_to_pcb.h index 250f863c9a..48312931e0 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb.h +++ b/gerbview/dialogs/dialog_layers_select_to_pcb.h @@ -33,9 +33,8 @@ class GERBVIEW_FRAME; -/* - * This dialog shows the gerber files loaded, and allows user to choose - * equivalence between gerber layers and pcb layers +/** + * Show the Gerber files loaded and allow the user to choose between Gerber layers and pcb layers. */ class LAYERS_MAP_DIALOG : public LAYERS_MAP_DIALOG_BASE { @@ -45,19 +44,21 @@ public: LAYERS_MAP_DIALOG( GERBVIEW_FRAME* parent ); LAYER_NUM * GetLayersLookUpTable() { return m_layersLookUpTable; } static int GetCopperLayersCount() { return m_exportBoardCopperLayersCount; } +protected: + bool TransferDataFromWindow() override; + private: void initDialog(); void normalizeBrdLayersCount(); void OnBrdLayersCountSelection( wxCommandEvent& event ) override; void OnSelectLayer( wxCommandEvent& event ); - void OnOkClick( wxCommandEvent& event ) override; void OnStoreSetup( wxCommandEvent& event ) override; void OnGetSetup( wxCommandEvent& event ) override; void OnResetClick( wxCommandEvent& event ) override; /** - * Finds number of loaded Gerbers where the matching KiCad layer can be identified + * Find number of loaded Gerbers where the matching KiCad layer can be identified. * * The passed vector will be returned with the same number of elements * as there are Gerber files. The indices into it are 1:1 with the loaded Gerber @@ -72,7 +73,7 @@ private: int findKnownGerbersLoaded( std::vector& aGerber2KicadMapping ); /** - * Finds number of loaded Gerbers using Altium file extensions + * Find number of loaded Gerbers using Altium file extensions. * * The passed vector will be returned with the same number of elements * as there are Gerber files. The indices into it are 1:1 with the loaded Gerber @@ -87,7 +88,7 @@ private: int findNumAltiumGerbersLoaded( std::vector& aGerber2KicadMapping ); /** - * Finds number of loaded Gerbers using KiCad naming convention + * Find number of loaded Gerbers using KiCad naming convention. * * The passed vector will be returned with the same number of elements * as there are Gerber files. The indices into it are 1:1 with the loaded Gerber @@ -102,7 +103,7 @@ private: int findNumKiCadGerbersLoaded( std::vector& aGerber2KicadMapping ); /** - * Finds number of loaded Gerbers using X2 File Functions to define layers + * Find number of loaded Gerbers using X2 File Functions to define layers. * * The passed vector will be returned with the same number of elements * as there are Gerber files. The indices into it are 1:1 with the loaded Gerber @@ -120,7 +121,7 @@ private: private: GERBVIEW_FRAME* m_Parent; - int m_gerberActiveLayersCount; // Number of initialized gerber layers + int m_gerberActiveLayersCount; // Number of initialized Gerber layers static int m_exportBoardCopperLayersCount; // Indexes Gerber layers to PCB file layers the last value in table is the number of diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp b/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp index 777f6a0113..6391dc1561 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -14,7 +14,6 @@ BEGIN_EVENT_TABLE( LAYERS_MAP_DIALOG_BASE, DIALOG_SHIM ) EVT_BUTTON( ID_STORE_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnStoreSetup ) EVT_BUTTON( ID_GET_PREVIOUS_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnGetSetup ) EVT_BUTTON( ID_RESET_CHOICE, LAYERS_MAP_DIALOG_BASE::_wxFB_OnResetClick ) - EVT_BUTTON( wxID_OK, LAYERS_MAP_DIALOG_BASE::_wxFB_OnOkClick ) END_EVENT_TABLE() LAYERS_MAP_DIALOG_BASE::LAYERS_MAP_DIALOG_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp index 0427d05a47..0a1071153a 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.fbp @@ -14,6 +14,7 @@ dialog_layers_select_to_pcb_base 1000 none + 1 dialog_layers_select_to_pcb_base @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -433,6 +435,7 @@ + 0 @@ -506,6 +509,7 @@ + 0 @@ -579,6 +583,7 @@ + 0 @@ -719,7 +724,6 @@ m_sdbSizerButtons protected - OnOkClick diff --git a/gerbview/dialogs/dialog_layers_select_to_pcb_base.h b/gerbview/dialogs/dialog_layers_select_to_pcb_base.h index 07d72d9dd8..3c2eb53adb 100644 --- a/gerbview/dialogs/dialog_layers_select_to_pcb_base.h +++ b/gerbview/dialogs/dialog_layers_select_to_pcb_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,10 +20,10 @@ #include #include #include +#include #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -49,7 +49,6 @@ class LAYERS_MAP_DIALOG_BASE : public DIALOG_SHIM void _wxFB_OnStoreSetup( wxCommandEvent& event ){ OnStoreSetup( event ); } void _wxFB_OnGetSetup( wxCommandEvent& event ){ OnGetSetup( event ); } void _wxFB_OnResetClick( wxCommandEvent& event ){ OnResetClick( event ); } - void _wxFB_OnOkClick( wxCommandEvent& event ){ OnOkClick( event ); } protected: @@ -73,7 +72,6 @@ class LAYERS_MAP_DIALOG_BASE : public DIALOG_SHIM virtual void OnStoreSetup( wxCommandEvent& event ) { event.Skip(); } virtual void OnGetSetup( wxCommandEvent& event ) { event.Skip(); } virtual void OnResetClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp index f37b5c2875..b18a44a54a 100644 --- a/gerbview/dialogs/dialog_select_one_pcb_layer.cpp +++ b/gerbview/dialogs/dialog_select_one_pcb_layer.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -49,68 +49,47 @@ enum layer_sel_id { class SELECT_LAYER_DIALOG : public DIALOG_SHIM { -private: - int m_PassedDefaultLayer; // Remember this in case user hits Cancel - wxRadioBox* m_layerRadioBox; - std::vector m_layerId; - public: - // Constructor and destructor SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount, - wxString aGerberName ); + wxString aGerberName ); ~SELECT_LAYER_DIALOG() { }; + int GetSelectedLayer() { return m_selectedLayer; } + +protected: + bool TransferDataFromWindow() override; + private: void OnLayerSelected( wxCommandEvent& event ); - void OnCancelClick( wxCommandEvent& event ); DECLARE_EVENT_TABLE() + + int m_selectedLayer; + wxRadioBox* m_layerRadioBox; + std::vector m_layerId; }; BEGIN_EVENT_TABLE( SELECT_LAYER_DIALOG, wxDialog ) - EVT_BUTTON( wxID_OK, SELECT_LAYER_DIALOG::OnLayerSelected ) - EVT_BUTTON( wxID_CANCEL, SELECT_LAYER_DIALOG::OnCancelClick ) EVT_RADIOBOX( ID_LAYER_SELECT, SELECT_LAYER_DIALOG::OnLayerSelected ) END_EVENT_TABLE() -/** Install the dialog box for layer selection - * @param aDefaultLayer = Preselection (GERBER_DRAWLAYERS_COUNT for "(Deselect)" layer) - * @param aCopperLayerCount = number of copper layers - * @param aShowDeselectOption = display a "(Deselect)" radiobutton (when set to true) - * @return new layer value (GERBER_DRAWLAYERS_COUNT when "(Deselect)" radiobutton selected), - * or -1 if canceled - * - * Providing the option to also display a "(Deselect)" radiobutton makes the - * 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 "Layer selection:" dialog box). - */ int GERBVIEW_FRAME::SelectPCBLayer( int aDefaultLayer, int aCopperLayerCount, wxString aGerberName ) { SELECT_LAYER_DIALOG* frame = new SELECT_LAYER_DIALOG( this, aDefaultLayer, aCopperLayerCount, aGerberName ); - int layer = frame->ShowModal(); + frame->ShowModal(); frame->Destroy(); - return layer; + return frame->GetSelectedLayer(); } -/* - * 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. - */ -SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( - GERBVIEW_FRAME* parent, int aDefaultLayer, int aCopperLayerCount, wxString aGerberName ) - : DIALOG_SHIM( parent, -1, wxString::Format( _( "Select Layer: %s" ), aGerberName ), - wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) +SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( GERBVIEW_FRAME* parent, int aDefaultLayer, + int aCopperLayerCount, wxString aGerberName ) + : DIALOG_SHIM( parent, -1, wxString::Format( _( "Select Layer: %s" ), aGerberName ), + wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { wxButton* button; int ii; @@ -118,7 +97,7 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( int selected = -1; // Store the passed default layer in case the user hits Cancel - m_PassedDefaultLayer = aDefaultLayer; + m_selectedLayer = aDefaultLayer; // Build the layer list; first build copper layers list int layerCount = 0; @@ -202,17 +181,20 @@ SELECT_LAYER_DIALOG::SELECT_LAYER_DIALOG( void SELECT_LAYER_DIALOG::OnLayerSelected( wxCommandEvent& event ) { - int ii = m_layerId[m_layerRadioBox->GetSelection()]; - - EndModal( ii ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } -void SELECT_LAYER_DIALOG::OnCancelClick( wxCommandEvent& event ) +bool SELECT_LAYER_DIALOG::TransferDataFromWindow() { - EndModal( m_PassedDefaultLayer ); + if( !wxDialog::TransferDataFromWindow() ) + return false; + + m_selectedLayer = m_layerId[m_layerRadioBox->GetSelection()]; + return true; } + // This function is a duplicate of // const wxChar* LSET::Name( PCB_LAYER_ID aLayerId ) // However it avoids a dependency to Pcbnew code. diff --git a/include/dialogs/dialog_locked_items_query.h b/include/dialogs/dialog_locked_items_query.h index a8c895e323..7fe727a214 100644 --- a/include/dialogs/dialog_locked_items_query.h +++ b/include/dialogs/dialog_locked_items_query.h @@ -37,8 +37,6 @@ public: private: void onOverrideLocks( wxCommandEvent& event ) override; - void onCancelClick( wxCommandEvent& event ) override; - void onOkClick( wxCommandEvent& event ) override; }; -#endif // DIALOG_LOCKED_ITEMS_QUERY_H \ No newline at end of file +#endif // DIALOG_LOCKED_ITEMS_QUERY_H diff --git a/include/dialogs/dialog_print_generic.h b/include/dialogs/dialog_print_generic.h index a31f4e100b..dbc816c45f 100644 --- a/include/dialogs/dialog_print_generic.h +++ b/include/dialogs/dialog_print_generic.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2018 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * Author: Maciej Suminski * * This program is free software: you can redistribute it and/or modify it @@ -66,12 +67,14 @@ protected: /** * Return scale value selected in the dialog. - * if this value is outside limits, it will be clamped + * + * If this value is outside limits, it will be clamped. */ double getScaleValue(); /** * Select a corresponding scale radio button and update custom scale value if needed. + * * @param aValue is the scale value to be selected (0 stands for fit-to-page). */ void setScaleValue( double aValue ); @@ -80,24 +83,26 @@ protected: // even if the dialog is closed without printing bool TransferDataToWindow() override; - APP_SETTINGS_BASE* m_config; - - PRINTOUT_SETTINGS* m_settings; - private: void onPageSetup( wxCommandEvent& event ) override; void onPrintPreview( wxCommandEvent& event ) override; void onPrintButtonClick( wxCommandEvent& event ) override; + void onCancelButtonClick( wxCommandEvent& aEvent ) override; - // onClose* handlers are needed to save the dialogs settings as TransferDataFromWindow() - // is not called for 'Cancel' button that closes the window - void onCloseButton( wxCommandEvent& event ) override; + // Needed to save the dialogs settings as TransferDataFromWindow() + // is not called for 'Cancel' button that closes the window. void onClose( wxCloseEvent& event ) override; void onSetCustomScale( wxCommandEvent& event ) override; void initPrintData(); +protected: + APP_SETTINGS_BASE* m_config; + + PRINTOUT_SETTINGS* m_settings; + +private: wxFloatingPointValidator m_scaleValidator; static wxPrintData* s_PrintData; diff --git a/include/dialogs/html_messagebox.h b/include/dialogs/html_messagebox.h index 40f0e5ca41..1a50914a71 100644 --- a/include/dialogs/html_messagebox.h +++ b/include/dialogs/html_messagebox.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2020 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see CHANGELOG.TXT for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,17 +29,8 @@ #include <../common/dialogs/dialog_display_info_HTML_base.h> -/** - * HTML_MESSAGE_BOX - */ class HTML_MESSAGE_BOX : public DIALOG_DISPLAY_HTML_TEXT_BASE { -protected: - // Handlers for HTML_MESSAGE_BOX_BASE events. - void OnOKButtonClick( wxCommandEvent& event ) override; - - virtual void OnCharHook( wxKeyEvent& aEvt ) override; - public: HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle = wxEmptyString, const wxPoint& aPosition = wxDefaultPosition, @@ -47,9 +38,11 @@ public: ~HTML_MESSAGE_BOX() override; /** - * set the dialog size, using a "logical" value. - * the physical size in pixel will depend on the display definition - * so a value used here shoul be OK with any display (HDPI for instance) + * Set the dialog size, using a "logical" value. + * + * The physical size in pixel will depend on the display definition so a value used here + * should be OK with any display (HDPI for instance). + * * @param aWidth is a "logical" value of the dialog width. * @param aHeight is a "logical" value of the dialog height. */ @@ -62,14 +55,14 @@ public: /** * Add a list of items. * - * @param aList = a string containing items. Items are separated by '\n' + * @param aList is a string containing HTML items. Items are separated by '\n' */ void ListSet( const wxString& aList ); /** * Add a list of items. * - * @param aList = a wxArrayString containing items. + * @param aList is the list of HTML strings to display. */ void ListSet( const wxArrayString& aList ); @@ -90,6 +83,8 @@ public: */ void ShowModeless(); +protected: + virtual void OnCharHook( wxKeyEvent& aEvt ) override; }; #endif // _html_messagebox_ diff --git a/pcb_calculator/dialogs/dialog_regulator_form.cpp b/pcb_calculator/dialogs/dialog_regulator_form.cpp index 0f0bb98377..04302fec2d 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form.cpp +++ b/pcb_calculator/dialogs/dialog_regulator_form.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre.charras - * Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,32 +28,30 @@ extern double DoubleFromString( const wxString& TextValue ); -void DIALOG_REGULATOR_FORM::OnOKClick( wxCommandEvent& event ) +bool DIALOG_REGULATOR_FORM::TransferDataFromWindow() { - if( !IsOK() ) - { - wxMessageBox( _( "Bad or missing parameters!" ) ); - return; - } + if( !wxDialog::TransferDataFromWindow() ) + return false; - EndModal( wxID_OK ); -} - - -bool DIALOG_REGULATOR_FORM::IsOK() -{ bool success = true; if( m_textCtrlName->GetValue().IsEmpty() ) + { success = false; + } + if( m_textCtrlVref->GetValue().IsEmpty() ) + { success = false; + } else { double vref = DoubleFromString( m_textCtrlVref->GetValue() ); + if( fabs( vref ) < 0.01 ) success = false; } + if( m_choiceRegType->GetSelection() == 1 ) { if( m_RegulIadjValue->GetValue().IsEmpty() ) diff --git a/pcb_calculator/dialogs/dialog_regulator_form.h b/pcb_calculator/dialogs/dialog_regulator_form.h index acb31f6335..3b1516b795 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form.h +++ b/pcb_calculator/dialogs/dialog_regulator_form.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 1992-2011 jean-pierre.charras - * Copyright (C) 1992-2020 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,10 +20,6 @@ /** * @file dialog_regulator_form.h - * Subclass of DIALOG_REGULATOR_FORM_BASE, which is generated by wxFormBuilder. - * - * This dialog is used to add / edit regulators to the list on the - * regulator tab of the pcb calculator */ #ifndef DIALOG_REGULATOR_FORM_H @@ -34,6 +30,12 @@ class PCB_CALCULATOR_FRAME; class REGULATOR_DATA; + +/** + * Subclass of DIALOG_REGULATOR_FORM_BASE, which is generated by wxFormBuilder. + * + * Dialog used to add / edit regulators to the list on the regulator tab of the pcb calculator. + */ class DIALOG_REGULATOR_FORM : public DIALOG_REGULATOR_FORM_BASE { public: @@ -52,37 +54,32 @@ public: ~DIALOG_REGULATOR_FORM(){}; - // Event called functions: - void OnOKClick( wxCommandEvent& event ) override; - /** - * Function IsOK() - * @return true if regulator parameters are acceptable + * @return true if regulator parameters are acceptable. */ - bool IsOK(); + bool TransferDataFromWindow(); /** - * Function CopyRegulatorDataToDialog - * Transfer data from dialog to aItem - * @param aItem = a pointer to the REGULATOR_DATA + * Transfer data from dialog to aItem. + * + * @param aItem is the #REGULATOR_DATA to copy to dialog. */ void CopyRegulatorDataToDialog( REGULATOR_DATA* aItem ); /** - * Function BuildRegulatorFromData - * Creates a new REGULATOR_DATA from dialog - * @return a pointer to the new REGULATOR_DATA + * Create a new #REGULATOR_DATA from dialog data. + * + * @return a the new #REGULATOR_DATA. */ REGULATOR_DATA* BuildRegulatorFromData(); /** - * Enable/disable Iadj related widgets, according to - * the regulator type + * Enable/disable Iadj related widgets, according to the regulator type. */ void UpdateDialog(); /** - * called when the current regulator type is changed + * Called when the current regulator type is changed. */ void OnRegTypeSelection( wxCommandEvent& event ) override { @@ -90,4 +87,4 @@ public: } }; -#endif // DIALOG_REGULATOR_FORM_H \ No newline at end of file +#endif // DIALOG_REGULATOR_FORM_H diff --git a/pcb_calculator/dialogs/dialog_regulator_form_base.cpp b/pcb_calculator/dialogs/dialog_regulator_form_base.cpp index bcbfe1ee2e..f43dcf2d9b 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form_base.cpp +++ b/pcb_calculator/dialogs/dialog_regulator_form_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -96,13 +96,11 @@ DIALOG_REGULATOR_FORM_BASE::DIALOG_REGULATOR_FORM_BASE( wxWindow* parent, wxWind // Connect Events m_choiceRegType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnRegTypeSelection ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnOKClick ), NULL, this ); } DIALOG_REGULATOR_FORM_BASE::~DIALOG_REGULATOR_FORM_BASE() { // Disconnect Events m_choiceRegType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnRegTypeSelection ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnOKClick ), NULL, this ); } diff --git a/pcb_calculator/dialogs/dialog_regulator_form_base.fbp b/pcb_calculator/dialogs/dialog_regulator_form_base.fbp index 8c8aeca576..ec22eb72ee 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form_base.fbp +++ b/pcb_calculator/dialogs/dialog_regulator_form_base.fbp @@ -14,6 +14,7 @@ dialog_regulator_form_base 1000 none + 1 dialog_regulator_form_base @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -53,7 +55,7 @@ - + 300,-1 bSizerMain wxVERTICAL @@ -803,7 +805,6 @@ m_sdbSizer protected - OnOKClick diff --git a/pcb_calculator/dialogs/dialog_regulator_form_base.h b/pcb_calculator/dialogs/dialog_regulator_form_base.h index f4ad624639..0ae0afc0b7 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form_base.h +++ b/pcb_calculator/dialogs/dialog_regulator_form_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -52,7 +52,6 @@ class DIALOG_REGULATOR_FORM_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnRegTypeSelection( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcb_calculator/regulators_funct.cpp b/pcb_calculator/regulators_funct.cpp index b4fc154e53..9004370451 100644 --- a/pcb_calculator/regulators_funct.cpp +++ b/pcb_calculator/regulators_funct.cpp @@ -52,9 +52,9 @@ void PCB_CALCULATOR_FRAME::OnRegulatorResetButtonClick( wxCommandEvent& event ) m_RegulVrefValue->SetValue( wxT( "3" ) ); m_RegulVoutValue->SetValue( wxT( "12" ) ); m_choiceRegType->SetSelection( 0 ); - m_rbRegulR1->SetValue(1); - m_rbRegulR2->SetValue(0); - m_rbRegulVout->SetValue(0); + m_rbRegulR1->SetValue( 1 ); + m_rbRegulR2->SetValue( 0 ); + m_rbRegulVout->SetValue( 0 ); RegulatorPageUpdate(); } @@ -107,9 +107,9 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event ) m_lastSelectedRegulatorName = item->m_Name; m_choiceRegType->SetSelection( item->m_Type ); wxString value; - value.Printf( wxT("%g"), item->m_Vref ); + value.Printf( wxT( "%g" ), item->m_Vref ); m_RegulVrefValue->SetValue( value ); - value.Printf( wxT("%g"), item->m_Iadj ); + value.Printf( wxT( "%g" ), item->m_Iadj ); m_RegulIadjValue->SetValue( value ); } @@ -127,10 +127,8 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) wildcard.Printf( _("PCB Calculator data file (*.%s)|*.%s"), DataFileNameExt, DataFileNameExt ); - wxFileDialog dlg( m_panelRegulators, - _("Select PCB Calculator Data File"), - wxEmptyString, fullfilename, - wildcard, wxFD_OPEN ); + wxFileDialog dlg( m_panelRegulators, _("Select PCB Calculator Data File"), + wxEmptyString, fullfilename, wildcard, wxFD_OPEN ); if (dlg.ShowModal() == wxID_CANCEL) return; @@ -144,8 +142,8 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) if( wxFileExists( fullfilename ) && m_RegulatorList.GetCount() > 0 ) // Read file { - if( wxMessageBox( _("Do you want to load this file and replace current regulator list?" ) ) - != wxID_OK ) + if( wxMessageBox( _( "Do you want to load this file and replace current regulator list?" ) ) + != wxID_OK ) return; } @@ -168,16 +166,11 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) { DIALOG_REGULATOR_FORM dlg( this, wxEmptyString ); + if( dlg.ShowModal() != wxID_OK ) return; - if( !dlg.IsOK() ) - { - wxMessageBox( _("Bad or missing parameters!") ); - return; - } - - REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData(); + REGULATOR_DATA* new_item = dlg.BuildRegulatorFromData(); // Add new item, if not existing if( m_RegulatorList.GetReg( new_item->m_Name ) == nullptr ) @@ -398,5 +391,4 @@ void PCB_CALCULATOR_FRAME::Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg break; } } - } diff --git a/pcbnew/dialogs/dialog_filter_selection.cpp b/pcbnew/dialogs/dialog_filter_selection.cpp index 001e96dbdb..3678a28245 100644 --- a/pcbnew/dialogs/dialog_filter_selection.cpp +++ b/pcbnew/dialogs/dialog_filter_selection.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -60,8 +60,11 @@ void DIALOG_FILTER_SELECTION::checkBoxClicked( wxCommandEvent& aEvent ) } -void DIALOG_FILTER_SELECTION::ExecuteCommand( wxCommandEvent& event ) +bool DIALOG_FILTER_SELECTION::TransferDataFromWindow() { + if( !wxDialog::TransferDataFromWindow() ) + return false; + m_options.includeModules = m_Include_Modules->GetValue(); m_options.includeLockedModules = m_IncludeLockedModules->GetValue(); m_options.includeTracks = m_Include_Tracks->GetValue(); @@ -71,5 +74,5 @@ void DIALOG_FILTER_SELECTION::ExecuteCommand( wxCommandEvent& event ) m_options.includeBoardOutlineLayer = m_Include_Edges_Items->GetValue(); m_options.includePcbTexts = m_Include_PcbTextes->GetValue(); - EndModal( wxID_OK ); + return true; } diff --git a/pcbnew/dialogs/dialog_filter_selection.h b/pcbnew/dialogs/dialog_filter_selection.h index 2cf00bcc82..0d1f7a1ac1 100644 --- a/pcbnew/dialogs/dialog_filter_selection.h +++ b/pcbnew/dialogs/dialog_filter_selection.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -47,23 +47,26 @@ public: bool includePcbTexts = true; }; + /** + * Create the filter selection dialog. + * + * @param[in] aParent is the parent window that called the dialog. + * @param[in,out] aOptions is the options to populate the dialog with and contains the + * changes made by the dialog on exit. + */ DIALOG_FILTER_SELECTION( PCB_BASE_FRAME* aParent, OPTIONS& aOptions ); ~DIALOG_FILTER_SELECTION() { } +protected: + bool TransferDataFromWindow() override; + private: - void ExecuteCommand( wxCommandEvent& event ) override; - - void OnCancel( wxCommandEvent& event ) override - { - EndModal( wxID_CANCEL ); - } - void checkBoxClicked( wxCommandEvent& aEvent ) override; - ///< Reference to the options struct to fill + ///< Reference to the options struct to fill. OPTIONS& m_options; }; diff --git a/pcbnew/dialogs/dialog_filter_selection_base.cpp b/pcbnew/dialogs/dialog_filter_selection_base.cpp index 08d6edfc09..c6f9ea0d8e 100644 --- a/pcbnew/dialogs/dialog_filter_selection_base.cpp +++ b/pcbnew/dialogs/dialog_filter_selection_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -74,7 +74,6 @@ DIALOG_FILTER_SELECTION_BASE::DIALOG_FILTER_SELECTION_BASE( wxWindow* parent, wx m_Include_Edges_Items->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this ); m_Include_Vias->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this ); m_Include_Zones->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this ); - m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::OnCancel ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::ExecuteCommand ), NULL, this ); } @@ -89,7 +88,6 @@ DIALOG_FILTER_SELECTION_BASE::~DIALOG_FILTER_SELECTION_BASE() m_Include_Edges_Items->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this ); m_Include_Vias->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this ); m_Include_Zones->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::checkBoxClicked ), NULL, this ); - m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::OnCancel ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FILTER_SELECTION_BASE::ExecuteCommand ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_filter_selection_base.fbp b/pcbnew/dialogs/dialog_filter_selection_base.fbp index 40e47f0d17..61f343b355 100644 --- a/pcbnew/dialogs/dialog_filter_selection_base.fbp +++ b/pcbnew/dialogs/dialog_filter_selection_base.fbp @@ -14,6 +14,7 @@ dialog_filter_selection_base 1000 none + 1 dialog_filter_selection_base @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -666,7 +668,6 @@ m_sdbSizer1 protected - OnCancel ExecuteCommand diff --git a/pcbnew/dialogs/dialog_filter_selection_base.h b/pcbnew/dialogs/dialog_filter_selection_base.h index ea87f30de9..e43f829383 100644 --- a/pcbnew/dialogs/dialog_filter_selection_base.h +++ b/pcbnew/dialogs/dialog_filter_selection_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -48,7 +48,6 @@ class DIALOG_FILTER_SELECTION_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void checkBoxClicked( wxCommandEvent& event ) { event.Skip(); } - virtual void OnCancel( wxCommandEvent& event ) { event.Skip(); } virtual void ExecuteCommand( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcbnew/dialogs/dialog_find.cpp b/pcbnew/dialogs/dialog_find.cpp index 55c3895337..0e984ecf6f 100644 --- a/pcbnew/dialogs/dialog_find.cpp +++ b/pcbnew/dialogs/dialog_find.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2012 Marco Mattila * Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -37,6 +37,7 @@ #include #include + //Defined as global because these values have to survive the destructor bool FindOptionCase = false; @@ -91,27 +92,32 @@ DIALOG_FIND::DIALOG_FIND( PCB_BASE_FRAME* aFrame ) : DIALOG_FIND_BASE( aFrame ) Center(); } + void DIALOG_FIND::onTextEnter( wxCommandEvent& aEvent ) { search( true ); } + void DIALOG_FIND::onFindNextClick( wxCommandEvent& aEvent ) { search( true ); } + void DIALOG_FIND::onFindPreviousClick( wxCommandEvent& aEvent ) { search( false ); } + void DIALOG_FIND::onSearchAgainClick( wxCommandEvent& aEvent ) { m_upToDate = false; search( true ); } + void DIALOG_FIND::search( bool aDirection ) { PCB_SCREEN* screen = m_frame->GetScreen(); @@ -239,7 +245,8 @@ void DIALOG_FIND::search( bool aDirection ) { FP_TEXT* textItem = dynamic_cast( item ); - if( textItem && textItem->Matches( m_frame->GetFindReplaceData(), nullptr ) ) + if( textItem && textItem->Matches( m_frame->GetFindReplaceData(), + nullptr ) ) { m_hitList.push_back( fp ); } @@ -262,6 +269,7 @@ void DIALOG_FIND::search( bool aDirection ) for( BOARD_ITEM* item : m_frame->GetBoard()->Zones() ) { ZONE* zoneItem = dynamic_cast( item ); + if( zoneItem && zoneItem->Matches( m_frame->GetFindReplaceData(), nullptr ) ) { m_hitList.push_back( zoneItem ); @@ -364,7 +372,18 @@ void DIALOG_FIND::search( bool aDirection ) m_highlightCallback( GetItem() ); } -void DIALOG_FIND::onClose( wxCommandEvent& aEvent ) + +void DIALOG_FIND::OnCloseButtonClick( wxCommandEvent& aEvent ) +{ + wxCloseEvent tmp; + + OnClose( tmp ); + + aEvent.Skip(); +} + + +void DIALOG_FIND::OnClose( wxCloseEvent& aEvent ) { FindOptionCase = m_matchCase->GetValue(); FindOptionWords = m_matchWords->GetValue(); @@ -376,5 +395,5 @@ void DIALOG_FIND::onClose( wxCommandEvent& aEvent ) FindIncludeMarkers = m_includeMarkers->GetValue(); FindIncludeReferences = m_includeReferences->GetValue(); - EndModal( 1 ); + aEvent.Skip(); } diff --git a/pcbnew/dialogs/dialog_find.h b/pcbnew/dialogs/dialog_find.h index f3ed3c8fd1..da9700764a 100644 --- a/pcbnew/dialogs/dialog_find.h +++ b/pcbnew/dialogs/dialog_find.h @@ -63,13 +63,15 @@ public: m_highlightCallback = aCallback; } +protected: + void OnClose( wxCloseEvent& event ) override; + void OnCloseButtonClick( wxCommandEvent& aEvent ) override; private: void onTextEnter( wxCommandEvent& event ) override; void onFindNextClick( wxCommandEvent& event ) override; void onFindPreviousClick( wxCommandEvent& event ) override; void onSearchAgainClick( wxCommandEvent& event ) override; - void onClose( wxCommandEvent& event ) override; void search( bool direction ); PCB_BASE_FRAME* m_frame; diff --git a/pcbnew/dialogs/dialog_find_base.cpp b/pcbnew/dialogs/dialog_find_base.cpp index 6d186d3c3f..c6e96e3621 100644 --- a/pcbnew/dialogs/dialog_find_base.cpp +++ b/pcbnew/dialogs/dialog_find_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -132,20 +132,22 @@ DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxStr this->Centre( wxBOTH ); // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIND_BASE::OnClose ) ); m_searchCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_FIND_BASE::onTextEnter ), NULL, this ); m_findNext->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindNextClick ), NULL, this ); m_findPrevious->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindPreviousClick ), NULL, this ); m_searchAgain->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onSearchAgainClick ), NULL, this ); - m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onClose ), NULL, this ); + m_closeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::OnCloseButtonClick ), NULL, this ); } DIALOG_FIND_BASE::~DIALOG_FIND_BASE() { // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FIND_BASE::OnClose ) ); m_searchCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_FIND_BASE::onTextEnter ), NULL, this ); m_findNext->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindNextClick ), NULL, this ); m_findPrevious->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onFindPreviousClick ), NULL, this ); m_searchAgain->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onSearchAgainClick ), NULL, this ); - m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::onClose ), NULL, this ); + m_closeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FIND_BASE::OnCloseButtonClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_find_base.fbp b/pcbnew/dialogs/dialog_find_base.fbp index d6b0ba8af2..61680aa66f 100644 --- a/pcbnew/dialogs/dialog_find_base.fbp +++ b/pcbnew/dialogs/dialog_find_base.fbp @@ -14,6 +14,7 @@ dialog_find_base 1000 none + 1 dialog_pcbnew_find @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -53,6 +55,7 @@ + OnClose bSizer10 @@ -836,6 +839,7 @@ + 0 @@ -909,6 +913,7 @@ + 0 @@ -982,6 +987,7 @@ + 0 @@ -1055,6 +1061,7 @@ + 0 @@ -1112,7 +1119,7 @@ - onClose + OnCloseButtonClick diff --git a/pcbnew/dialogs/dialog_find_base.h b/pcbnew/dialogs/dialog_find_base.h index 3921eb7bd7..3567a7c356 100644 --- a/pcbnew/dialogs/dialog_find_base.h +++ b/pcbnew/dialogs/dialog_find_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,10 +20,10 @@ #include #include #include +#include #include #include #include -#include #include #include @@ -56,11 +56,12 @@ class DIALOG_FIND_BASE : public DIALOG_SHIM wxStaticText* m_status; // Virtual event handlers, overide them in your derived class + virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void onTextEnter( wxCommandEvent& event ) { event.Skip(); } virtual void onFindNextClick( wxCommandEvent& event ) { event.Skip(); } virtual void onFindPreviousClick( wxCommandEvent& event ) { event.Skip(); } virtual void onSearchAgainClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onClose( wxCommandEvent& event ) { event.Skip(); } + virtual void OnCloseButtonClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index f2af04de0d..9ea95d6be4 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012-2014 Miguel Angel Ajo - * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,6 +38,7 @@ #include + enum FPGeneratorRowNames { FP_GEN_ROW_NUMBER = 0, @@ -134,7 +135,8 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::initLists() wxString message; pcbnewGetScriptsSearchPaths( message ); m_tcSearchPaths->SetValue( message ); - // Display info about scripts: unloadable scripts (due to syntax errors is python source) + + // Display info about scripts: unloadable scripts (due to syntax errors is python source). pcbnewGetUnloadableScriptNames( message ); if( message.IsEmpty() ) @@ -161,6 +163,7 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick( wxGridEvent& event ) int click_row = event.GetRow(); m_footprintWizard = FOOTPRINT_WIZARD_LIST::GetWizard( click_row ); m_footprintGeneratorsGrid->SelectRow( event.GetRow(), false ); + // Move the grid cursor to the active line, mainly for aesthetic reasons: m_footprintGeneratorsGrid->GoToCell( event.GetRow(), FP_GEN_ROW_NUMBER ); } @@ -168,9 +171,10 @@ void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorClick( wxGridEvent& event ) void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellFpGeneratorDoubleClick( wxGridEvent& event ) { - EndModal( wxID_OK ); + wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) ); } + void DIALOG_FOOTPRINT_WIZARD_LIST::onShowTrace( wxCommandEvent& event ) { wxString trace; diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index b1fb79d70f..da4c86f099 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -62,7 +62,10 @@ int GLOBAL_EDIT_TOOL::GlobalDeletions( const TOOL_EVENT& aEvent ) DIALOG_GLOBAL_DELETION dlg( editFrame ); dlg.SetCurrentLayer( frame()->GetActiveLayer() ); - dlg.ShowModal(); + + if( dlg.ShowModal() == wxID_OK ) + dlg.DoGlobalDeletions(); + return 0; } @@ -96,7 +99,7 @@ void DIALOG_GLOBAL_DELETION::onCheckDeleteDrawings( wxCommandEvent& event ) } -void DIALOG_GLOBAL_DELETION::doGlobalDeletions() +void DIALOG_GLOBAL_DELETION::DoGlobalDeletions() { bool gen_rastnest = false; @@ -107,12 +110,12 @@ void DIALOG_GLOBAL_DELETION::doGlobalDeletions() if( m_delAll->GetValue() ) { - if( !IsOK( this, _( "Are you sure you want to delete the entire board?" ) ) ) + if( !IsOK( GetParent(), _( "Are you sure you want to delete the entire board?" ) ) ) return; delete_all = true; } - else if( !IsOK( this, _( "Are you sure you want to delete the selected items?" ) ) ) + else if( !IsOK( GetParent(), _( "Are you sure you want to delete the selected items?" ) ) ) { return; } @@ -246,6 +249,7 @@ void DIALOG_GLOBAL_DELETION::doGlobalDeletions() if( gen_rastnest ) m_Parent->Compile_Ratsnest( true ); - // There is a chance that some of tracks have changed their nets, so rebuild ratsnest from scratch + // There is a chance that some of tracks have changed their nets, so rebuild ratsnest + // from scratch. m_Parent->GetCanvas()->Refresh(); } diff --git a/pcbnew/dialogs/dialog_global_deletion.h b/pcbnew/dialogs/dialog_global_deletion.h index d0683ce20d..b79352c04b 100644 --- a/pcbnew/dialogs/dialog_global_deletion.h +++ b/pcbnew/dialogs/dialog_global_deletion.h @@ -32,19 +32,10 @@ public: DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent ); void SetCurrentLayer( LAYER_NUM aLayer ); + ///< @todo Move this back into the tool rather than having the dialog do the deleting. + void DoGlobalDeletions(); + private: - void onOkClick( wxCommandEvent& event ) override - { - doGlobalDeletions(); - EndModal( wxID_OK ); - } - - void onCancelClick( wxCommandEvent& event ) override - { - EndModal( wxID_CANCEL ); - } - - void doGlobalDeletions(); void onCheckDeleteTracks( wxCommandEvent& event ) override; void onCheckDeleteFootprints( wxCommandEvent& event ) override; void onCheckDeleteDrawings( wxCommandEvent& event ) override; diff --git a/pcbnew/dialogs/dialog_global_deletion_base.cpp b/pcbnew/dialogs/dialog_global_deletion_base.cpp index bbcfb16c1c..5bbffaeedf 100644 --- a/pcbnew/dialogs/dialog_global_deletion_base.cpp +++ b/pcbnew/dialogs/dialog_global_deletion_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -132,8 +132,6 @@ DIALOG_GLOBAL_DELETION_BASE::DIALOG_GLOBAL_DELETION_BASE( wxWindow* parent, wxWi m_delDrawings->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteDrawings ), NULL, this ); m_delFootprints->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteFootprints ), NULL, this ); m_delTracks->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteTracks ), NULL, this ); - m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCancelClick ), NULL, this ); - m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onOkClick ), NULL, this ); } DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE() @@ -142,7 +140,5 @@ DIALOG_GLOBAL_DELETION_BASE::~DIALOG_GLOBAL_DELETION_BASE() m_delDrawings->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteDrawings ), NULL, this ); m_delFootprints->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteFootprints ), NULL, this ); m_delTracks->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCheckDeleteTracks ), NULL, this ); - m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onCancelClick ), NULL, this ); - m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GLOBAL_DELETION_BASE::onOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_global_deletion_base.fbp b/pcbnew/dialogs/dialog_global_deletion_base.fbp index b94254b539..384361b93d 100644 --- a/pcbnew/dialogs/dialog_global_deletion_base.fbp +++ b/pcbnew/dialogs/dialog_global_deletion_base.fbp @@ -14,6 +14,7 @@ dialog_global_deletion_base 1000 none + 1 dialog_global_deletion @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -1354,8 +1356,6 @@ m_sdbSizer1 protected - onCancelClick - onOkClick diff --git a/pcbnew/dialogs/dialog_global_deletion_base.h b/pcbnew/dialogs/dialog_global_deletion_base.h index 9a347d49c2..dd4572ecfd 100644 --- a/pcbnew/dialogs/dialog_global_deletion_base.h +++ b/pcbnew/dialogs/dialog_global_deletion_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.9.0 Jun 18 2020) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -65,8 +65,6 @@ class DIALOG_GLOBAL_DELETION_BASE : public DIALOG_SHIM virtual void onCheckDeleteDrawings( wxCommandEvent& event ) { event.Skip(); } virtual void onCheckDeleteFootprints( wxCommandEvent& event ) { event.Skip(); } virtual void onCheckDeleteTracks( wxCommandEvent& event ) { event.Skip(); } - virtual void onCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onOkClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_push_pad_properties.cpp b/pcbnew/dialogs/dialog_push_pad_properties.cpp index 6613de56a9..ff6fd96d45 100644 --- a/pcbnew/dialogs/dialog_push_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_push_pad_properties.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -63,8 +63,6 @@ DIALOG_PUSH_PAD_PROPERTIES::DIALOG_PUSH_PAD_PROPERTIES( PCB_BASE_FRAME* aParent } -/* Update the parameters for the component being edited. - */ void DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) { int returncode = 0; @@ -80,7 +78,12 @@ void DIALOG_PUSH_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) m_Pad_Layer_Filter = m_Pad_Layer_Filter_CB->GetValue(); m_Pad_Orient_Filter = m_Pad_Orient_Filter_CB->GetValue(); m_Pad_Type_Filter = m_Pad_Type_Filter_CB->GetValue(); - EndModal( returncode ); + + if( IsQuasiModal() ) + EndQuasiModal( returncode ); + else + EndDialog( returncode ); + break; } diff --git a/pcbnew/microwave/microwave_polygon.cpp b/pcbnew/microwave/microwave_polygon.cpp index f0cf0a9b34..effaaf8e66 100644 --- a/pcbnew/microwave/microwave_polygon.cpp +++ b/pcbnew/microwave/microwave_polygon.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -62,14 +63,15 @@ enum id_mw_cmd { }; -class MWAVE_POLYGONAL_SHAPE_DLG : public wxDialog +class MWAVE_POLYGONAL_SHAPE_DLG : public DIALOG_SHIM { public: MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& pos ); ~MWAVE_POLYGONAL_SHAPE_DLG() { }; + bool TransferDataFromWindow() override; + private: - void OnOkClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); /** @@ -99,7 +101,6 @@ private: BEGIN_EVENT_TABLE( MWAVE_POLYGONAL_SHAPE_DLG, wxDialog ) - EVT_BUTTON( wxID_OK, MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick ) EVT_BUTTON( wxID_CANCEL, MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick ) EVT_BUTTON( ID_READ_SHAPE_FILE, MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr ) END_EVENT_TABLE() @@ -107,8 +108,8 @@ END_EVENT_TABLE() MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, const wxPoint& framepos ) : - wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ), - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) + DIALOG_SHIM( parent, -1, _( "Complex shape" ), framepos, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) { m_Parent = parent; @@ -149,15 +150,19 @@ MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG( PCB_EDIT_FRAME* parent, void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick( wxCommandEvent& event ) { PolyEdges.clear(); - EndModal( wxID_CANCEL ); + event.Skip(); } -void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick( wxCommandEvent& event ) +bool MWAVE_POLYGONAL_SHAPE_DLG::TransferDataFromWindow() { + if( !wxDialog::TransferDataFromWindow() ) + return false; + ShapeSize = m_SizeCtrl->GetValue(); PolyShapeType = m_ShapeOptionCtrl->GetSelection(); - EndModal( wxID_OK ); + + return true; } @@ -342,6 +347,7 @@ FOOTPRINT* MICROWAVE_TOOL::createPolygonShape() pt.y = -pt.y; // mirror about X axis polyPoints.push_back( pt ); } + break; } diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index 29b43525bf..16c61ef8e6 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -6,7 +6,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -38,7 +38,8 @@ #define LAYERNAME_COLNUM 2 -/* classes to display a layer list using a wxGrid. +/* + * Display a layer list using a wxGrid. */ class PCB_LAYER_SELECTOR: public LAYER_SELECTOR { @@ -52,20 +53,19 @@ public: protected: PCB_BASE_FRAME* m_frame; - // Returns true if the layer id is enabled (i.e. is it should be displayed) + ///< @return true if the layer id is enabled (i.e. is it should be displayed). bool isLayerEnabled( LAYER_NUM aLayer ) const override { return m_frame->GetBoard()->IsLayerEnabled( PCB_LAYER_ID( aLayer ) ); } - // Returns a color index from the layer id - // Virtual function + // Return the color index from the layer ID. COLOR4D getLayerColor( LAYER_NUM aLayer ) const override { return m_frame->GetColorSettings()->GetColor( aLayer ); } - // Returns the name of the layer id + // Return the name of the layer ID. wxString getLayerName( LAYER_NUM aLayer ) const override { return m_frame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) ); @@ -73,19 +73,11 @@ protected: }; -/* - * This class display a pcb layers list in a dialog, - * to select one layer from this list +/** + * Display a PCB layers list in a dialog to select one layer from this list. */ -class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR, - public DIALOG_LAYER_SELECTION_BASE +class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR, public DIALOG_LAYER_SELECTION_BASE { - PCB_LAYER_ID m_layerSelected; - LSET m_notAllowedLayersMask; - BOARD* m_brd; - std::vector m_layersIdLeftColumn; - std::vector m_layersIdRightColumn; - public: PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, BOARD * aBrd, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask ); @@ -102,6 +94,12 @@ private: void onCharHook( wxKeyEvent& event ); void buildList(); + + PCB_LAYER_ID m_layerSelected; + LSET m_notAllowedLayersMask; + BOARD* m_brd; + std::vector m_layersIdLeftColumn; + std::vector m_layersIdRightColumn; }; @@ -211,14 +209,22 @@ void PCB_ONE_LAYER_SELECTOR::buildList() void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event ) { m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ]; - EndModal( 1 ); + + if( IsQuasiModal() ) + EndQuasiModal( 1 ); + else + EndDialog( 1 ); } void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event ) { m_layerSelected = m_layersIdRightColumn[ event.GetRow() ]; - EndModal( 2 ); + + if( IsQuasiModal() ) + EndQuasiModal( 2 ); + else + EndDialog( 2 ); } @@ -243,22 +249,11 @@ PCB_LAYER_ID PCB_BASE_FRAME::SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aN /** - * SELECT_COPPER_LAYERS_PAIR_DIALOG - * displays a double pcb copper layers list in a dialog, - * to select a layer pair from these lists + * Display a pair PCB copper layers list in a dialog to select a layer pair from these lists. */ class SELECT_COPPER_LAYERS_PAIR_DIALOG: public PCB_LAYER_SELECTOR, public DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE { -private: - BOARD* m_brd; - PCB_LAYER_ID m_frontLayer; - PCB_LAYER_ID m_backLayer; - int m_leftRowSelected; - int m_rightRowSelected; - - std::vector m_layersId; - public: SELECT_COPPER_LAYERS_PAIR_DIALOG( PCB_BASE_FRAME* aParent, BOARD* aPcb, PCB_LAYER_ID aFrontLayer, PCB_LAYER_ID aBackLayer ); @@ -274,6 +269,14 @@ private: void OnRightGridCellClick( wxGridEvent& event ) override; void buildList(); + + BOARD* m_brd; + PCB_LAYER_ID m_frontLayer; + PCB_LAYER_ID m_backLayer; + int m_leftRowSelected; + int m_rightRowSelected; + + std::vector m_layersId; };