#include <wx/menu.h>

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.
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.
Public Member Functions | |
| wxMenu (long style) | |
| wxMenu (const wxString &title="", long style=0) | |
| ~wxMenu () | |
| wxMenuItem * | Append (int id, const wxString &item=wxEmptyString, const wxString &helpString=wxEmptyString, wxItemKind kind=wxITEM_NORMAL) |
| wxMenuItem * | Append (int id, const wxString &item, wxMenu *subMenu, const wxString &helpString=wxEmptyString) |
| wxMenuItem * | Append (wxMenuItem *menuItem) |
| wxMenuItem * | AppendCheckItem (int id, const wxString &item, const wxString &helpString="") |
| wxMenuItem * | AppendRadioItem (int id, const wxString &item, const wxString &helpString="") |
| wxMenuItem * | AppendSeparator () |
| wxMenuItem * | AppendSubMenu (wxMenu *submenu, const wxString &text, const wxString &help=wxEmptyString) |
| void | Break () |
| void | Check (int id, const bool check) |
| void | Delete (int id) |
| void | Delete (wxMenuItem *item) |
| void | Destroy (int id) |
| void | Destroy (wxMenuItem *item) |
| void | Enable (int id, const bool enable) |
| int | FindItem (const wxString &itemString) const |
| const wxMenuItem * | FindItem (int id, wxMenu **menu=NULL) const |
| wxMenuItem * | FindItemByPosition (size_t position) const |
| wxString | GetHelpString (int id) const |
| wxString | GetLabel (int id) const |
| wxString | GetLabelText (int id) const |
| size_t | GetMenuItemCount () const |
| wxMenuItemList | GetMenuItems () const |
| wxString | GetTitle () const |
| wxMenuItem * | Insert (size_t pos, wxMenuItem *item) |
| wxMenuItem * | Insert (size_t pos, int id, const wxString &item="", const wxString &helpString="", wxItemKind kind=wxITEM_NORMAL) |
| wxMenuItem * | InsertCheckItem (size_t pos, int id, const wxString &item, const wxString &helpString="") |
| wxMenuItem * | InsertRadioItem (size_t pos, int id, const wxString &item, const wxString &helpString="") |
| wxMenuItem * | InsertSeparator (size_t pos) |
| bool | IsChecked (int id) const |
| bool | IsEnabled (int id) const |
| wxMenuItem * | Prepend (wxMenuItem *item) |
| wxMenuItem * | Prepend (int id, const wxString &item="", const wxString &helpString="", wxItemKind kind=wxITEM_NORMAL) |
| wxMenuItem * | PrependCheckItem (int id, const wxString &item, const wxString &helpString="") |
| wxMenuItem * | PrependRadioItem (int id, const wxString &item, const wxString &helpString="") |
| wxMenuItem * | PrependSeparator () |
| wxMenuItem * | Remove (int id) |
| wxMenuItem * | Remove (wxMenuItem *item) |
| void | SetHelpString (int id, const wxString &helpString) |
| void | SetLabel (int id, const wxString &label) |
| void | SetTitle (const wxString &title) |
| void | UpdateUI (wxEvtHandler *source=NULL) const |
| wxMenu::wxMenu | ( | long | style | ) |
Constructs a wxMenu object.
| style | If set to wxMENU_TEAROFF, the menu will be detachable (wxGTK only). |
| wxMenu::wxMenu | ( | const wxString & | title = "", |
|
| long | style = 0 | |||
| ) |
Constructs a wxMenu object with a title
| title | Title at the top of the menu (not always supported). | |
| style | If set to wxMENU_TEAROFF, the menu will be detachable (wxGTK only). |
| wxMenu::~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.
| wxMenuItem* wxMenu::Append | ( | int | id, | |
| const wxString & | item = wxEmptyString, |
|||
| const wxString & | helpString = wxEmptyString, |
|||
| wxItemKind | kind = wxITEM_NORMAL | |||
| ) |
Adds a menu item.
| id | The menu command identifier. | |
| item | The string to appear on the menu item. | |
| helpString | An optional help string associated with the item. By default, the handler for the wxEVT_MENU_HIGHLIGHT event displays this string in the status line. | |
| kind | May be wxITEM_SEPARATOR, wxITEM_NORMAL, wxITEM_CHECK or wxITEM_RADIO |
| wxMenuItem* wxMenu::Append | ( | int | id, | |
| const wxString & | item, | |||
| wxMenu * | subMenu, | |||
| const wxString & | helpString = wxEmptyString | |||
| ) |
Adds a submenu.
| id | The menu command identifier. | |
| item | The string to appear on the menu item. | |
| subMenu | Pull-right submenu. | |
| helpString | An optional help string associated with the item. By default, the handler for the wxEVT_MENU_HIGHLIGHT event displays this string in the status line. |
| wxMenuItem* wxMenu::Append | ( | wxMenuItem * | menuItem | ) |
Adds a menu item object. This is the most generic variant of Append() method because it may be used for both items (including separators) and submenus and because you can also specify various extra properties of a menu item this way, such as bitmaps and fonts.
| menuItem | A menuitem object. It will be owned by the wxMenu object after this function is called, so do not delete it yourself. |
| wxMenuItem* wxMenu::AppendCheckItem | ( | int | id, | |
| const wxString & | item, | |||
| const wxString & | helpString = "" | |||
| ) |
| wxMenuItem* wxMenu::AppendRadioItem | ( | int | id, | |
| const wxString & | item, | |||
| const 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.
| wxMenuItem* wxMenu::AppendSeparator | ( | ) |
| wxMenuItem* wxMenu::AppendSubMenu | ( | wxMenu * | submenu, | |
| const wxString & | text, | |||
| const wxString & | help = wxEmptyString | |||
| ) |
Adds the given submenu to this menu. text is the text shown in the menu for it and help is the help string shown in the status bar when the submenu item is selected.
| void wxMenu::Break | ( | ) |
Inserts a break in a menu, causing the next appended item to appear in a new column.
| void wxMenu::Check | ( | int | id, | |
| const bool | check | |||
| ) |
Checks or unchecks the menu item.
| id | The menu item identifier. | |
| check | If true, the item will be checked, otherwise it will be unchecked. |
| void wxMenu::Delete | ( | int | id | ) |
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.
| id | Id of the menu item to be deleted. |
| void wxMenu::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.
| item | Menu item to be deleted. |
| void wxMenu::Destroy | ( | int | id | ) |
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).
| id | Id of the menu item to be deleted. |
| void wxMenu::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).
| item | Menu item to be deleted. |
| void wxMenu::Enable | ( | int | id, | |
| const bool | enable | |||
| ) |
Enables or disables (greys out) a menu item.
| id | The menu item identifier. | |
| enable | true to enable the menu item, false to disable it. |
| int wxMenu::FindItem | ( | const wxString & | itemString | ) | const |
Finds the menu id for a menu item string.
| itemString | Menu item string to find. |
| const wxMenuItem* wxMenu::FindItem | ( | int | id, | |
| wxMenu ** | menu = NULL | |||
| ) | const |
Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to.
| id | Menu item identifier. | |
| menu | If the pointer is not NULL, it will be filled with the item's parent menu (if the item was found) |
| wxMenuItem* wxMenu::FindItemByPosition | ( | size_t | position | ) | const |
Returns the wxMenuItem given a position in the menu.
| wxString wxMenu::GetHelpString | ( | int | id | ) | const |
Returns the help string associated with a menu item.
| id | The menu item identifier. |
| wxString wxMenu::GetLabel | ( | int | id | ) | const |
Returns a menu item label.
| id | The menu item identifier. |
| wxString wxMenu::GetLabelText | ( | int | id | ) | const |
Returns a menu item label, without any of the original mnemonics and accelerators.
| id | The menu item identifier. |
| size_t wxMenu::GetMenuItemCount | ( | ) | const |
Returns the number of items in the menu.
| wxMenuItemList wxMenu::GetMenuItems | ( | ) | const |
Returns the list of items in the menu. wxMenuItemList is a pseudo-template list class containing wxMenuItem pointers, see wxList.
| wxString wxMenu::GetTitle | ( | ) | const |
Returns the title of the menu.
| wxMenuItem* wxMenu::Insert | ( | size_t | pos, | |
| wxMenuItem * | item | |||
| ) |
Inserts the given item before the position pos. Inserting the item at position GetMenuItemCount() is the same as appending it.
| wxMenuItem* wxMenu::Insert | ( | size_t | pos, | |
| int | id, | |||
| const wxString & | item = "", |
|||
| const 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.
| wxMenuItem* wxMenu::InsertCheckItem | ( | size_t | pos, | |
| int | id, | |||
| const wxString & | item, | |||
| const wxString & | helpString = "" | |||
| ) |
| wxMenuItem* wxMenu::InsertRadioItem | ( | size_t | pos, | |
| int | id, | |||
| const wxString & | item, | |||
| const wxString & | helpString = "" | |||
| ) |
| wxMenuItem* wxMenu::InsertSeparator | ( | size_t | pos | ) |
| bool wxMenu::IsChecked | ( | int | id | ) | const |
Determines whether a menu item is checked.
| id | The menu item identifier. |
| bool wxMenu::IsEnabled | ( | int | id | ) | const |
Determines whether a menu item is enabled.
| id | The menu item identifier. |
| wxMenuItem* wxMenu::Prepend | ( | wxMenuItem * | item | ) |
| wxMenuItem* wxMenu::Prepend | ( | int | id, | |
| const wxString & | item = "", |
|||
| const wxString & | helpString = "", |
|||
| wxItemKind | kind = wxITEM_NORMAL | |||
| ) |
| wxMenuItem* wxMenu::PrependCheckItem | ( | int | id, | |
| const wxString & | item, | |||
| const wxString & | helpString = "" | |||
| ) |
| wxMenuItem* wxMenu::PrependRadioItem | ( | int | id, | |
| const wxString & | item, | |||
| const wxString & | helpString = "" | |||
| ) |
| wxMenuItem* wxMenu::PrependSeparator | ( | ) |
| wxMenuItem* wxMenu::Remove | ( | int | id | ) |
Removes the menu item from the menu but doesn't delete the associated C++ object. This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus).
| id | The identifier of the menu item to remove. |
| wxMenuItem* wxMenu::Remove | ( | wxMenuItem * | item | ) |
Removes the menu item from the menu but doesn't delete the associated C++ object. This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus).
| item | The menu item to remove. |
| void wxMenu::SetHelpString | ( | int | id, | |
| const wxString & | helpString | |||
| ) |
Sets an item's help string.
| id | The menu item identifier. | |
| helpString | The help string to set. |
| void wxMenu::SetLabel | ( | int | id, | |
| const wxString & | label | |||
| ) |
Sets the label of a menu item.
| id | The menu item identifier. | |
| label | The menu item label to set. |
| void wxMenu::SetTitle | ( | const wxString & | title | ) |
Sets the title of the menu.
| title | The title to set. |
| void wxMenu::UpdateUI | ( | wxEvtHandler * | source = NULL |
) | const |
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.
|
[ top ] |