diff --git a/common/bitmap.cpp b/common/bitmap.cpp index 318bacb045..69d19ea4b1 100644 --- a/common/bitmap.cpp +++ b/common/bitmap.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include struct SCALED_BITMAP_ID { diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 16d41a5edf..348c899159 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -65,15 +65,16 @@ END_EVENT_TABLE() DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title, - const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : - wxDialog( aParent, id, title, pos, size, style, name ), - KIWAY_HOLDER( nullptr ), - m_units( MILLIMETRES ), - m_firstPaintEvent( true ), - m_initialFocusTarget( nullptr ), - m_qmodal_loop( nullptr ), - m_qmodal_showing( false ), - m_qmodal_parent_disabler( nullptr ) + const wxPoint& pos, const wxSize& size, long style, + const wxString& name ) : + wxDialog( aParent, id, title, pos, size, style, name ), + KIWAY_HOLDER( nullptr, KIWAY_HOLDER::DIALOG ), + m_units( MILLIMETRES ), + m_firstPaintEvent( true ), + m_initialFocusTarget( nullptr ), + m_qmodal_loop( nullptr ), + m_qmodal_showing( false ), + m_qmodal_parent_disabler( nullptr ) { KIWAY_HOLDER* kiwayHolder = nullptr; @@ -88,34 +89,34 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl } } - if( kiwayHolder ) - { - // Inherit units from parent - m_units = kiwayHolder->GetUserUnits(); + // Inherit units from parent + if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::FRAME ) + m_units = static_cast( kiwayHolder )->GetUserUnits(); + else if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::DIALOG ) + m_units = static_cast( kiwayHolder )->GetUserUnits(); - // Don't mouse-warp after a dialog run from the context menu - TOOL_MANAGER* toolMgr = kiwayHolder->GetToolManager(); + // Don't mouse-warp after a dialog run from the context menu + if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::FRAME ) + { + TOOL_MANAGER* toolMgr = static_cast( kiwayHolder )->GetToolManager(); if( toolMgr ) toolMgr->VetoContextMenuMouseWarp(); + } - // Set up the message bus + // Set up the message bus + if( kiwayHolder ) SetKiway( this, &kiwayHolder->Kiway() ); - } Bind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this ); Bind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this ); #ifdef __WINDOWS__ - // On Windows, the app top windows can be brought to the foreground - // (at least temporary) in certain circumstances, - // for instance when calling an external tool in Eeschema BOM generation. - // So set the parent KIWAY_PLAYER kicad frame (if exists) to top window - // to avoid this annoying behavior - KIWAY_PLAYER* parent_kiwayplayer = dynamic_cast( aParent ); - - if( parent_kiwayplayer ) - Pgm().App().SetTopWindow( parent_kiwayplayer ); + // On Windows, the app top windows can be brought to the foreground (at least temporarily) + // in certain circumstances such as when calling an external tool in Eeschema BOM generation. + // So set the parent frame (if exists) to top window to avoid this annoying behavior. + if( kiwayHolder && kiwayHolder->GetType() == KIWAY_HOLDER::FRAME ) + Pgm().App().SetTopWindow( (EDA_BASE_FRAME*) kiwayHolder ); #endif Connect( wxEVT_PAINT, wxPaintEventHandler( DIALOG_SHIM::OnPaint ) ); diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index c78eceb791..ce48f283a1 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/dialogs/dialog_print_generic.cpp b/common/dialogs/dialog_print_generic.cpp index d5313de826..b3347fc141 100644 --- a/common/dialogs/dialog_print_generic.cpp +++ b/common/dialogs/dialog_print_generic.cpp @@ -19,7 +19,7 @@ #include "dialog_print_generic.h" #include -#include +#include #include #include diff --git a/common/displlst.cpp b/common/displlst.cpp index 7b046cdd5f..d7b9bff3cb 100644 --- a/common/displlst.cpp +++ b/common/displlst.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index da01d56491..8088ca499f 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -24,7 +24,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 816904c1c9..b707d14dce 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -80,9 +80,10 @@ BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame ) END_EVENT_TABLE() EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, - const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString& aFrameName ) : - wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ) + const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, + long aStyle, const wxString& aFrameName, KIWAY* aKiway ) : + wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ), + KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ) { m_Ident = aFrameType; m_hasAutoSave = false; diff --git a/common/eda_dde.cpp b/common/eda_dde.cpp index 0d86d2f7a8..e125a01740 100644 --- a/common/eda_dde.cpp +++ b/common/eda_dde.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/eda_dockart.cpp b/common/eda_dockart.cpp index 7bca5f5aac..2e93170b13 100644 --- a/common/eda_dockart.cpp +++ b/common/eda_dockart.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include void EDA_DOCKART::DrawBorder( wxDC& aDC, wxWindow* aWindow, const wxRect& aRect, wxAuiPaneInfo& aPane ) diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 6c3a3a47b0..af3e0cc60a 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/hotkeys_basic.cpp b/common/hotkeys_basic.cpp index 0827ac84f7..cef95dacf5 100644 --- a/common/hotkeys_basic.cpp +++ b/common/hotkeys_basic.cpp @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include diff --git a/common/kiway_holder.cpp b/common/kiway_holder.cpp index de66fb5a82..b2f630e3f5 100644 --- a/common/kiway_holder.cpp +++ b/common/kiway_holder.cpp @@ -37,18 +37,6 @@ PROJECT& KIWAY_HOLDER::Prj() const } -EDA_UNITS_T KIWAY_HOLDER::GetUserUnits() const -{ - return MILLIMETRES; -} - - -TOOL_MANAGER* KIWAY_HOLDER::GetToolManager() const -{ - return nullptr; -} - - // this is not speed critical, hide it out of line. void KIWAY_HOLDER::SetKiway( wxWindow* aDest, KIWAY* aKiway ) { diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index 4784d33820..51f2fc362b 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -43,8 +43,7 @@ END_EVENT_TABLE() KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aWdoName ) : - EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName ), - KIWAY_HOLDER( aKiway ), + EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName, aKiway ), m_modal( false ), m_modal_loop( 0 ), m_modal_resultant_parent( 0 ) { @@ -55,8 +54,7 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aWdoName ) : - EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName ), - KIWAY_HOLDER( 0 ), + EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName, nullptr ), m_modal( false ), m_modal_loop( 0 ), m_modal_resultant_parent( 0 ), diff --git a/common/origin_viewitem.cpp b/common/origin_viewitem.cpp index ad56aacaea..5eb6145e64 100644 --- a/common/origin_viewitem.cpp +++ b/common/origin_viewitem.cpp @@ -22,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include diff --git a/common/page_layout/ws_painter.cpp b/common/page_layout/ws_painter.cpp index f5c9251e60..da7158589b 100644 --- a/common/page_layout/ws_painter.cpp +++ b/common/page_layout/ws_painter.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/page_layout/ws_proxy_undo_item.cpp b/common/page_layout/ws_proxy_undo_item.cpp index ef12435e19..d98afe1eb7 100644 --- a/common/page_layout/ws_proxy_undo_item.cpp +++ b/common/page_layout/ws_proxy_undo_item.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include using namespace KIGFX; diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 182d56da4d..35d6e2f55a 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/status_popup.cpp b/common/status_popup.cpp index 6d3cb53427..c96ca3d3ef 100644 --- a/common/status_popup.cpp +++ b/common/status_popup.cpp @@ -27,7 +27,7 @@ */ #include -#include +#include STATUS_POPUP::STATUS_POPUP( wxWindow* aParent ) : wxPopupWindow( aParent ), diff --git a/common/tool/action_manager.cpp b/common/tool/action_manager.cpp index bf76556ab4..b12c036974 100644 --- a/common/tool/action_manager.cpp +++ b/common/tool/action_manager.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index d03b18c409..75eb61db9e 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -22,7 +22,7 @@ */ #include -#include +#include #include #include #include diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 90599ce426..9086927c55 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/common/tool/grid_menu.cpp b/common/tool/grid_menu.cpp index 40221b55d2..680450d820 100644 --- a/common/tool/grid_menu.cpp +++ b/common/tool/grid_menu.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/tool/tool_base.cpp b/common/tool/tool_base.cpp index 314760975e..828b919add 100644 --- a/common/tool/tool_base.cpp +++ b/common/tool/tool_base.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include bool TOOL_BASE::IsToolActive() const diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 4b71e555b2..f495168e44 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index a3353a7bd3..a31a27a6c2 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include /// Struct describing the current execution state of a TOOL struct TOOL_MANAGER::TOOL_STATE diff --git a/common/tool/tool_menu.cpp b/common/tool/tool_menu.cpp index 22433d8f66..90a41edf74 100644 --- a/common/tool/tool_menu.cpp +++ b/common/tool/tool_menu.cpp @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include +#include #include #include #include diff --git a/common/tool/zoom_menu.cpp b/common/tool/zoom_menu.cpp index 0b4c9ef5f1..61a9b0e40b 100644 --- a/common/tool/zoom_menu.cpp +++ b/common/tool/zoom_menu.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/common/tool/zoom_tool.cpp b/common/tool/zoom_tool.cpp index c07df2131b..abd7e0eb1c 100644 --- a/common/tool/zoom_tool.cpp +++ b/common/tool/zoom_tool.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 34caf4910a..796c2be15d 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include "widgets/unit_binder.h" diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 67ccf0e2b7..aed93cbbd4 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -28,7 +28,7 @@ #include -#include +#include #include diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h index ee5292d37c..8fc542ae65 100644 --- a/eeschema/sch_base_frame.h +++ b/eeschema/sch_base_frame.h @@ -26,7 +26,7 @@ #define SCH_BASE_FRAME_H_ #include -#include +#include #include #include diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index dd6844b1d1..442af17cfd 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -103,7 +103,7 @@ static GRID_TYPE SchematicGridList[] = { SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) : BASE_SCREEN( SCH_SCREEN_T ), - KIWAY_HOLDER( aKiway ), + KIWAY_HOLDER( aKiway, KIWAY_HOLDER::HOLDER_TYPE::SCREEN ), m_paper( wxT( "A4" ) ) { m_modification_sync = 0; diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index 582448d4aa..d83ed3bd6e 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -22,16 +22,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file sch_screen.h - * @brief Definitions for the Eeschema program SCH_SCREEN class. - */ - #ifndef SCREEN_H #define SCREEN_H #include - #include #include #include @@ -39,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index e2332479fb..43f4de8f63 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -114,7 +114,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame // Force the frame name used in config. the lib viewer frame has a name // depending on aFrameType (needed to identify the frame by wxWidgets), // but only one configuration is preferable. - m_configFrameName = LIB_VIEW_NAME; + m_configName = LIB_VIEW_NAME; // Give an icon wxIcon icon; diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index 1756acacf3..2ac8f66284 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway, diff --git a/eeschema/widgets/widget_eeschema_color_config.cpp b/eeschema/widgets/widget_eeschema_color_config.cpp index 41e97f71cd..90017cb664 100644 --- a/eeschema/widgets/widget_eeschema_color_config.cpp +++ b/eeschema/widgets/widget_eeschema_color_config.cpp @@ -26,7 +26,7 @@ */ #include -#include +#include #include #include #include diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 6ff849fb6c..2e9a4d002e 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/base_screen.h b/include/base_screen.h index beccd8fd2d..763e9bdf64 100644 --- a/include/base_screen.h +++ b/include/base_screen.h @@ -31,7 +31,7 @@ #ifndef BASE_SCREEN_H #define BASE_SCREEN_H -#include +#include #include #include #include diff --git a/include/dialog_shim.h b/include/dialog_shim.h index 0cb58c29b5..0134ffab6f 100644 --- a/include/dialog_shim.h +++ b/include/dialog_shim.h @@ -130,7 +130,7 @@ public: void OnPaint( wxPaintEvent &event ); - EDA_UNITS_T GetUserUnits() const override { return m_units; } + EDA_UNITS_T GetUserUnits() const { return m_units; } protected: diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 1c5c23a36e..3c70f91095 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -48,6 +48,7 @@ #include #include "hotkeys_basic.h" #include +#include #ifdef USE_WX_OVERLAY #include @@ -98,7 +99,7 @@ enum id_librarytype { * and that class is not a player. *

*/ -class EDA_BASE_FRAME : public wxFrame +class EDA_BASE_FRAME : public wxFrame, public KIWAY_HOLDER { /** * (with its unexpected name so it does not collide with the real OnWindowClose() @@ -115,32 +116,29 @@ class EDA_BASE_FRAME : public wxFrame wxWindow* findQuasiModalDialog(); protected: - FRAME_T m_Ident; ///< Id Type (pcb, schematic, library..) + FRAME_T m_Ident; // Id Type (pcb, schematic, library..) wxPoint m_FramePos; wxSize m_FrameSize; - wxString m_configFrameName; ///< prefix used in config to identify some params (frame size...) - ///< if empty, the frame name defined in CTOR is used - - wxString m_AboutTitle; ///< Name of program displayed in About. + wxString m_AboutTitle; // Name of program displayed in About. wxAuiManager m_auimgr; - /// Flag to indicate if this frame supports auto save. - bool m_hasAutoSave; + wxString m_configName; // prefix used to identify some params (frame size...) + // and to name some config files (legacy hotkey files) - /// Flag to indicate the last auto save state. - bool m_autoSaveState; + TOOL_MANAGER* m_toolManager; - /// The auto save interval time in seconds. - int m_autoSaveInterval; - - /// The timer used to implement the auto save feature; + bool m_hasAutoSave; + bool m_autoSaveState; + int m_autoSaveInterval; // The auto save interval time in seconds. wxTimer* m_autoSaveTimer; - wxString m_perspective; ///< wxAuiManager perspective. + wxString m_perspective; // wxAuiManager perspective. + + wxString m_mruPath; // Most recently used path. - wxString m_mruPath; ///< Most recently used path. + EDA_UNITS_T m_UserUnits; ///> Default style flags used for wxAUI toolbars static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND; @@ -189,15 +187,40 @@ protected: virtual wxString help_name(); + /** + * Called when when the units setting has changed to allow for any derived classes + * to handle refreshing and controls that have units based measurements in them. The + * default version only updates the status bar. Don't forget to call the default + * in your derived class or the status bar will not get updated properly. + */ + virtual void unitsChangeRefresh() { } + DECLARE_EVENT_TABLE() public: EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString& aFrameName ); + long aStyle, const wxString& aFrameName, KIWAY* aKiway ); ~EDA_BASE_FRAME(); + /** + * Return the user units currently in use. + */ + EDA_UNITS_T GetUserUnits() const { return m_UserUnits; } + void SetUserUnits( EDA_UNITS_T aUnits ) { m_UserUnits = aUnits; } + + void ChangeUserUnits( EDA_UNITS_T aUnits ) + { + SetUserUnits( aUnits ); + unitsChangeRefresh(); + } + + /** + * Return the MVC controller. + */ + TOOL_MANAGER* GetToolManager() const { return m_toolManager; } + /** * Override the default process event handler to implement the auto save feature. * @@ -254,17 +277,15 @@ public: virtual void SaveSettings( wxConfigBase* aCfg ); /** - * @return a base name prefix used in Load/Save settings to build - * the full name of keys used in config. - * This is usually the name of the frame set by CTOR, unless m_configFrameName - * contains a base name. - * this is the case of frames which can be shown in normal or modal mode. - * This is needed because we want only one base name prefix, - * regardless the mode used. + * @return a base name prefix used in Load/Save settings to build the full name of keys + * used in config. + * This is usually the name of the frame set by CTOR, except for frames shown in multiple + * modes in which case the m_configName must be set to the base name so that a single + * config can be used. */ wxString ConfigBaseName() { - wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName; + wxString baseCfgName = m_configName.IsEmpty() ? GetName() : m_configName; return baseCfgName; } diff --git a/include/draw_frame.h b/include/eda_draw_frame.h similarity index 96% rename from include/draw_frame.h rename to include/eda_draw_frame.h index 431c0d1d63..a5179a8969 100644 --- a/include/draw_frame.h +++ b/include/eda_draw_frame.h @@ -113,10 +113,8 @@ protected: // is at scale = 1 int m_UndoRedoCountMax; ///< default Undo/Redo command Max depth, to be handed // to screens - EDA_UNITS_T m_UserUnits; bool m_PolarCoords; //< for those frames that support polar coordinates - TOOL_MANAGER* m_toolManager; TOOL_DISPATCHER* m_toolDispatcher; ACTIONS* m_actions; @@ -174,13 +172,7 @@ protected: double bestZoom( double sizeX, double sizeY, double scaleFactor, wxPoint centre ); - /** - * Called when when the units setting has changed to allow for any derived classes - * to handle refreshing and controls that have units based measurements in them. The - * default version only updates the status bar. Don't forget to call the default - * in your derived class or the status bar will not get updated properly. - */ - virtual void unitsChangeRefresh(); + void unitsChangeRefresh() override; void CommonSettingsChanged() override; @@ -256,18 +248,6 @@ public: */ virtual const wxSize GetPageSizeIU() const = 0; - /** - * Return the user units currently in use. - */ - EDA_UNITS_T GetUserUnits() const override { return m_UserUnits; } - void SetUserUnits( EDA_UNITS_T aUnits ) { m_UserUnits = aUnits; } - - void ChangeUserUnits( EDA_UNITS_T aUnits ) - { - SetUserUnits( aUnits ); - unitsChangeRefresh(); - } - /** * For those frames that support polar coordinates. */ @@ -701,11 +681,6 @@ public: EDA_DRAW_PANEL_GAL* GetGalCanvas() const { return m_galCanvas; } void SetGalCanvas( EDA_DRAW_PANEL_GAL* aPanel ) { m_galCanvas = aPanel; } - /** - * Return the tool manager instance, if any. - */ - TOOL_MANAGER* GetToolManager() const override { return m_toolManager; } - /** * A way to pass info to draw functions. the base class has no knowledge about * these options. It is virtual because this function must be overloaded to diff --git a/include/kiway_holder.h b/include/kiway_holder.h index d8ba9c6026..104081a4f4 100644 --- a/include/kiway_holder.h +++ b/include/kiway_holder.h @@ -25,11 +25,10 @@ #define KIWAY_HOLDER_H_ #include -#include + class KIWAY; class PROJECT; -class TOOL_MANAGER; /** @@ -40,10 +39,15 @@ class TOOL_MANAGER; class KIWAY_HOLDER { public: - KIWAY_HOLDER( KIWAY* aKiway ) : - m_kiway( aKiway ) + enum HOLDER_TYPE { DIALOG, FRAME, PANEL, SCREEN }; + + KIWAY_HOLDER( KIWAY* aKiway, HOLDER_TYPE aType ) : + m_kiway( aKiway ), + m_type( aType ) {} + HOLDER_TYPE GetType() { return m_type; } + /** * Function Kiway * returns a reference to the KIWAY that this object has an opportunity @@ -61,21 +65,6 @@ public: */ PROJECT& Prj() const; - /** - * Function GetUserUnits - * Allows participation in KEYWAY_PLAYER/DIALOG_SHIM userUnits inheritance. - * - * This would fit better in KEYWAY_PLAYER, but DIALOG_SHIMs can only use mix-ins - * because their primary superclass must be wxDialog. - */ - virtual EDA_UNITS_T GetUserUnits() const; - - /** - * Function GetToolManager - * Return the tool manager instance, if any. - */ - virtual TOOL_MANAGER* GetToolManager() const; - /** * Function SetKiway * @@ -90,6 +79,7 @@ public: private: // private, all setting is done through SetKiway(). KIWAY* m_kiway; // no ownership. + HOLDER_TYPE m_type; }; diff --git a/include/kiway_player.h b/include/kiway_player.h index e21d5d1c6f..8386c1b325 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -56,7 +56,7 @@ class WX_EVENT_LOOP; #ifdef SWIG class KIWAY_PLAYER : public wxFrame, public KIWAY_HOLDER #else -class KIWAY_PLAYER : public EDA_BASE_FRAME, public KIWAY_HOLDER +class KIWAY_PLAYER : public EDA_BASE_FRAME #endif { public: diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h index 87c0c7e27c..51de3ff9e2 100644 --- a/include/pcb_base_frame.h +++ b/include/pcb_base_frame.h @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include // EDA_DRAW_MODE_T #include diff --git a/kicad/kicad.h b/kicad/kicad.h index d78e21add5..1ad4c05eab 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -76,7 +76,7 @@ enum TreeFileType { /** * The main KiCad project manager frame. It is not a KIWAY_PLAYER. */ -class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME, public KIWAY_HOLDER +class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME { public: KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 7a577ac186..61374a11cb 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -29,7 +29,7 @@ */ -#include +#include #include #include #include @@ -57,8 +57,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ) : EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size, - KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME ), - KIWAY_HOLDER( &::Kiway ) + KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME, &::Kiway ) { m_active_project = false; m_mainToolBar = nullptr; diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h index 19c65021f4..54247f2c0a 100644 --- a/pagelayout_editor/pl_editor_frame.h +++ b/pagelayout_editor/pl_editor_frame.h @@ -28,7 +28,7 @@ #include -#include +#include #include #include diff --git a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp index 8d120912fe..e0fb1d15fa 100644 --- a/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp +++ b/pcbnew/dialogs/dialog_pns_diff_pair_dimensions.cpp @@ -26,7 +26,7 @@ #include "dialog_pns_diff_pair_dimensions.h" #include #include -#include +#include #include DIALOG_PNS_DIFF_PAIR_DIMENSIONS::DIALOG_PNS_DIFF_PAIR_DIMENSIONS( EDA_DRAW_FRAME* aParent, diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp index c2bb155172..eb6d96b243 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include // TODO validators diff --git a/pcbnew/dialogs/dialog_track_via_size.cpp b/pcbnew/dialogs/dialog_track_via_size.cpp index 0fa1d52ac5..fef6af158b 100644 --- a/pcbnew/dialogs/dialog_track_via_size.cpp +++ b/pcbnew/dialogs/dialog_track_via_size.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "board_design_settings.h" diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 7eee6c95ca..019495c5fd 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -248,7 +248,7 @@ FOOTPRINT_PREVIEW_PANEL::FOOTPRINT_PREVIEW_PANEL( KIWAY* aKiway, wxWindow* aPare std::unique_ptr aOpts, GAL_TYPE aGalType ) : PCB_DRAW_PANEL_GAL ( aParent, -1, wxPoint( 0, 0 ), wxSize(200, 200), *aOpts, aGalType ), - KIWAY_HOLDER( aKiway ), + KIWAY_HOLDER( aKiway, KIWAY_HOLDER::PANEL ), m_DisplayOptions( std::move( aOpts ) ), m_footprintDisplayed( true ) { diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index ab42fc522a..9f5491470f 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -134,7 +134,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent // Force the frame name used in config. the footprint viewer frame has a name // depending on aFrameType (needed to identify the frame by wxWidgets), // but only one configuration is preferable. - m_configFrameName = FOOTPRINT_VIEWER_FRAME_NAME; + m_configName = FOOTPRINT_VIEWER_FRAME_NAME; m_showAxis = true; // true to draw axis. diff --git a/pcbnew/router/pns_tune_status_popup.cpp b/pcbnew/router/pns_tune_status_popup.cpp index cbd86946a5..05c8c5ab3d 100644 --- a/pcbnew/router/pns_tune_status_popup.cpp +++ b/pcbnew/router/pns_tune_status_popup.cpp @@ -19,7 +19,7 @@ * with this program. If not, see . */ -#include "draw_frame.h" +#include "eda_draw_frame.h" #include "pns_tune_status_popup.h" #include "pns_router.h" #include "pns_meander_placer.h"