wxmenubara menu bar is a series of menus accessible from the top of a frame. derived from
wxwindow include files <wx/menu.h> event handling to respond to a menu selection, provide a handler for evt_menu, in the frame that contains the menu bar. if you have a toolbar which uses the same identifiers as your evt_menu entries, events from the toolbar will also be processed by your evt_menu event handlers. tip: under windows, if you discover that menu shortcuts (for example, alt-f to show the file menu) are not working, check any evt_char events you are handling in child windows. if you are not calling event.skip() for events that you don't process in these event handlers, menu shortcuts may cease to work. see also wxmenu, event handling overview members
wxmenubar::wxmenubar
wxmenubar::wxmenubarwxmenubar(long style = 0) default constructor. wxmenubar(size_t n, wxmenu* menus[], const wxstring titles[], long style = 0) construct a menu bar from arrays of menus and titles. parameters n
menus
titles
style
wxpython note: only the default constructor is supported in wxpython. use wxmenubar::append instead. wxperl note: wxperl only supports the first constructor: use wxmenubar::append instead.
wxmenubar::~wxmenubarvoid ~wxmenubar() destructor, destroying the menu bar and removing it from the parent frame (if any).
wxmenubar::appendbool append(wxmenu *menu, const wxstring& title) adds the item to the end of the menu bar. parameters menu
title
return value true on success, false if an error occurred. see also
wxmenubar::checkvoid check(int id, const bool check) checks or unchecks a menu item. parameters id
check
remarks only use this when the menu bar has been associated with a frame; otherwise, use the wxmenu equivalent call.
wxmenubar::enablevoid enable(int id, const bool enable) enables or disables (greys out) a menu item. parameters id
enable
remarks only use this when the menu bar has been associated with a frame; otherwise, use the wxmenu equivalent call.
wxmenubar::enabletopvoid enabletop(int pos, const bool enable) enables or disables a whole menu. parameters pos
enable
remarks only use this when the menu bar has been associated with a frame.
wxmenubar::findmenuint findmenu(const wxstring& title) const returns the index of the menu with the given title or wxnot_found if no such menu exists in this menubar. the title parameter may specify either the menu title (with accelerator characters, i.e. "&file") or just the menu label ("file") indifferently.
wxmenubar::findmenuitemint findmenuitem(const wxstring& menustring, const wxstring& itemstring) const finds the menu item id for a menu name/menu item string pair. parameters menustring
itemstring
return value the menu item identifier, or wxnot_found if none was found. remarks any special menu codes are stripped out of source and target strings before matching.
wxmenubar::finditemwxmenuitem * finditem(int id, wxmenu **menu = null) const finds the menu item object associated with the given menu item identifier. parameters id
menu
return value the found menu item object, or null if one was not found.
wxmenubar::gethelpstringwxstring gethelpstring(int id) const gets the help string associated with the menu item identifier. parameters id
return value the help string, or the empty string if there was no help string or the menu item was not found. see also
wxmenubar::getlabelwxstring getlabel(int id) const gets the label associated with a menu item. parameters id
return value the menu item label, or the empty string if the item was not found. remarks use only after the menubar has been associated with a frame.
wxmenubar::getlabeltopwxstring getlabeltop(int pos) const returns the label of a top-level menu. note that the returned string does not include the accelerator characters which could have been specified in the menu title string during its construction. parameters pos
return value the menu label, or the empty string if the menu was not found. remarks use only after the menubar has been associated with a frame. this function is deprecated in favour of getmenulabel and getmenulabeltext. see also
wxmenubar::getmenuwxmenu* getmenu(int menuindex) const returns the menu at menuindex (zero-based).
wxmenubar::getmenucountint getmenucount() const returns the number of menus in this menubar.
wxmenubar::getmenulabelwxstring getmenulabel(int pos) const returns the label of a top-level menu. note that the returned string includes the accelerator characters that have been specified in the menu title string during its construction. parameters pos
return value the menu label, or the empty string if the menu was not found. remarks use only after the menubar has been associated with a frame. see also wxmenubar::getmenulabeltext, wxmenubar::setmenulabel
wxmenubar::getmenulabeltextwxstring getmenulabeltext(int pos) const returns the label of a top-level menu. note that the returned string does not include any accelerator characters that may have been specified in the menu title string during its construction. parameters pos
return value the menu label, or the empty string if the menu was not found. remarks use only after the menubar has been associated with a frame. see also wxmenubar::getmenulabel, wxmenubar::setmenulabel
wxmenubar::insertbool insert(size_t pos, wxmenu *menu, const wxstring& title) inserts the menu at the given position into the menu bar. inserting menu at position 0 will insert it in the very beginning of it, inserting at position getmenucount() is the same as calling append(). parameters pos
menu
title
return value true on success, false if an error occurred. see also
wxmenubar::ischeckedbool ischecked(int id) const determines whether an item is checked. parameters id
return value true if the item was found and is checked, false otherwise.
wxmenubar::isenabledbool isenabled(int id) const determines whether an item is enabled. parameters id
return value true if the item was found and is enabled, false otherwise.
wxmenubar::refreshvoid refresh() redraw the menu bar
wxmenubar::removewxmenu * remove(size_t pos) removes the menu from the menu bar and returns the menu object - the caller is responsible for deleting it. this function may be used together with wxmenubar::insert to change the menubar dynamically. see also
wxmenubar::replacewxmenu * replace(size_t pos, wxmenu *menu, const wxstring& title) replaces the menu at the given position with another one. parameters pos
menu
title
return value the menu which was previously at position pos. the caller is responsible for deleting it. see also wxmenubar::insert, wxmenubar::remove
wxmenubar::sethelpstringvoid sethelpstring(int id, const wxstring& helpstring) sets the help string associated with a menu item. parameters id
helpstring
see also
wxmenubar::setlabelvoid setlabel(int id, const wxstring& label) sets the label of a menu item. parameters id
label
remarks use only after the menubar has been associated with a frame. see also
wxmenubar::setlabeltopvoid setlabeltop(int pos, const wxstring& label) sets the label of a top-level menu. parameters pos
label
remarks use only after the menubar has been associated with a frame. this function has been deprecated in favour of setmenulabel. see also
wxmenubar::setmenulabelvoid setmenulabel(int pos, const wxstring& label) sets the label of a top-level menu. parameters pos
label
remarks use only after the menubar has been associated with a frame. see also wxmenubar::getmenulabel, wxmenubar::getmenulabeltext
|