pcb_calculator: Remove form builder main window

The form builder window only contained the notebook control, so it was
basically pointless. This removes the base frame and instead makes
PCB_CALCULATOR_FRAME inherit directly from KIWAY_PLAYER.
This commit is contained in:
Ian McInerney 2021-10-08 18:28:10 +01:00
parent 0a1a181798
commit 288a94f5aa
6 changed files with 66 additions and 275 deletions

View File

@ -44,7 +44,6 @@ set( PCB_CALCULATOR_SRCS
transline/twistedpair.cpp transline/twistedpair.cpp
transline_dlg_funct.cpp transline_dlg_funct.cpp
attenuators/attenuator_classes.cpp attenuators/attenuator_classes.cpp
dialogs/pcb_calculator_frame_base.cpp
dialogs/dialog_regulator_form_base.cpp dialogs/dialog_regulator_form_base.cpp
dialogs/dialog_regulator_form.cpp dialogs/dialog_regulator_form.cpp
../common/env_vars.cpp # needed on MSW to avoid a link issue (a symbol not found) ../common/env_vars.cpp # needed on MSW to avoid a link issue (a symbol not found)

View File

@ -1,43 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "pcb_calculator_frame_base.h"
///////////////////////////////////////////////////////////////////////////
PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : KIWAY_PLAYER( parent, id, title, pos, size, style, name )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
m_menubar = new wxMenuBar( 0 );
this->SetMenuBar( m_menubar );
wxBoxSizer* bmainFrameSizer;
bmainFrameSizer = new wxBoxSizer( wxVERTICAL );
m_Notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
bmainFrameSizer->Add( m_Notebook, 1, wxEXPAND, 5 );
this->SetSizer( bmainFrameSizer );
this->Layout();
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME_BASE::OnClosePcbCalc ) );
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME_BASE::OnUpdateUI ) );
}
PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME_BASE::OnClosePcbCalc ) );
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME_BASE::OnUpdateUI ) );
}

View File

@ -1,151 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_php_events">0</property>
<property name="disconnect_python_events">0</property>
<property name="embedded_files_path">res</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">pcb_calculator_frame_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">pcb_calculator_frame_base</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_lua_events">1</property>
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">PCB_CALCULATOR_FRAME_BASE</property>
<property name="pos"></property>
<property name="size">646,361</property>
<property name="style">wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">KIWAY_PLAYER; kiway_player.h</property>
<property name="title">PCB Calculator</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name">pcb_calculator</property>
<property name="window_style">wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL</property>
<property name="xrc_skip_sizer">1</property>
<event name="OnClose">OnClosePcbCalc</event>
<event name="OnUpdateUI">OnUpdateUI</event>
<object class="wxMenuBar" expanded="0">
<property name="bg"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_menubar</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bmainFrameSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxNotebook" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmapsize"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Notebook</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>

View File

@ -1,50 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "kiway_player.h"
#include <wx/menu.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/notebook.h>
#include <wx/sizer.h>
#include <wx/frame.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class PCB_CALCULATOR_FRAME_BASE
///////////////////////////////////////////////////////////////////////////////
class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER
{
private:
protected:
wxMenuBar* m_menubar;
wxNotebook* m_Notebook;
// Virtual event handlers, override them in your derived class
virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
public:
PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Calculator"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 646,361 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL, const wxString& name = wxT("pcb_calculator") );
~PCB_CALCULATOR_FRAME_BASE();
};

View File

