]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/menu.tex
added wxCheckBox::IsChecked() to wxMac and documented it
[wxWidgets.git] / docs / latex / wx / menu.tex
1 \section{\class{wxMenu}}\label{wxmenu}
2
3 A menu is a popup (or pull down) list of items, one of which may be
4 selected before the menu goes away (clicking elsewhere dismisses the
5 menu). Menus may be used to construct either menu bars or popup menus.
6
7 A menu item has an integer ID associated with it which can be used to
8 identify the selection, or to change the menu item in some way. A menu item
9 with a special identifier $-1$ is a separator item and doesn't have an
10 associated command but just makes a separator line appear in the menu.
11
12 Menu items may be either normal items, check items or radio items. Normal items
13 don't have any special properties while the check items have a boolean flag
14 associated to them and they show a checkmark in the menu when the flag is set.
15 wxWindows automatically togles the flag value when the item is clicked and its
16 value may be retrieved using either \helpref{IsChecked}{wxmenuischecked} method
17 of wxMenu or wxMenuBar itself or by using
18 \helpref{wxEvent::IsChecked}{wxcommandeventischecked} when you get the menu
19 notification for the item in question.
20
21 The radio items are similar to the check items except that all the other items
22 in the same radio group are unchecked when a radio item is checked. The radio
23 group is formed by a contiguous range of radio items, i.e. it starts at the
24 first item of this kind and ends with the first item of a different kind (or
25 the end of the menu). Notice that because the radio groups are defined in terms
26 of the item positions inserting or removing the items in the menu containing
27 the radio items risks to not work correctly. Finally note that the radio items
28 are only supported under Windows and GTK+ currently.
29
30 \wxheading{Derived from}
31
32 \helpref{wxEvtHandler}{wxevthandler}\\
33 \helpref{wxObject}{wxobject}
34
35 \wxheading{Include files}
36
37 <wx/menu.h>
38
39 \wxheading{Event handling}
40
41 If the menu is part of a menubar, then \helpref{wxMenuBar}{wxmenubar} event processing is used.
42
43 With a popup menu, there is a variety of ways to handle a menu selection event
44 (wxEVT\_COMMAND\_MENU\_SELECTED).
45
46 \begin{enumerate}\itemsep=0pt
47 \item Derive a new class from wxMenu and define event table entries using the EVT\_MENU macro.
48 \item Set a new event handler for wxMenu, using an object whose class has EVT\_MENU entries.
49 \item Provide EVT\_MENU handlers in the window which pops up the menu, or in an ancestor of
50 this window.
51 \item Define a callback of type wxFunction, which you pass to the wxMenu constructor.
52 The callback takes a reference to the menu, and a reference to a
53 \helpref{wxCommandEvent}{wxcommandevent}. This method is deprecated and should
54 not be used in the new code, it is provided for backwards compatibility only.
55 \end{enumerate}
56
57 \wxheading{See also}
58
59 \helpref{wxMenuBar}{wxmenubar}, \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu},\rtfsp
60 \helpref{Event handling overview}{eventhandlingoverview}
61
62 \latexignore{\rtfignore{\wxheading{Members}}}
63
64 \membersection{wxMenu::wxMenu}\label{wxmenuconstr}
65
66 \func{}{wxMenu}{\param{const wxString\& }{title = ""}, \param{long}{ style = 0}}
67
68 Constructs a wxMenu object.
69
70 \wxheading{Parameters}
71
72 \docparam{title}{A title for the popup menu: the empty string denotes no title.}
73
74 \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
75
76 \func{}{wxMenu}{\param{long}{ style}}
77
78 Constructs a wxMenu object.
79
80 \wxheading{Parameters}
81
82 \docparam{style}{If set to {\tt wxMENU\_TEAROFF}, the menu will be detachable (wxGTK only).}
83
84 \membersection{wxMenu::\destruct{wxMenu}}
85
86 \func{}{\destruct{wxMenu}}{\void}
87
88 Destructor, destroying the menu.
89
90 Note: under Motif, a popup menu must have a valid parent (the window
91 it was last popped up on) when being destroyed. Therefore, make sure
92 you delete or re-use the popup menu {\it before} destroying the
93 parent window. Re-use in this context means popping up the menu on
94 a different window from last time, which causes an implicit destruction
95 and recreation of internal data structures.
96
97 \membersection{wxMenu::Append}\label{wxmenuappend}
98
99 \func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
100 \param{wxItemKind}{ kind = wxItem\_Normal}}
101
102 Adds a string item to the end of the menu.
103
104 \func{void}{Append}{\param{int}{ id}, \param{const wxString\& }{ item}, \param{wxMenu *}{subMenu},\rtfsp
105 \param{const wxString\& }{helpString = ""}}
106
107 Adds a pull-right submenu to the end of the menu.
108
109 \func{void}{Append}{\param{wxMenuItem*}{ menuItem}}
110
111 Adds a menu item object. This is the most generic variant of Append() method
112 because it may be used for both items (including separators) and submenus and
113 because you can also specify various extra properties of a menu item this way,
114 such as bitmaps and fonts.
115
116 \wxheading{Parameters}
117
118 \docparam{id}{The menu command identifier.}
119
120 \docparam{item}{The string to appear on the menu item.}
121
122 \docparam{menu}{Pull-right submenu.}
123
124 \docparam{kind}{May be {\tt wxItem\_Separator}, {\tt wxItem\_Normal},
125 {\tt wxItem\_Check} or {\tt wxItem\_Radio}}
126
127 \docparam{helpString}{An optional help string associated with the item.
128 By default, \helpref{wxFrame::OnMenuHighlight}{wxframeonmenuhighlight} displays
129 this string in the status line.}
130
131 \docparam{menuItem}{A menuitem object. It will be owned by the wxMenu object after this function
132 is called, so do not delete it yourself.}
133
134 \wxheading{Remarks}
135
136 This command can be used after the menu has been shown, as well as on initial
137 creation of a menu or menubar.
138
139 \wxheading{See also}
140
141 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator},\rtfsp
142 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem},\rtfsp
143 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem},\rtfsp
144 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
145 \helpref{wxMenu::SetLabel}{wxmenusetlabel}, \helpref{wxMenu::GetHelpString}{wxmenugethelpstring},\rtfsp
146 \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenuItem}{wxmenuitem}
147
148 \pythonnote{In place of a single overloaded method name, wxPython
149 implements the following methods:\par
150 \indented{2cm}{\begin{twocollist}
151 \twocolitem{{\bf Append(id, string, helpStr="", checkable=FALSE)}}{}
152 \twocolitem{{\bf AppendMenu(id, string, aMenu, helpStr="")}}{}
153 \twocolitem{{\bf AppendItem(aMenuItem)}}{}
154 \end{twocollist}}
155 }
156
157 \membersection{wxMenu::AppendCheckItem}\label{wxmenuappendcheckitem}
158
159 \func{void}{AppendCheckItem}{\param{int}{ id},\rtfsp
160 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
161
162 Adds a checkable item to the end of the menu.
163
164 \wxheading{See also}
165
166 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
167 \helpref{wxMenu::InsertCheckItem}{wxmenuinsertcheckitem}
168
169 \membersection{wxMenu::AppendRadioItem}\label{wxmenuappendradioitem}
170
171 \func{void}{AppendRadioItem}{\param{int}{ id},\rtfsp
172 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
173
174 Adds a radio item to the end of the menu. All consequent radio items form a
175 group and when an item in the group is checked, all the others are
176 automatically unchecked.
177
178 {\bf NB:} Currently only implemented under Windows and GTK, use
179 {\tt\#if wxHAS\_RADIO\_MENU\_ITEMS} to test for availability of this feature.
180
181 \wxheading{See also}
182
183 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
184 \helpref{wxMenu::InsertRadioItem}{wxmenuinsertradioitem}
185
186 \membersection{wxMenu::AppendSeparator}\label{wxmenuappendseparator}
187
188 \func{void}{AppendSeparator}{\void}
189
190 Adds a separator to the end of the menu.
191
192 \wxheading{See also}
193
194 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
195 \helpref{wxMenu::InsertSeparator}{wxmenuinsertseparator}
196
197 \membersection{wxMenu::Break}\label{wxmenubreak}
198
199 \func{void}{Break}{\void}
200
201 Inserts a break in a menu, causing the next appended item to appear in a new column.
202
203 \membersection{wxMenu::Check}\label{wxmenucheck}
204
205 \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
206
207 Checks or unchecks the menu item.
208
209 \wxheading{Parameters}
210
211 \docparam{id}{The menu item identifier.}
212
213 \docparam{check}{If TRUE, the item will be checked, otherwise it will be unchecked.}
214
215 \wxheading{See also}
216
217 \helpref{wxMenu::IsChecked}{wxmenuischecked}
218
219 \membersection{wxMenu::Delete}\label{wxmenudelete}
220
221 \func{void}{Delete}{\param{int }{id}}
222
223 \func{void}{Delete}{\param{wxMenuItem *}{item}}
224
225 Deletes the menu item from the menu. If the item is a submenu, it will
226 {\bf not} be deleted. Use \helpref{Destroy}{wxmenudestroy} if you want to
227 delete a submenu.
228
229 \wxheading{Parameters}
230
231 \docparam{id}{Id of the menu item to be deleted.}
232
233 \docparam{item}{Menu item to be deleted.}
234
235 \wxheading{See also}
236
237 \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
238 \helpref{wxMenu::Destroy}{wxmenudestroy},\rtfsp
239 \helpref{wxMenu::Remove}{wxmenuremove}
240
241 \membersection{wxMenu::Destroy}\label{wxmenudestroy}
242
243 \func{void}{Destroy}{\param{int }{id}}
244
245 \func{void}{Destroy}{\param{wxMenuItem *}{item}}
246
247 Deletes the menu item from the menu. If the item is a submenu, it will
248 be deleted. Use \helpref{Remove}{wxmenuremove} if you want to keep the submenu
249 (for example, to reuse it later).
250
251 \wxheading{Parameters}
252
253 \docparam{id}{Id of the menu item to be deleted.}
254
255 \docparam{item}{Menu item to be deleted.}
256
257 \wxheading{See also}
258
259 \helpref{wxMenu::FindItem}{wxmenufinditem},\rtfsp
260 \helpref{wxMenu::Deletes}{wxmenudelete},\rtfsp
261 \helpref{wxMenu::Remove}{wxmenuremove}
262
263 \membersection{wxMenu::Enable}\label{wxmenuenable}
264
265 \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
266
267 Enables or disables (greys out) a menu item.
268
269 \wxheading{Parameters}
270
271 \docparam{id}{The menu item identifier.}
272
273 \docparam{enable}{TRUE to enable the menu item, FALSE to disable it.}
274
275 \wxheading{See also}
276
277 \helpref{wxMenu::IsEnabled}{wxmenuisenabled}
278
279 \membersection{wxMenu::FindItem}\label{wxmenufinditem}
280
281 \constfunc{int}{FindItem}{\param{const wxString\& }{itemString}}
282
283 Finds the menu item id for a menu item string.
284
285 \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu **}{menu = NULL}}
286
287 Finds the menu item object associated with the given menu item identifier and,
288 optionally, the (sub)menu it belongs to.
289
290 \perlnote{In wxPerl this method takes just the {\tt id} parameter;
291 in scalar context it returns the associated {\tt Wx::MenuItem}, in list
292 context it returns a 2-element list {\tt ( item, submenu )}}
293
294 \wxheading{Parameters}
295
296 \docparam{itemString}{Menu item string to find.}
297
298 \docparam{id}{Menu item identifier.}
299
300 \docparam{menu}{If the pointer is not NULL, it will be filled with the items
301 parent menu (if the item was found)}
302
303 \wxheading{Return value}
304
305 First form: menu item identifier, or wxNOT\_FOUND if none is found.
306
307 Second form: returns the menu item object, or NULL if it is not found.
308
309 \wxheading{Remarks}
310
311 Any special menu codes are stripped out of source and target strings
312 before matching.
313
314 \pythonnote{The name of this method in wxPython is {\tt FindItemById}
315 and it does not support the second parameter.}
316
317 \membersection{wxMenu::GetHelpString}\label{wxmenugethelpstring}
318
319 \constfunc{wxString}{GetHelpString}{\param{int}{ id}}
320
321 Returns the help string associated with a menu item.
322
323 \wxheading{Parameters}
324
325 \docparam{id}{The menu item identifier.}
326
327 \wxheading{Return value}
328
329 The help string, or the empty string if there is no help string or the
330 item was not found.
331
332 \wxheading{See also}
333
334 \helpref{wxMenu::SetHelpString}{wxmenusethelpstring}, \helpref{wxMenu::Append}{wxmenuappend}
335
336 \membersection{wxMenu::GetLabel}\label{wxmenugetlabel}
337
338 \constfunc{wxString}{GetLabel}{\param{int}{ id}}
339
340 Returns a menu item label.
341
342 \wxheading{Parameters}
343
344 \docparam{id}{The menu item identifier.}
345
346 \wxheading{Return value}
347
348 The item label, or the empty string if the item was not found.
349
350 \wxheading{See also}
351
352 \helpref{wxMenu::SetLabel}{wxmenusetlabel}
353
354 \membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount}
355
356 \constfunc{size\_t}{GetMenuItemCount}{\void}
357
358 Returns the number of items in the menu.
359
360 \membersection{wxMenu::GetMenuItems}\label{wxmenugetmenuitems}
361
362 \constfunc{wxMenuItemList\&}{GetMenuItems}{\void}
363
364 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
365 list class containing wxMenuItem pointers.
366
367 \membersection{wxMenu::GetTitle}\label{wxmenugettitle}
368
369 \constfunc{wxString}{GetTitle}{\void}
370
371 Returns the title of the menu.
372
373 \wxheading{Remarks}
374
375 This is relevant only to popup menus.
376
377 \wxheading{See also}
378
379 \helpref{wxMenu::SetTitle}{wxmenusettitle}
380
381 \membersection{wxMenu::Insert}\label{wxmenuinsert}
382
383 \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
384
385 \func{void}{Insert}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
386 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
387 \param{wxItemKind}{ kind = wxItem\_Normal}}
388
389 Inserts the given {\it item} before the position {\it pos}. Inserting the item
390 at the position \helpref{GetMenuItemCount}{wxmenugetmenuitemcount} is the same
391 as appending it.
392
393 \wxheading{See also}
394
395 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
396 \helpref{wxMenu::Prepend}{wxmenuprepend}
397
398 \membersection{wxMenu::InsertCheckItem}\label{wxmenuinsertcheckitem}
399
400 \func{void}{InsertCheckItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
401 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
402
403 Inserts a checkable item at the given position.
404
405 \wxheading{See also}
406
407 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
408 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
409
410 \membersection{wxMenu::InsertRadioItem}\label{wxmenuinsertradioitem}
411
412 \func{void}{InsertRadioItem}{\param{size\_t }{pos}, \param{int}{ id},\rtfsp
413 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
414
415 Inserts a radio item at the given position.
416
417 \wxheading{See also}
418
419 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
420 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
421
422 \membersection{wxMenu::InsertSeparator}\label{wxmenuinsertseparator}
423
424 \func{void}{InsertSeparator}{\param{size\_t }{pos}}
425
426 Inserts a separator at the given position.
427
428 \wxheading{See also}
429
430 \helpref{wxMenu::Insert}{wxmenuinsert},\rtfsp
431 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
432
433 \membersection{wxMenu::IsChecked}\label{wxmenuischecked}
434
435 \constfunc{bool}{IsChecked}{\param{int}{ id}}
436
437 Determines whether a menu item is checked.
438
439 \wxheading{Parameters}
440
441 \docparam{id}{The menu item identifier.}
442
443 \wxheading{Return value}
444
445 TRUE if the menu item is checked, FALSE otherwise.
446
447 \wxheading{See also}
448
449 \helpref{wxMenu::Check}{wxmenucheck}
450
451 \membersection{wxMenu::IsEnabled}\label{wxmenuisenabled}
452
453 \constfunc{bool}{IsEnabled}{\param{int}{ id}}
454
455 Determines whether a menu item is enabled.
456
457 \wxheading{Parameters}
458
459 \docparam{id}{The menu item identifier.}
460
461 \wxheading{Return value}
462
463 TRUE if the menu item is enabled, FALSE otherwise.
464
465 \wxheading{See also}
466
467 \helpref{wxMenu::Enable}{wxmenuenable}
468
469 \membersection{wxMenu::Prepend}\label{wxmenuprepend}
470
471 \func{bool}{Prepend}{\param{size\_t }{pos}, \param{wxMenuItem *}{item}}
472
473 \func{void}{Prepend}{\param{int}{ id},\rtfsp
474 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""},\rtfsp
475 \param{wxItemKind}{ kind = wxItem\_Normal}}
476
477 Inserts the given {\it item} at the position $0$.
478
479 \wxheading{See also}
480
481 \helpref{wxMenu::Append}{wxmenuappend},\rtfsp
482 \helpref{wxMenu::Inserts}{wxmenuinsert}
483
484 \membersection{wxMenu::PrependCheckItem}\label{wxmenuprependcheckitem}
485
486 \func{void}{PrependCheckItem}{\param{int}{ id},\rtfsp
487 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
488
489 Inserts a checkable item at the position $0$.
490
491 \wxheading{See also}
492
493 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
494 \helpref{wxMenu::AppendCheckItem}{wxmenuappendcheckitem}
495
496 \membersection{wxMenu::PrependRadioItem}\label{wxmenuprependradioitem}
497
498 \func{void}{PrependRadioItem}{\param{int}{ id},\rtfsp
499 \param{const wxString\& }{ item}, \param{const wxString\& }{helpString = ""}}
500
501 Inserts a radio item at the position $0$.
502
503 \wxheading{See also}
504
505 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
506 \helpref{wxMenu::AppendRadioItem}{wxmenuappendradioitem}
507
508 \membersection{wxMenu::PrependSeparator}\label{wxmenuprependseparator}
509
510 \func{void}{PrependSeparator}{\param{size\_t }{pos}}
511
512 Inserts a separator at the position $0$.
513
514 \wxheading{See also}
515
516 \helpref{wxMenu::Prepend}{wxmenuprepend},\rtfsp
517 \helpref{wxMenu::AppendSeparator}{wxmenuappendseparator}
518
519 \membersection{wxMenu::Remove}\label{wxmenuremove}
520
521 \func{wxMenuItem *}{Remove}{\param{int }{id}}
522
523 \func{wxMenuItem *}{Remove}{\param{wxMenuItem *}{item}}
524
525 Removes the menu item from the menu but doesn't delete the associated C++
526 object. This allows to reuse the same item later by adding it back to the menu
527 (especially useful with submenus).
528
529 \wxheading{Parameters}
530
531 \docparam{id}{The identifier of the menu item to remove.}
532
533 \docparam{item}{The menu item to remove.}
534
535 \wxheading{Return value}
536
537 The item which was detached from the menu.
538
539 \membersection{wxMenu::SetHelpString}\label{wxmenusethelpstring}
540
541 \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
542
543 Sets an item's help string.
544
545 \wxheading{Parameters}
546
547 \docparam{id}{The menu item identifier.}
548
549 \docparam{helpString}{The help string to set.}
550
551 \wxheading{See also}
552
553 \helpref{wxMenu::GetHelpString}{wxmenugethelpstring}
554
555 \membersection{wxMenu::SetLabel}\label{wxmenusetlabel}
556
557 \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
558
559 Sets the label of a menu item.
560
561 \wxheading{Parameters}
562
563 \docparam{id}{The menu item identifier.}
564
565 \docparam{label}{The menu item label to set.}
566
567 \wxheading{See also}
568
569 \helpref{wxMenu::Append}{wxmenuappend}, \helpref{wxMenu::GetLabel}{wxmenugetlabel}
570
571 \membersection{wxMenu::SetTitle}\label{wxmenusettitle}
572
573 \func{void}{SetTitle}{\param{const wxString\& }{title}}
574
575 Sets the title of the menu.
576
577 \wxheading{Parameters}
578
579 \docparam{title}{The title to set.}
580
581 \wxheading{Remarks}
582
583 This is relevant only to popup menus.
584
585 \wxheading{See also}
586
587 \helpref{wxMenu::SetTitle}{wxmenusettitle}
588
589 \membersection{wxMenu::UpdateUI}\label{wxmenuupdateui}
590
591 \constfunc{void}{UpdateUI}{\param{wxEvtHandler*}{ source = NULL}}
592
593 Sends events to {\it source} (or owning window if NULL) to update the
594 menu UI. This is called just before the menu is popped up with \helpref{wxWindow::PopupMenu}{wxwindowpopupmenu}, but
595 the application may call it at other times if required.
596
597 \wxheading{See also}
598
599 \helpref{wxUpdateUIEvent}{wxupdateuievent}
600
601 \section{\class{wxMenuBar}}\label{wxmenubar}
602
603 A menu bar is a series of menus accessible from the top of a frame.
604
605 \wxheading{Derived from}
606
607 \helpref{wxEvtHandler}{wxevthandler}\\
608 \helpref{wxObject}{wxobject}
609
610 \wxheading{Include files}
611
612 <wx/menu.h>
613
614 \wxheading{Event handling}
615
616 To respond to a menu selection, provide a handler for EVT\_MENU, in the frame
617 that contains the menu bar. If you have a toolbar which uses the same identifiers
618 as your EVT\_MENU entries, events from the toolbar will also be processed by your
619 EVT\_MENU event handlers.
620
621 Note that menu commands (and UI update events for menus) are first sent to
622 the focus window within the frame. If no window within the frame has the focus,
623 then the events are sent directly to the frame. This allows command and UI update
624 handling to be processed by specific windows and controls, and not necessarily
625 by the application frame.
626
627 {\bf Tip:} under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu)
628 are not working, check any EVT\_CHAR events you are handling in child windows.
629 If you are not calling {\tt event.Skip()} for events that you don't process in these event handlers,
630 menu shortcuts may cease to work.
631
632 \wxheading{See also}
633
634 \helpref{wxMenu}{wxmenu}, \helpref{Event handling overview}{eventhandlingoverview}
635
636 \latexignore{\rtfignore{\wxheading{Members}}}
637
638 \membersection{wxMenuBar::wxMenuBar}\label{wxmenubarconstr}
639
640 \func{void}{wxMenuBar}{\param{long }{style = 0}}
641
642 Default constructor.
643
644 \func{void}{wxMenuBar}{\param{int}{ n}, \param{wxMenu*}{ menus[]}, \param{const wxString }{titles[]}}
645
646 Construct a menu bar from arrays of menus and titles.
647
648 \wxheading{Parameters}
649
650 \docparam{n}{The number of menus.}
651
652 \docparam{menus}{An array of menus. Do not use this array again - it now belongs to the
653 menu bar.}
654
655 \docparam{titles}{An array of title strings. Deallocate this array after creating the menu bar.}
656
657 \docparam{style}{If {\tt wxMB\_DOCKABLE} the menu bar can be detached (wxGTK only).}
658
659 \pythonnote{Only the default constructor is supported in wxPython.
660 Use wxMenuBar.Append instead.}
661
662 \perlnote{wxPerl only supports the first contructor:
663 use {\tt Append} instead.}
664
665 \membersection{wxMenuBar::\destruct{wxMenuBar}}
666
667 \func{void}{\destruct{wxMenuBar}}{\void}
668
669 Destructor, destroying the menu bar and removing it from the parent frame (if any).
670
671 \membersection{wxMenuBar::Append}\label{wxmenubarappend}
672
673 \func{bool}{Append}{\param{wxMenu *}{menu}, \param{const wxString\& }{title}}
674
675 Adds the item to the end of the menu bar.
676
677 \wxheading{Parameters}
678
679 \docparam{menu}{The menu to add. Do not deallocate this menu after calling {\bf Append}.}
680
681 \docparam{title}{The title of the menu.}
682
683 \wxheading{Return value}
684
685 TRUE on success, FALSE if an error occurred.
686
687 \wxheading{See also}
688
689 \helpref{wxMenuBar::Insert}{wxmenubarinsert}
690
691 \membersection{wxMenuBar::Check}\label{wxmenubarcheck}
692
693 \func{void}{Check}{\param{int}{ id}, \param{const bool}{ check}}
694
695 Checks or unchecks a menu item.
696
697 \wxheading{Parameters}
698
699 \docparam{id}{The menu item identifier.}
700
701 \docparam{check}{If TRUE, checks the menu item, otherwise the item is unchecked.}
702
703 \wxheading{Remarks}
704
705 Only use this when the menu bar has been associated
706 with a frame; otherwise, use the wxMenu equivalent call.
707
708 \membersection{wxMenuBar::Enable}\label{wxmenubarenable}
709
710 \func{void}{Enable}{\param{int}{ id}, \param{const bool}{ enable}}
711
712 Enables or disables (greys out) a menu item.
713
714 \wxheading{Parameters}
715
716 \docparam{id}{The menu item identifier.}
717
718 \docparam{enable}{TRUE to enable the item, FALSE to disable it.}
719
720 \wxheading{Remarks}
721
722 Only use this when the menu bar has been
723 associated with a frame; otherwise, use the wxMenu equivalent call.
724
725 \membersection{wxMenuBar::EnableTop}\label{wxmenubarenabletop}
726
727 \func{void}{EnableTop}{\param{int}{ pos}, \param{const bool}{ enable}}
728
729 Enables or disables a whole menu.
730
731 \wxheading{Parameters}
732
733 \docparam{pos}{The position of the menu, starting from zero.}
734
735 \docparam{enable}{TRUE to enable the menu, FALSE to disable it.}
736
737 \wxheading{Remarks}
738
739 Only use this when the menu bar has been
740 associated with a frame.
741
742 \membersection{wxMenuBar::FindMenu}\label{wxmenubarfindmenu}
743
744 \constfunc{int}{FindMenu}{\param{const wxString\& }{title}}
745
746 Returns the index of the menu with the given {\it title} or wxNOT\_FOUND if no
747 such menu exists in this menubar. The {\it title} parameter may specify either
748 the menu title (with accelerator characters, i.e. {\tt "\&File"}) or just the
749 menu label ({\tt "File"}) indifferently.
750
751 \membersection{wxMenuBar::FindMenuItem}\label{wxmenubarfindmenuitem}
752
753 \constfunc{int}{FindMenuItem}{\param{const wxString\& }{menuString}, \param{const wxString\& }{itemString}}
754
755 Finds the menu item id for a menu name/menu item string pair.
756
757 \wxheading{Parameters}
758
759 \docparam{menuString}{Menu title to find.}
760
761 \docparam{itemString}{Item to find.}
762
763 \wxheading{Return value}
764
765 The menu item identifier, or wxNOT\_FOUND if none was found.
766
767 \wxheading{Remarks}
768
769 Any special menu codes are stripped out of source and target strings
770 before matching.
771
772 \membersection{wxMenuBar::FindItem}\label{wxmenubarfinditem}
773
774 \constfunc{wxMenuItem *}{FindItem}{\param{int}{ id}, \param{wxMenu}{ **menu = NULL}}
775
776 Finds the menu item object associated with the given menu item identifier.
777
778 \wxheading{Parameters}
779
780 \docparam{id}{Menu item identifier.}
781
782 \docparam{menu}{If not NULL, menu will get set to the associated menu.}
783
784 \wxheading{Return value}
785
786 The found menu item object, or NULL if one was not found.
787
788 \membersection{wxMenuBar::GetHelpString}\label{wxmenubargethelpstring}
789
790 \constfunc{wxString}{GetHelpString}{\param{int}{ id}}
791
792 Gets the help string associated with the menu item identifer.
793
794 \wxheading{Parameters}
795
796 \docparam{id}{The menu item identifier.}
797
798 \wxheading{Return value}
799
800 The help string, or the empty string if there was no help string or the menu item
801 was not found.
802
803 \wxheading{See also}
804
805 \helpref{wxMenuBar::SetHelpString}{wxmenubarsethelpstring}
806
807 \membersection{wxMenuBar::GetLabel}\label{wxmenubargetlabel}
808
809 \constfunc{wxString}{GetLabel}{\param{int}{ id}}
810
811 Gets the label associated with a menu item.
812
813 \wxheading{Parameters}
814
815 \docparam{id}{The menu item identifier.}
816
817 \wxheading{Return value}
818
819 The menu item label, or the empty string if the item was not found.
820
821 \wxheading{Remarks}
822
823 Use only after the menubar has been associated with a frame.
824
825 \membersection{wxMenuBar::GetLabelTop}\label{wxmenubargetlabeltop}
826
827 \constfunc{wxString}{GetLabelTop}{\param{int}{ pos}}
828
829 Returns the label of a top-level menu.
830
831 \wxheading{Parameters}
832
833 \docparam{pos}{Position of the menu on the menu bar, starting from zero.}
834
835 \wxheading{Return value}
836
837 The menu label, or the empty string if the menu was not found.
838
839 \wxheading{Remarks}
840
841 Use only after the menubar has been associated with a frame.
842
843 \wxheading{See also}
844
845 \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop}
846
847 \membersection{wxMenuBar::GetMenu}\label{wxmenubargetmenu}
848
849 \constfunc{wxMenu*}{GetMenu}{\param{int}{ menuIndex}}
850
851 Returns the menu at {\it menuIndex} (zero-based).
852
853 \membersection{wxMenuBar::GetMenuCount}\label{wxmenubargetmenucount}
854
855 \constfunc{int}{GetMenuCount}{\void}
856
857 Returns the number of menus in this menubar.
858
859 \membersection{wxMenuBar::Insert}\label{wxmenubarinsert}
860
861 \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
862
863 Inserts the menu at the given position into the menu bar. Inserting menu at
864 position $0$ will insert it in the very beginning of it, inserting at position
865 \helpref{GetMenuCount()}{wxmenubargetmenucount} is the same as calling
866 \helpref{Append()}{wxmenubarappend}.
867
868 \wxheading{Parameters}
869
870 \docparam{pos}{The position of the new menu in the menu bar}
871
872 \docparam{menu}{The menu to add. wxMenuBar owns the menu and will free it.}
873
874 \docparam{title}{The title of the menu.}
875
876 \wxheading{Return value}
877
878 TRUE on success, FALSE if an error occurred.
879
880 \wxheading{See also}
881
882 \helpref{wxMenuBar::Append}{wxmenubarappend}
883
884 \membersection{wxMenuBar::IsChecked}\label{wxmenubarischecked}
885
886 \constfunc{bool}{IsChecked}{\param{int}{ id}}
887
888 Determines whether an item is checked.
889
890 \wxheading{Parameters}
891
892 \docparam{id}{The menu item identifier.}
893
894 \wxheading{Return value}
895
896 TRUE if the item was found and is checked, FALSE otherwise.
897
898 \membersection{wxMenuBar::IsEnabled}\label{wxmenubarisenabled}
899
900 \constfunc{bool}{IsEnabled}{\param{int}{ id}}
901
902 Determines whether an item is enabled.
903
904 \wxheading{Parameters}
905
906 \docparam{id}{The menu item identifier.}
907
908 \wxheading{Return value}
909
910 TRUE if the item was found and is enabled, FALSE otherwise.
911
912 \membersection{wxMenuBar::Refresh}\label{wxmenubarrefresh}
913
914 \func{void}{Refresh}{\void}
915
916 Redraw the menu bar
917
918 \membersection{wxMenuBar::Remove}\label{wxmenubarremove}
919
920 \func{wxMenu *}{Remove}{\param{size\_t }{pos}}
921
922 Removes the menu from the menu bar and returns the menu object - the caller is
923 responsible for deleting it. This function may be used together with
924 \helpref{wxMenuBar::Insert}{wxmenubarinsert} to change the menubar
925 dynamically.
926
927 \wxheading{See also}
928
929 \helpref{wxMenuBar::Replace}{wxmenubarreplace}
930
931 \membersection{wxMenuBar::Replace}\label{wxmenubarreplace}
932
933 \func{wxMenu *}{Replace}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
934
935 Replaces the menu at the given position with another one.
936
937 \wxheading{Parameters}
938
939 \docparam{pos}{The position of the new menu in the menu bar}
940
941 \docparam{menu}{The menu to add.}
942
943 \docparam{title}{The title of the menu.}
944
945 \wxheading{Return value}
946
947 The menu which was previously at the position {\it pos}. The caller is
948 responsible for deleting it.
949
950 \wxheading{See also}
951
952 \helpref{wxMenuBar::Insert}{wxmenubarinsert},\rtfsp
953 \helpref{wxMenuBar::Remove}{wxmenubarremove}
954
955 \membersection{wxMenuBar::SetHelpString}\label{wxmenubarsethelpstring}
956
957 \func{void}{SetHelpString}{\param{int}{ id}, \param{const wxString\& }{helpString}}
958
959 Sets the help string associated with a menu item.
960
961 \wxheading{Parameters}
962
963 \docparam{id}{Menu item identifier.}
964
965 \docparam{helpString}{Help string to associate with the menu item.}
966
967 \wxheading{See also}
968
969 \helpref{wxMenuBar::GetHelpString}{wxmenubargethelpstring}
970
971 \membersection{wxMenuBar::SetLabel}\label{wxmenubarsetlabel}
972
973 \func{void}{SetLabel}{\param{int}{ id}, \param{const wxString\& }{label}}
974
975 Sets the label of a menu item.
976
977 \wxheading{Parameters}
978
979 \docparam{id}{Menu item identifier.}
980
981 \docparam{label}{Menu item label.}
982
983 \wxheading{Remarks}
984
985 Use only after the menubar has been associated with a frame.
986
987 \wxheading{See also}
988
989 \helpref{wxMenuBar::GetLabel}{wxmenubargetlabel}
990
991 \membersection{wxMenuBar::SetLabelTop}\label{wxmenubarsetlabeltop}
992
993 \func{void}{SetLabelTop}{\param{int}{ pos}, \param{const wxString\& }{label}}
994
995 Sets the label of a top-level menu.
996
997 \wxheading{Parameters}
998
999 \docparam{pos}{The position of a menu on the menu bar, starting from zero.}
1000
1001 \docparam{label}{The menu label.}
1002
1003 \wxheading{Remarks}
1004
1005 Use only after the menubar has been associated with a frame.
1006
1007 \wxheading{See also}
1008
1009 \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop}
1010