KiCad PCB EDA Suite
bitmap.cpp File Reference
#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>

Go to the source code of this file.

Functions

wxBitmap KiBitmap (BITMAP_DEF aBitmap)
 Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF. More...
 
wxBitmap * KiBitmapNew (BITMAP_DEF aBitmap)
 Function KiBitmapNew allocates a wxBitmap on heap from a memory record, held in a BITMAP_DEF. More...
 
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...
 

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 55 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(), 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(), 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(), PCB_LAYER_WIDGET::onRightDownLayers(), PL_EDITOR_FRAME::OnTreeRightClick(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), prepareDesignRulesMenu(), prepareDimensionsMenu(), prepareEditMenu(), prepareExportMenu(), prepareFilesMenu(), prepareHelpMenu(), prepareImportExportMenu(), prepareLibraryMenu(), preparePlaceMenu(), preparePreferencesMenu(), prepareRouteMenu(), prepareToolsMenu(), prepareViewMenu(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), and SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU().

57 {
58  wxMenuItem* item;
59 
60  item = new wxMenuItem( aMenu, aId, aText, wxEmptyString, aType );
61 
62  // Retrieve the global applicaton show icon option:
63  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
64 
65  if( useImagesInMenus )
66  {
67  if( aType == wxITEM_CHECK )
68  {
69  #if defined( __WINDOWS__ )
70  item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage );
71  // A workaround to a strange bug on Windows, wx Widgets 3.0:
72  // size of bitmaps is not taken in account for wxITEM_CHECK menu
73  // unless we call SetFont
74  item->SetFont(*wxNORMAL_FONT);
75  #endif
76  }
77  else
78  item->SetBitmap( aImage );
79  }
80 
81  aMenu->Append( item );
82 
83  return item;
84 }
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:36
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 86 of file bitmap.cpp.

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

89 {
90  wxMenuItem* item;
91 
92  item = new wxMenuItem( aMenu, aId, aText, aHelpText, aType );
93 
94  // Retrieve the global applicaton show icon option:
95  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
96 
97  if( useImagesInMenus )
98  {
99  if( aType == wxITEM_CHECK )
100  {
101  #if defined( __WINDOWS__ )
102  item->SetBitmaps( KiBitmap( checked_ok_xpm ), aImage );
103  // A workaround to a strange bug on Windows, wx Widgets 3.0:
104  // size of bitmaps is not taken in account for wxITEM_CHECK menu
105  // unless we call SetFont
106  item->SetFont(*wxNORMAL_FONT);
107  #endif
108  }
109  else
110  item->SetBitmap( aImage );
111  }
112 
113  aMenu->Append( item );
114 
115  return item;
116 }
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:36
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 118 of file bitmap.cpp.

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

120 {
121  wxMenuItem* item;
122 
123  item = new wxMenuItem( aMenu, aId, aText );
124  item->SetSubMenu( aSubMenu );
125 
126  // Retrieve the global applicaton show icon option:
127  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
128 
129  if( useImagesInMenus )
130  item->SetBitmap( aImage );
131 
132  aMenu->Append( item );
133 
134  return item;
135 };
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 138 of file bitmap.cpp.

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

141 {
142  wxMenuItem* item;
143 
144  item = new wxMenuItem( aMenu, aId, aText, aHelpText );
145  item->SetSubMenu( aSubMenu );
146 
147  // Retrieve the global applicaton show icon option:
148  bool useImagesInMenus = Pgm().GetUseIconsInMenus();
149 
150  if( useImagesInMenus )
151  item->SetBitmap( aImage );
152 
153  aMenu->Append( item );
154 
155  return item;
156 };
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
bool GetUseIconsInMenus()
Definition: pgm_base.h:328
wxBitmap KiBitmap ( BITMAP_DEF  aBitmap)

Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.

Definition at line 36 of file bitmap.cpp.

References BITMAP_OPAQUE::byteCount, and BITMAP_OPAQUE::png.

