A menu item represents an item in a popup menu. Note that the majority of this class is only implemented under Windows so far, but everything except fonts, colours and bitmaps can be achieved via wxMenu on all platforms.
Derived from
wxOwnerDrawn (Windows only)
wxObject
Include files
<wx/menuitem.h>
See also
Members
wxMenuItem::wxMenuItem
wxMenuItem::~wxMenuItem
wxMenuItem::Check
wxMenuItem::DeleteSubMenu
wxMenuItem::Enable
wxMenuItem::GetBackgroundColour
wxMenuItem::GetBitmap
wxMenuItem::GetFont
wxMenuItem::GetHelp
wxMenuItem::GetId
wxMenuItem::GetLabel
wxMenuItem::GetLabelFromText
wxMenuItem::GetMarginWidth
wxMenuItem::GetName
wxMenuItem::GetText
wxMenuItem::GetSubMenu
wxMenuItem::GetTextColour
wxMenuItem::IsCheckable
wxMenuItem::IsChecked
wxMenuItem::IsEnabled
wxMenuItem::IsSeparator
wxMenuItem::SetBackgroundColour
wxMenuItem::SetBitmaps
wxMenuItem::SetFont
wxMenuItem::SetHelp
wxMenuItem::SetMarginWidth
wxMenuItem::SetName
wxMenuItem::SetTextColour
wxMenuItem(wxMenu* parentMenu = NULL, int id = ID_SEPARATOR, const wxString& text = "", const wxString& helpString = "", bool checkable = FALSE, wxMenu* subMenu = NULL, )
Constructs a wxMenuItem object.
Parameters
parentMenu
id
text
helpString
checkable
subMenu
~wxMenuItem()
Destructor.
void Check(bool check)
Checks or unchecks the menu item.
void DeleteSubMenu()
Deletes the submenu, if any.
void Enable(bool enable)
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.
wxString GetLabel() const
Returns the text associated with the menu item without any accelerator characaters it might contain.
See also
static wxString GetLabelFromText(const wxString& text)
Strips all accelerator characeters 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).
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.
void SetBackgroundColour(const wxColour& colour) const
Sets the background colour associated with the menu item (Windows only).
void SetBitmaps(const wxBitmap& checked, const wxBitmap& unchecked = wxNullBitmap) const
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) const
Sets the font associated with the menu item (Windows only).
void SetHelp(const wxString& helpString) const
Sets the help string.
void SetMarginWidth(int width) const
Sets the width of the menu item checkmark bitmap (Windows only).
void SetName(const wxString& text) const
Sets the text associated with the menu item.
void SetTextColour(const wxColour& colour) const
Sets the text colour associated with the menu item (Windows only).