From 0a1a1817988baea276006fcc8f3f7ed7e459c592 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Fri, 8 Oct 2021 18:13:41 +0100 Subject: [PATCH] pcb_calculator: Move calculator panels to a registration architecture This simplifies operations that touch every panel and is a bit neater. --- .../dialogs/dialog_regulator_form.cpp | 5 +- .../dialogs/pcb_calculator_frame_base.cpp | 20 +- .../dialogs/pcb_calculator_frame_base.fbp | 519 +----------------- .../dialogs/pcb_calculator_frame_base.h | 28 +- pcb_calculator/params_read_write.cpp | 2 +- pcb_calculator/pcb_calculator_frame.cpp | 155 +++--- pcb_calculator/pcb_calculator_frame.h | 25 +- 7 files changed, 126 insertions(+), 628 deletions(-) diff --git a/pcb_calculator/dialogs/dialog_regulator_form.cpp b/pcb_calculator/dialogs/dialog_regulator_form.cpp index b2b80c3a99..9f5cea86d5 100644 --- a/pcb_calculator/dialogs/dialog_regulator_form.cpp +++ b/pcb_calculator/dialogs/dialog_regulator_form.cpp @@ -20,8 +20,9 @@ #include -#include "class_regulator_data.h" -#include "pcb_calculator_frame.h" +#include +#include +#include #include "dialog_regulator_form.h" diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp index 9addc94987..ffcc0ca5f3 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -20,24 +20,6 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow bmainFrameSizer = new wxBoxSizer( wxVERTICAL ); m_Notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - m_panelRegulators = new PANEL_REGULATOR( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelRegulators, _("Regulators"), true ); - m_panelAttenuators = new PANEL_ATTENUATORS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelAttenuators, _("RF Attenuators"), false ); - m_panelESeries = new PANEL_E_SERIE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelESeries, _("E-Series"), false ); - m_panelColorCode = new PANEL_COLOR_CODE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelColorCode, _("Color Code"), false ); - m_panelTransline = new PANEL_TRANSLINE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelTransline, _("TransLine"), false ); - m_panelViaSize = new PANEL_VIA_SIZE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelViaSize, _("Via Size"), false ); - m_panelTrackWidth = new PANEL_TRACK_WIDTH( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelTrackWidth, _("Track Width"), false ); - m_panelElectricalSpacing = new PANEL_ELECTRICAL_SPACING( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelElectricalSpacing, _("Electrical Spacing"), false ); - m_panelBoardClass = new PANEL_BOARD_CLASS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_Notebook->AddPage( m_panelBoardClass, _("Board Classes"), false ); bmainFrameSizer->Add( m_Notebook, 1, wxEXPAND, 5 ); diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp index 937ce33bda..20f6aed144 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp @@ -1,6 +1,6 @@ - + C++ @@ -14,6 +14,7 @@ pcb_calculator_frame_base 1000 none + 1 pcb_calculator_frame_base @@ -25,6 +26,7 @@ 1 1 UI + 0 0 0 @@ -50,6 +52,7 @@ KIWAY_PLAYER; kiway_player.h PCB Calculator + 0 pcb_calculator wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL @@ -65,7 +68,6 @@ 0 wxID_ANY - MenuBar m_menubar @@ -141,519 +143,6 @@ - - - Regulators - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelRegulators - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_REGULATOR; calculator_panels/panel_regulator.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - RF Attenuators - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelAttenuators - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_ATTENUATORS; calculator_panels/panel_attenuators.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - E-Series - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelESeries - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_E_SERIE; calculator_panels/panel_eserie.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - Color Code - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelColorCode - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_COLOR_CODE; calculator_panels/panel_color_code.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - TransLine - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelTransline - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_TRANSLINE; calculator_panels/panel_transline.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - Via Size - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelViaSize - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_VIA_SIZE; calculator_panels/panel_via_size.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - Track Width - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelTrackWidth - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_TRACK_WIDTH; calculator_panels/panel_track_width.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - - - - Electrical Spacing - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelElectricalSpacing - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_ELECTRICAL_SPACING; calculator_panels/panel_electrical_spacing.h; ... - 0 - - - - wxTAB_TRAVERSAL - - - - - Board Classes - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_panelBoardClass - 1 - - - protected - 1 - - Resizable - 1 - - PANEL_BOARD_CLASS; calculator_panels/panel_board_class.h; Not forward_declare - 0 - - - - wxTAB_TRAVERSAL - - diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.h b/pcb_calculator/dialogs/pcb_calculator_frame_base.h index 0757f518c4..d9fa499b62 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.h +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -10,26 +10,13 @@ #include #include #include -#include "calculator_panels/panel_regulator.h" -#include "calculator_panels/panel_attenuators.h" -#include "calculator_panels/panel_eserie.h" -#include "calculator_panels/panel_color_code.h" -#include "calculator_panels/panel_transline.h" -#include "calculator_panels/panel_via_size.h" -#include "calculator_panels/panel_track_width.h" -#include "calculator_panels/panel_electrical_spacing.h" -#include "calculator_panels/panel_board_class.h" #include "kiway_player.h" -#include #include #include #include #include #include -#include -#include -#include -#include +#include #include #include #include @@ -47,17 +34,8 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER protected: wxMenuBar* m_menubar; wxNotebook* m_Notebook; - PANEL_REGULATOR* m_panelRegulators; - PANEL_ATTENUATORS* m_panelAttenuators; - PANEL_E_SERIE* m_panelESeries; - PANEL_COLOR_CODE* m_panelColorCode; - PANEL_TRANSLINE* m_panelTransline; - PANEL_VIA_SIZE* m_panelViaSize; - PANEL_TRACK_WIDTH* m_panelTrackWidth; - PANEL_ELECTRICAL_SPACING* m_panelElectricalSpacing; - PANEL_BOARD_CLASS* m_panelBoardClass; - // Virtual event handlers, overide them in your derived class + // Virtual event handlers, override them in your derived class virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); } virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); } diff --git a/pcb_calculator/params_read_write.cpp b/pcb_calculator/params_read_write.cpp index f3536dae1d..452a5f1fd4 100644 --- a/pcb_calculator/params_read_write.cpp +++ b/pcb_calculator/params_read_write.cpp @@ -83,7 +83,7 @@ double DoubleFromString( const wxString& TextValue ) PANEL_TRANSLINE* getTranslinePanel() { PCB_CALCULATOR_FRAME* frame = (PCB_CALCULATOR_FRAME*) wxTheApp->GetTopWindow(); - return frame->GetPanelTransline(); + return frame->GetCalculator(); } diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index 784bcf1600..8b37384ce8 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -26,6 +26,16 @@ #include "pcb_calculator_frame.h" #include "pcb_calculator_settings.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_CALCULATOR_FRAME_BASE( aParent ), @@ -37,9 +47,29 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include // some methods in code and avoid link errors + AddCalculator( new PANEL_REGULATOR( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "Regulators" ) ); + AddCalculator( new PANEL_ATTENUATORS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "RF Attenuators" ) ); + AddCalculator( new PANEL_E_SERIE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "E-Series" ) ); + AddCalculator( new PANEL_COLOR_CODE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "Color Code" ) ); + AddCalculator( new PANEL_TRANSLINE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "TransLine ") ); + AddCalculator( new PANEL_VIA_SIZE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "Via Size" ) ); + AddCalculator( new PANEL_TRACK_WIDTH( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "Track Width" ) ); + AddCalculator( new PANEL_ELECTRICAL_SPACING( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _( "Electrical Spacing" ) ); + AddCalculator( new PANEL_BOARD_CLASS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), + _("Board Classes") ); + LoadSettings( config() ); - m_panelRegulators->ReadDataFile(); + if( PANEL_REGULATOR* regPanel = GetCalculator() ) + regPanel->ReadDataFile(); // Give an icon wxIcon icon; @@ -75,20 +105,24 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME() } -void PCB_CALCULATOR_FRAME::onThemeChanged( wxSysColourChangedEvent &aEvent ) +void PCB_CALCULATOR_FRAME::AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName ) +{ + // Update internal structures + m_panels.push_back( aPanel ); + m_panelTypes[ typeid( aPanel ).name() ] = aPanel; + + m_Notebook->AddPage( aPanel, panelUIName, false ); +} + + +void PCB_CALCULATOR_FRAME::onThemeChanged( wxSysColourChangedEvent& aEvent ) { // Force the bitmaps to refresh GetBitmapStore()->ThemeChanged(); // Update the panels - m_panelTransline->ThemeChanged(); - m_panelRegulators->ThemeChanged(); - m_panelAttenuators->ThemeChanged(); - m_panelColorCode->ThemeChanged(); - m_panelViaSize->ThemeChanged(); - m_panelTrackWidth->ThemeChanged(); - m_panelElectricalSpacing->ThemeChanged(); - m_panelBoardClass->ThemeChanged(); + for( auto& panel : m_panels ) + panel->ThemeChanged(); aEvent.Skip(); } @@ -100,28 +134,38 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event ) { // Kick all the things that wxWidgets can't seem to redraw on its own. // This is getting seriously ridiculous.... - - wxCommandEvent event2( wxEVT_RADIOBUTTON ); - event2.SetEventObject( m_panelTransline->GetTranslineSelector() ); - event2.SetInt( m_panelTransline->GetCurrTransLineType() ); - m_panelTransline->GetTranslineSelector()->Command( event2 ); - - for( int i = 0; i < m_panelAttenuators->m_AttenuatorList.size(); ++i ) + if( PANEL_TRANSLINE* translinePanel = GetCalculator() ) { - if( m_panelAttenuators->m_AttenuatorList[i] == m_panelAttenuators->m_CurrAttenuator ) - { - event2.SetEventObject( m_panelAttenuators->GetAttenuatorsSelector() ); - event2.SetInt( i ); - m_panelAttenuators->GetAttenuatorsSelector()->Command( event2 ); - break; - } + wxCommandEvent event2( wxEVT_RADIOBUTTON ); + event2.SetEventObject( translinePanel->GetTranslineSelector() ); + event2.SetInt( translinePanel->GetCurrTransLineType() ); + + translinePanel->GetTranslineSelector()->Command( event2 ); } - m_panelAttenuators->UpdateUI(); + if( PANEL_ATTENUATORS* attenPanel = GetCalculator() ) + { + for( int i = 0; i < attenPanel->m_AttenuatorList.size(); ++i ) + { + if( attenPanel->m_AttenuatorList[i] == attenPanel->m_CurrAttenuator ) + { + wxCommandEvent event2( wxEVT_RADIOBUTTON ); + event2.SetEventObject( attenPanel->GetAttenuatorsSelector() ); + event2.SetInt( i ); - m_panelViaSize->Layout(); + attenPanel->GetAttenuatorsSelector()->Command( event2 ); + break; + } + } - m_panelRegulators->Layout(); + attenPanel->UpdateUI(); + } + + if( PANEL_VIA_SIZE* viaSizePanel = GetCalculator() ) + viaSizePanel->Layout(); + + if( PANEL_REGULATOR* regulPanel = GetCalculator() ) + regulPanel->Layout(); // Until it's shown on screen the above won't work; but doing it anyway at least keeps // putting new OnUpdateUI events into the queue until it *is* shown on screen. @@ -132,17 +176,20 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event ) #ifdef __WXMAC__ if( m_macHack ) { - wxSize pageSize = m_panelElectricalSpacing->GetSize(); + if( PANEL_ELECTRICAL_SPACING* elecSpacingPanel = GetCalculator() ) + { + wxSize pageSize = elecSpacingPanel->GetSize(); - pageSize.x -= 100; - m_panelElectricalSpacing->SetSize( pageSize ); - m_panelElectricalSpacing->Layout(); + pageSize.x -= 100; + elecSpacingPanel->SetSize( pageSize ); + elecSpacingPanel->Layout(); - pageSize.x += 100; - m_panelElectricalSpacing->SetSize( pageSize ); - m_panelElectricalSpacing->Layout(); + pageSize.x += 100; + elecSpacingPanel->SetSize( pageSize ); + elecSpacingPanel->Layout(); - m_macHack = false; + m_macHack = false; + } } #endif @@ -154,12 +201,14 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event ) void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event ) { - if( m_panelRegulators->m_RegulatorListChanged ) + PANEL_REGULATOR* regPanel = GetCalculator(); + + if( regPanel && regPanel->m_RegulatorListChanged ) { wxString msg; wxString title = _( "Write Data Failed" ); - if( m_panelRegulators->GetDataFilename().IsEmpty() ) + if( regPanel->GetDataFilename().IsEmpty() ) { msg = _( "No data filename to save modifications.\n" "Do you want to exit and abandon your changes?" ); @@ -169,11 +218,11 @@ void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event ) } else { - if( !m_panelRegulators->WriteDataFile() ) + if( !regPanel->WriteDataFile() ) { msg.Printf( _( "Unable to write file '%s'\n" "Do you want to exit and abandon your changes?"), - m_panelRegulators->GetDataFilename() ); + regPanel->GetDataFilename() ); if( wxMessageBox( msg, title, wxYES_NO | wxICON_ERROR ) == wxNO ) return; @@ -196,22 +245,8 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) m_Notebook->ChangeSelection( cfg->m_LastPage ); - m_panelTransline->LoadSettings( cfg ); - - // Attenuators panel config: - m_panelAttenuators->LoadSettings( cfg ); - - // Regul panel config: - m_panelRegulators->LoadSettings( cfg ); - - // color panel config: - m_panelColorCode->LoadSettings( cfg ); - - m_panelViaSize->LoadSettings( cfg ); - m_panelTrackWidth->LoadSettings( cfg ); - m_panelElectricalSpacing->LoadSettings( cfg ); - m_panelBoardClass->LoadSettings( cfg ); - m_panelESeries->LoadSettings( cfg ); + for( auto& panel : m_panels ) + panel->LoadSettings( cfg ); } @@ -229,14 +264,8 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) { cfg->m_LastPage = m_Notebook->GetSelection(); - m_panelTransline->SaveSettings( cfg ); - m_panelRegulators->Regulators_WriteConfig( cfg ); - m_panelAttenuators->SaveSettings( cfg ); - m_panelColorCode->SaveSettings( cfg ); - m_panelViaSize->SaveSettings( cfg ); - m_panelTrackWidth->SaveSettings( cfg ); - m_panelElectricalSpacing->SaveSettings( cfg ); - m_panelBoardClass->SaveSettings( cfg ); + for( auto& panel : m_panels ) + panel->SaveSettings( cfg ); } } diff --git a/pcb_calculator/pcb_calculator_frame.h b/pcb_calculator/pcb_calculator_frame.h index 1b58924f5e..07c67ebbae 100644 --- a/pcb_calculator/pcb_calculator_frame.h +++ b/pcb_calculator/pcb_calculator_frame.h @@ -20,6 +20,7 @@ #ifndef PCB_CALCULATOR_H #define PCB_CALCULATOR_H +#include "calculator_panels/calculator_panel.h" #include "pcb_calculator_frame_base.h" class APP_SETTINGS_BASE; @@ -42,8 +43,21 @@ public: return nullptr; } - // Accessor: - PANEL_TRANSLINE* GetPanelTransline() { return m_panelTransline; } + /* + * Return the panel of given type or nullptr if there is no such panel exists. + */ + template + T* GetCalculator() + { + std::map::iterator panel = m_panelTypes.find( typeid( T ).name() ); + + if( panel != m_panelTypes.end() ) + return static_cast( panel->second ); + + return nullptr; + } + + void AddCalculator( CALCULATOR_PANEL *aPanel, const wxString& panelUIName ); private: // Event handlers @@ -51,7 +65,7 @@ private: void OnUpdateUI( wxUpdateUIEvent& event ) override; - void onThemeChanged( wxSysColourChangedEvent &aEvent ); + void onThemeChanged( wxSysColourChangedEvent& aEvent ); // Config read-write, virtual from EDA_BASE_FRAME void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; @@ -60,6 +74,11 @@ private: private: int m_lastNotebookPage; bool m_macHack; + + std::vector m_panels; + std::map m_panelTypes; + + };