diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 418a976c39..9ea253fe72 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include @@ -653,3 +655,37 @@ bool EDA_BASE_FRAME::PostCommandMenuEvent( int evt_type ) return false; } + + +void EDA_BASE_FRAME::OnChangeIconsOptions( wxCommandEvent& event ) +{ + if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS ) + { + Pgm().SetUseIconsInMenus( event.IsChecked() ); + } + + ReCreateMenuBar(); +} + + +void EDA_BASE_FRAME::AddMenuIconsOptions( wxMenu* MasterMenu ) +{ + wxMenu* menu = NULL; + wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS ); + + if( item ) // This menu exists, do nothing + return; + + menu = new wxMenu; + + menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS, + _( "Icons in Menus" ), wxEmptyString, + wxITEM_CHECK ) ); + menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, Pgm().GetUseIconsInMenus() ); + + AddMenuItem( MasterMenu, menu, + ID_KICAD_SELECT_ICONS_OPTIONS, + _( "Icons Options" ), + _( "Select show icons in menus and icons sizes" ), + KiBitmap( hammer_xpm ) ); +} diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index ac308cd7f9..80d72cd615 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -210,9 +210,6 @@ void KIWAY_PLAYER::language_change( wxCommandEvent& event ) void KIWAY_PLAYER::OnChangeIconsOptions( wxCommandEvent& event ) { - if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS ) - { - Pgm().SetUseIconsInMenus( event.IsChecked() ); - Kiway().ShowChangedIcons(); - } + EDA_BASE_FRAME::OnChangeIconsOptions( event ); + Kiway().ShowChangedIcons(); } diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 59e0c434c4..cb95381182 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -908,26 +908,3 @@ void PGM_BASE::ConfigurePaths( wxWindow* aParent ) SetLocalEnvVariables( dlg_envvars.GetEnvVarMap() ); } - - -void PGM_BASE::AddMenuIconsOptions( wxMenu* MasterMenu ) -{ - wxMenu* menu = NULL; - wxMenuItem* item = MasterMenu->FindItem( ID_KICAD_SELECT_ICONS_OPTIONS ); - - if( item ) // This menu exists, do nothing - return; - - menu = new wxMenu; - - menu->Append( new wxMenuItem( menu, ID_KICAD_SELECT_ICONS_IN_MENUS, - _( "Icons in Menus" ), wxEmptyString, - wxITEM_CHECK ) ); - menu->Check( ID_KICAD_SELECT_ICONS_IN_MENUS, m_useIconsInMenus ); - - AddMenuItem( MasterMenu, menu, - ID_KICAD_SELECT_ICONS_OPTIONS, - _( "Icons Options" ), - _( "Select show icons in menus and icons sizes" ), - KiBitmap( hammer_xpm ) ); -} diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index b4a0ba0553..a6da75ea6e 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -65,7 +65,7 @@ static void prepareEditMenu( wxMenu* aParentMenu ); static void prepareViewMenu( wxMenu* aParentMenu ); // Build the preferences menu -static void preparePreferencesMenu( wxMenu* aParentMenu ); +static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu ); void SCH_EDIT_FRAME::ReCreateMenuBar() @@ -104,7 +104,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Menu Preferences: wxMenu* preferencesMenu = new wxMenu; - preparePreferencesMenu( preferencesMenu ); + preparePreferencesMenu( this, preferencesMenu ); // Menu Tools: wxMenu* toolsMenu = new wxMenu; @@ -594,7 +594,7 @@ void prepareImportExportMenu( wxMenu* aParentMenu ) KiBitmap( hotkeys_import_xpm ) ); } -static void preparePreferencesMenu( wxMenu* aParentMenu ) +static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu ) { // Library AddMenuItem( aParentMenu, @@ -619,7 +619,7 @@ static void preparePreferencesMenu( wxMenu* aParentMenu ) Pgm().AddMenuLanguageList( aParentMenu ); // Icons options submenu - Pgm().AddMenuIconsOptions( aParentMenu ); + aFrame->AddMenuIconsOptions( aParentMenu ); // Import/export (submenu in preferences menu) aParentMenu->AppendSeparator(); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 0a686abf15..adef496daa 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -195,7 +195,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() Pgm().AddMenuLanguageList( configMenu ); // Icons options submenu - Pgm().AddMenuIconsOptions( configMenu ); + AddMenuIconsOptions( configMenu ); // Hotkey submenu AddHotkeyConfigMenu( configMenu ); diff --git a/include/kiway_player.h b/include/kiway_player.h index 34cd3ed6ab..a4fd6836ca 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -240,7 +240,7 @@ protected: * is an event handler called on a icons options in menus or toolbars * menu selection. */ - void OnChangeIconsOptions( wxCommandEvent& event ); + void OnChangeIconsOptions( wxCommandEvent& event ) override; // variables for modal behavior support, only used by a few derivatives. bool m_modal; // true if frame is intended to be modal, not modeless diff --git a/include/pgm_base.h b/include/pgm_base.h index 96e957217b..0fa00f7be9 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -216,16 +216,6 @@ public: */ VTBL_ENTRY void AddMenuLanguageList( wxMenu* MasterMenu ); - /** - * Function AddMenuIconsOptions - * creates a menu list for icons in menu and icon sizes choice, - * and add it as submenu to \a MasterMenu. - * - * @param MasterMenu The main menu. The sub menu list will be accessible from the menu - * item with id ID_KICAD_SELECT_ICONS_OPTIONS - */ - VTBL_ENTRY void AddMenuIconsOptions( wxMenu* MasterMenu ); - /** * Function SetLanguageIdentifier * sets in .m_language_id member the wxWidgets language identifier Id from diff --git a/include/wxstruct.h b/include/wxstruct.h index 7d3bd6344e..990adf29ee 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -407,12 +407,29 @@ public: */ virtual void ShowChangedLanguage(); + /** + * Function OnChangeIconsOptions + * Selects the current icons options in menus (or toolbars) in Kicad + * (the default for toolbars/menus is 26x26 pixels, and shows icons in menus). + */ + virtual void OnChangeIconsOptions( wxCommandEvent& event ); + /** * Function ShowChangedIcons * redraws items menus after a icon was changed option. */ virtual void ShowChangedIcons(); + /** + * Function AddMenuIconsOptions + * creates a menu list for icons in menu and icon sizes choice, + * and add it as submenu to \a MasterMenu. + * + * @param MasterMenu The main menu. The sub menu list will be accessible from the menu + * item with id ID_KICAD_SELECT_ICONS_OPTIONS + */ + void AddMenuIconsOptions( wxMenu* MasterMenu ); + /** * Function PostCommandMenuEvent diff --git a/kicad/kicad.h b/kicad/kicad.h index e6b220db7a..7aa046de85 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN (www.cern.ch) - * Copyright (C) 2015 KiCad Developers, see CHANGELOG.txt for contributors. + * Copyright (C) 2017 KiCad Developers, see CHANGELOG.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -150,7 +150,7 @@ public: * Selects the current icons options in menus (or toolbars) in Kicad * (the default for toolbars/menus is 26x26 pixels, and shows icons in menus). */ - void OnChangeIconsOptions( wxCommandEvent& event ); + void OnChangeIconsOptions( wxCommandEvent& event ) override; /** * Function OnLoadProject diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 61af68c435..99f9695da6 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 CERN (www.cern.ch) - * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -441,11 +441,8 @@ void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event ) void KICAD_MANAGER_FRAME::OnChangeIconsOptions( wxCommandEvent& event ) { - if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS ) - { - Pgm().SetUseIconsInMenus( event.IsChecked() ); - Kiway.ShowChangedIcons(); - } + EDA_BASE_FRAME::OnChangeIconsOptions( event ); + Kiway.ShowChangedIcons(); } diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index b694f31449..439b4d8334 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -366,7 +366,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() // Icons options submenu preferencesMenu->AppendSeparator(); - Pgm().AddMenuIconsOptions( preferencesMenu ); + AddMenuIconsOptions( preferencesMenu ); // Menu Tools: wxMenu* toolsMenu = new wxMenu; diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index bc7d607214..c1805813b4 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -138,7 +138,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() Pgm().AddMenuLanguageList( preferencesMenu ); // Icons options submenu - Pgm().AddMenuIconsOptions( preferencesMenu ); + AddMenuIconsOptions( preferencesMenu ); // Hotkey submenu AddHotkeyConfigMenu( preferencesMenu ); diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index 118d905d3d..b966a2aa8e 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -77,7 +77,7 @@ static void prepareLibraryMenu( wxMenu* aParentMenu ); static void prepareDesignRulesMenu( wxMenu* aParentMenu ); // Build the preferences menu -static void preparePreferencesMenu( wxMenu* aParentMenu ); +static void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu ); void PCB_EDIT_FRAME::ReCreateMenuBar() @@ -122,7 +122,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() prepareLibraryMenu( configmenu ); configmenu->AppendSeparator(); - preparePreferencesMenu( configmenu ); + preparePreferencesMenu( this, configmenu ); // Update menu labels: configmenu->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER, @@ -190,7 +190,7 @@ void prepareDesignRulesMenu( wxMenu* aParentMenu ) // Build the preferences menu -void preparePreferencesMenu( wxMenu* aParentMenu ) +void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu ) { AddMenuItem( aParentMenu, ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER, _( "Hide La&yers Manager" ), @@ -224,7 +224,7 @@ void preparePreferencesMenu( wxMenu* aParentMenu ) Pgm().AddMenuLanguageList( aParentMenu ); // Icons options submenu - Pgm().AddMenuIconsOptions( aParentMenu ); + aFrame->AddMenuIconsOptions( aParentMenu ); // Hotkey submenu AddHotkeyConfigMenu( aParentMenu );