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