]>
git.saurik.com Git - wxWidgets.git/blob - interface/menuitem.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxMenuItem class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A menu item represents an item in a menu. Note that you usually don't have to
14 deal with it directly as wxMenu methods usually construct an
15 object of this class for you.
17 Also please note that the methods related to fonts and bitmaps are currently
18 only implemented for Windows and GTK+.
26 class wxMenuItem
: public wxObject
30 Constructs a wxMenuItem object.
31 Menu items can be standard, or "stock menu items'', or custom. For the
32 standard menu items (such as commands to open a file, exit the program and so
33 on, see @ref overview_stockitems "stock items" for the full list) it is enough
35 specify just the stock ID and leave @a text and @a helpString empty. In
36 fact, leaving at least @a text empty for the stock menu items is strongly
37 recommended as they will have appearance and keyboard interface (including
38 standard accelerators) familiar to the user.
39 For the custom (non-stock) menu items, @a text must be specified and while
40 @a helpString may be left empty, it's recommended to pass the item
41 description (which is automatically shown by the library in the status bar when
42 the menu item is selected) in this parameter.
43 Finally note that you can e.g. use a stock menu label without using its stock
46 that is, stock properties are set independently one from the other.
49 Menu that the menu item belongs to.
51 Identifier for this menu item, or wxID_SEPARATOR to indicate a separator.
53 Text for the menu item, as shown on the menu. An accelerator
54 key can be specified using the ampersand '' character. In order to embed an
55 ampersand character in the menu item text, the ampersand must be doubled.
57 Optional help string that will be shown on the status bar.
59 May be wxITEM_SEPARATOR, wxITEM_NORMAL,
60 wxITEM_CHECK or wxITEM_RADIO
62 If non-@NULL, indicates that the menu item is a submenu.
64 wxMenuItem(wxMenu
* parentMenu
= NULL
, int id
= wxID_SEPARATOR
,
65 const wxString
& text
= "",
66 const wxString
& helpString
= "",
67 wxItemKind kind
= wxITEM_NORMAL
,
68 wxMenu
* subMenu
= NULL
);
76 Checks or unchecks the menu item.
77 Note that this only works when the item is already appended to a menu.
79 void Check(bool check
= true);
82 Enables or disables the menu item.
84 void Enable(bool enable
= true);
87 Returns the background colour associated with the menu item (Windows only).
89 wxColour
GetBackgroundColour();
92 Returns the checked or unchecked bitmap (Windows only).
94 wxBitmap
GetBitmap(bool checked
= true);
97 Returns the font associated with the menu item (Windows only).
102 Returns the help string associated with the menu item.
107 Returns the menu item identifier.
112 Returns the text associated with the menu item including any accelerator
113 characters that were passed to the constructor or SetItemLabel.
115 @see GetItemLabelText(), GetLabelText()
117 wxString
GetItemLabel();
120 Returns the text associated with the menu item, without any accelerator
123 @see GetItemLabel(), GetLabelText()
125 wxString
GetItemLabelText();
128 Returns the item kind, one of @c wxITEM_SEPARATOR, @c wxITEM_NORMAL,
129 @c wxITEM_CHECK or @c wxITEM_RADIO.
131 wxItemKind
GetKind();
134 Returns the text associated with the menu item without any accelerator
135 characters it might contain.
136 This function is deprecated in favour of GetItemLabelText().
138 @see GetText(), GetLabelFromText()
143 Strips all accelerator characters and mnemonics from the given @e text.
146 will return just @c "Hello".
147 This function is deprecated; please use GetLabelText() instead.
149 @see GetText(), GetLabel()
151 static wxString
GetLabelFromText(const wxString
& text
);
154 Strips all accelerator characters and mnemonics from the given @e text.
157 will return just @c "Hello".
159 @see GetItemLabelText(), GetItemLabel()
161 static wxString
GetLabelText(const wxString
& text
);
164 Gets the width of the menu item checkmark bitmap (Windows only).
166 int GetMarginWidth();
169 Returns the menu this menu item is in, or @NULL if this menu item is not
175 Returns the text associated with the menu item.
176 @b NB: this function is deprecated, please use
177 GetItemLabel() or GetItemLabelText()
183 Returns the submenu associated with the menu item, or @NULL if there isn't one.
185 wxMenu
* GetSubMenu();
188 Returns the text associated with the menu item, such as it was passed to the
189 wxMenuItem constructor, i.e. with any accelerator characters it may contain.
190 This function is deprecated in favour of GetItemLabel().
192 @see GetLabel(), GetLabelFromText()
197 Returns the text colour associated with the menu item (Windows only).
199 wxColour
GetTextColour();
202 Returns @true if the item is checkable.
207 Returns @true if the item is checked.
212 Returns @true if the item is enabled.
217 Returns @true if the item is a separator.
222 Returns @true if the item is a submenu.
227 Sets the background colour associated with the menu item (Windows only).
229 void SetBackgroundColour(const wxColour
& colour
);
232 Sets the bitmap for the menu item (Windows and GTK+ only). It is
233 equivalent to wxMenuItem::SetBitmaps(bmp, wxNullBitmap).
235 void SetBitmap(const wxBitmap
& bmp
);
238 Sets the checked/unchecked bitmaps for the menu item (Windows only). The first
240 is also used as the single bitmap for uncheckable menu items.
242 void SetBitmaps(const wxBitmap
& checked
,
243 const wxBitmap
& unchecked
= wxNullBitmap
);
246 Sets the font associated with the menu item (Windows only).
248 void SetFont(const wxFont
& font
);
251 Sets the help string.
253 void SetHelp(const wxString
& helpString
);
256 Sets the label associated with the menu item.
258 void SetItemLabel(const wxString
& label
);
261 Sets the width of the menu item checkmark bitmap (Windows only).
263 void SetMarginWidth(int width
);
266 Sets the parent menu which will contain this menu item.
268 void SetMenu(const wxMenu
* menu
);
271 Sets the submenu of this menu item.
273 void SetSubMenu(const wxMenu
* menu
);
276 Sets the text associated with the menu item.
277 This function is deprecated in favour of SetItemLabel().
279 void SetText(const wxString
& text
);
282 Sets the text colour associated with the menu item (Windows only).
284 void SetTextColour(const wxColour
& colour
);