.\" This is a wxWidgets manpage page generated from the XML docs .TH wxMenu 3wx 2005-02-15 "wxWidgets" "wxWidgets class documentation" .SH NAME wxMenu \- Displays a series of menu items for selection .SH DESCRIPTION A menu is a popup (or pull down) list of items, one of which may be selected before the menu goes away (clicking elsewhere dismisses the menu). Menus may be used to construct either menu bars or popup menus. A menu item has an integer ID associated with it which can be used to identify the selection, or to change the menu item in some way. A menu item with a special identifier -1 is a separator item and doesn't have an associated command but just makes a separator line appear in the menu. NB: Please note that wxID_ABOUT and wxID_EXIT are predefined by wxWidgets and have a special meaning since entries using these IDs will be taken out of the normal menus under MacOS X and will be inserted into the system menu (following the appropriate MacOS X interface guideline). On PalmOS wxID_EXIT is disabled according to Palm OS Companion guidelines. Menu items may be either normal items, check items or radio items. Normal items don't have any special properties while the check items have a boolean flag associated to them and they show a checkmark in the menu when the flag is set. wxWidgets automatically toggles the flag value when the item is clicked and its value may be retrieved using either IsChecked method of wxMenu or wxMenuBar itself or by using wxEvent::IsChecked when you get the menu notification for the item in question. The radio items are similar to the check items except that all the other items in the same radio group are unchecked when a radio item is checked. The radio group is formed by a contiguous range of radio items, i.e. it starts at the first item of this kind and ends with the first item of a different kind (or the end of the menu). Notice that because the radio groups are defined in terms of the item positions inserting or removing the items in the menu containing the radio items risks to not work correctly. Finally note that radio items are not supported under Motif. Allocation strategy All menus except the popup ones must be created on the heap. All menus attached to a menubar or to another menu will be deleted by their parent when it is deleted. As the frame menubar is deleted by the frame itself, it means that normally all menus used are deleted automatically. .SH "PARENTS" wxEvtHandler wxObject .SH "INCLUDE FILES" wx/menu.h .SH MEMBERS .SS wxMenu (const wxString& title = ""long style = 0) Constructs a wxMenu object. .SS wxMenu (long style) Constructs a wxMenu object. .SS ~wxMenu () Destructor, destroying the menu. Note: under Motif, a popup menu must have a valid parent (the window it was last popped up on) when being destroyed. Therefore, make sure you delete or re-use the popup menu before destroying the parent window. Re-use in this context means popping up the menu on a different window from last time, which causes an implicit destruction and recreation of internal data structures. .SS wxMenuItem* Append (int idconst wxString& itemconst wxString& helpString = ""wxItemKind kind = wxITEM_NORMAL) Adds a string item to the end of the menu. .SS wxMenuItem* Append (int idconst wxString& itemwxMenu *subMenuconst wxString& helpString = "") Adds a pull-right submenu to the end of the menu. Append the submenu to the parent menu after you have added your menu items, or accelerators may not be registered properly. .SS wxMenuItem* Append (wxMenuItem* menuItem) .SS wxMenuItem* AppendCheckItem (int idconst wxString& itemconst wxString& helpString = "") Adds a checkable item to the end of the menu. .SS wxMenuItem* AppendRadioItem (int idconst wxString& itemconst wxString& helpString = "") Adds a radio item to the end of the menu. All consequent radio items form a group and when an item in the group is checked, all the others are automatically unchecked. NB: Currently only implemented under Windows and GTK, use #if wxHAS_RADIO_MENU_ITEMS to test for availability of this feature. .SS wxMenuItem* AppendSeparator () Adds a separator to the end of the menu. .SS void Break () Inserts a break in a menu, causing the next appended item to appear in a new column. .SS void Check (int idconst bool check) Checks or unchecks the menu item. .SS void Delete (int id) .SS void Delete (wxMenuItem *item) Deletes the menu item from the menu. If the item is a submenu, it will not be deleted. Use Destroy if you want to delete a submenu. .SS void Destroy (int id) .SS void Destroy (wxMenuItem *item) Deletes the menu item from the menu. If the item is a submenu, it will be deleted. Use Remove if you want to keep the submenu (for example, to reuse it later). .SS void Enable (int idconst bool enable) Enables or disables (greys out) a menu item. .SS int FindItem (const wxString& itemString) Finds the menu item id for a menu item string. .SS wxMenuItem * FindItem (int idwxMenu **menu = NULL) Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to. .SS wxMenuItem* FindItemByPosition (size_t position) Returns the wxMenuItem given a position in the menu. .SS wxString GetHelpString (int id) .SS wxString GetLabel (int id) Returns a menu item label. .SS size_t GetMenuItemCount () Returns the number of items in the menu. .SS wxMenuItemList& GetMenuItems () Returns the list of items in the menu. wxMenuItemList is a pseudo-template list class containing wxMenuItem pointers. .SS wxString GetTitle () Returns the title of the menu. .SS wxMenuItem* Insert (size_t poswxMenuItem *item) .SS wxMenuItem* Insert (size_t posint idconst wxString& itemconst wxString& helpString = ""wxItemKind kind = wxITEM_NORMAL) Inserts the given item before the position pos . Inserting the item at position GetMenuItemCount is the same as appending it. .SS wxMenuItem* InsertCheckItem (size_t posint idconst wxString& itemconst wxString& helpString = "") Inserts a checkable item at the given position. .SS wxMenuItem* InsertRadioItem (size_t posint idconst wxString& itemconst wxString& helpString = "") Inserts a radio item at the given position. .SS wxMenuItem* InsertSeparator (size_t pos) Inserts a separator at the given position. .SS bool IsChecked (int id) Determines whether a menu item is checked. .SS bool IsEnabled (int id) Determines whether a menu item is enabled. .SS wxMenuItem* Prepend (wxMenuItem *item) .SS wxMenuItem* Prepend (int idconst wxString& itemconst wxString& helpString = ""wxItemKind kind = wxITEM_NORMAL) Inserts the given item at position 0, i.e. before all the other existing items. .SS wxMenuItem* PrependCheckItem (int idconst wxString& itemconst wxString& helpString = "") Inserts a checkable item at position 0. .SS wxMenuItem* PrependRadioItem (int idconst wxString& itemconst wxString& helpString = "") Inserts a radio item at position 0. .SS wxMenuItem* PrependSeparator () Inserts a separator at position 0. .SS wxMenuItem * Remove (int id) .SS wxMenuItem * Remove (wxMenuItem *item) Removes the menu item from the menu but doesn't delete the associated C++ object. This allows to reuse the same item later by adding it back to the menu (especially useful with submenus). .SS void SetHelpString (int idconst wxString& helpString) Sets an item's help string. .SS void SetLabel (int idconst wxString& label) .SS void SetTitle (const wxString& title) Sets the title of the menu. .SS void UpdateUI (wxEvtHandler* source = NULL) Sends events to source (or owning window if NULL) to update the menu UI. This is called just before the menu is popped up with wxWindow::PopupMenu , but the application may call it at other times if required. .SH EVENTS .SH "SEE ALSO" wxEvtHandler wxObject wxMenuBar wxWindow::PopupMenu , Event handling overview , wxFileHistory (most recently used files menu) .SH "AUTHORS" Documentation content by Julian Smart, Robert Roebling, Vadim Zeitlin, Robin Dunn, et al Conversion to manpage format by Arnout Engelen (http://bzzt.net), bugreports welcome.