KiCad PCB EDA Suite
menus_helpers.h File Reference

Usefull macros and inline functions to create menus items in menubars or popup menus. More...

#include <wx/menu.h>
#include <wx/menuitem.h>
#include <bitmaps.h>

Go to the source code of this file.

Functions

wxMenuItem * AddMenuItem (wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
 Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into aMenu. More...
 
wxMenuItem * AddMenuItem (wxMenu *aMenu, int aId, const wxString &aText, const wxString &aHelpText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
 Function AddMenuItem is an inline helper function to create and insert a menu item with an icon and a help message string into aMenu. More...
 
wxMenuItem * AddMenuItem (wxMenu *aMenu, wxMenu *aSubMenu, int aId, const wxString &aText, const wxBitmap &aImage)
 Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into aSubMenu in aMenu. More...
 
wxMenuItem * AddMenuItem (wxMenu *aMenu, wxMenu *aSubMenu, int aId, const wxString &aText, const wxString &aHelpText, const wxBitmap &aImage)
 Function AddMenuItem is an inline helper function to create and insert a menu item with an icon and a help message string into aSubMenu in aMenu. More...
 

Detailed Description

Usefull macros and inline functions to create menus items in menubars or popup menus.

Definition in file menus_helpers.h.

Function Documentation

wxMenuItem* AddMenuItem ( wxMenu *  aMenu,
int  aId,
const wxString &  aText,
const wxBitmap &  aImage,
wxItemKind  aType = wxITEM_NORMAL 
)

Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into aMenu.

Parameters
aMenuis the menu to add the new item.
aIdis the command ID for the new menu item.
aTextis the string for the new menu item.
aImageis the icon to add to the new menu item.
aTypeis the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ...
Returns
a pointer to the new created wxMenuItem

Definition at line 223 of file bitmap.cpp.

References PGM_BASE::CommonSettings(), KiBitmap(), Pgm(), and USE_ICONS_IN_MENUS_KEY.

Referenced by SCH_EDIT_FRAME::addJunctionMenuEntries(), PGM_BASE::AddMenuLanguageList(), AddMenusForBitmap(), AddMenusForBlock(), AddMenusForBus(), AddMenusForBusEntry(), AddMenusForComponent(), AddMenusForComponentField(), AddMenusForEditComponent(), AddMenusForGLabel(), AddMenusForHierchicalSheet(), AddMenusForHLabel(), AddMenusForLabel(), AddMenusForMarkers(), AddMenusForPin(), AddMenusForSheetPin(), AddMenusForText(), AddMenusForWire(), EDA_DRAW_FRAME::AddMenuZoomAndGrid(), AddNewItemsCommand(), PCB_LAYER_WIDGET::AddRightClickMenuItems(), GERBER_LAYER_WIDGET::AddRightClickMenuItems(), EDA_3D_VIEWER::CreateMenuBar(), PCB_EDIT_FRAME::createPopUpBlockMenu(), PCB_EDIT_FRAME::createPopUpMenuForFootprints(), PCB_EDIT_FRAME::createPopUpMenuForFpPads(), PCB_EDIT_FRAME::createPopUpMenuForFpTexts(), PCB_EDIT_FRAME::createPopUpMenuForMarkers(), PCB_EDIT_FRAME::createPopUpMenuForTexts(), PCB_EDIT_FRAME::createPopupMenuForTracks(), PCB_EDIT_FRAME::createPopUpMenuForZones(), PYTHON_ACTION_PLUGINS::deregister_action(), FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE(), LIB_EDIT_FRAME::locateItem(), SCH_EDIT_FRAME::LocateItem(), FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay(), DIALOG_CONFIGURE_PATHS::OnGridCellRightClick(), TREE_PROJECT_FRAME::OnRight(), FOOTPRINT_EDIT_FRAME::OnRightClick(), EDA_3D_CANVAS::OnRightClick(), PL_EDITOR_FRAME::OnRightClick(), GERBVIEW_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRightClick(), LIB_EDIT_FRAME::OnRightClick(), PCB_EDIT_FRAME::OnRightClick(), LAYER_WIDGET::OnRightDownLayer(), LAYER_WIDGET::OnRightDownRender(), PL_EDITOR_FRAME::OnTreeRightClick(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), prepareEditMenu(), prepareExportMenu(), prepareFilesMenu(), prepareHelpMenu(), prepareInspectMenu(), prepareLibraryMenu(), preparePlaceMenu(), preparePreferencesMenu(), prepareRouteMenu(), prepareToolsMenu(), prepareViewMenu(), LIB_VIEW_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU(), and SYMBOL_TREE_PANE::SYMBOL_TREE_PANE().

225 {
226  wxMenuItem* item;
227 
228  item = new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType );
229 
230  // Retrieve the global applicaton show icon option:
231  bool useImagesInMenus;
232  Pgm().CommonSettings()->Read( USE_ICONS_IN_MENUS_KEY, &useImagesInMenus );
233 
234  if( useImagesInMenus )
235  {
236  if( aType == wxITEM_CHECK || aType == wxITEM_RADIO )
237  {
238  #if defined( __WINDOWS__ )
239  item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage );
240  // A workaround to a strange bug on Windows, wx Widgets 3.0:
241  // size of bitmaps is not taken in account for wxITEM_{CHECK,RADIO} menu
242  // unless we call SetFont
243  item->SetFont( *wxNORMAL_FONT );
244  #endif
245  }
246  else if( aType != wxITEM_RADIO )
247  {
248  item->SetBitmap( aImage );
249  }
250  }
251 
252  aMenu->Append( item );
253 
254  return item;
255 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:44
wxMenuItem* AddMenuItem ( wxMenu *  aMenu,
int  aId,
const wxString &  aText,
const wxString &  aHelpText,
const wxBitmap &  aImage,
wxItemKind  aType = wxITEM_NORMAL 
)

Function AddMenuItem is an inline helper function to create and insert a menu item with an icon and a help message string into aMenu.

Parameters
aMenuis the menu to add the new item.
aIdis the command ID for the new menu item.
aTextis the string for the new menu item.
aHelpTextis the help message string for the new menu item.
aImageis the icon to add to the new menu item.
aTypeis the type of menu :wxITEM_NORMAL (default), wxITEM_CHECK ...
Returns
a pointer to the new created wxMenuItem

Definition at line 258 of file bitmap.cpp.

References PGM_BASE::CommonSettings(), KiBitmap(), Pgm(), and USE_ICONS_IN_MENUS_KEY.

261 {
262  wxMenuItem* item;
263 
264  item = new wxMenuItem( aMenu, aId, aText, aHelpText, aType );
265 
266  // Retrieve the global applicaton show icon option:
267  bool useImagesInMenus;
268  Pgm().CommonSettings()->Read( USE_ICONS_IN_MENUS_KEY, &useImagesInMenus );
269 
270  if( useImagesInMenus )
271  {
272  if( aType == wxITEM_CHECK || aType == wxITEM_RADIO )
273  {
274  #if defined( __WINDOWS__ )
275  item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage );
276  // A workaround to a strange bug on Windows, wx Widgets 3.0:
277  // size of bitmaps is not taken in account for wxITEM_{CHECK,RADIO} menu
278  // unless we call SetFont
279  item->SetFont( *wxNORMAL_FONT );
280  #endif
281  }
282  else if( aType != wxITEM_RADIO )
283  {
284  item->SetBitmap( aImage );
285  }
286  }
287 
288  aMenu->Append( item );
289 
290  return item;
291 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:44
wxMenuItem* AddMenuItem ( wxMenu *  aMenu,
wxMenu *  aSubMenu,
int  aId,
const wxString &  aText,
const wxBitmap &  aImage 
)

Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into aSubMenu in aMenu.

Parameters
aMenuis the menu to add the new submenu item.
aSubMenuis the submenu to add the new menu.
aIdis the command ID for the new menu item.
aTextis the string for the new menu item.
aImageis the icon to add to the new menu item.
Returns
a pointer to the new created wxMenuItem

Definition at line 294 of file bitmap.cpp.

References PGM_BASE::CommonSettings(), Pgm(), and USE_ICONS_IN_MENUS_KEY.

296 {
297  wxMenuItem* item;
298 
299  item = new wxMenuItem( aMenu, aId, aText );
300  item->SetSubMenu( aSubMenu );
301 
302  // Retrieve the global applicaton show icon option:
303  bool useImagesInMenus;
304  Pgm().CommonSettings()->Read( USE_ICONS_IN_MENUS_KEY, &useImagesInMenus );
305 
306  if( useImagesInMenus )
307  item->SetBitmap( aImage );
308 
309  aMenu->Append( item );
310 
311  return item;
312 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:44
wxMenuItem* AddMenuItem ( wxMenu *  aMenu,
wxMenu *  aSubMenu,
int  aId,
const wxString &  aText,
const wxString &  aHelpText,
const wxBitmap &  aImage 
)

Function AddMenuItem is an inline helper function to create and insert a menu item with an icon and a help message string into aSubMenu in aMenu.

Parameters
aMenuis the menu to add the new submenu item.
aSubMenuis the submenu to add the new menu.
aIdis the command ID for the new menu item.
aTextis the string for the new menu item.
aHelpTextis the help message string for the new menu item.
aImageis the icon to add to the new menu item.
Returns
a pointer to the new created wxMenuItem

Definition at line 315 of file bitmap.cpp.

References PGM_BASE::CommonSettings(), Pgm(), and USE_ICONS_IN_MENUS_KEY.

318 {
319  wxMenuItem* item;
320 
321  item = new wxMenuItem( aMenu, aId, aText, aHelpText );
322  item->SetSubMenu( aSubMenu );
323 
324  // Retrieve the global applicaton show icon option:
325  bool useImagesInMenus;
326  Pgm().CommonSettings()->Read( USE_ICONS_IN_MENUS_KEY, &useImagesInMenus );
327 
328  if( useImagesInMenus )
329  item->SetBitmap( aImage );
330 
331  aMenu->Append( item );
332 
333  return item;
334 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:187
#define USE_ICONS_IN_MENUS_KEY
Definition: pgm_base.h:44