]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/menuitem.tex
removed non-const wxDC accessors for pens, brushes, ... (bug 1039169)
[wxWidgets.git] / docs / latex / wx / menuitem.tex
1 \section{\class{wxMenuItem}}\label{wxmenuitem}
2
3 A menu item represents an item in a menu. Note that you usually don't have to
4 deal with it directly as \helpref{wxMenu}{wxmenu} methods usually construct an
5 object of this class for you.
6
7 Also please note that the methods related to fonts and bitmaps are currently
8 only implemented for Windows.
9
10 \wxheading{Derived from}
11
12 wxOwnerDrawn (Windows only)\\
13 \helpref{wxObject}{wxobject}
14
15 \wxheading{Include files}
16
17 <wx/menuitem.h>
18
19 \wxheading{See also}
20
21 \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}
22
23 \latexignore{\rtfignore{\wxheading{Members}}}
24
25
26 \membersection{wxMenuItem::wxMenuItem}\label{wxmenuitemctor}
27
28 \func{}{wxMenuItem}{\param{wxMenu*}{ parentMenu = NULL}, \param{int}{ id = wxID\_SEPARATOR},
29 \param{const wxString\& }{text = ""}, \param{const wxString\& }{helpString = ""},
30 \param{wxItemKind }{kind = wxITEM\_NORMAL}, \param{wxMenu*}{ subMenu = NULL}, }
31
32 Constructs a wxMenuItem object.
33
34 \wxheading{Parameters}
35
36 \docparam{parentMenu}{Menu that the menu item belongs to.}
37
38 \docparam{id}{Identifier for this menu item, or wxID\_SEPARATOR to indicate a separator.}
39
40 \docparam{text}{Text for the menu item, as shown on the menu. An accelerator
41 key can be specified using the ampersand '\&' character. In order to embed an
42 ampersand character in the menu item text, the ampersand must be doubled.}
43
44 \docparam{helpString}{Optional help string that will be shown on the status bar.}
45
46 \docparam{kind}{May be {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
47 {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}}
48
49 \docparam{subMenu}{If non-NULL, indicates that the menu item is a submenu.}
50
51
52 \membersection{wxMenuItem::\destruct{wxMenuItem}}\label{wxmenuitemdtor}
53
54 \func{}{\destruct{wxMenuItem}}{\void}
55
56 Destructor.
57
58
59 \membersection{wxMenuItem::Check}\label{wxmenuitemcheck}
60
61 \func{void}{Check}{\param{bool}{ check}}
62
63 Checks or unchecks the menu item.
64
65 Note that this only works when the item is already appended to a menu.
66
67
68 \membersection{wxMenuItem::Enable}\label{wxmenuitemenable}
69
70 \func{void}{Enable}{\param{bool}{ enable}}
71
72 Enables or disables the menu item.
73
74
75 \membersection{wxMenuItem::GetBackgroundColour}\label{wxmenuitemgetbackgroundcolour}
76
77 \constfunc{wxColour\&}{GetBackgroundColour}{\void}
78
79 Returns the background colour associated with the menu item (Windows only).
80
81
82 \membersection{wxMenuItem::GetBitmap}\label{wxmenuitemgetbitmap}
83
84 \constfunc{wxBitmap\&}{GetBitmap}{\param{bool}{ checked = true}}
85
86 Returns the checked or unchecked bitmap (Windows only).
87
88
89 \membersection{wxMenuItem::GetFont}\label{wxmenuitemgetfont}
90
91 \constfunc{wxFont\&}{GetFont}{\void}
92
93 Returns the font associated with the menu item (Windows only).
94
95
96 \membersection{wxMenuItem::GetHelp}\label{wxmenuitemgethelp}
97
98 \constfunc{wxString}{GetHelp}{\void}
99
100 Returns the help string associated with the menu item.
101
102
103 \membersection{wxMenuItem::GetId}\label{wxmenuitemgetid}
104
105 \constfunc{int}{GetId}{\void}
106
107 Returns the menu item identifier.
108
109
110 \membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind}
111
112 \constfunc{wxItemKind}{GetKind}{\void}
113
114 Returns the item kind, one of {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
115 {\tt wxITEM\_CHECK} or {\tt wxITEM\_RADIO}.
116
117
118 \membersection{wxMenuItem::GetLabel}\label{wxmenuitemgetlabel}
119
120 \constfunc{wxString}{GetLabel}{\void}
121
122 Returns the text associated with the menu item without any accelerator
123 characters it might contain.
124
125 \wxheading{See also}
126
127 \helpref{GetText}{wxmenuitemgettext},
128 \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
129
130
131 \membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext}
132
133 \func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}}
134
135 Strips all accelerator characters and mnemonics from the given {\it text}.
136 For example,
137
138 \begin{verbatim}
139 wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
140 \end{verbatim}
141
142 will return just {\tt "Hello"}.
143
144 \wxheading{See also}
145
146 \helpref{GetText}{wxmenuitemgettext},
147 \helpref{GetLabel}{wxmenuitemgetlabel}
148
149
150 \membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth}
151
152 \constfunc{int}{GetMarginWidth}{\void}
153
154 Gets the width of the menu item checkmark bitmap (Windows only).
155
156
157 \membersection{wxMenuItem::GetName}\label{wxmenuitemgetname}
158
159 \constfunc{wxString}{GetName}{\void}
160
161 Returns the text associated with the menu item.
162
163 {\bf NB:} this function is deprecated, please use
164 \helpref{GetText}{wxmenuitemgettext} or \helpref{GetLabel}{wxmenuitemgetlabel}
165 instead.
166
167
168 \membersection{wxMenuItem::GetText}\label{wxmenuitemgettext}
169
170 \constfunc{wxString}{GetText}{\void}
171
172 Returns the text associated with the menu item, such as it was passed to the
173 wxMenuItem constructor, i.e. with any accelerator characters it may contain.
174
175 \wxheading{See also}
176
177 \helpref{GetLabel}{wxmenuitemgetlabel},
178 \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
179
180
181 \membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu}
182
183 \constfunc{wxMenu*}{GetSubMenu}{\void}
184
185 Returns the submenu associated with the menu item, or NULL if there isn't one.
186
187
188 \membersection{wxMenuItem::GetTextColour}\label{wxmenuitemgettextcolour}
189
190 \constfunc{wxColour\&}{GetTextColour}{\void}
191
192 Returns the text colour associated with the menu item (Windows only).
193
194
195 \membersection{wxMenuItem::IsCheckable}\label{wxmenuitemischeckable}
196
197 \constfunc{bool}{IsCheckable}{\void}
198
199 Returns true if the item is checkable.
200
201
202 \membersection{wxMenuItem::IsChecked}\label{wxmenuitemischecked}
203
204 \constfunc{bool}{IsChecked}{\void}
205
206 Returns true if the item is checked.
207
208
209 \membersection{wxMenuItem::IsEnabled}\label{wxmenuitemisenabled}
210
211 \constfunc{bool}{IsEnabled}{\void}
212
213 Returns true if the item is enabled.
214
215
216 \membersection{wxMenuItem::IsSeparator}\label{wxmenuitemisseparator}
217
218 \constfunc{bool}{IsSeparator}{\void}
219
220 Returns true if the item is a separator.
221
222
223 \membersection{wxMenuItem::SetBackgroundColour}\label{wxmenuitemsetbackgroundcolour}
224
225 \constfunc{void}{SetBackgroundColour}{\param{const wxColour\& }{colour}}
226
227 Sets the background colour associated with the menu item (Windows only).
228
229
230 \membersection{wxMenuItem::SetBitmap}\label{wxmenuitemsetbitmap}
231
232 \constfunc{void}{SetBitmap}{\param{const wxBitmap\& }{bmp}}
233
234 Sets the bitmap for the menu item (Windows and GTK+ only). It is
235 equivalent to \helpref{SetBitmaps}{wxmenuitemsetbitmaps}(bmp, wxNullBitmap).
236
237
238 \membersection{wxMenuItem::SetBitmaps}\label{wxmenuitemsetbitmaps}
239
240 \constfunc{void}{SetBitmaps}{\param{const wxBitmap\& }{checked},
241 \param{const wxBitmap\& }{unchecked = wxNullBitmap}}
242
243 Sets the checked/unchecked bitmaps for the menu item (Windows only). The first bitmap
244 is also used as the single bitmap for uncheckable menu items.
245
246
247 \membersection{wxMenuItem::SetFont}\label{wxmenuitemsetfont}
248
249 \constfunc{void}{SetFont}{\param{const wxFont\& }{font}}
250
251 Sets the font associated with the menu item (Windows only).
252
253
254 \membersection{wxMenuItem::SetHelp}\label{wxmenuitemsethelp}
255
256 \constfunc{void}{SetHelp}{\param{const wxString\& }{helpString}}
257
258 Sets the help string.
259
260
261 \membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth}
262
263 \constfunc{void}{SetMarginWidth}{\param{int}{ width}}
264
265 Sets the width of the menu item checkmark bitmap (Windows only).
266
267
268 \membersection{wxMenuItem::SetText}\label{wxmenuitemsettext}
269
270 \constfunc{void}{SetText}{\param{const wxString\& }{text}}
271
272 Sets the text associated with the menu item.
273
274
275 \membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour}
276
277 \constfunc{void}{SetTextColour}{\param{const wxColour\& }{colour}}
278
279 Sets the text colour associated with the menu item (Windows only).
280