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 174 of file bitmap.cpp.

References PGM_BASE::GetUseIconsInMenus(), KiBitmap(), and Pgm().

Referenced by AddHotkeyConfigMenu(), SCH_EDIT_FRAME::addJunctionMenuEntries(), EDA_BASE_FRAME::AddMenuIconsOptions(), 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(), CMP_TREE_PANE::CMP_TREE_PANE(), 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(), LIB_EDIT_FRAME::locateItem(), SCH_EDIT_FRAME::LocateItem(), FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay(), TREE_PROJECT_FRAME::OnRight(), FOOTPRINT_EDIT_FRAME::OnRightClick(), EDA_3D_CANVAS::OnRightClick(), PL_EDITOR_FRAME::OnRightClick(), GERBVIEW_FRAME::OnRightClick(), LIB_EDIT_FRAME::OnRightClick(), SCH_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(), prepareSetupMenu(), prepareToolsMenu(), prepareViewMenu(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), and SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU().

176 {
177  wxMenuItem* item;
178 
179  item = new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType );
180 
181  // Retrieve the global applicaton show icon option:
182  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
183 
184  if( useImagesInMenus )
185  {
186  if( aType == wxITEM_CHECK || aType == wxITEM_RADIO )
187  {
188  #if defined( __WINDOWS__ )
189  item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage );
190  // A workaround to a strange bug on Windows, wx Widgets 3.0:
191  // size of bitmaps is not taken in account for wxITEM_{CHECK,RADIO} menu
192  // unless we call SetFont
193  item->SetFont( *wxNORMAL_FONT );
194  #endif
195  }
196  else if( aType != wxITEM_RADIO )
197  {
198  item->SetBitmap( aImage );
199  }
200  }
201 
202  aMenu->Append( item );
203 
204  return item;
205 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
bool GetUseIconsInMenus()
Definition: pgm_base.h:328
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 208 of file bitmap.cpp.

References PGM_BASE::GetUseIconsInMenus(), KiBitmap(), and Pgm().

211 {
212  wxMenuItem* item;
213 
214  item = new wxMenuItem( aMenu, aId, aText, aHelpText, aType );
215 
216  // Retrieve the global applicaton show icon option:
217  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
218 
219  if( useImagesInMenus )
220  {
221  if( aType == wxITEM_CHECK || aType == wxITEM_RADIO )
222  {
223  #if defined( __WINDOWS__ )
224  item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage );
225  // A workaround to a strange bug on Windows, wx Widgets 3.0:
226  // size of bitmaps is not taken in account for wxITEM_{CHECK,RADIO} menu
227  // unless we call SetFont
228  item->SetFont( *wxNORMAL_FONT );
229  #endif
230  }
231  else if( aType != wxITEM_RADIO )
232  {
233  item->SetBitmap( aImage );
234  }
235  }
236 
237  aMenu->Append( item );
238 
239  return item;
240 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
bool GetUseIconsInMenus()
Definition: pgm_base.h:328
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 243 of file bitmap.cpp.

References PGM_BASE::GetUseIconsInMenus(), and Pgm().

245 {
246  wxMenuItem* item;
247 
248  item = new wxMenuItem( aMenu, aId, aText );
249  item->SetSubMenu( aSubMenu );
250 
251  // Retrieve the global applicaton show icon option:
252  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
253 
254  if( useImagesInMenus )
255  item->SetBitmap( aImage );
256 
257  aMenu->Append( item );
258 
259  return item;
260 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
bool GetUseIconsInMenus()
Definition: pgm_base.h:328
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 263 of file bitmap.cpp.

References PGM_BASE::GetUseIconsInMenus(), and Pgm().

266 {
267  wxMenuItem* item;
268 
269  item = new wxMenuItem( aMenu, aId, aText, aHelpText );
270  item->SetSubMenu( aSubMenu );
271 
272  // Retrieve the global applicaton show icon option:
273  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
274 
275  if( useImagesInMenus )
276  item->SetBitmap( aImage );
277 
278  aMenu->Append( item );
279 
280  return item;
281 }
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
bool GetUseIconsInMenus()
Definition: pgm_base.h:328