]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/menuitem.tex
fix LaTeX error (escape underscores); don't abuse bold face
[wxWidgets.git] / docs / latex / wx / menuitem.tex
CommitLineData
66760199
WS
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: menuitem.tex
3%% Purpose: wxMenuItem documentation
4%% Author: wxWidgets Team
5%% Modified by:
6%% Created:
7%% RCS-ID: $Id$
8%% Copyright: (c) wxWidgets Team
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
a660d684
KB
12\section{\class{wxMenuItem}}\label{wxmenuitem}
13
d65c269b
VZ
14A menu item represents an item in a menu. Note that you usually don't have to
15deal with it directly as \helpref{wxMenu}{wxmenu} methods usually construct an
16object of this class for you.
17
18Also please note that the methods related to fonts and bitmaps are currently
c436b310 19only implemented for Windows and GTK+.
a660d684
KB
20
21\wxheading{Derived from}
22
8dbb7967 23% add wxOwnerDrawn once it is documented
a660d684
KB
24\helpref{wxObject}{wxobject}
25
954b8ae6
JS
26\wxheading{Include files}
27
28<wx/menuitem.h>
29
a7af285d
VZ
30\wxheading{Library}
31
32\helpref{wxCore}{librarieslist}
33
a660d684
KB
34\wxheading{See also}
35
2432b92d 36\helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}
a660d684
KB
37
38\latexignore{\rtfignore{\wxheading{Members}}}
39
1892d641 40
dcbd177f 41\membersection{wxMenuItem::wxMenuItem}\label{wxmenuitemctor}
a660d684 42
0ed48c11 43\func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = wxID\_SEPARATOR},
a660d684 44 \param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""},
3980000c 45 \param{wxItemKind }{kind = wxITEM\_NORMAL}, \param{wxMenu*}{ subMenu = NULL}}
a660d684
KB
46
47Constructs a wxMenuItem object.
48
345319d6
VZ
49Menu items can be standard, or ``stock menu items'', or custom. For the
50standard menu items (such as commands to open a file, exit the program and so
51on, see \helpref{stock items}{stockitems} for the full list) it is enough to
52specify just the stock ID and leave \arg{text} and \arg{helpString} empty. In
53fact, leaving at least \arg{text} empty for the stock menu items is strongly
54recommended as they will have appearance and keyboard interface (including
55standard accelerators) familiar to the user.
56
57For the custom (non-stock) menu items, \arg{text} must be specified and while
58\arg{helpString} may be left empty, it's recommended to pass the item
59description (which is automatically shown by the library in the status bar when
60the menu item is selected) in this parameter.
61
62Finally note that you can e.g. use a stock menu label without using its stock
63help string:
64
65\begin{verbatim}
66// use all stock properties:
67helpMenu->Append(wxID_ABOUT);
68
69// use the stock label and the stock accelerator but not the stock help string:
70helpMenu->Append(wxID_ABOUT, wxEmptyString, wxT("My custom help string"));
71
72// use all stock properties except for the bitmap:
73wxMenuItem *mymenu = new wxMenuItem(helpMenu, wxID_ABOUT);
74mymenu->SetBitmap(wxArtProvider::GetBitmap(wxART_WARNING));
75helpMenu->Append(mymenu);
76\end{verbatim}
77
78that is, stock properties are set independently one from the other.
ee0a94cf 79
a660d684
KB
80\wxheading{Parameters}
81
82\docparam{parentMenu}{Menu that the menu item belongs to.}
83
0ed48c11 84\docparam{id}{Identifier for this menu item, or wxID\_SEPARATOR to indicate a separator.}
a660d684 85
2b5f62a0
VZ
86\docparam{text}{Text for the menu item, as shown on the menu. An accelerator
87key can be specified using the ampersand '\&' character. In order to embed an
88ampersand character in the menu item text, the ampersand must be doubled.}
a660d684
KB
89
90\docparam{helpString}{Optional help string that will be shown on the status bar.}
91
8def689d
VZ
92\docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
93{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
a660d684
KB
94
95\docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.}
96
1892d641 97
dcbd177f 98\membersection{wxMenuItem::\destruct{wxMenuItem}}\label{wxmenuitemdtor}
a660d684
KB
99
100\func{}{\destruct{wxMenuItem}}{\void}
101
102Destructor.
103
1892d641 104
a660d684
KB
105\membersection{wxMenuItem::Check}\label{wxmenuitemcheck}
106
3980000c 107\func{void}{Check}{\param{bool}{ check = true}}
a660d684
KB
108
109Checks or unchecks the menu item.
110
1892d641
VZ
111Note that this only works when the item is already appended to a menu.
112
113
a660d684
KB
114\membersection{wxMenuItem::Enable}\label{wxmenuitemenable}
115
3980000c 116\func{void}{Enable}{\param{bool}{ enable = true}}
a660d684
KB
117
118Enables or disables the menu item.
119
1892d641 120
a660d684
KB
121\membersection{wxMenuItem::GetBackgroundColour}\label{wxmenuitemgetbackgroundcolour}
122
123\constfunc{wxColour\&}{GetBackgroundColour}{\void}
124
125Returns the background colour associated with the menu item (Windows only).
126
1892d641 127
a660d684
KB
128\membersection{wxMenuItem::GetBitmap}\label{wxmenuitemgetbitmap}
129
cc81d32f 130\constfunc{wxBitmap\&}{GetBitmap}{\param{bool}{ checked = true}}
a660d684
KB
131
132Returns the checked or unchecked bitmap (Windows only).
133
1892d641 134
a660d684
KB
135\membersection{wxMenuItem::GetFont}\label{wxmenuitemgetfont}
136
137\constfunc{wxFont\&}{GetFont}{\void}
138
139Returns the font associated with the menu item (Windows only).
140
1892d641 141
a660d684
KB
142\membersection{wxMenuItem::GetHelp}\label{wxmenuitemgethelp}
143
144\constfunc{wxString}{GetHelp}{\void}
145
146Returns the help string associated with the menu item.
147
1892d641 148
a660d684
KB
149\membersection{wxMenuItem::GetId}\label{wxmenuitemgetid}
150
151\constfunc{int}{GetId}{\void}
152
153Returns the menu item identifier.
154
1892d641 155
4fcbc84d
JS
156\membersection{wxMenuItem::GetItemLabel}\label{wxmenuitemgetitemlabel}
157
158\constfunc{wxString}{GetItemLabel}{\void}
159
160Returns the text associated with the menu item including any accelerator
161characters that were passed to the constructor or SetItemLabel.
162
163\wxheading{See also}
164
165\helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext},
166\helpref{GetLabelText}{wxmenuitemgetlabeltext}
167
168
169\membersection{wxMenuItem::GetItemLabelText}\label{wxmenuitemgetitemlabeltext}
170
171\constfunc{wxString}{GetItemLabelText}{\void}
172
173Returns the text associated with the menu item, without any accelerator
174characters.
175
176\wxheading{See also}
177
178\helpref{GetItemLabel}{wxmenuitemgetitemlabel},
179\helpref{GetLabelText}{wxmenuitemgetlabeltext}
180
181
d65c269b
VZ
182\membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind}
183
184\constfunc{wxItemKind}{GetKind}{\void}
185
8def689d
VZ
186Returns the item kind, one of {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
187{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}.
d65c269b 188
1892d641 189
64a89766
VZ
190\membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel}
191
192\constfunc{wxString}{GetLabel}{\void}
193
194Returns the text associated with the menu item without any accelerator
2edb0bde 195characters it might contain.
64a89766 196
4fcbc84d
JS
197This function is deprecated in favour of \helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext}.
198
64a89766
VZ
199\wxheading{See also}
200
fa482912 201\helpref{GetText}{wxmenuitemgettext},
3b59cdbf
VZ
202\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
203
4fcbc84d
JS
204\membersection{wxMenuItem::GetLabelText}\label{wxmenuitemgetlabeltext}
205
206\func{static wxString}{GetLabelText}{\param{const wxString\& }{text}}
207
208Strips all accelerator characters and mnemonics from the given {\it text}.
209For example,
210
211\begin{verbatim}
212wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
213\end{verbatim}
214
215will return just {\tt "Hello"}.
216
217\wxheading{See also}
218
219\helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext},
220\helpref{GetItemLabel}{wxmenuitemgetitemlabel}
221
1892d641 222
3b59cdbf
VZ
223\membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext}
224
225\func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}}
226
2edb0bde 227Strips all accelerator characters and mnemonics from the given {\it text}.
3b59cdbf
VZ
228For example,
229
230\begin{verbatim}
231wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
232\end{verbatim}
233
234will return just {\tt "Hello"}.
235
4fcbc84d
JS
236This function is deprecated; please use \helpref{wxMenuItem::GetLabelText}{wxmenuitemgetlabeltext} instead.
237
3b59cdbf
VZ
238\wxheading{See also}
239
fa482912 240\helpref{GetText}{wxmenuitemgettext},
3b59cdbf 241\helpref{GetLabel}{wxmenuitemgetlabel}
64a89766 242
1892d641 243
a660d684
KB
244\membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth}
245
246\constfunc{int}{GetMarginWidth}{\void}
247
248Gets the width of the menu item checkmark bitmap (Windows only).
249
1892d641 250
66760199
WS
251\membersection{wxMenuItem::GetMenu}\label{wxmenuitemgetmenu}
252
253\constfunc{wxMenu*}{GetMenu}{\void}
254
255Returns the menu this menu item is in, or NULL if this menu item is not attached.
256
257
a660d684
KB
258\membersection{wxMenuItem::GetName}\label{wxmenuitemgetname}
259
260\constfunc{wxString}{GetName}{\void}
261
262Returns the text associated with the menu item.
263
64a89766 264{\bf NB:} this function is deprecated, please use
4fcbc84d 265\helpref{GetItemLabel}{wxmenuitemgetitemlabel} or \helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext}
64a89766
VZ
266instead.
267
1892d641 268
64a89766
VZ
269\membersection{wxMenuItem::GetText}\label{wxmenuitemgettext}
270
271\constfunc{wxString}{GetText}{\void}
272
273Returns the text associated with the menu item, such as it was passed to the
274wxMenuItem constructor, i.e. with any accelerator characters it may contain.
275
4fcbc84d
JS
276This function is deprecated in favour of \helpref{GetItemLabel}{wxmenuitemgetitemlabel}.
277
64a89766
VZ
278\wxheading{See also}
279
fa482912 280\helpref{GetLabel}{wxmenuitemgetlabel},
3b59cdbf 281\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
64a89766 282
1892d641 283
a660d684
KB
284\membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu}
285
286\constfunc{wxMenu*}{GetSubMenu}{\void}
287
288Returns the submenu associated with the menu item, or NULL if there isn't one.
289
1892d641 290
a660d684
KB
291\membersection{wxMenuItem::GetTextColour}\label{wxmenuitemgettextcolour}
292
293\constfunc{wxColour\&}{GetTextColour}{\void}
294
295Returns the text colour associated with the menu item (Windows only).
296
1892d641 297
a660d684
KB
298\membersection{wxMenuItem::IsCheckable}\label{wxmenuitemischeckable}
299
300\constfunc{bool}{IsCheckable}{\void}
301
cc81d32f 302Returns true if the item is checkable.
a660d684 303
1892d641 304
a660d684
KB
305\membersection{wxMenuItem::IsChecked}\label{wxmenuitemischecked}
306
307\constfunc{bool}{IsChecked}{\void}
308
cc81d32f 309Returns true if the item is checked.
a660d684 310
1892d641 311
a660d684
KB
312\membersection{wxMenuItem::IsEnabled}\label{wxmenuitemisenabled}
313
314\constfunc{bool}{IsEnabled}{\void}
315
cc81d32f 316Returns true if the item is enabled.
a660d684 317
1892d641 318
a660d684
KB
319\membersection{wxMenuItem::IsSeparator}\label{wxmenuitemisseparator}
320
321\constfunc{bool}{IsSeparator}{\void}
322
cc81d32f 323Returns true if the item is a separator.
a660d684 324
1892d641 325
c87957c2
WS
326\membersection{wxMenuItem::IsSubMenu}\label{wxmenuitemissubmenu}
327
328\constfunc{bool}{IsSubMenu}{\void}
329
330Returns true if the item is a submenu.
331
332
a660d684
KB
333\membersection{wxMenuItem::SetBackgroundColour}\label{wxmenuitemsetbackgroundcolour}
334
e14dccff 335\constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}}
a660d684
KB
336
337Sets the background colour associated with the menu item (Windows only).
338
1892d641 339
0996d32a
VS
340\membersection{wxMenuItem::SetBitmap}\label{wxmenuitemsetbitmap}
341
66760199 342\func{void}{SetBitmap}{\param{const wxBitmap\& }{bmp}}
0996d32a
VS
343
344Sets the bitmap for the menu item (Windows and GTK+ only). It is
345equivalent to \helpref{SetBitmaps}{wxmenuitemsetbitmaps}(bmp, wxNullBitmap).
346
1892d641 347
a660d684
KB
348\membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps}
349
66760199 350\func{void}{SetBitmaps}{\param{const wxBitmap\& }{checked},
e14dccff 351 \param{const wxBitmap\& }{unchecked = wxNullBitmap}}
a660d684
KB
352
353Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap
354is also used as the single bitmap for uncheckable menu items.
355
1892d641 356
a660d684
KB
357\membersection{wxMenuItem::SetFont}\label{wxmenuitemsetfont}
358
66760199 359\func{void}{SetFont}{\param{const wxFont\& }{font}}
a660d684
KB
360
361Sets the font associated with the menu item (Windows only).
362
1892d641 363
a660d684
KB
364\membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp}
365
66760199 366\func{void}{SetHelp}{\param{const wxString\& }{helpString}}
a660d684
KB
367
368Sets the help string.
369
1892d641 370
4fcbc84d
JS
371\membersection{wxMenuItem::SetItemLabel}\label{wxmenuitemsetitemlabel}
372
373\func{void}{SetItemLabel}{\param{const wxString\& }{label}}
374
375Sets the label associated with the menu item.
376
377
a660d684
KB
378\membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth}
379
380\constfunc{void}{SetMarginWidth}{\param{int}{ width}}
381
382Sets the width of the menu item checkmark bitmap (Windows only).
383
1892d641 384
66760199
WS
385\membersection{wxMenuItem::SetMenu}\label{wxmenuitemsetmenu}
386
387\func{void}{SetMenu}{\param{const wxMenu*}{menu}}
388
389Sets the parent menu which will contain this menu item.
390
391
392\membersection{wxMenuItem::SetSubMenu}\label{wxmenuitemsetsubmenu}
393
394\func{void}{SetSubMenu}{\param{const wxMenu*}{menu}}
395
396Sets the submenu of this menu item.
397
398
4e6978c3 399\membersection{wxMenuItem::SetText}\label{wxmenuitemsettext}
a660d684 400
66760199 401\func{void}{SetText}{\param{const wxString\& }{text}}
a660d684
KB
402
403Sets the text associated with the menu item.
404
4fcbc84d
JS
405This function is deprecated in favour of \helpref{SetItemLabel}{wxmenuitemsetitemlabel}.
406
1892d641 407
a660d684
KB
408\membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour}
409
66760199 410\func{void}{SetTextColour}{\param{const wxColour\& }{colour}}
a660d684
KB
411
412Sets the text colour associated with the menu item (Windows only).
413