Referenced by CONTEXT_MENU::Add(), AddHotkeyConfigMenu(), SCH_EDIT_FRAME::addJunctionMenuEntries(), EDA_BASE_FRAME::AddMenuIconsOptions(), AddMenuItem(), PGM_BASE::AddMenuLanguageList(), AddMenusForBitmap(), AddMenusForBlock(), AddMenusForBus(), AddMenusForBusEntry(), AddMenusForComponent(), AddMenusForComponentField(), AddMenusForEditComponent(), AddMenusForGLabel(), AddMenusForHierchicalSheet(), AddMenusForHLabel(), AddMenusForLabel(), AddMenusForMarkers(), AddMenusForPin(), AddMenusForSheetPin(), AddMenusForText(), AddMenusForWire(), EDA_DRAW_FRAME::AddMenuZoomAndGrid(), AddNewItemsCommand(), LAUNCHER_PANEL::CreateCommandToolbar(), EDA_3D_VIEWER::CreateMenuBar(), LIB_EDIT_FRAME::CreateOptionToolbar(), 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(), dialog_about::CreateStaticBitmap(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), dialog_about::dialog_about(), DIALOG_EXIT::DIALOG_EXIT(), DIALOG_MODULE_BOARD_EDITOR::DIALOG_MODULE_BOARD_EDITOR(), DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR(), DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS(), DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME(), EDA_3D_VIEWER::EDA_3D_VIEWER(), EVT_GRID_CMD_CELL_CHANGED(), EVT_TOOL(), EVT_TOOL_RANGE(), EVT_UPDATE_UI(), EVT_UPDATE_UI_RANGE(), GERBVIEW_FRAME::GERBVIEW_FRAME(), DIALOG_LIB_EDIT_PIN_TABLE::DataViewModel::Pin::GetValue(), HIERARCHY_TREE::HIERARCHY_TREE(), DIALOG_3D_VIEW_OPTIONS::initDialog(), InitKiCadAboutNew(), PANEL_PREV_3D::initPanel(), KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME(), LIB_EDIT_FRAME::LIB_EDIT_FRAME(), LIB_EDIT_FRAME::locateItem(), SCH_EDIT_FRAME::LocateItem(), FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay(), WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnPageChanged(), WIZARD_FPLIB_TABLE::OnPageChanged(), 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(), PCB_LAYER_WIDGET::onRightDownLayers(), SIM_PLOT_FRAME::onSimFinished(), SIM_PLOT_FRAME::onSimStarted(), PL_EDITOR_FRAME::OnTreeRightClick(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), PinShapeComboBox::PinShapeComboBox(), PinTypeComboBox::PinTypeComboBox(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), prepareDesignRulesMenu(), prepareDimensionsMenu(), prepareEditMenu(), prepareExportMenu(), prepareFilesMenu(), prepareHelpMenu(), prepareImportExportMenu(), prepareLibraryMenu(), preparePlaceMenu(), preparePreferencesMenu(), prepareRouteMenu(), prepareToolsMenu(), prepareViewMenu(), DIALOG_ERC::ReBuildMatrixPanel(), PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), KICAD_MANAGER_FRAME::RecreateBaseHToolbar(), DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar(), LIB_VIEW_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateHToolbar(), PL_EDITOR_FRAME::ReCreateHToolbar(), CVPCB_MAINFRAME::ReCreateHToolbar(), FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar(), GERBVIEW_FRAME::ReCreateHToolbar(), LIB_EDIT_FRAME::ReCreateHToolbar(), SCH_EDIT_FRAME::ReCreateHToolbar(), PCB_EDIT_FRAME::ReCreateHToolbar(), EDA_3D_VIEWER::ReCreateMainToolbar(), LIB_VIEW_FRAME::ReCreateMenuBar(), FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), LIB_EDIT_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateMicrowaveVToolbar(), DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar(), GERBVIEW_FRAME::ReCreateOptToolbar(), SCH_EDIT_FRAME::ReCreateOptToolbar(), PCB_EDIT_FRAME::ReCreateOptToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateVToolbar(), PL_EDITOR_FRAME::ReCreateVToolbar(), GERBVIEW_FRAME::ReCreateVToolbar(), LIB_EDIT_FRAME::ReCreateVToolbar(), SCH_EDIT_FRAME::ReCreateVToolbar(), PCB_EDIT_FRAME::ReCreateVToolbar(), DIALOG_ERC::setDRCMatrixButtonState(), DIALOG_LIB_EDIT_PIN::SetOrientationList(), SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and TREEPROJECTFILES::TREEPROJECTFILES().

37 {
38  wxMemoryInputStream is( aBitmap->png, aBitmap->byteCount );
39  wxImage image( is, wxBITMAP_TYPE_PNG );
40  wxBitmap bitmap( image );
41 
42  return bitmap;
43 }
const unsigned char * png
Definition: bitmap_types.h:40
wxBitmap* KiBitmapNew ( BITMAP_DEF  aBitmap)

Function KiBitmapNew allocates a wxBitmap on heap from a memory record, held in a BITMAP_DEF.

Returns
wxBitmap* - caller owns it.

Definition at line 46 of file bitmap.cpp.

References BITMAP_OPAQUE::byteCount, and BITMAP_OPAQUE::png.

Referenced by InitKiCadAboutNew().

47 {
48  wxMemoryInputStream is( aBitmap->png, aBitmap->byteCount );
49  wxImage image( is, wxBITMAP_TYPE_PNG );
50  wxBitmap* bitmap = new wxBitmap( image );
51 
52  return bitmap;
53 }
const unsigned char * png
Definition: bitmap_types.h:40