Icons options menu: code rework

This commit is contained in:
jean-pierre charras 2017-03-03 14:18:07 +01:00
parent 1dfd74bec9
commit 4eeed8d04f
13 changed files with 74 additions and 60 deletions

View File

@ -38,6 +38,8 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <pgm_base.h> #include <pgm_base.h>
#include <wxstruct.h> #include <wxstruct.h>
#include <menus_helpers.h>
#include <bitmaps.h>
#include <wx/display.h> #include <wx/display.h>
#include <wx/utils.h> #include <wx/utils.h>
@ -653,3 +655,37 @@ bool EDA_BASE_FRAME::PostCommandMenuEvent( int evt_type )
return false; 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 ) );
}

View File

@ -210,9 +210,6 @@ void KIWAY_PLAYER::language_change( wxCommandEvent& event )
void KIWAY_PLAYER::OnChangeIconsOptions( wxCommandEvent& event ) void KIWAY_PLAYER::OnChangeIconsOptions( wxCommandEvent& event )
{ {
if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS ) EDA_BASE_FRAME::OnChangeIconsOptions( event );
{ Kiway().ShowChangedIcons();
Pgm().SetUseIconsInMenus( event.IsChecked() );
Kiway().ShowChangedIcons();
}
} }

View File

@ -908,26 +908,3 @@ void PGM_BASE::ConfigurePaths( wxWindow* aParent )
SetLocalEnvVariables( dlg_envvars.GetEnvVarMap() ); 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 ) );
}

View File

