From e7e972804a891ebbfab1f7d8f77de77a7b06c640 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 2 Mar 2017 14:46:18 +0100 Subject: [PATCH] Make show/hide icons in menus a run time option, instead of compil option. --- CMakeLists.txt | 8 --- common/basicframe.cpp | 11 +++- common/bitmap.cpp | 119 ++++++++++++++++++++++++++++++++-- common/kiway.cpp | 28 +++++++- common/kiway_player.cpp | 15 ++++- common/pgm_base.cpp | 33 +++++++++- eeschema/menubar.cpp | 5 ++ gerbview/menubar.cpp | 7 +- include/id.h | 8 ++- include/kiway.h | 8 +++ include/kiway_player.h | 7 ++ include/menus_helpers.h | 117 ++++----------------------------- include/pgm_base.h | 27 +++++++- include/wxstruct.h | 6 ++ kicad/kicad.h | 7 ++ kicad/mainframe.cpp | 13 +++- kicad/menubar.cpp | 7 ++ pagelayout_editor/menubar.cpp | 3 + pcbnew/menubar_pcbframe.cpp | 4 ++ 19 files changed, 302 insertions(+), 131 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dc9fd77b3..83d4f905d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -338,14 +338,6 @@ if( USE_WX_GRAPHICS_CONTEXT OR APPLE ) endif() -# By default images in menu items are enabled on all platforms except OSX. -if( NOT APPLE ) - set( USE_IMAGES_IN_MENUS ON CACHE BOOL "Enable images in menus" ) -else() - set( USE_IMAGES_IN_MENUS OFF CACHE BOOL "Enable images in menus" ) -endif() - - # KIFACE_SUFFIX is the file extension used for top level program modules which # implement the KIFACE interface. A valid suffix starts with a period '.'. diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 417bbc6edf..418a976c39 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.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-2015 Wayne Stambaugh - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 @@ -244,6 +244,13 @@ void EDA_BASE_FRAME::ShowChangedLanguage() } +void EDA_BASE_FRAME::ShowChangedIcons() +{ + ReCreateMenuBar(); + GetMenuBar()->Refresh(); +} + + void EDA_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) { int maximized = 0; diff --git a/common/bitmap.cpp b/common/bitmap.cpp index 25cb8ada6b..d9741ec2e1 100644 --- a/common/bitmap.cpp +++ b/common/bitmap.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2011 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 @@ -26,20 +26,131 @@ #include #include #include +#include +#include +#include #include - +#include wxBitmap KiBitmap( BITMAP_DEF aBitmap ) { wxMemoryInputStream is( aBitmap->png, aBitmap->byteCount ); + wxImage image( is, wxBITMAP_TYPE_PNG ); + wxBitmap bitmap( image ); - return wxBitmap( wxImage( is, wxBITMAP_TYPE_PNG, -1 ), -1 ); + return bitmap; } + wxBitmap* KiBitmapNew( BITMAP_DEF aBitmap ) { wxMemoryInputStream is( aBitmap->png, aBitmap->byteCount ); + wxImage image( is, wxBITMAP_TYPE_PNG ); + wxBitmap* bitmap = new wxBitmap( image ); - return new wxBitmap( wxImage( is, wxBITMAP_TYPE_PNG, -1 ), -1 ); + return bitmap; } + +wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, + const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType ); + + // Retrieve the global applicaton show icon option: + bool useImagesInMenus = Pgm().GetUseIconsInMenus(); + + if( useImagesInMenus ) + { + if( aType == wxITEM_CHECK ) + { + #if defined( __WINDOWS__ ) + item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage ); + // A workaround to a strange bug on Windows, wx Widgets 3.0: + // size of bitmaps is not taken in account for wxITEM_CHECK menu + // unless we call SetFont + item->SetFont(*wxNORMAL_FONT); + #endif + } + else + item->SetBitmap( aImage ); + } + + aMenu->Append( item ); + + return item; +} + +wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, + const wxString& aHelpText, const wxBitmap& aImage, + wxItemKind aType = wxITEM_NORMAL ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText, aHelpText, aType ); + + // Retrieve the global applicaton show icon option: + bool useImagesInMenus = Pgm().GetUseIconsInMenus(); + + if( useImagesInMenus ) + { + if( aType == wxITEM_CHECK ) + { + #if defined( __WINDOWS__ ) + item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage ); + // A workaround to a strange bug on Windows, wx Widgets 3.0: + // size of bitmaps is not taken in account for wxITEM_CHECK menu + // unless we call SetFont + item->SetFont(*wxNORMAL_FONT); + #endif + } + else + item->SetBitmap( aImage ); + } + + aMenu->Append( item ); + + return item; +} + +wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, + const wxString& aText, const wxBitmap& aImage ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText ); + item->SetSubMenu( aSubMenu ); + + // Retrieve the global applicaton show icon option: + bool useImagesInMenus = Pgm().GetUseIconsInMenus(); + + if( useImagesInMenus ) + item->SetBitmap( aImage ); + + aMenu->Append( item ); + + return item; +}; + + +wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, + const wxString& aText, const wxString& aHelpText, + const wxBitmap& aImage ) +{ + wxMenuItem* item; + + item = new wxMenuItem( aMenu, aId, aText, aHelpText ); + item->SetSubMenu( aSubMenu ); + + // Retrieve the global applicaton show icon option: + bool useImagesInMenus = Pgm().GetUseIconsInMenus(); + + if( useImagesInMenus ) + item->SetBitmap( aImage ); + + aMenu->Append( item ); + + return item; +}; diff --git a/common/kiway.cpp b/common/kiway.cpp index 65f8cc53c1..b8ca1357be 100644 --- a/common/kiway.cpp +++ b/common/kiway.cpp @@ -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-2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-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 @@ -429,6 +429,32 @@ void KIWAY::SetLanguage( int aLanguage ) } } +void KIWAY::ShowChangedIcons() +{ +#if 1 + if( m_ctl & KFCTL_CPP_PROJECT_SUITE ) + { + // A dynamic_cast could be better, but creates link issues + // (some basic_frame functions not found) on some platforms, + // so a static_cast is used. + EDA_BASE_FRAME* top = static_cast( m_top ); + + if( top ) + top->ShowChangedIcons(); + } +#endif + + for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i ) + { + KIWAY_PLAYER* frame = GetPlayerFrame( ( FRAME_T )i ); + + if( frame ) + { + frame->ShowChangedIcons(); + } + } +} + bool KIWAY::ProcessEvent( wxEvent& aEvent ) { diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index b5df953b86..ac308cd7f9 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -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-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.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 @@ -23,6 +23,7 @@ */ +#include #include #include #include @@ -36,6 +37,8 @@ BEGIN_EVENT_TABLE( KIWAY_PLAYER, EDA_BASE_FRAME ) EVT_KIWAY_EXPRESS( KIWAY_PLAYER::kiway_express ) EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KIWAY_PLAYER::language_change ) + EVT_MENU_RANGE( ID_KICAD_SELECT_ICONS_OPTIONS, ID_KICAD_SELECT_ICON_OPTIONS_END, + KIWAY_PLAYER::OnChangeIconsOptions ) END_EVENT_TABLE() @@ -203,3 +206,13 @@ void KIWAY_PLAYER::language_change( wxCommandEvent& event ) // tell all the KIWAY_PLAYERs about the language change. Kiway().SetLanguage( id ); } + + +void KIWAY_PLAYER::OnChangeIconsOptions( wxCommandEvent& event ) +{ + if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS ) + { + Pgm().SetUseIconsInMenus( event.IsChecked() ); + Kiway().ShowChangedIcons(); + } +} diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index ce26c2b7f8..59e0c434c4 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2015 Wayne Stambaugh - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 @@ -63,6 +63,8 @@ static const wxChar languageCfgKey[] = wxT( "LanguageID" ); static const wxChar pathEnvVariables[] = wxT( "EnvironmentVariables" ); static const wxChar showEnvVarWarningDialog[] = wxT( "ShowEnvVarWarningDialog" ); static const wxChar traceEnvVars[] = wxT( "KIENVVARS" ); +///< enable/disable icons in menus +static const wxChar entryUseIconsInMenus[] = wxT( "UseIconsInMenus" ); /** @@ -583,8 +585,11 @@ void PGM_BASE::loadCommonSettings() m_help_size.x = 500; m_help_size.y = 400; + m_iconsScale = 1.0; + m_useIconsInMenus = true; m_common_settings->Read( showEnvVarWarningDialog, &m_show_env_var_dialog ); + m_common_settings->Read( entryUseIconsInMenus, &m_useIconsInMenus, true ); m_editor_name = m_common_settings->Read( wxT( "Editor" ) ); @@ -625,6 +630,7 @@ void PGM_BASE::SaveCommonSettings() m_common_settings->Write( workingDirKey, cur_dir ); m_common_settings->Write( showEnvVarWarningDialog, m_show_env_var_dialog ); + m_common_settings->Write( entryUseIconsInMenus, m_useIconsInMenus); // Save the local environment variables. m_common_settings->SetPath( pathEnvVariables ); @@ -902,3 +908,26 @@ 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 9220d1bd50..b4a0ba0553 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -615,9 +615,14 @@ static void preparePreferencesMenu( wxMenu* aParentMenu ) #endif // __WXMAC__ // Language submenu + aParentMenu->AppendSeparator(); Pgm().AddMenuLanguageList( aParentMenu ); + // Icons options submenu + Pgm().AddMenuIconsOptions( aParentMenu ); + // Import/export (submenu in preferences menu) + aParentMenu->AppendSeparator(); wxMenu* importExportSubmenu = new wxMenu(); prepareImportExportMenu( importExportSubmenu ); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 12fc71313c..0a686abf15 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009-2013 Wayne Stambaugh - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 @@ -194,6 +194,9 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // Language submenu Pgm().AddMenuLanguageList( configMenu ); + // Icons options submenu + Pgm().AddMenuIconsOptions( configMenu ); + // Hotkey submenu AddHotkeyConfigMenu( configMenu ); diff --git a/include/id.h b/include/id.h index c27dc5ac58..c01676de6f 100644 --- a/include/id.h +++ b/include/id.h @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009-2016 Wayne Stambaugh - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 @@ -147,6 +147,10 @@ enum main_id ID_LANGUAGE_LITHUANIAN, ID_LANGUAGE_CHOICE_END, + ID_KICAD_SELECT_ICONS_OPTIONS, + ID_KICAD_SELECT_ICONS_IN_MENUS, + ID_KICAD_SELECT_ICON_OPTIONS_END, + ID_SET_REPEAT_OPTION, // Popup Menu (mouse Right button) (id consecutifs) diff --git a/include/kiway.h b/include/kiway.h index 3536bd723c..0d36667481 100644 --- a/include/kiway.h +++ b/include/kiway.h @@ -357,6 +357,14 @@ public: */ VTBL_ENTRY void SetLanguage( int aLanguage ); + /** + * Function ShowChangedIcons + * Calls ShowChangedIcons() on all KIWAY_PLAYERs. + * Used after changing options related to icons in menus and toolbars + * (like enable/disable icons in menus) + */ + VTBL_ENTRY void ShowChangedIcons(); + KIWAY( PGM_BASE* aProgram, int aCtlBits, wxFrame* aTop = NULL ); /** diff --git a/include/kiway_player.h b/include/kiway_player.h index 68f6a14cf7..34cd3ed6ab 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -235,6 +235,13 @@ protected: */ void language_change( wxCommandEvent& event ); + /** + * Function OnChangeIconsOptions + * is an event handler called on a icons options in menus or toolbars + * menu selection. + */ + void OnChangeIconsOptions( wxCommandEvent& event ); + // variables for modal behavior support, only used by a few derivatives. bool m_modal; // true if frame is intended to be modal, not modeless WX_EVENT_LOOP* m_modal_loop; // points to nested event_loop, NULL means not modal and dismissed diff --git a/include/menus_helpers.h b/include/menus_helpers.h index ace6be52ed..3794799d57 100644 --- a/include/menus_helpers.h +++ b/include/menus_helpers.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2014 KiCad Developers. + * Copyright (C) 2004-2017 KiCad Developers. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,20 +33,9 @@ #include #include - #include -/** - * SET_BITMAP is a macro used to add a bitmap to a menu item. - * @note Do not use with checked menu items. - * @param aImage is the image to add the menu item. - */ -#if !defined( USE_IMAGES_IN_MENUS ) -# define SET_BITMAP( aImage ) -#else -# define SET_BITMAP( aImage ) item->SetBitmap( aImage ) -#endif /** * Function AddMenuItem @@ -60,35 +49,8 @@ * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... * @return a pointer to the new created wxMenuItem */ -static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, - int aId, - const wxString& aText, - const wxBitmap& aImage, - wxItemKind aType = wxITEM_NORMAL ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType ); - - if( aType == wxITEM_CHECK ) - { -#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) - item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage ); - // A workaround to a strange bug on Windows, wx Widgets 3.0: - // size of bitmaps is not taken in account for wxITEM_CHECK menu - // unless we call SetFont - item->SetFont(*wxNORMAL_FONT); -#endif - } - else - { - SET_BITMAP( aImage ); - } - - aMenu->Append( item ); - - return item; -} +wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, + const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL ); /** @@ -104,36 +66,9 @@ static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, * @param aType is the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ... * @return a pointer to the new created wxMenuItem */ -static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, - int aId, - const wxString& aText, - const wxString& aHelpText, - const wxBitmap& aImage, - wxItemKind aType = wxITEM_NORMAL ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText, aHelpText, aType ); - - if( aType == wxITEM_CHECK ) - { -#if defined( USE_IMAGES_IN_MENUS ) && defined( __WINDOWS__ ) - item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage ); - // A workaround to a strange bug on Windows, wx Widgets 3.0: - // size of bitmaps is not taken in account for wxITEM_CHECK menu - // unless we call SetFont - item->SetFont(*wxNORMAL_FONT); -#endif - } - else - { - SET_BITMAP( aImage ); - } - - aMenu->Append( item ); - - return item; -} +wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText, + const wxString& aHelpText, const wxBitmap& aImage, + wxItemKind aType = wxITEM_NORMAL ); /** @@ -148,23 +83,8 @@ static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, * @param aImage is the icon to add to the new menu item. * @return a pointer to the new created wxMenuItem */ -static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, - wxMenu* aSubMenu, - int aId, - const wxString& aText, - const wxBitmap& aImage ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText ); - item->SetSubMenu( aSubMenu ); - - SET_BITMAP( aImage ); - - aMenu->Append( item ); - - return item; -}; +wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, + const wxString& aText, const wxBitmap& aImage ); /** @@ -180,23 +100,8 @@ static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, * @param aImage is the icon to add to the new menu item. * @return a pointer to the new created wxMenuItem */ -static inline wxMenuItem* AddMenuItem( wxMenu* aMenu, - wxMenu* aSubMenu, - int aId, - const wxString& aText, - const wxString& aHelpText, - const wxBitmap& aImage ) -{ - wxMenuItem* item; - - item = new wxMenuItem( aMenu, aId, aText, aHelpText ); - item->SetSubMenu( aSubMenu ); - - SET_BITMAP( aImage ); - - aMenu->Append( item ); - - return item; -}; +wxMenuItem* AddMenuItem( wxMenu* aMenu, wxMenu* aSubMenu, int aId, + const wxString& aText, const wxString& aHelpText, + const wxBitmap& aImage ); #endif // MENUS_HELPERS_H_ diff --git a/include/pgm_base.h b/include/pgm_base.h index 271f4f77d2..96e957217b 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2015 Wayne Stambaugh - * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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 @@ -216,6 +216,16 @@ 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 @@ -320,6 +330,14 @@ public: */ void SaveCommonSettings(); + /// Scaling factor for menus and tool icons + void SetIconsScale( double aValue ) { m_iconsScale = aValue; } + double GetIconsScale() { return m_iconsScale; } + /// True to use menu icons + void SetUseIconsInMenus( bool aUseIcons ) { m_useIconsInMenus = aUseIcons; } + bool GetUseIconsInMenus() { return m_useIconsInMenus; } + + protected: /** @@ -350,6 +368,11 @@ protected: /// true to use the selected PDF browser, if exists, or false to use the default bool m_use_system_pdf_browser; + /// Scaling factor for menus and tool icons + double m_iconsScale; + /// True to use menu icons + bool m_useIconsInMenus; + /// Trap all changes in here, simplifies debugging void setLanguageId( int aId ) { m_language_id = aId; } diff --git a/include/wxstruct.h b/include/wxstruct.h index 9623397cc1..7d3bd6344e 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -407,6 +407,12 @@ public: */ virtual void ShowChangedLanguage(); + /** + * Function ShowChangedIcons + * redraws items menus after a icon was changed option. + */ + virtual void ShowChangedIcons(); + /** * Function PostCommandMenuEvent diff --git a/kicad/kicad.h b/kicad/kicad.h index c430875b9a..e6b220db7a 100644 --- a/kicad/kicad.h +++ b/kicad/kicad.h @@ -145,6 +145,13 @@ public: void OnCloseWindow( wxCloseEvent& Event ); void OnSize( wxSizeEvent& event ); + /** + * 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). + */ + void OnChangeIconsOptions( wxCommandEvent& event ); + /** * Function OnLoadProject * loads an exiting or creates a new project (.pro) file. diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 8901ff8f52..61af68c435 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -54,7 +54,7 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, m_leftWinWidth = 60; m_manager_Hokeys_Descr = NULL; - // Create the status line (bottom of the frame + // Create the status line (bottom of the frame) static const int dims[3] = { -1, -1, 100 }; CreateStatusBar( 3 ); @@ -439,6 +439,16 @@ 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(); + } +} + + void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event ) { Execute( this, BITMAPCONVERTER_EXE ); @@ -545,6 +555,7 @@ void KICAD_MANAGER_FRAME::PrintPrjInfo() PrintMsg( msg ); } + void KICAD_MANAGER_FRAME::Process_Config( wxCommandEvent& event ) { int id = event.GetId(); diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 7b247eeade..b694f31449 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -105,6 +105,9 @@ BEGIN_EVENT_TABLE( KICAD_MANAGER_FRAME, EDA_BASE_FRAME ) EVT_BUTTON( ID_TO_PL_EDITOR, KICAD_MANAGER_FRAME::OnRunPageLayoutEditor ) EVT_MENU( ID_TO_PL_EDITOR, KICAD_MANAGER_FRAME::OnRunPageLayoutEditor ) + EVT_MENU_RANGE( ID_KICAD_SELECT_ICONS_OPTIONS, ID_KICAD_SELECT_ICON_OPTIONS_END, + KICAD_MANAGER_FRAME::OnChangeIconsOptions ) + EVT_UPDATE_UI( ID_SELECT_DEFAULT_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdateDefaultPdfBrowser ) EVT_UPDATE_UI( ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser ) @@ -361,6 +364,10 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() preferencesMenu->AppendSeparator(); Pgm().AddMenuLanguageList( preferencesMenu ); + // Icons options submenu + preferencesMenu->AppendSeparator(); + Pgm().AddMenuIconsOptions( preferencesMenu ); + // Menu Tools: wxMenu* toolsMenu = new wxMenu; diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index 8de9e1f1fd..bc7d607214 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -137,6 +137,9 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() // Language submenu Pgm().AddMenuLanguageList( preferencesMenu ); + // Icons options submenu + Pgm().AddMenuIconsOptions( preferencesMenu ); + // Hotkey submenu AddHotkeyConfigMenu( preferencesMenu ); diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index c247d0dc45..118d905d3d 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -220,8 +220,12 @@ void preparePreferencesMenu( wxMenu* aParentMenu ) KiBitmap( add_tracks_xpm ) ); // fixme: icon // Language submenu + aParentMenu->AppendSeparator(); Pgm().AddMenuLanguageList( aParentMenu ); + // Icons options submenu + Pgm().AddMenuIconsOptions( aParentMenu ); + // Hotkey submenu AddHotkeyConfigMenu( aParentMenu );