]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/menuitem.tex
assert if opening more than one find/replace dialog under the same parent -- this...
[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
a660d684
KB
30\wxheading{See also}
31
2432b92d 32\helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}
a660d684
KB
33
34\latexignore{\rtfignore{\wxheading{Members}}}
35
1892d641 36
dcbd177f 37\membersection{wxMenuItem::wxMenuItem}\label{wxmenuitemctor}
a660d684 38
0ed48c11 39\func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = wxID\_SEPARATOR},
a660d684 40 \param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""},
3980000c 41 \param{wxItemKind }{kind = wxITEM\_NORMAL}, \param{wxMenu*}{ subMenu = NULL}}
a660d684
KB
42
43Constructs a wxMenuItem object.
44
45\wxheading{Parameters}
46
47\docparam{parentMenu}{Menu that the menu item belongs to.}
48
0ed48c11 49\docparam{id}{Identifier for this menu item, or wxID\_SEPARATOR to indicate a separator.}
a660d684 50
2b5f62a0
VZ
51\docparam{text}{Text for the menu item, as shown on the menu. An accelerator
52key can be specified using the ampersand '\&' character. In order to embed an
53ampersand character in the menu item text, the ampersand must be doubled.}
a660d684
KB
54
55\docparam{helpString}{Optional help string that will be shown on the status bar.}
56
8def689d
VZ
57\docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
58{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
a660d684
KB
59
60\docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.}
61
1892d641 62
dcbd177f 63\membersection{wxMenuItem::\destruct{wxMenuItem}}\label{wxmenuitemdtor}
a660d684
KB
64
65\func{}{\destruct{wxMenuItem}}{\void}
66
67Destructor.
68
1892d641 69
a660d684
KB
70\membersection{wxMenuItem::Check}\label{wxmenuitemcheck}
71
3980000c 72\func{void}{Check}{\param{bool}{ check = true}}
a660d684
KB
73
74Checks or unchecks the menu item.
75
1892d641
VZ
76Note that this only works when the item is already appended to a menu.
77
78
a660d684
KB
79\membersection{wxMenuItem::Enable}\label{wxmenuitemenable}
80
3980000c 81\func{void}{Enable}{\param{bool}{ enable = true}}
a660d684
KB
82
83Enables or disables the menu item.
84
1892d641 85
a660d684
KB
86\membersection{wxMenuItem::GetBackgroundColour}\label{wxmenuitemgetbackgroundcolour}
87
88\constfunc{wxColour\&}{GetBackgroundColour}{\void}
89
90Returns the background colour associated with the menu item (Windows only).
91
1892d641 92
a660d684
KB
93\membersection{wxMenuItem::GetBitmap}\label{wxmenuitemgetbitmap}
94
cc81d32f 95\constfunc{wxBitmap\&}{GetBitmap}{\param{bool}{ checked = true}}
a660d684
KB
96
97Returns the checked or unchecked bitmap (Windows only).
98
1892d641 99
a660d684
KB
100\membersection{wxMenuItem::GetFont}\label{wxmenuitemgetfont}
101
102\constfunc{wxFont\&}{GetFont}{\void}
103
104Returns the font associated with the menu item (Windows only).
105
1892d641 106
a660d684
KB
107\membersection{wxMenuItem::GetHelp}\label{wxmenuitemgethelp}
108
109\constfunc{wxString}{GetHelp}{\void}
110
111Returns the help string associated with the menu item.
112
1892d641 113
a660d684
KB
114\membersection{wxMenuItem::GetId}\label{wxmenuitemgetid}
115
116\constfunc{int}{GetId}{\void}
117
118Returns the menu item identifier.
119
1892d641 120
d65c269b
VZ
121\membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind}
122
123\constfunc{wxItemKind}{GetKind}{\void}
124
8def689d
VZ
125Returns the item kind, one of {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
126{\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}.
d65c269b 127
1892d641 128
64a89766
VZ
129\membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel}
130
131\constfunc{wxString}{GetLabel}{\void}
132
133Returns the text associated with the menu item without any accelerator
2edb0bde 134characters it might contain.
64a89766
VZ
135
136\wxheading{See also}
137
fa482912 138\helpref{GetText}{wxmenuitemgettext},
3b59cdbf
VZ
139\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
140
1892d641 141
3b59cdbf
VZ
142\membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext}
143
144\func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}}
145
2edb0bde 146Strips all accelerator characters and mnemonics from the given {\it text}.
3b59cdbf
VZ
147For example,
148
149\begin{verbatim}
150wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
151\end{verbatim}
152
153will return just {\tt "Hello"}.
154
155\wxheading{See also}
156
fa482912 157\helpref{GetText}{wxmenuitemgettext},
3b59cdbf 158\helpref{GetLabel}{wxmenuitemgetlabel}
64a89766 159
1892d641 160
a660d684
KB
161\membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth}
162
163\constfunc{int}{GetMarginWidth}{\void}
164
165Gets the width of the menu item checkmark bitmap (Windows only).
166
1892d641 167
66760199
WS
168\membersection{wxMenuItem::GetMenu}\label{wxmenuitemgetmenu}
169
170\constfunc{wxMenu*}{GetMenu}{\void}
171
172Returns the menu this menu item is in, or NULL if this menu item is not attached.
173
174
a660d684
KB
175\membersection{wxMenuItem::GetName}\label{wxmenuitemgetname}
176
177\constfunc{wxString}{GetName}{\void}
178
179Returns the text associated with the menu item.
180
64a89766
VZ
181{\bf NB:} this function is deprecated, please use
182\helpref{GetText}{wxmenuitemgettext} or \helpref{GetLabel}{wxmenuitemgetlabel}
183instead.
184
1892d641 185
64a89766
VZ
186\membersection{wxMenuItem::GetText}\label{wxmenuitemgettext}
187
188\constfunc{wxString}{GetText}{\void}
189
190Returns the text associated with the menu item, such as it was passed to the
191wxMenuItem constructor, i.e. with any accelerator characters it may contain.
192
193\wxheading{See also}
194
fa482912 195\helpref{GetLabel}{wxmenuitemgetlabel},
3b59cdbf 196\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
64a89766 197
1892d641 198
a660d684
KB
199\membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu}
200
201\constfunc{wxMenu*}{GetSubMenu}{\void}
202
203Returns the submenu associated with the menu item, or NULL if there isn't one.
204
1892d641 205
a660d684
KB
206\membersection{wxMenuItem::GetTextColour}\label{wxmenuitemgettextcolour}
207
208\constfunc{wxColour\&}{GetTextColour}{\void}
209
210Returns the text colour associated with the menu item (Windows only).
211
1892d641 212
a660d684
KB
213\membersection{wxMenuItem::IsCheckable}\label{wxmenuitemischeckable}
214
215\constfunc{bool}{IsCheckable}{\void}
216
cc81d32f 217Returns true if the item is checkable.
a660d684 218
1892d641 219
a660d684
KB
220\membersection{wxMenuItem::IsChecked}\label{wxmenuitemischecked}
221
222\constfunc{bool}{IsChecked}{\void}
223
cc81d32f 224Returns true if the item is checked.
a660d684 225
1892d641 226
a660d684
KB
227\membersection{wxMenuItem::IsEnabled}\label{wxmenuitemisenabled}
228
229\constfunc{bool}{IsEnabled}{\void}
230
cc81d32f 231Returns true if the item is enabled.
a660d684 232
1892d641 233
a660d684
KB
234\membersection{wxMenuItem::IsSeparator}\label{wxmenuitemisseparator}
235
236\constfunc{bool}{IsSeparator}{\void}
237
cc81d32f 238Returns true if the item is a separator.
a660d684 239
1892d641 240
c87957c2
WS
241\membersection{wxMenuItem::IsSubMenu}\label{wxmenuitemissubmenu}
242
243\constfunc{bool}{IsSubMenu}{\void}
244
245Returns true if the item is a submenu.
246
247
a660d684
KB
248\membersection{wxMenuItem::SetBackgroundColour}\label{wxmenuitemsetbackgroundcolour}
249
e14dccff 250\constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}}
a660d684
KB
251
252Sets the background colour associated with the menu item (Windows only).
253
1892d641 254
0996d32a
VS
255\membersection{wxMenuItem::SetBitmap}\label{wxmenuitemsetbitmap}
256
66760199 257\func{void}{SetBitmap}{\param{const wxBitmap\& }{bmp}}
0996d32a
VS
258
259Sets the bitmap for the menu item (Windows and GTK+ only). It is
260equivalent to \helpref{SetBitmaps}{wxmenuitemsetbitmaps}(bmp, wxNullBitmap).
261
1892d641 262
a660d684
KB
263\membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps}
264
66760199 265\func{void}{SetBitmaps}{\param{const wxBitmap\& }{checked},
e14dccff 266 \param{const wxBitmap\& }{unchecked = wxNullBitmap}}
a660d684
KB
267
268Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap
269is also used as the single bitmap for uncheckable menu items.
270
1892d641 271
a660d684
KB
272\membersection{wxMenuItem::SetFont}\label{wxmenuitemsetfont}
273
66760199 274\func{void}{SetFont}{\param{const wxFont\& }{font}}
a660d684
KB
275
276Sets the font associated with the menu item (Windows only).
277
1892d641 278
a660d684
KB
279\membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp}
280
66760199 281\func{void}{SetHelp}{\param{const wxString\& }{helpString}}
a660d684
KB
282
283Sets the help string.
284
1892d641 285
a660d684
KB
286\membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth}
287
288\constfunc{void}{SetMarginWidth}{\param{int}{ width}}
289
290Sets the width of the menu item checkmark bitmap (Windows only).
291
1892d641 292
66760199
WS
293\membersection{wxMenuItem::SetMenu}\label{wxmenuitemsetmenu}
294
295\func{void}{SetMenu}{\param{const wxMenu*}{menu}}
296
297Sets the parent menu which will contain this menu item.
298
299
300\membersection{wxMenuItem::SetSubMenu}\label{wxmenuitemsetsubmenu}
301
302\func{void}{SetSubMenu}{\param{const wxMenu*}{menu}}
303
304Sets the submenu of this menu item.
305
306
4e6978c3 307\membersection{wxMenuItem::SetText}\label{wxmenuitemsettext}
a660d684 308
66760199 309\func{void}{SetText}{\param{const wxString\& }{text}}
a660d684
KB
310
311Sets the text associated with the menu item.
312
1892d641 313
a660d684
KB
314\membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour}
315
66760199 316\func{void}{SetTextColour}{\param{const wxColour\& }{colour}}
a660d684
KB
317
318Sets the text colour associated with the menu item (Windows only).
319