$szTitle = "wxmenuitem"; include "./_header.inc"; ?>
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
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::getitemlabel
wxmenuitem::getitemlabeltext
wxmenuitem::getkind
wxmenuitem::getlabel
wxmenuitem::getlabeltext
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::setitemlabel
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.
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()
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.
wxstring 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
wxstring getitemlabeltext() const
returns the text associated with the menu item, without any accelerator characters.
see also
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.
this function is deprecated in favour of getitemlabeltext.
see also
static 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
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".
this function is deprecated; please use wxmenuitem::getlabeltext instead.
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 getitemlabel or getitemlabeltext 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.
this function is deprecated in favour of getitemlabel.
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 setitemlabel(const wxstring& label)
sets the label associated with the menu item.
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.
this function is deprecated in favour of setitemlabel.
void settextcolour(const wxcolour& colour)
sets the text colour associated with the menu item (windows only).
include "./_footer.inc"; ?>