Make show/hide icons in menus a run time option, instead of compil option.
This commit is contained in:
parent
bea0a9ab6e
commit
e7e972804a
|
@ -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 '.'.
|
||||
|
||||
|
|
|
@ -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 <stambaughw@verizon.net>
|
||||
* 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;
|
||||
|
|
|
@ -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 <dick@softplc.com>
|
||||
* 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 <wx/image.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/menu.h>
|
||||
#include <wx/menuitem.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <bitmaps.h>
|
||||
|
||||
#include <pgm_base.h>
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -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 <dick@softplc.com>
|
||||
* 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<EDA_BASE_FRAME*>( 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 )
|
||||
{
|
||||
|
|
|
@ -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 <dick@softplc.com>
|
||||
* 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 <pgm_base.h>
|
||||
#include <kiway_player.h>
|
||||
#include <kiway_express.h>
|
||||
#include <kiway.h>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <stambaughw@verizon.net>
|
||||
* 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 ) );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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 <stambaughw@verizon.net>
|
||||
* 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 );
|
||||
|
||||
|
|
|
@ -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 <stambaughw@verizon.net>
|
||||
* 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)
|
||||
|
|
|
@ -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 );
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <wx/menu.h>
|
||||
#include <wx/menuitem.h>
|
||||
|
||||
#include <bitmaps.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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_
|
||||
|
|
|
@ -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 <stambaughw@verizon.net>
|
||||
* 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; }
|
||||
|
||||
|
|
|
@ -407,6 +407,12 @@ public:
|
|||
*/
|
||||
virtual void ShowChangedLanguage();
|
||||
|
||||
/**
|
||||
* Function ShowChangedIcons
|
||||
* redraws items menus after a icon was changed option.
|
||||
*/
|
||||
virtual void ShowChangedIcons();
|
||||
|
||||
|
||||
/**
|
||||
* Function PostCommandMenuEvent
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -137,6 +137,9 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
|
|||
// Language submenu
|
||||
Pgm().AddMenuLanguageList( preferencesMenu );
|
||||
|
||||
// Icons options submenu
|
||||
Pgm().AddMenuIconsOptions( preferencesMenu );
|
||||
|
||||
// Hotkey submenu
|
||||
AddHotkeyConfigMenu( preferencesMenu );
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue