wxMenuItem

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

wxMenuBar, wxMenu



wxMenuItem::wxMenuItem



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
Menu that the menu item belongs to.

id
Identifier for this menu item, or wxID_SEPARATOR to indicate a separator.

text
Text for the menu item, as shown on the menu. An accelerator key can be specified using the ampersand '&' character. In order to embed an ampersand character in the menu item text, the ampersand must be doubled.

helpString
Optional help string that will be shown on the status bar.

kind
May be wxITEM_SEPARATOR, wxITEM_NORMAL, wxITEM_CHECK or wxITEM_RADIO

subMenu
If non-NULL, indicates that the menu item is a submenu.



wxMenuItem::~wxMenuItem



~wxMenuItem(void)

Destructor.



wxMenuItem::Check



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.



wxMenuItem::Enable



void Enable(bool enable = true)

Enables or disables the menu item.



wxMenuItem::GetBackgroundColour

wxColour& GetBackgroundColour(void) const

Returns the background colour associated with the menu item (Windows only).



wxMenuItem::GetBitmap

wxBitmap& GetBitmap(bool checked = true) const

Returns the checked or unchecked bitmap (Windows only).



wxMenuItem::GetFont

wxFont& GetFont(void) const

Returns the font associated with the menu item (Windows only).



wxMenuItem::GetHelp

wxString GetHelp(void) const

Returns the help string associated with the menu item.



wxMenuItem::GetId

int GetId(void) const

Returns the menu item identifier.



wxMenuItem::GetKind

wxItemKind GetKind(void) const

Returns the item kind, one of wxITEM_SEPARATOR, wxITEM_NORMAL, wxITEM_CHECK or wxITEM_RADIO.



wxMenuItem::GetLabel

wxString GetLabel(void) const

Returns the text associated with the menu item without any accelerator characters it might contain.

See also

GetText, GetLabelFromText



wxMenuItem::GetLabelFromText



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

GetText, GetLabel



wxMenuItem::GetMarginWidth

int GetMarginWidth(void) const

Gets the width of the menu item checkmark bitmap (Windows only).



wxMenuItem::GetMenu

wxMenu* GetMenu(void) const

Returns the menu this menu item is in, or NULL if this menu item is not attached.



wxMenuItem::GetName

wxString GetName(void) const

Returns the text associated with the menu item.

NB: this function is deprecated, please use GetText or GetLabel instead.



wxMenuItem::GetText

wxString GetText(void) 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

GetLabel, GetLabelFromText



wxMenuItem::GetSubMenu

wxMenu* GetSubMenu(void) const

Returns the submenu associated with the menu item, or NULL if there isn't one.



wxMenuItem::GetTextColour

wxColour& GetTextColour(void) const

Returns the text colour associated with the menu item (Windows only).



wxMenuItem::IsCheckable

bool IsCheckable(void) const

Returns true if the item is checkable.



wxMenuItem::IsChecked

bool IsChecked(void) const

Returns true if the item is checked.



wxMenuItem::IsEnabled

bool IsEnabled(void) const

Returns true if the item is enabled.



wxMenuItem::IsSeparator

bool IsSeparator(void) const

Returns true if the item is a separator.



wxMenuItem::IsSubMenu

bool IsSubMenu(void) const

Returns true if the item is a submenu.



wxMenuItem::SetBackgroundColour

void SetBackgroundColour(const wxColour& colour) const

Sets the background colour associated with the menu item (Windows only).



wxMenuItem::SetBitmap



void SetBitmap(const wxBitmap& bmp)

Sets the bitmap for the menu item (Windows and GTK+ only). It is equivalent to SetBitmaps(bmp, wxNullBitmap).



wxMenuItem::SetBitmaps



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.



wxMenuItem::SetFont



void SetFont(const wxFont& font)

Sets the font associated with the menu item (Windows only).



wxMenuItem::SetHelp



void SetHelp(const wxString& helpString)

Sets the help string.



wxMenuItem::SetMarginWidth

void SetMarginWidth(int width) const

Sets the width of the menu item checkmark bitmap (Windows only).



wxMenuItem::SetMenu



void SetMenu(const wxMenu* menu)

Sets the parent menu which will contain this menu item.



wxMenuItem::SetSubMenu



void SetSubMenu(const wxMenu* menu)

Sets the submenu of this menu item.



wxMenuItem::SetText



void SetText(const wxString& text)

Sets the text associated with the menu item.



wxMenuItem::SetTextColour



void SetTextColour(const wxColour& colour)

Sets the text colour associated with the menu item (Windows only).

ymasuda 平成17年11月19日