A menu item represents an item in a menu. Note that you usually don't have to deal with it directly as wxMenu methods usually construct an object of this class for you.
Also please note that the methods related to fonts and bitmaps are currently only implemented for Windows and GTK+.
Derived from
wxOwnerDrawn (Windows only)
wxObject
Include files
<wx/menuitem.h>
See also
Members
wxMenuItem::wxMenuItem
wxMenuItem::~wxMenuItem
wxMenuItem::Check
wxMenuItem::Enable
wxMenuItem::GetBackgroundColour
wxMenuItem::GetBitmap
wxMenuItem::GetFont
wxMenuItem::GetHelp
wxMenuItem::GetId
wxMenuItem::GetKind
wxMenuItem::GetLabel
wxMenuItem::GetLabelFromText
wxMenuItem::GetMarginWidth
wxMenuItem::GetMenu
wxMenuItem::GetName
wxMenuItem::GetText
wxMenuItem::GetSubMenu
wxMenuItem::GetTextColour
wxMenuItem::IsCheckable
wxMenuItem::IsChecked
wxMenuItem::IsEnabled
wxMenuItem::IsSeparator
wxMenuItem::IsSubMenu
wxMenuItem::SetBackgroundColour
wxMenuItem::SetBitmap
wxMenuItem::SetBitmaps
wxMenuItem::SetFont
wxMenuItem::SetHelp
wxMenuItem::SetMarginWidth
wxMenuItem::SetMenu
wxMenuItem::SetSubMenu
wxMenuItem::SetText
wxMenuItem::SetTextColour
wxMenuItem(wxMenu* parentMenu = NULL, int id = wxID_SEPARATOR, const wxString& text = "", const wxString& helpString = "", wxItemKind kind = wxITEM_NORMAL, wxMenu* subMenu = NULL)
Constructs a wxMenuItem object.
Parameters
parentMenu
id
text
helpString
kind
subMenu
~wxMenuItem()
Destructor.
void Check(bool check = true)
Checks or unchecks the menu item.
Note that this only works when the item is already appended to a menu.
void Enable(bool enable = true)
Enables or disables the menu item.
wxColour& GetBackgroundColour() const
Returns the background colour associated with the menu item (Windows only).
wxBitmap& GetBitmap(bool checked = true) const
Returns the checked or unchecked bitmap (Windows only).
wxFont& GetFont() const
Returns the font associated with the menu item (Windows only).
wxString GetHelp() const
Returns the help string associated with the menu item.
int GetId() const
Returns the menu item identifier.
wxItemKind GetKind() const
Returns the item kind, one of wxITEM_SEPARATOR, wxITEM_NORMAL, wxITEM_CHECK or wxITEM_RADIO.
wxString GetLabel() const
Returns the text associated with the menu item without any accelerator characters it might contain.
See also
static wxString GetLabelFromText(const wxString& text)
Strips all accelerator characters and mnemonics from the given text. For example,
wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");will return just "Hello".
See also
int GetMarginWidth() const
Gets the width of the menu item checkmark bitmap (Windows only).
wxMenu* GetMenu() const
Returns the menu this menu item is in, or NULL if this menu item is not attached.
wxString GetName() const
Returns the text associated with the menu item.
NB: this function is deprecated, please use GetText or GetLabel instead.
wxString GetText() const
Returns the text associated with the menu item, such as it was passed to the wxMenuItem constructor, i.e. with any accelerator characters it may contain.
See also
wxMenu* GetSubMenu() const
Returns the submenu associated with the menu item, or NULL if there isn't one.
wxColour& GetTextColour() const
Returns the text colour associated with the menu item (Windows only).
bool IsCheckable() const
Returns true if the item is checkable.
bool IsChecked() const
Returns true if the item is checked.
bool IsEnabled() const
Returns true if the item is enabled.
bool IsSeparator() const
Returns true if the item is a separator.
bool IsSubMenu() const
Returns true if the item is a submenu.
void SetBackgroundColour(const wxColour& colour) const
Sets the background colour associated with the menu item (Windows only).
void SetBitmap(const wxBitmap& bmp)
Sets the bitmap for the menu item (Windows and GTK+ only). It is equivalent to SetBitmaps(bmp, wxNullBitmap).
void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap)
Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap is also used as the single bitmap for uncheckable menu items.
void SetFont(const wxFont& font)
Sets the font associated with the menu item (Windows only).
void SetHelp(const wxString& helpString)
Sets the help string.
void SetMarginWidth(int width) const
Sets the width of the menu item checkmark bitmap (Windows only).
void SetMenu(const wxMenu*menu)
Sets the parent menu which will contain this menu item.
void SetSubMenu(const wxMenu*menu)
Sets the submenu of this menu item.
void SetText(const wxString& text)
Sets the text associated with the menu item.
void SetTextColour(const wxColour& colour)
Sets the text colour associated with the menu item (Windows only).