wxMenuItemA 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 Include files <wx/menuitem.h> See also Members
wxMenuItem::wxMenuItem
wxMenuItem::wxMenuItemwxMenuItem(wxMenu* parentMenu = NULL, int id = wxID_SEPARATOR, const wxString& text = "", const wxString& helpString = "", wxItemKind kind = wxITEM_NORMAL, wxMenu* subMenu = NULL) Constructs a wxMenuItem object. Menu items can be standard, or "stock menu items'', or custom. For the standard menu items (such as commands to open a file, exit the program and so on, see stock items for the full list) it is enough to specify just the stock ID and leave text and helpString empty. In fact, leaving at least text empty for the stock menu items is strongly recommended as they will have appearance and keyboard interface (including standard accelerators) familiar to the user. For the custom (non-stock) menu items, text must be specified and while helpString may be left empty, it's recommended to pass the item description (which is automatically shown by the library in the status bar when the menu item is selected) in this parameter. Finally note that you can e.g. use a stock menu label without using its stock help string:
// use all stock properties: helpMenu->Append(wxID_ABOUT); // use the stock label and the stock accelerator but not the stock help string: helpMenu->Append(wxID_ABOUT, wxEmptyString, wxT("My custom help string")); // use all stock properties except for the bitmap: wxMenuItem *mymenu = new wxMenuItem(helpMenu, wxID_ABOUT); mymenu->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING)); helpMenu->Append(mymenu);that is, stock properties are set independently one from the other. Parameters parentMenu
id
text
helpString
kind
subMenu
wxMenuItem::~wxMenuItem~wxMenuItem() Destructor.
wxMenuItem::Checkvoid 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::Enablevoid Enable(bool enable = true) Enables or disables the menu item.
wxMenuItem::GetBackgroundColourwxColour& GetBackgroundColour() const Returns the background colour associated with the menu item (Windows only).
wxMenuItem::GetBitmapwxBitmap& GetBitmap(bool checked = true) const Returns the checked or unchecked bitmap (Windows only).
wxMenuItem::GetFontwxFont& GetFont() const Returns the font associated with the menu item (Windows only).
wxMenuItem::GetHelpwxString GetHelp() const Returns the help string associated with the menu item.
wxMenuItem::GetIdint GetId() const Returns the menu item identifier.
wxMenuItem::GetItemLabelwxString GetItemLabel() const Returns the text associated with the menu item including any accelerator characters that were passed to the constructor or SetItemLabel. See also GetItemLabelText, GetLabelText
wxMenuItem::GetItemLabelTextwxString GetItemLabelText() const Returns the text associated with the menu item, without any accelerator characters. See also
wxMenuItem::GetKindwxItemKind GetKind() const Returns the item kind, one of wxITEM_SEPARATOR, wxITEM_NORMAL, wxITEM_CHECK or wxITEM_RADIO.
wxMenuItem::GetLabelwxString GetLabel() const Returns the text associated with the menu item without any accelerator characters it might contain. This function is deprecated in favour of GetItemLabelText. See also
wxMenuItem::GetLabelTextstatic wxString GetLabelText(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 GetItemLabelText, GetItemLabel
wxMenuItem::GetLabelFromTextstatic 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". This function is deprecated; please use wxMenuItem::GetLabelText instead. See also
wxMenuItem::GetMarginWidthint GetMarginWidth() const Gets the width of the menu item checkmark bitmap (Windows only).
wxMenuItem::GetMenuwxMenu* GetMenu() const Returns the menu this menu item is in, or NULL if this menu item is not attached.
wxMenuItem::GetNamewxString GetName() const Returns the text associated with the menu item. NB: this function is deprecated, please use GetItemLabel or GetItemLabelText instead.
wxMenuItem::GetTextwxString 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. This function is deprecated in favour of GetItemLabel. See also
wxMenuItem::GetSubMenuwxMenu* GetSubMenu() const Returns the submenu associated with the menu item, or NULL if there isn't one.
wxMenuItem::GetTextColourwxColour& GetTextColour() const Returns the text colour associated with the menu item (Windows only).
wxMenuItem::IsCheckablebool IsCheckable() const Returns true if the item is checkable.
wxMenuItem::IsCheckedbool IsChecked() const Returns true if the item is checked.
wxMenuItem::IsEnabledbool IsEnabled() const Returns true if the item is enabled.
wxMenuItem::IsSeparatorbool IsSeparator() const Returns true if the item is a separator.
wxMenuItem::IsSubMenubool IsSubMenu() const Returns true if the item is a submenu.
wxMenuItem::SetBackgroundColourvoid SetBackgroundColour(const wxColour& colour) const Sets the background colour associated with the menu item (Windows only).
wxMenuItem::SetBitmapvoid SetBitmap(const wxBitmap& bmp) Sets the bitmap for the menu item (Windows and GTK+ only). It is equivalent to SetBitmaps(bmp, wxNullBitmap).
wxMenuItem::SetBitmapsvoid 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::SetFontvoid SetFont(const wxFont& font) Sets the font associated with the menu item (Windows only).
wxMenuItem::SetHelpvoid SetHelp(const wxString& helpString) Sets the help string.
wxMenuItem::SetItemLabelvoid SetItemLabel(const wxString& label) Sets the label associated with the menu item.
wxMenuItem::SetMarginWidthvoid SetMarginWidth(int width) const Sets the width of the menu item checkmark bitmap (Windows only).
wxMenuItem::SetMenuvoid SetMenu(const wxMenu*menu) Sets the parent menu which will contain this menu item.
wxMenuItem::SetSubMenuvoid SetSubMenu(const wxMenu*menu) Sets the submenu of this menu item.
wxMenuItem::SetTextvoid SetText(const wxString& text) Sets the text associated with the menu item. This function is deprecated in favour of SetItemLabel.
wxMenuItem::SetTextColourvoid SetTextColour(const wxColour& colour) Sets the text colour associated with the menu item (Windows only).
|