From 34857d06c46e3f4c921729d99d05a73ebb9a080b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Jul 2018 15:48:35 +0100 Subject: [PATCH] Create CvPcb's footprint viewer through Kiway().Player() This allows it to participate in Kiway things such as updating language or common settings. Fixes: lp:1779558 * https://bugs.launchpad.net/kicad/+bug/1779558 (cherry picked from commit b3f8478) --- common/draw_panel.cpp | 11 +++-------- common/eda_base_frame.cpp | 16 +++++++++++----- cvpcb/cvpcb.cpp | 10 +++++----- cvpcb/cvpcb_mainframe.cpp | 2 +- cvpcb/display_footprints_frame.cpp | 7 +++---- cvpcb/display_footprints_frame.h | 23 +++++++++-------------- 6 files changed, 32 insertions(+), 37 deletions(-) diff --git a/common/draw_panel.cpp b/common/draw_panel.cpp index 2d22268821..f6a8eae62d 100644 --- a/common/draw_panel.cpp +++ b/common/draw_panel.cpp @@ -121,14 +121,9 @@ EDA_DRAW_PANEL::EDA_DRAW_PANEL( EDA_DRAW_FRAME* parent, int id, m_mouseCaptureCallback = NULL; m_endMouseCaptureCallback = NULL; - wxConfigBase* cfg = Kiface().KifaceSettings(); - - if( cfg ) - { - cfg->Read( ENBL_MOUSEWHEEL_PAN_KEY, &m_enableMousewheelPan, false ); - cfg->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false ); - cfg->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true ); - } + Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &m_enableMousewheelPan, false ); + Pgm().CommonSettings()->Read( ENBL_ZOOM_NO_CENTER_KEY, &m_enableZoomNoCenter, false ); + Pgm().CommonSettings()->Read( ENBL_AUTO_PAN_KEY, &m_enableAutoPan, true ); m_requestAutoPan = false; m_enableBlockCommands = false; diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 7417ba9d64..6354e068ad 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -252,8 +252,11 @@ void EDA_BASE_FRAME::ReCreateMenuBar() void EDA_BASE_FRAME::ShowChangedLanguage() { - ReCreateMenuBar(); - GetMenuBar()->Refresh(); + if( GetMenuBar() ) + { + ReCreateMenuBar(); + GetMenuBar()->Refresh(); + } } @@ -263,9 +266,12 @@ void EDA_BASE_FRAME::CommonSettingsChanged() Pgm().CommonSettings()->Read( AUTOSAVE_INTERVAL_KEY, &autosaveInterval ); SetAutoSaveInterval( autosaveInterval ); - // For icons in menus & icon scaling - ReCreateMenuBar(); - GetMenuBar()->Refresh(); + if( GetMenuBar() ) + { + // For icons in menus & icon scaling + ReCreateMenuBar(); + GetMenuBar()->Refresh(); + } } diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index bc167ebb5a..c81dfd6038 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -65,11 +66,10 @@ static struct IFACE : public KIFACE_I switch( aClassId ) { case FRAME_CVPCB: - { - CVPCB_MAINFRAME* frame = new CVPCB_MAINFRAME( aKiway, aParent ); - return frame; - } - break; + return new CVPCB_MAINFRAME( aKiway, aParent ); + + case FRAME_CVPCB_DISPLAY: + return new DISPLAY_FOOTPRINTS_FRAME( aKiway, aParent ); default: ; diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 3041f1dce8..72c4594af5 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -836,7 +836,7 @@ void CVPCB_MAINFRAME::CreateScreenCmp() if( !fpframe ) { - fpframe = new DISPLAY_FOOTPRINTS_FRAME( &Kiway(), this ); + fpframe = (DISPLAY_FOOTPRINTS_FRAME*) Kiway().Player( FRAME_CVPCB_DISPLAY, true, this ); fpframe->Show( true ); } else diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index beea4f36e4..6f4483e8c1 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -72,10 +72,10 @@ BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME ) END_EVENT_TABLE() -DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRAME* aParent ) : +DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_BASE_FRAME( aKiway, aParent, FRAME_CVPCB_DISPLAY, _( "Footprint Viewer" ), - wxDefaultPosition, wxDefaultSize, - KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME ) + wxDefaultPosition, wxDefaultSize, + KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME ) { m_showAxis = true; // true to draw axis. @@ -259,7 +259,6 @@ void DISPLAY_FOOTPRINTS_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent ) aEvent.Check( displ_opts->m_DisplayModTextFill == SKETCH ); m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] ); - } diff --git a/cvpcb/display_footprints_frame.h b/cvpcb/display_footprints_frame.h index a823531abd..6246de1b04 100644 --- a/cvpcb/display_footprints_frame.h +++ b/cvpcb/display_footprints_frame.h @@ -42,8 +42,8 @@ class CVPCB_MAINFRAME; class DISPLAY_FOOTPRINTS_FRAME : public PCB_BASE_FRAME { public: - DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRAME* aParent ); - ~DISPLAY_FOOTPRINTS_FRAME(); + DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aParent ); + ~DISPLAY_FOOTPRINTS_FRAME() override; void OnCloseWindow( wxCloseEvent& Event ) override; @@ -55,7 +55,6 @@ public: void ReCreateHToolbar() override; void ReCreateVToolbar() override; void ReCreateOptToolbar() override; - void RecreateMenuBar(); void OnSelectOptionToolbar( wxCommandEvent& event ); @@ -74,7 +73,7 @@ public: * Function IsGridVisible() , virtual * @return true if the grid must be shown */ - virtual bool IsGridVisible() const override; + bool IsGridVisible() const override; /** * Function SetGridVisibility() , virtual @@ -82,12 +81,12 @@ public: * if you want to store/retrieve the grid visibility in configuration. * @param aVisible = true if the grid must be shown */ - virtual void SetGridVisibility( bool aVisible ) override; + void SetGridVisibility( bool aVisible ) override; /** * Function GetGridColor() , virtual * @return the color of the grid */ - virtual COLOR4D GetGridColor() override; + COLOR4D GetGridColor() override; void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override; void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override; @@ -99,8 +98,6 @@ public: ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override { return NULL; } - void Process_Settings( wxCommandEvent& event ); - /** * Display 3D frame of current footprint selection. */ @@ -110,9 +107,8 @@ public: * currently: do nothing in CvPcb. * but but be defined because it is a pure virtual in PCB_BASE_FRAME */ - virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, - UNDO_REDO_T aTypeCommand = UR_UNSPECIFIED, - const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override + void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy, UNDO_REDO_T aTypeCommand = UR_UNSPECIFIED, + const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override { } @@ -126,9 +122,8 @@ public: * @param aTransformPoint = the reference point of the transformation, * for commands like move */ - virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, - UNDO_REDO_T aTypeCommand, - const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override + void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, + const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override { // currently: do nothing in CvPcb. }