@ -65,7 +65,7 @@ static void prepareEditMenu( wxMenu* aParentMenu );
static void prepareViewMenu( wxMenu* aParentMenu ); static void prepareViewMenu( wxMenu* aParentMenu );
// Build the preferences menu // Build the preferences menu
static void preparePreferencesMenu( wxMenu* aParentMenu ); static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu );
void SCH_EDIT_FRAME::ReCreateMenuBar() void SCH_EDIT_FRAME::ReCreateMenuBar()
@ -104,7 +104,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Menu Preferences: // Menu Preferences:
wxMenu* preferencesMenu = new wxMenu; wxMenu* preferencesMenu = new wxMenu;
preparePreferencesMenu( preferencesMenu ); preparePreferencesMenu( this, preferencesMenu );
// Menu Tools: // Menu Tools:
wxMenu* toolsMenu = new wxMenu; wxMenu* toolsMenu = new wxMenu;
@ -594,7 +594,7 @@ void prepareImportExportMenu( wxMenu* aParentMenu )
KiBitmap( hotkeys_import_xpm ) ); KiBitmap( hotkeys_import_xpm ) );
} }
static void preparePreferencesMenu( wxMenu* aParentMenu ) static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu )
{ {
// Library // Library
AddMenuItem( aParentMenu, AddMenuItem( aParentMenu,
@ -619,7 +619,7 @@ static void preparePreferencesMenu( wxMenu* aParentMenu )
Pgm().AddMenuLanguageList( aParentMenu ); Pgm().AddMenuLanguageList( aParentMenu );
// Icons options submenu // Icons options submenu
Pgm().AddMenuIconsOptions( aParentMenu ); aFrame->AddMenuIconsOptions( aParentMenu );
// Import/export (submenu in preferences menu) // Import/export (submenu in preferences menu)
aParentMenu->AppendSeparator(); aParentMenu->AppendSeparator();

View File

@ -195,7 +195,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
Pgm().AddMenuLanguageList( configMenu ); Pgm().AddMenuLanguageList( configMenu );
// Icons options submenu // Icons options submenu
Pgm().AddMenuIconsOptions( configMenu ); AddMenuIconsOptions( configMenu );
// Hotkey submenu // Hotkey submenu
AddHotkeyConfigMenu( configMenu ); AddHotkeyConfigMenu( configMenu );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 * is an event handler called on a icons options in menus or toolbars
* menu selection. * menu selection.
*/ */
void OnChangeIconsOptions( wxCommandEvent& event ); void OnChangeIconsOptions( wxCommandEvent& event ) override;
// variables for modal behavior support, only used by a few derivatives. // variables for modal behavior support, only used by a few derivatives.
bool m_modal; // true if frame is intended to be modal, not modeless bool m_modal; // true if frame is intended to be modal, not modeless

View File

@ -216,16 +216,6 @@ public:
*/ */
VTBL_ENTRY void AddMenuLanguageList( wxMenu* MasterMenu ); 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 * Function SetLanguageIdentifier
* sets in .m_language_id member the wxWidgets language identifier Id from * sets in .m_language_id member the wxWidgets language identifier Id from

View File

@ -407,12 +407,29 @@ public:
*/ */
virtual void ShowChangedLanguage(); 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 * Function ShowChangedIcons
* redraws items menus after a icon was changed option. * redraws items menus after a icon was changed option.
*/ */
virtual void ShowChangedIcons(); 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 * Function PostCommandMenuEvent

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 CERN (www.cern.ch) * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 * Selects the current icons options in menus (or toolbars) in Kicad
* (the default for toolbars/menus is 26x26 pixels, and shows icons in menus). * (the default for toolbars/menus is 26x26 pixels, and shows icons in menus).
*/ */
void OnChangeIconsOptions( wxCommandEvent& event ); void OnChangeIconsOptions( wxCommandEvent& event ) override;
/** /**
* Function OnLoadProject * Function OnLoadProject

View File

@ -1,9 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ) void KICAD_MANAGER_FRAME::OnChangeIconsOptions( wxCommandEvent& event )
{ {
if( event.GetId() == ID_KICAD_SELECT_ICONS_IN_MENUS ) EDA_BASE_FRAME::OnChangeIconsOptions( event );
{ Kiway.ShowChangedIcons();
Pgm().SetUseIconsInMenus( event.IsChecked() );
Kiway.ShowChangedIcons();
}
} }

View File

@ -366,7 +366,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar()
// Icons options submenu // Icons options submenu
preferencesMenu->AppendSeparator(); preferencesMenu->AppendSeparator();
Pgm().AddMenuIconsOptions( preferencesMenu ); AddMenuIconsOptions( preferencesMenu );
// Menu Tools: // Menu Tools:
wxMenu* toolsMenu = new wxMenu; wxMenu* toolsMenu = new wxMenu;

View File

@ -138,7 +138,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
Pgm().AddMenuLanguageList( preferencesMenu ); Pgm().AddMenuLanguageList( preferencesMenu );
// Icons options submenu // Icons options submenu
Pgm().AddMenuIconsOptions( preferencesMenu ); AddMenuIconsOptions( preferencesMenu );
// Hotkey submenu // Hotkey submenu
AddHotkeyConfigMenu( preferencesMenu ); AddHotkeyConfigMenu( preferencesMenu );

View File

@ -77,7 +77,7 @@ static void prepareLibraryMenu( wxMenu* aParentMenu );
static void prepareDesignRulesMenu( wxMenu* aParentMenu ); static void prepareDesignRulesMenu( wxMenu* aParentMenu );
// Build the preferences menu // Build the preferences menu
static void preparePreferencesMenu( wxMenu* aParentMenu ); static void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu );
void PCB_EDIT_FRAME::ReCreateMenuBar() void PCB_EDIT_FRAME::ReCreateMenuBar()
@ -122,7 +122,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
prepareLibraryMenu( configmenu ); prepareLibraryMenu( configmenu );
configmenu->AppendSeparator(); configmenu->AppendSeparator();
preparePreferencesMenu( configmenu ); preparePreferencesMenu( this, configmenu );
// Update menu labels: // Update menu labels:
configmenu->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER, configmenu->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER,
@ -190,7 +190,7 @@ void prepareDesignRulesMenu( wxMenu* aParentMenu )
// Build the preferences menu // 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, AddMenuItem( aParentMenu, ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER,
_( "Hide La&yers Manager" ), _( "Hide La&yers Manager" ),
@ -224,7 +224,7 @@ void preparePreferencesMenu( wxMenu* aParentMenu )
Pgm().AddMenuLanguageList( aParentMenu ); Pgm().AddMenuLanguageList( aParentMenu );
// Icons options submenu // Icons options submenu
Pgm().AddMenuIconsOptions( aParentMenu ); aFrame->AddMenuIconsOptions( aParentMenu );
// Hotkey submenu // Hotkey submenu
AddHotkeyConfigMenu( aParentMenu ); AddHotkeyConfigMenu( aParentMenu );