diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 0371015355..4adb28ca60 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -159,6 +159,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame wxSize( m_FrameSize.x, m_MsgFrameHeight ) ); m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() ); + + Connect( wxEVT_ACTIVATE, wxActivateEventHandler( EDA_DRAW_FRAME::onActivate ), NULL, this ); + Connect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_FRAME::onIdle ), NULL, this ); } @@ -187,6 +190,29 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME() m_auimgr.UnInit(); ReleaseFile(); + + Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( EDA_DRAW_FRAME::onActivate ), NULL, this ); + Disconnect( wxEVT_IDLE, wxIdleEventHandler( EDA_DRAW_FRAME::onIdle ), NULL, this ); +} + + +void EDA_DRAW_FRAME::onActivate( wxActivateEvent& event ) +{ +#ifdef __WXMAC__ + // Work around wxWidgets bug where the OSX Preferences item gets lost when reactivating + // a draw frame... + m_menuBarDirty = true; +#endif +} + + +void EDA_DRAW_FRAME::onIdle( wxIdleEvent& event ) +{ + if( m_menuBarDirty ) + { + m_menuBarDirty = false; + ReCreateMenuBar(); + } } diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 0857a862b3..b35fac09b6 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -114,6 +114,7 @@ protected: bool m_showBorderAndTitleBlock; // Show the worksheet (border and title block). long m_firstRunDialogSetting; // Show first run dialog on startup + bool m_menuBarDirty; wxChoice* m_gridSelectBox; wxChoice* m_zoomSelectBox; @@ -132,6 +133,9 @@ protected: /// The current canvas type EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType; + void onActivate( wxActivateEvent& event ); + void onIdle( wxIdleEvent& event ); + virtual void SetScreen( BASE_SCREEN* aScreen ) { m_currentScreen = aScreen; } double bestZoom( double sizeX, double sizeY, double scaleFactor, wxPoint centre ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 31e89dedfa..f0c690c721 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -515,7 +515,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() SetMenuBar( menuBar ); delete oldMenuBar; - m_menuBarDirty = false; #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) // Populate the Action Plugin sub-menu diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 6880a6fc81..919d198876 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -111,8 +111,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_CHOICE( ID_ON_ZOOM_SELECT, PCB_EDIT_FRAME::OnSelectZoom ) EVT_CHOICE( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid ) - EVT_ACTIVATE( PCB_EDIT_FRAME::OnActivate ) - EVT_IDLE( PCB_EDIT_FRAME::OnIdle ) EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow ) EVT_SIZE( PCB_EDIT_FRAME::OnSize ) @@ -461,22 +459,6 @@ void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event ) } -void PCB_EDIT_FRAME::OnActivate( wxActivateEvent& event ) -{ -#ifdef __WXMAC__ - // Work around wxWidgets bug where the Preferences item gets lost... - m_menuBarDirty = true; -#endif -} - - -void PCB_EDIT_FRAME::OnIdle( wxIdleEvent& event ) -{ - if( m_menuBarDirty ) - ReCreateMenuBar(); -} - - void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) { if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() ) diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 922739e30a..d00fa50330 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -280,7 +280,6 @@ public: wxChoice* m_SelTrackWidthBox; // a choice box to display and select current track width wxChoice* m_SelViaSizeBox; // a choice box to display and select current via diameter - bool m_menuBarDirty; bool m_show_microwave_tools; bool m_show_layer_manager_tools; @@ -299,9 +298,6 @@ public: */ void LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter ); - void OnActivate( wxActivateEvent& event ); - void OnIdle( wxIdleEvent& event ); - void OnQuit( wxCommandEvent& event ); /**