]>
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.
32 Menu items can be standard, or "stock menu items'', or custom. For the
33 standard menu items (such as commands to open a file, exit the program and so
34 on, see @ref overview_stockitems "stock items" for the full list) it is enough
36 specify just the stock ID and leave @e text and @e helpString empty. In
37 fact, leaving at least @e text empty for the stock menu items is strongly
38 recommended as they will have appearance and keyboard interface (including
39 standard accelerators) familiar to the user.
41 For the custom (non-stock) menu items, @e text must be specified and while
42 @e helpString may be left empty, it's recommended to pass the item
43 description (which is automatically shown by the library in the status bar when
44 the menu item is selected) in this parameter.
46 Finally note that you can e.g. use a stock menu label without using its stock
48 that is, stock properties are set independently one from the other.
51 Menu that the menu item belongs to.
54 Identifier for this menu item, or wxID_SEPARATOR to indicate a separator.
57 Text for the menu item, as shown on the menu. An accelerator
58 key can be specified using the ampersand '' character. In order to embed an
59 ampersand character in the menu item text, the ampersand must be doubled.
62 Optional help string that will be shown on the status bar.
65 May be wxITEM_SEPARATOR, wxITEM_NORMAL,
66 wxITEM_CHECK or wxITEM_RADIO
69 If non-@NULL, indicates that the menu item is a submenu.
71 wxMenuItem(wxMenu
* parentMenu
= @NULL
, int id
= wxID_SEPARATOR
,
72 const wxString
& text
= "",
73 const wxString
& helpString
= "",
74 wxItemKind kind
= wxITEM_NORMAL
,
75 wxMenu
* subMenu
= @NULL
);
83 Checks or unchecks the menu item.
85 Note that this only works when the item is already appended to a menu.
87 void Check(bool check
= @
true);
90 Enables or disables the menu item.
92 void Enable(bool enable
= @
true);
95 Returns the background colour associated with the menu item (Windows only).
97 wxColour
GetBackgroundColour();
100 Returns the checked or unchecked bitmap (Windows only).
102 wxBitmap
GetBitmap(bool checked
= @
true);
105 Returns the font associated with the menu item (Windows only).
110 Returns the help string associated with the menu item.
115 Returns the menu item identifier.
120 Returns the text associated with the menu item including any accelerator
121 characters that were passed to the constructor or SetItemLabel.
123 @sa GetItemLabelText(), GetLabelText()
125 wxString
GetItemLabel();
128 Returns the text associated with the menu item, without any accelerator
131 @sa GetItemLabel(), GetLabelText()
133 wxString
GetItemLabelText();
136 Returns the item kind, one of @c wxITEM_SEPARATOR, @c wxITEM_NORMAL,
137 @c wxITEM_CHECK or @c wxITEM_RADIO.
139 wxItemKind
GetKind();
142 Returns the text associated with the menu item without any accelerator
143 characters it might contain.
145 This function is deprecated in favour of GetItemLabelText().
147 @sa GetText(), GetLabelFromText()
152 Strips all accelerator characters and mnemonics from the given @e text.
154 will return just @c "Hello".
156 This function is deprecated; please use GetLabelText() instead.
158 @sa GetText(), GetLabel()
160 static wxString
GetLabelFromText(const wxString
& text
);
163 Strips all accelerator characters and mnemonics from the given @e text.
165 will return just @c "Hello".
167 @sa GetItemLabelText(), GetItemLabel()
169 static wxString
GetLabelText(const wxString
& text
);
172 Gets the width of the menu item checkmark bitmap (Windows only).
174 int GetMarginWidth();
177 Returns the menu this menu item is in, or @NULL if this menu item is not
183 Returns the text associated with the menu item.
185 @b NB: this function is deprecated, please use
186 GetItemLabel() or GetItemLabelText()
192 Returns the submenu associated with the menu item, or @NULL if there isn't one.
194 wxMenu
* GetSubMenu();
197 Returns the text associated with the menu item, such as it was passed to the
198 wxMenuItem constructor, i.e. with any accelerator characters it may contain.
200 This function is deprecated in favour of GetItemLabel().
202 @sa GetLabel(), GetLabelFromText()
207 Returns the text colour associated with the menu item (Windows only).
209 wxColour
GetTextColour();
212 Returns @true if the item is checkable.
217 Returns @true if the item is checked.
222 Returns @true if the item is enabled.
227 Returns @true if the item is a separator.
232 Returns @true if the item is a submenu.
237 Sets the background colour associated with the menu item (Windows only).
239 void SetBackgroundColour(const wxColour
& colour
);
242 Sets the bitmap for the menu item (Windows and GTK+ only). It is
243 equivalent to wxMenuItem::SetBitmaps(bmp, wxNullBitmap).
245 void SetBitmap(const wxBitmap
& bmp
);
248 Sets the checked/unchecked bitmaps for the menu item (Windows only). The first
250 is also used as the single bitmap for uncheckable menu items.
252 void SetBitmaps(const wxBitmap
& checked
,
253 const wxBitmap
& unchecked
= wxNullBitmap
);
256 Sets the font associated with the menu item (Windows only).
258 void SetFont(const wxFont
& font
);
261 Sets the help string.
263 void SetHelp(const wxString
& helpString
);
266 Sets the label associated with the menu item.
268 void SetItemLabel(const wxString
& label
);
271 Sets the width of the menu item checkmark bitmap (Windows only).
273 void SetMarginWidth(int width
);
276 Sets the parent menu which will contain this menu item.
278 void SetMenu(const wxMenu
* menu
);
281 Sets the submenu of this menu item.
283 void SetSubMenu(const wxMenu
* menu
);
286 Sets the text associated with the menu item.
288 This function is deprecated in favour of SetItemLabel().
290 void SetText(const wxString
& text
);
293 Sets the text colour associated with the menu item (Windows only).
295 void SetTextColour(const wxColour
& colour
);