diff --git a/common/dialogs/panel_color_settings.cpp b/common/dialogs/panel_color_settings.cpp
index 888555edab..fb7c2ef8f1 100644
--- a/common/dialogs/panel_color_settings.cpp
+++ b/common/dialogs/panel_color_settings.cpp
@@ -61,7 +61,7 @@ void PANEL_COLOR_SETTINGS::OnBtnOpenThemeFolderClicked( wxCommandEvent& event )
}
-void PANEL_COLOR_SETTINGS::OnBtnResetClicked( wxCommandEvent& event )
+void PANEL_COLOR_SETTINGS::ResetPanel()
{
if( !m_currentSettings )
return;
diff --git a/common/dialogs/panel_color_settings.h b/common/dialogs/panel_color_settings.h
index d6eb86731f..a1fa6c9ac9 100644
--- a/common/dialogs/panel_color_settings.h
+++ b/common/dialogs/panel_color_settings.h
@@ -43,11 +43,16 @@ public:
ID_REVERT
};
+ virtual void ResetPanel() override;
+
+ virtual wxString GetResetTooltip() override
+ {
+ return _( "Reset all colors in this theme to the KiCad defaults" );
+ }
+
protected:
void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) override;
- void OnBtnResetClicked( wxCommandEvent& aEvent ) override;
-
void OnLeftDownTheme( wxMouseEvent& event ) override;
void OnThemeChanged( wxCommandEvent& aEvent ) override;
diff --git a/common/dialogs/panel_color_settings_base.cpp b/common/dialogs/panel_color_settings_base.cpp
index 9d02552cf2..e740d09594 100644
--- a/common/dialogs/panel_color_settings_base.cpp
+++ b/common/dialogs/panel_color_settings_base.cpp
@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
-PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
+PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
{
m_mainSizer = new wxBoxSizer( wxVERTICAL );
@@ -39,11 +39,6 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
bControlSizer->Add( 0, 0, 1, wxEXPAND, 5 );
- m_btnReset = new wxButton( this, wxID_ANY, _("&Reset to Defaults"), wxDefaultPosition, wxDefaultSize, 0 );
- m_btnReset->SetToolTip( _("Reset all colors in this theme to the KiCad defaults") );
-
- bControlSizer->Add( m_btnReset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
-
m_btnOpenFolder = new wxButton( this, wxID_ANY, _("Open Theme Folder"), wxDefaultPosition, wxDefaultSize, 0 );
m_btnOpenFolder->SetToolTip( _("Open the folder containing color themes") );
@@ -92,7 +87,6 @@ PANEL_COLOR_SETTINGS_BASE::PANEL_COLOR_SETTINGS_BASE( wxWindow* parent, wxWindow
m_cbTheme->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_cbTheme->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( PANEL_COLOR_SETTINGS_BASE::OnLeftDownTheme ), NULL, this );
m_optOverrideColors->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnOverrideItemColorsClicked ), NULL, this );
- m_btnReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );
}
@@ -103,7 +97,6 @@ PANEL_COLOR_SETTINGS_BASE::~PANEL_COLOR_SETTINGS_BASE()
m_cbTheme->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnThemeChanged ), NULL, this );
m_cbTheme->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( PANEL_COLOR_SETTINGS_BASE::OnLeftDownTheme ), NULL, this );
m_optOverrideColors->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnOverrideItemColorsClicked ), NULL, this );
- m_btnReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnResetClicked ), NULL, this );
m_btnOpenFolder->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COLOR_SETTINGS_BASE::OnBtnOpenThemeFolderClicked ), NULL, this );
}
diff --git a/common/dialogs/panel_color_settings_base.fbp b/common/dialogs/panel_color_settings_base.fbp
index 7efa2063a9..9de65ef450 100644
--- a/common/dialogs/panel_color_settings_base.fbp
+++ b/common/dialogs/panel_color_settings_base.fbp
@@ -44,7 +44,7 @@
PANEL_COLOR_SETTINGS_BASE
826,300
- ; ; forward_declare
+ RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare
@@ -276,79 +276,6 @@
0
-
5
wxALIGN_CENTER_VERTICAL|wxALL
diff --git a/common/dialogs/panel_color_settings_base.h b/common/dialogs/panel_color_settings_base.h
index 1fc369b3e2..0cdbcc0fc0 100644
--- a/common/dialogs/panel_color_settings_base.h
+++ b/common/dialogs/panel_color_settings_base.h
@@ -10,6 +10,7 @@
#include
#include
#include
+#include "widgets/resettable_panel.h"
#include
#include
#include
@@ -32,7 +33,7 @@
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_COLOR_SETTINGS_BASE
///////////////////////////////////////////////////////////////////////////////
-class PANEL_COLOR_SETTINGS_BASE : public wxPanel
+class PANEL_COLOR_SETTINGS_BASE : public RESETTABLE_PANEL
{
private:
@@ -40,7 +41,6 @@ class PANEL_COLOR_SETTINGS_BASE : public wxPanel
wxBoxSizer* m_mainSizer;
wxStaticText* m_staticText9;
wxChoice* m_cbTheme;
- wxButton* m_btnReset;
wxButton* m_btnOpenFolder;
wxStaticLine* m_staticline2;
wxBoxSizer* m_colorsMainSizer;
@@ -52,7 +52,6 @@ class PANEL_COLOR_SETTINGS_BASE : public wxPanel
virtual void OnThemeChanged( wxCommandEvent& event ) { event.Skip(); }
virtual void OnLeftDownTheme( wxMouseEvent& event ) { event.Skip(); }
virtual void OnOverrideItemColorsClicked( wxCommandEvent& event ) { event.Skip(); }
- virtual void OnBtnResetClicked( wxCommandEvent& event ) { event.Skip(); }
virtual void OnBtnOpenThemeFolderClicked( wxCommandEvent& event ) { event.Skip(); }
diff --git a/common/dialogs/panel_hotkeys_editor.cpp b/common/dialogs/panel_hotkeys_editor.cpp
index 7b59cbfbc3..ab4be27c8d 100644
--- a/common/dialogs/panel_hotkeys_editor.cpp
+++ b/common/dialogs/panel_hotkeys_editor.cpp
@@ -58,7 +58,7 @@ static wxSearchCtrl* CreateTextFilterBox( wxWindow* aParent, const wxString& aDe
PANEL_HOTKEYS_EDITOR::PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow,
bool aReadOnly ) :
- wxPanel( aWindow, wxID_ANY, wxDefaultPosition, default_dialog_size ),
+ RESETTABLE_PANEL( aWindow, wxID_ANY, wxDefaultPosition, default_dialog_size ),
m_frame( aFrame ),
m_readOnly( aReadOnly ),
m_hotkeyStore()
@@ -102,6 +102,12 @@ void PANEL_HOTKEYS_EDITOR::AddHotKeys( TOOL_MANAGER* aToolMgr )
}
+void PANEL_HOTKEYS_EDITOR::ResetPanel()
+{
+ m_hotkeyListCtrl->ResetAllHotkeys( true );
+}
+
+
void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
{
const BUTTON_ROW_PANEL::BTN_DEF_LIST l_btn_defs = {
@@ -113,14 +119,6 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
m_hotkeyListCtrl->ResetAllHotkeys( false );
}
},
- {
- wxID_ANY,
- _( "Restore All to Defaults" ),
- _( "Set all hotkeys to the built-in KiCad defaults" ),
- [this]( wxCommandEvent& ){
- m_hotkeyListCtrl->ResetAllHotkeys( true );
- }
- },
{
wxID_ANY,
_( "Import Hotkeys..." ),
diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp
index 71a9a30ec7..52a7a000f1 100644
--- a/common/eda_base_frame.cpp
+++ b/common/eda_base_frame.cpp
@@ -665,7 +665,7 @@ void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event )
void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event )
{
- PAGED_DIALOG dlg( this, _( "Preferences" ) );
+ PAGED_DIALOG dlg( this, _( "Preferences" ), true );
wxTreebook* book = dlg.GetTreebook();
book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
diff --git a/common/widgets/paged_dialog.cpp b/common/widgets/paged_dialog.cpp
index c7d5660c9c..f352c32527 100644
--- a/common/widgets/paged_dialog.cpp
+++ b/common/widgets/paged_dialog.cpp
@@ -18,6 +18,7 @@
*/
#include
+#include
#include
#include
#include
@@ -34,7 +35,7 @@ std::map g_lastPage;
std::map g_lastParentPage;
-PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle,
+PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aUseReset,
const wxString& aAuxiliaryAction ) :
DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
@@ -55,20 +56,28 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle,
auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
+ if( aUseReset )
+ {
+ m_resetButton = new wxButton( this, wxID_ANY, _( "Reset to Defaults" ) );
+ buttonsSizer->Add( m_resetButton, 0, wxRIGHT | wxLEFT, 5 );
+ }
+
if( !aAuxiliaryAction.IsEmpty() )
{
m_auxiliaryButton = new wxButton( this, wxID_ANY, aAuxiliaryAction );
buttonsSizer->Add( m_auxiliaryButton, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
}
+ buttonsSizer->AddStretchSpacer();
+
auto sdbSizer = new wxStdDialogButtonSizer();
- auto sdbSizerOK = new wxButton( this, wxID_OK );
+ wxButton* sdbSizerOK = new wxButton( this, wxID_OK );
sdbSizer->AddButton( sdbSizerOK );
- auto sdbSizerCancel = new wxButton( this, wxID_CANCEL );
+ wxButton* sdbSizerCancel = new wxButton( this, wxID_CANCEL );
sdbSizer->AddButton( sdbSizerCancel );
sdbSizer->Realize();
- buttonsSizer->Add( sdbSizer, 1, wxEXPAND, 5 );
+ buttonsSizer->Add( sdbSizer, 1, 0, 5 );
mainSizer->Add( buttonsSizer, 0, wxALL|wxEXPAND, 5 );
sdbSizerOK->SetDefault();
@@ -81,6 +90,9 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle,
if( m_auxiliaryButton )
m_auxiliaryButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PAGED_DIALOG::OnAuxiliaryAction ), nullptr, this );
+ if( m_resetButton )
+ m_resetButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PAGED_DIALOG::OnResetButton ), nullptr, this );
+
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PAGED_DIALOG::OnUpdateUI ), nullptr, this );
}
@@ -141,8 +153,10 @@ PAGED_DIALOG::~PAGED_DIALOG()
if( m_auxiliaryButton )
m_auxiliaryButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PAGED_DIALOG::OnAuxiliaryAction ), nullptr, this );
- m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
+ if( m_resetButton )
+ m_resetButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PAGED_DIALOG::OnResetButton ), nullptr, this );
+ m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED, wxBookCtrlEventHandler( PAGED_DIALOG::OnPageChange ), NULL, this );
Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PAGED_DIALOG::OnUpdateUI ), nullptr, this );
}
@@ -299,11 +313,27 @@ void PAGED_DIALOG::OnUpdateUI( wxUpdateUIEvent& event )
void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event )
{
-#ifdef __WXMAC__
- // Work around an OSX bug where the wxGrid children don't get placed correctly until
- // the first resize event
int page = event.GetSelection();
+ // Enable the reset button only if the page is resettable
+ if( m_resetButton )
+ {
+ if( auto panel = dynamic_cast( m_treebook->GetPage( page ) ) )
+ {
+ m_resetButton->SetToolTip( panel->GetResetTooltip() );
+ m_resetButton->Enable( true );
+ }
+ else
+ {
+ m_resetButton->SetToolTip( wxString() );
+ m_resetButton->Enable( false );
+ }
+
+ }
+
+ // Work around an OSX bug where the wxGrid children don't get placed correctly until
+ // the first resize event
+#ifdef __WXMAC__
if( page + 1 <= m_macHack.size() && m_macHack[ page ] )
{
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
@@ -314,6 +344,20 @@ void PAGED_DIALOG::OnPageChange( wxBookCtrlEvent& event )
m_macHack[ page ] = false;
}
#endif
+
+ Layout();
}
+void PAGED_DIALOG::OnResetButton( wxCommandEvent& aEvent )
+{
+ int sel = m_treebook->GetSelection();
+
+ if( sel == wxNOT_FOUND )
+ return;
+
+ RESETTABLE_PANEL* panel = dynamic_cast( m_treebook->GetPage( sel ) );
+
+ if( panel )
+ panel->ResetPanel();
+}
diff --git a/eeschema/dialogs/dialog_schematic_setup.cpp b/eeschema/dialogs/dialog_schematic_setup.cpp
index 2376ca213f..7f45c8f03e 100644
--- a/eeschema/dialogs/dialog_schematic_setup.cpp
+++ b/eeschema/dialogs/dialog_schematic_setup.cpp
@@ -36,7 +36,7 @@
DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
- PAGED_DIALOG( aFrame, _( "Schematic Setup" ),
+ PAGED_DIALOG( aFrame, _( "Schematic Setup" ), true,
_( "Import Settings from Another Project..." ) ),
m_frame( aFrame ),
m_severities( nullptr )
@@ -96,11 +96,26 @@ DIALOG_SCHEMATIC_SETUP::~DIALOG_SCHEMATIC_SETUP()
void DIALOG_SCHEMATIC_SETUP::OnPageChange( wxBookCtrlEvent& event )
{
-#ifdef __WXMAC__
- // Work around an OSX bug where the wxGrid children don't get placed correctly until
- // the first resize event
int page = event.GetSelection();
+ // Enable the reset button only if the page is resettable
+ if( m_resetButton )
+ {
+ if( auto panel = dynamic_cast( m_treebook->GetPage( page ) ) )
+ {
+ m_resetButton->SetToolTip( panel->GetResetTooltip() );
+ m_resetButton->Enable( true );
+ }
+ else
+ {
+ m_resetButton->SetToolTip( wxString() );
+ m_resetButton->Enable( false );
+ }
+ }
+
+ // Work around an OSX bug where the wxGrid children don't get placed correctly until
+ // the first resize event
+#ifdef __WXMAC__
if( m_macHack[ page ] )
{
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
@@ -111,6 +126,8 @@ void DIALOG_SCHEMATIC_SETUP::OnPageChange( wxBookCtrlEvent& event )
m_macHack[ page ] = false;
}
#endif
+
+ Layout();
}
diff --git a/eeschema/dialogs/panel_eeschema_color_settings.cpp b/eeschema/dialogs/panel_eeschema_color_settings.cpp
index 8c6cbd580f..3050a64ef1 100644
--- a/eeschema/dialogs/panel_eeschema_color_settings.cpp
+++ b/eeschema/dialogs/panel_eeschema_color_settings.cpp
@@ -345,9 +345,9 @@ void PANEL_EESCHEMA_COLOR_SETTINGS::onColorChanged()
}
-void PANEL_EESCHEMA_COLOR_SETTINGS::OnBtnResetClicked( wxCommandEvent& event )
+void PANEL_EESCHEMA_COLOR_SETTINGS::ResetPanel()
{
- PANEL_COLOR_SETTINGS::OnBtnResetClicked( event );
+ PANEL_COLOR_SETTINGS::ResetPanel();
updatePreview();
}
diff --git a/eeschema/dialogs/panel_eeschema_color_settings.h b/eeschema/dialogs/panel_eeschema_color_settings.h
index 9a9b1fc29b..26e2341c2c 100644
--- a/eeschema/dialogs/panel_eeschema_color_settings.h
+++ b/eeschema/dialogs/panel_eeschema_color_settings.h
@@ -44,6 +44,8 @@ public:
~PANEL_EESCHEMA_COLOR_SETTINGS() override;
+ void ResetPanel() override;
+
protected:
bool TransferDataFromWindow() override;
@@ -53,8 +55,6 @@ protected:
void OnSize( wxSizeEvent& aEvent ) override;
- void OnBtnResetClicked( wxCommandEvent& event ) override;
-
bool validateSave( bool aQuiet = false ) override;
bool saveCurrentTheme( bool aValidate ) override;
diff --git a/eeschema/dialogs/panel_setup_pinmap.cpp b/eeschema/dialogs/panel_setup_pinmap.cpp
index fa95aee883..6df81aa65f 100644
--- a/eeschema/dialogs/panel_setup_pinmap.cpp
+++ b/eeschema/dialogs/panel_setup_pinmap.cpp
@@ -66,7 +66,7 @@ PANEL_SETUP_PINMAP::PANEL_SETUP_PINMAP( wxWindow* aWindow, SCH_EDIT_FRAME* paren
}
-void PANEL_SETUP_PINMAP::OnResetMatrixClick( wxCommandEvent& aEvent )
+void PANEL_SETUP_PINMAP::ResetPanel()
{
m_schematic->ErcSettings().ResetPinMap();
reBuildMatrixPanel();
diff --git a/eeschema/dialogs/panel_setup_pinmap.h b/eeschema/dialogs/panel_setup_pinmap.h
index 0d67d67150..fe9d30b4d3 100644
--- a/eeschema/dialogs/panel_setup_pinmap.h
+++ b/eeschema/dialogs/panel_setup_pinmap.h
@@ -51,9 +51,9 @@ public:
bool Show( bool show ) override;
void ImportSettingsFrom( PIN_ERROR aPinMap[][ELECTRICAL_PINTYPES_TOTAL] );
-private:
- void OnResetMatrixClick( wxCommandEvent& aEvent ) override;
+ void ResetPanel() override;
+private:
void changeErrorLevel( wxCommandEvent& event );
void reBuildMatrixPanel();
void setDRCMatrixButtonState( wxBitmapButton *aButton, PIN_ERROR aState );
diff --git a/eeschema/dialogs/panel_setup_pinmap_base.cpp b/eeschema/dialogs/panel_setup_pinmap_base.cpp
index aff5b2aa82..8a74e9e937 100644
--- a/eeschema/dialogs/panel_setup_pinmap_base.cpp
+++ b/eeschema/dialogs/panel_setup_pinmap_base.cpp
@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
-PANEL_SETUP_PINMAP_BASE::PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
+PANEL_SETUP_PINMAP_BASE::PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : RESETTABLE_PANEL( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxHORIZONTAL );
@@ -26,13 +26,7 @@ PANEL_SETUP_PINMAP_BASE::PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID i
sbSizer3->Add( m_matrixPanel, 1, wxEXPAND | wxALL, 5 );
- m_panelMatrixSizer->Add( sbSizer3, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
-
-
- m_panelMatrixSizer->Add( 0, 0, 0, wxEXPAND|wxTOP, 5 );
-
- m_ResetOptButton = new wxButton( this, ID_RESET_MATRIX, _("Reset to Defaults"), wxDefaultPosition, wxDefaultSize, 0 );
- m_panelMatrixSizer->Add( m_ResetOptButton, 0, wxRIGHT|wxLEFT, 10 );
+ m_panelMatrixSizer->Add( sbSizer3, 1, wxALL|wxEXPAND, 10 );
bSizer2->Add( m_panelMatrixSizer, 1, wxEXPAND|wxLEFT, 10 );
@@ -41,14 +35,8 @@ PANEL_SETUP_PINMAP_BASE::PANEL_SETUP_PINMAP_BASE( wxWindow* parent, wxWindowID i
this->SetSizer( bSizer2 );
this->Layout();
bSizer2->Fit( this );
-
- // Connect Events
- m_ResetOptButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_PINMAP_BASE::OnResetMatrixClick ), NULL, this );
}
PANEL_SETUP_PINMAP_BASE::~PANEL_SETUP_PINMAP_BASE()
{
- // Disconnect Events
- m_ResetOptButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_PINMAP_BASE::OnResetMatrixClick ), NULL, this );
-
}
diff --git a/eeschema/dialogs/panel_setup_pinmap_base.fbp b/eeschema/dialogs/panel_setup_pinmap_base.fbp
index 6376051f51..65b83200c0 100644
--- a/eeschema/dialogs/panel_setup_pinmap_base.fbp
+++ b/eeschema/dialogs/panel_setup_pinmap_base.fbp
@@ -44,7 +44,7 @@
PANEL_SETUP_PINMAP_BASE
-1,-1
- ; forward_declare
+ RESETTABLE_PANEL; widgets/resettable_panel.h; Not forward_declare
@@ -65,7 +65,7 @@
none
10
- wxEXPAND|wxTOP|wxRIGHT|wxLEFT
+ wxALL|wxEXPAND
1
wxID_ANY
@@ -134,89 +134,6 @@
-
- 5
- wxEXPAND|wxTOP
- 0
-
- 0
- protected
- 0
-
-
-
- 10
- wxRIGHT|wxLEFT
- 0
-
- 1
- 1
- 1
- 1
-
-
-
-
-
-
-
-
- 1
- 0
- 1
-
- 1
-
- 0
- 0
-
- Dock
- 0
- Left
- 1
-
- 1
-
-
- 0
- 0
- ID_RESET_MATRIX
- Reset to Defaults
-
- 0
-
- 0
-
-
- 0
-
- 1
- m_ResetOptButton
- 1
-
-
- protected
- 1
-
-
-
- Resizable
- 1
-
-
-
- 0
-
-
- wxFILTER_NONE
- wxDefaultValidator
-
-
-
-
- OnResetMatrixClick
-
-
diff --git a/eeschema/dialogs/panel_setup_pinmap_base.h b/eeschema/dialogs/panel_setup_pinmap_base.h
index cccd889638..643125e88f 100644
--- a/eeschema/dialogs/panel_setup_pinmap_base.h
+++ b/eeschema/dialogs/panel_setup_pinmap_base.h
@@ -10,6 +10,7 @@
#include
#include
#include
+#include "widgets/resettable_panel.h"
#include
#include
#include
@@ -18,32 +19,18 @@
#include
#include
#include
-#include
-#include
-#include
-#include
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_SETUP_PINMAP_BASE
///////////////////////////////////////////////////////////////////////////////
-class PANEL_SETUP_PINMAP_BASE : public wxPanel
+class PANEL_SETUP_PINMAP_BASE : public RESETTABLE_PANEL
{
private:
protected:
- enum
- {
- ID_RESET_MATRIX = 1000
- };
-
wxPanel* m_matrixPanel;
- wxButton* m_ResetOptButton;
-
- // Virtual event handlers, overide them in your derived class
- virtual void OnResetMatrixClick( wxCommandEvent& event ) { event.Skip(); }
-
public:
diff --git a/include/panel_hotkeys_editor.h b/include/panel_hotkeys_editor.h
index 6d5dbb8753..d5926d051c 100644
--- a/include/panel_hotkeys_editor.h
+++ b/include/panel_hotkeys_editor.h
@@ -27,6 +27,7 @@
#include
#include
+#include
#include
#include "wx/panel.h"
@@ -37,12 +38,12 @@ class wxSizer;
class TOOL_MANAGER;
-class PANEL_HOTKEYS_EDITOR : public wxPanel
+class PANEL_HOTKEYS_EDITOR : public RESETTABLE_PANEL
{
protected:
EDA_BASE_FRAME* m_frame;
bool m_readOnly;
-
+
std::vector m_toolManagers;
HOTKEY_STORE m_hotkeyStore;
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
@@ -51,10 +52,17 @@ public:
PANEL_HOTKEYS_EDITOR( EDA_BASE_FRAME* aFrame, wxWindow* aWindow, bool aReadOnly );
void AddHotKeys( TOOL_MANAGER* aToolMgr );
-
+
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
+ void ResetPanel() override;
+
+ wxString GetResetTooltip() override
+ {
+ return _( "Reset all hotkeys to the built-in KiCad defaults" );
+ }
+
private:
/**
diff --git a/include/widgets/paged_dialog.h b/include/widgets/paged_dialog.h
index 51bec810f6..0d5e732a71 100644
--- a/include/widgets/paged_dialog.h
+++ b/include/widgets/paged_dialog.h
@@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
- * Copyright (C) 2017-2018 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2017-2020 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,7 @@ private:
std::vector m_macHack;
public:
- PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle,
+ PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aUseReset = false,
const wxString& aAuxiliaryAction = wxEmptyString );
~PAGED_DIALOG() override;
@@ -59,11 +59,13 @@ protected:
bool TransferDataFromWindow() override;
virtual void OnAuxiliaryAction( wxCommandEvent& event ) { event.Skip(); }
+ void OnResetButton( wxCommandEvent& aEvent );
void OnUpdateUI( wxUpdateUIEvent& event );
void OnPageChange( wxBookCtrlEvent& event );
wxTreebook* m_treebook;
wxButton* m_auxiliaryButton;
+ wxButton* m_resetButton;
};
diff --git a/include/widgets/resettable_panel.h b/include/widgets/resettable_panel.h
new file mode 100644
index 0000000000..57378e858b
--- /dev/null
+++ b/include/widgets/resettable_panel.h
@@ -0,0 +1,58 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 2020 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
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#ifndef RESETTABLE_PANEL_H_
+#define RESETTABLE_PANEL_H_
+
+#include
+
+class PAGED_DIALOG;
+
+/**
+ * A wxPanel that is designed to be reset in a standard manor.
+ */
+class RESETTABLE_PANEL : public wxPanel
+{
+public:
+ RESETTABLE_PANEL( wxWindow* aParent, wxWindowID aId = wxID_ANY,
+ const wxPoint& aPos = wxDefaultPosition,
+ const wxSize& aSize = wxSize( -1,-1 ),
+ long aStyle = wxTAB_TRAVERSAL,
+ const wxString& aName = wxEmptyString )
+ : wxPanel( aParent, aId, aPos, aSize, aStyle, aName )
+ {
+ }
+
+ /**
+ * Reset the contents of this panel.
+ */
+ virtual void ResetPanel() = 0;
+
+ /**
+ * Get the tooltip the reset button should display when showing this panel.
+ *
+ * @return the tooltip
+ */
+ virtual wxString GetResetTooltip()
+ {
+ return _( "Reset all settings on this page to their default" );
+ }
+};
+
+#endif
diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp
index 6a7e59d5d7..39635f497f 100644
--- a/pcbnew/dialogs/dialog_board_setup.cpp
+++ b/pcbnew/dialogs/dialog_board_setup.cpp
@@ -41,7 +41,7 @@
#include "panel_setup_rules.h"
DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
- PAGED_DIALOG( aFrame, _( "Board Setup" ), _( "Import Settings from Another Board..." ) ),
+ PAGED_DIALOG( aFrame, _( "Board Setup" ), false, _( "Import Settings from Another Board..." ) ),
m_frame( aFrame )
{
BOARD* board = aFrame->GetBoard();