@ -17,14 +17,19 @@
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <wx/menu.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include <wx/notebook.h>
#include <wx/sizer.h>
#include <bitmaps.h> #include <bitmaps.h>
#include <bitmap_store.h> #include <bitmap_store.h>
#include <geometry/shape_poly_set.h> #include <geometry/shape_poly_set.h>
#include <kiface_base.h> #include <kiface_base.h>
#include "attenuators/attenuator_classes.h"
#include "pcb_calculator_frame.h" #include <attenuators/attenuator_classes.h>
#include "pcb_calculator_settings.h" #include <pcb_calculator_frame.h>
#include <pcb_calculator_settings.h>
#include <calculator_panels/panel_attenuators.h> #include <calculator_panels/panel_attenuators.h>
#include <calculator_panels/panel_board_class.h> #include <calculator_panels/panel_board_class.h>
@ -38,32 +43,51 @@
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
PCB_CALCULATOR_FRAME_BASE( aParent ), KIWAY_PLAYER( aParent, wxID_ANY,
_( "PCB Calculator" ), // Window title
wxDefaultPosition,
wxSize( 646,361 ), // Default size
wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL,
wxT( "pcb_calculator" ) ), // Window name
m_lastNotebookPage( -1 ), m_lastNotebookPage( -1 ),
m_macHack( true ) m_macHack( true )
{ {
SetKiway( this, aKiway );
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
// some methods in code and avoid link errors // some methods in code and avoid link errors
AddCalculator( new PANEL_REGULATOR( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), SetKiway( this, aKiway );
SetSizeHints( wxDefaultSize, wxDefaultSize );
m_menubar = new wxMenuBar( 0 );
SetMenuBar( m_menubar );
m_mainSizer = new wxBoxSizer( wxVERTICAL );
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_mainSizer->Add( m_notebook, 1, wxEXPAND, 5 );
SetSizer( m_mainSizer );
Layout();
Centre( wxBOTH );
AddCalculator( new PANEL_REGULATOR( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Regulators" ) ); _( "Regulators" ) );
AddCalculator( new PANEL_ATTENUATORS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_ATTENUATORS( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "RF Attenuators" ) ); _( "RF Attenuators" ) );
AddCalculator( new PANEL_E_SERIE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_E_SERIE( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "E-Series" ) ); _( "E-Series" ) );
AddCalculator( new PANEL_COLOR_CODE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_COLOR_CODE( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Color Code" ) ); _( "Color Code" ) );
AddCalculator( new PANEL_TRANSLINE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_TRANSLINE( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "TransLine ") ); _( "TransLine ") );
AddCalculator( new PANEL_VIA_SIZE( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_VIA_SIZE( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Via Size" ) ); _( "Via Size" ) );
AddCalculator( new PANEL_TRACK_WIDTH( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_TRACK_WIDTH( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Track Width" ) ); _( "Track Width" ) );
AddCalculator( new PANEL_ELECTRICAL_SPACING( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_ELECTRICAL_SPACING( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Electrical Spacing" ) ); _( "Electrical Spacing" ) );
AddCalculator( new PANEL_BOARD_CLASS( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_BOARD_CLASS( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_("Board Classes") ); _("Board Classes") );
LoadSettings( config() ); LoadSettings( config() );
@ -92,6 +116,10 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
if( m_framePos == wxDefaultPosition ) if( m_framePos == wxDefaultPosition )
Centre(); Centre();
// Connect Events
Bind( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME::OnClosePcbCalc ), this );
Bind( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PCB_CALCULATOR_FRAME::OnUpdateUI ), this );
Bind( wxEVT_SYS_COLOUR_CHANGED, Bind( wxEVT_SYS_COLOUR_CHANGED,
wxSysColourChangedEventHandler( PCB_CALCULATOR_FRAME::onThemeChanged ), this ); wxSysColourChangedEventHandler( PCB_CALCULATOR_FRAME::onThemeChanged ), this );
} }
@ -111,7 +139,7 @@ void PCB_CALCULATOR_FRAME::AddCalculator( CALCULATOR_PANEL *aPanel, const wxStri
m_panels.push_back( aPanel ); m_panels.push_back( aPanel );
m_panelTypes[ typeid( aPanel ).name() ] = aPanel; m_panelTypes[ typeid( aPanel ).name() ] = aPanel;
m_Notebook->AddPage( aPanel, panelUIName, false ); m_notebook->AddPage( aPanel, panelUIName, false );
} }
@ -130,7 +158,7 @@ void PCB_CALCULATOR_FRAME::onThemeChanged( wxSysColourChangedEvent& aEvent )
void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event ) void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
{ {
if( m_Notebook->GetSelection() != m_lastNotebookPage ) if( m_notebook->GetSelection() != m_lastNotebookPage )
{ {
// Kick all the things that wxWidgets can't seem to redraw on its own. // Kick all the things that wxWidgets can't seem to redraw on its own.
// This is getting seriously ridiculous.... // This is getting seriously ridiculous....
@ -169,7 +197,7 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
// Until it's shown on screen the above won't work; but doing it anyway at least keeps // 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. // putting new OnUpdateUI events into the queue until it *is* shown on screen.
if( m_Notebook->IsShownOnScreen() ) if( m_notebook->IsShownOnScreen() )
{ {
// Work around an OSX bug where the wxGrid children don't get placed correctly until // Work around an OSX bug where the wxGrid children don't get placed correctly until
// the first resize event. // the first resize event.
@ -193,7 +221,7 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
} }
#endif #endif
m_lastNotebookPage = m_Notebook->GetSelection(); m_lastNotebookPage = m_notebook->GetSelection();
} }
} }
} }
@ -243,7 +271,7 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
PCB_CALCULATOR_SETTINGS* cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( aCfg ); PCB_CALCULATOR_SETTINGS* cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( aCfg );
m_Notebook->ChangeSelection( cfg->m_LastPage ); m_notebook->ChangeSelection( cfg->m_LastPage );
for( auto& panel : m_panels ) for( auto& panel : m_panels )
panel->LoadSettings( cfg ); panel->LoadSettings( cfg );
@ -262,7 +290,7 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
if( cfg ) if( cfg )
{ {
cfg->m_LastPage = m_Notebook->GetSelection(); cfg->m_LastPage = m_notebook->GetSelection();
for( auto& panel : m_panels ) for( auto& panel : m_panels )
panel->SaveSettings( cfg ); panel->SaveSettings( cfg );

View File

@ -17,11 +17,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PCB_CALCULATOR_H #ifndef PCB_CALCULATOR_FRAME_H_
#define PCB_CALCULATOR_H #define PCB_CALCULATOR_FRAME_H_
#include "calculator_panels/calculator_panel.h" #include <calculator_panels/calculator_panel.h>
#include "pcb_calculator_frame_base.h" #include <kiway_player.h>
class wxMenuBar;
class wxNotebook;
class wxBoxSizer;
class APP_SETTINGS_BASE; class APP_SETTINGS_BASE;
class KIWAY; class KIWAY;
@ -31,7 +35,7 @@ class PANEL_TRANSLINE;
/** /**
* PCB calculator the main frame. * PCB calculator the main frame.
*/ */
class PCB_CALCULATOR_FRAME : public PCB_CALCULATOR_FRAME_BASE class PCB_CALCULATOR_FRAME : public KIWAY_PLAYER
{ {
public: public:
PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ); PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent );
@ -61,9 +65,9 @@ public:
private: private:
// Event handlers // Event handlers
void OnClosePcbCalc( wxCloseEvent& event ) override; void OnClosePcbCalc( wxCloseEvent& event );
void OnUpdateUI( wxUpdateUIEvent& event ) override; void OnUpdateUI( wxUpdateUIEvent& event );
void onThemeChanged( wxSysColourChangedEvent& aEvent ); void onThemeChanged( wxSysColourChangedEvent& aEvent );
@ -72,8 +76,12 @@ private:
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;
private: private:
int m_lastNotebookPage; wxMenuBar* m_menubar;
bool m_macHack; wxNotebook* m_notebook;
wxBoxSizer* m_mainSizer;
int m_lastNotebookPage;
bool m_macHack;
std::vector<CALCULATOR_PANEL*> m_panels; std::vector<CALCULATOR_PANEL*> m_panels;
std::map<const char*, CALCULATOR_PANEL*> m_panelTypes; std::map<const char*, CALCULATOR_PANEL*> m_panelTypes;