]> git.saurik.com Git - wxWidgets.git/blame - interface/menu.h
documented that Freeze and Thaw are now recursive
[wxWidgets.git] / interface / menu.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
e54c96f1 3// Purpose: interface of wxMenuBar
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxMenuBar
11 @wxheader{menu.h}
7c913512 12
23324ae1 13 A menu bar is a series of menus accessible from the top of a frame.
7c913512 14
23324ae1
FM
15 @library{wxcore}
16 @category{menus}
7c913512 17
e54c96f1 18 @see wxMenu, @ref overview_eventhandlingoverview
23324ae1
FM
19*/
20class wxMenuBar : public wxWindow
21{
22public:
23 //@{
24 /**
25 Construct a menu bar from arrays of menus and titles.
3c4f71cc 26
7c913512 27 @param n
4cc4bfaf 28 The number of menus.
7c913512 29 @param menus
4cc4bfaf
FM
30 An array of menus. Do not use this array again - it now belongs to the
31 menu bar.
7c913512 32 @param titles
4cc4bfaf
FM
33 An array of title strings. Deallocate this array after creating the menu
34 bar.
7c913512 35 @param style
4cc4bfaf 36 If wxMB_DOCKABLE the menu bar can be detached (wxGTK only).
23324ae1
FM
37 */
38 wxMenuBar(long style = 0);
7c913512
FM
39 wxMenuBar(size_t n, wxMenu* menus[], const wxString titles[],
40 long style = 0);
23324ae1
FM
41 //@}
42
43 /**
44 Destructor, destroying the menu bar and removing it from the parent frame (if
45 any).
46 */
47 ~wxMenuBar();
48
49 /**
50 Adds the item to the end of the menu bar.
3c4f71cc 51
7c913512 52 @param menu
4cc4bfaf 53 The menu to add. Do not deallocate this menu after calling Append.
7c913512 54 @param title
4cc4bfaf 55 The title of the menu.
3c4f71cc 56
23324ae1 57 @returns @true on success, @false if an error occurred.
3c4f71cc 58
4cc4bfaf 59 @see Insert()
23324ae1 60 */
4cc4bfaf 61 bool Append(wxMenu* menu, const wxString& title);
23324ae1
FM
62
63 /**
64 Checks or unchecks a menu item.
3c4f71cc 65
7c913512 66 @param id
4cc4bfaf 67 The menu item identifier.
7c913512 68 @param check
4cc4bfaf 69 If @true, checks the menu item, otherwise the item is unchecked.
3c4f71cc 70
23324ae1 71 @remarks Only use this when the menu bar has been associated with a
4cc4bfaf 72 frame; otherwise, use the wxMenu equivalent call.
23324ae1
FM
73 */
74 void Check(int id, const bool check);
75
76 /**
77 Enables or disables (greys out) a menu item.
3c4f71cc 78
7c913512 79 @param id
4cc4bfaf 80 The menu item identifier.
7c913512 81 @param enable
4cc4bfaf 82 @true to enable the item, @false to disable it.
3c4f71cc 83
23324ae1 84 @remarks Only use this when the menu bar has been associated with a
4cc4bfaf 85 frame; otherwise, use the wxMenu equivalent call.
23324ae1
FM
86 */
87 void Enable(int id, const bool enable);
88
89 /**
90 Enables or disables a whole menu.
3c4f71cc 91
7c913512 92 @param pos
4cc4bfaf 93 The position of the menu, starting from zero.
7c913512 94 @param enable
4cc4bfaf 95 @true to enable the menu, @false to disable it.
3c4f71cc 96
23324ae1
FM
97 @remarks Only use this when the menu bar has been associated with a frame.
98 */
99 void EnableTop(int pos, const bool enable);
100
101 /**
102 Finds the menu item object associated with the given menu item identifier.
3c4f71cc 103
7c913512 104 @param id
4cc4bfaf 105 Menu item identifier.
7c913512 106 @param menu
4cc4bfaf 107 If not @NULL, menu will get set to the associated menu.
3c4f71cc 108
23324ae1
FM
109 @returns The found menu item object, or @NULL if one was not found.
110 */
328f5751 111 wxMenuItem* FindItem(int id, wxMenu menu = NULL) const;
23324ae1
FM
112
113 /**
4cc4bfaf
FM
114 Returns the index of the menu with the given @a title or @c wxNOT_FOUND if no
115 such menu exists in this menubar. The @a title parameter may specify either
23324ae1
FM
116 the menu title (with accelerator characters, i.e. @c "File") or just the
117 menu label (@c "File") indifferently.
118 */
328f5751 119 int FindMenu(const wxString& title) const;
23324ae1
FM
120
121 /**
122 Finds the menu item id for a menu name/menu item string pair.
3c4f71cc 123
7c913512 124 @param menuString
4cc4bfaf 125 Menu title to find.
7c913512 126 @param itemString
4cc4bfaf 127 Item to find.
3c4f71cc 128
23324ae1 129 @returns The menu item identifier, or wxNOT_FOUND if none was found.
3c4f71cc 130
23324ae1 131 @remarks Any special menu codes are stripped out of source and target
4cc4bfaf 132 strings before matching.
23324ae1
FM
133 */
134 int FindMenuItem(const wxString& menuString,
328f5751 135 const wxString& itemString) const;
23324ae1
FM
136
137 /**
138 Gets the help string associated with the menu item identifier.
3c4f71cc 139
7c913512 140 @param id
4cc4bfaf 141 The menu item identifier.
3c4f71cc 142
23324ae1 143 @returns The help string, or the empty string if there was no help string
4cc4bfaf 144 or the menu item was not found.
3c4f71cc 145
4cc4bfaf 146 @see SetHelpString()
23324ae1 147 */
328f5751 148 wxString GetHelpString(int id) const;
23324ae1
FM
149
150 /**
151 Gets the label associated with a menu item.
3c4f71cc 152
7c913512 153 @param id
4cc4bfaf 154 The menu item identifier.
3c4f71cc 155
23324ae1 156 @returns The menu item label, or the empty string if the item was not
4cc4bfaf 157 found.
3c4f71cc 158
23324ae1
FM
159 @remarks Use only after the menubar has been associated with a frame.
160 */
328f5751 161 wxString GetLabel(int id) const;
23324ae1
FM
162
163 /**
164 Returns the label of a top-level menu. Note that the returned string does not
165 include the accelerator characters which could have been specified in the menu
166 title string during its construction.
3c4f71cc 167
7c913512 168 @param pos
4cc4bfaf 169 Position of the menu on the menu bar, starting from zero.
3c4f71cc 170
23324ae1 171 @returns The menu label, or the empty string if the menu was not found.
3c4f71cc 172
23324ae1 173 @remarks Use only after the menubar has been associated with a frame.
3c4f71cc 174
4cc4bfaf 175 @see SetLabelTop()
23324ae1 176 */
328f5751 177 wxString GetLabelTop(int pos) const;
23324ae1
FM
178
179 /**
4cc4bfaf 180 Returns the menu at @a menuIndex (zero-based).
23324ae1 181 */
328f5751 182 wxMenu* GetMenu(int menuIndex) const;
23324ae1
FM
183
184 /**
185 Returns the number of menus in this menubar.
186 */
328f5751 187 size_t GetMenuCount() const;
23324ae1
FM
188
189 /**
190 Returns the label of a top-level menu. Note that the returned string
191 includes the accelerator characters that have been specified in the menu
192 title string during its construction.
3c4f71cc 193
7c913512 194 @param pos
4cc4bfaf 195 Position of the menu on the menu bar, starting from zero.
3c4f71cc 196
23324ae1 197 @returns The menu label, or the empty string if the menu was not found.
3c4f71cc 198
23324ae1 199 @remarks Use only after the menubar has been associated with a frame.
3c4f71cc 200
4cc4bfaf 201 @see GetMenuLabelText(), SetMenuLabel()
23324ae1 202 */
328f5751 203 wxString GetMenuLabel(int pos) const;
23324ae1
FM
204
205 /**
206 Returns the label of a top-level menu. Note that the returned string does not
207 include any accelerator characters that may have been specified in the menu
208 title string during its construction.
3c4f71cc 209
7c913512 210 @param pos
4cc4bfaf 211 Position of the menu on the menu bar, starting from zero.
3c4f71cc 212
23324ae1 213 @returns The menu label, or the empty string if the menu was not found.
3c4f71cc 214
23324ae1 215 @remarks Use only after the menubar has been associated with a frame.
3c4f71cc 216
4cc4bfaf 217 @see GetMenuLabel(), SetMenuLabel()
23324ae1 218 */
328f5751 219 wxString GetMenuLabelText(int pos) const;
23324ae1
FM
220
221 /**
222 Inserts the menu at the given position into the menu bar. Inserting menu at
7c913512
FM
223 position 0 will insert it in the very beginning of it, inserting at position
224 GetMenuCount() is the same as calling
23324ae1 225 Append().
3c4f71cc 226
7c913512 227 @param pos
4cc4bfaf 228 The position of the new menu in the menu bar
7c913512 229 @param menu
4cc4bfaf 230 The menu to add. wxMenuBar owns the menu and will free it.
7c913512 231 @param title
4cc4bfaf 232 The title of the menu.
3c4f71cc 233
23324ae1 234 @returns @true on success, @false if an error occurred.
3c4f71cc 235
4cc4bfaf 236 @see Append()
23324ae1 237 */
4cc4bfaf 238 bool Insert(size_t pos, wxMenu* menu, const wxString& title);
23324ae1
FM
239
240 /**
241 Determines whether an item is checked.
3c4f71cc 242
7c913512 243 @param id
4cc4bfaf 244 The menu item identifier.
3c4f71cc 245
23324ae1
FM
246 @returns @true if the item was found and is checked, @false otherwise.
247 */
328f5751 248 bool IsChecked(int id) const;
23324ae1
FM
249
250 /**
251 Determines whether an item is enabled.
3c4f71cc 252
7c913512 253 @param id
4cc4bfaf 254 The menu item identifier.
3c4f71cc 255
23324ae1
FM
256 @returns @true if the item was found and is enabled, @false otherwise.
257 */
328f5751 258 bool IsEnabled(int id) const;
23324ae1
FM
259
260 /**
261 Redraw the menu bar
262 */
263 void Refresh();
264
265 /**
266 Removes the menu from the menu bar and returns the menu object - the caller is
7c913512 267 responsible for deleting it. This function may be used together with
23324ae1
FM
268 Insert() to change the menubar
269 dynamically.
3c4f71cc 270
4cc4bfaf 271 @see Replace()
23324ae1 272 */
4cc4bfaf 273 wxMenu* Remove(size_t pos);
23324ae1
FM
274
275 /**
276 Replaces the menu at the given position with another one.
3c4f71cc 277
7c913512 278 @param pos
4cc4bfaf 279 The position of the new menu in the menu bar
7c913512 280 @param menu
4cc4bfaf 281 The menu to add.
7c913512 282 @param title
4cc4bfaf 283 The title of the menu.
3c4f71cc 284
23324ae1 285 @returns The menu which was previously at position pos. The caller is
4cc4bfaf 286 responsible for deleting it.
3c4f71cc 287
4cc4bfaf 288 @see Insert(), Remove()
23324ae1 289 */
4cc4bfaf 290 wxMenu* Replace(size_t pos, wxMenu* menu, const wxString& title);
23324ae1
FM
291
292 /**
293 Sets the help string associated with a menu item.
3c4f71cc 294
7c913512 295 @param id
4cc4bfaf 296 Menu item identifier.
7c913512 297 @param helpString
4cc4bfaf 298 Help string to associate with the menu item.
3c4f71cc 299
4cc4bfaf 300 @see GetHelpString()
23324ae1
FM
301 */
302 void SetHelpString(int id, const wxString& helpString);
303
304 /**
305 Sets the label of a menu item.
3c4f71cc 306
7c913512 307 @param id
4cc4bfaf 308 Menu item identifier.
7c913512 309 @param label
4cc4bfaf 310 Menu item label.
3c4f71cc 311
23324ae1 312 @remarks Use only after the menubar has been associated with a frame.
3c4f71cc 313
4cc4bfaf 314 @see GetLabel()
23324ae1
FM
315 */
316 void SetLabel(int id, const wxString& label);
317
318 /**
319 Sets the label of a top-level menu.
3c4f71cc 320
7c913512 321 @param pos
4cc4bfaf 322 The position of a menu on the menu bar, starting from zero.
7c913512 323 @param label
4cc4bfaf 324 The menu label.
3c4f71cc 325
23324ae1 326 @remarks Use only after the menubar has been associated with a frame.
3c4f71cc 327
4cc4bfaf 328 @see GetLabelTop()
23324ae1
FM
329 */
330 void SetLabelTop(int pos, const wxString& label);
331
332 /**
333 Sets the label of a top-level menu.
3c4f71cc 334
7c913512 335 @param pos
4cc4bfaf 336 The position of a menu on the menu bar, starting from zero.
7c913512 337 @param label
4cc4bfaf 338 The menu label.
3c4f71cc 339
23324ae1
FM
340 @remarks Use only after the menubar has been associated with a frame.
341 */
342 void SetMenuLabel(int pos, const wxString& label);
343};
344
345
e54c96f1 346
23324ae1
FM
347/**
348 @class wxMenu
349 @wxheader{menu.h}
7c913512 350
23324ae1
FM
351 A menu is a popup (or pull down) list of items, one of which may be
352 selected before the menu goes away (clicking elsewhere dismisses the
353 menu). Menus may be used to construct either menu bars or popup menus.
7c913512 354
23324ae1
FM
355 A menu item has an integer ID associated with it which can be used to
356 identify the selection, or to change the menu item in some way. A menu item
357 with a special identifier -1 is a separator item and doesn't have an
358 associated command but just makes a separator line appear in the menu.
7c913512 359
23324ae1
FM
360 @b NB: Please note that @e wxID_ABOUT and @e wxID_EXIT are
361 predefined by wxWidgets and have a special meaning since entries
362 using these IDs will be taken out of the normal menus under MacOS X
363 and will be inserted into the system menu (following the appropriate
364 MacOS X interface guideline). On PalmOS @e wxID_EXIT is disabled according
365 to Palm OS Companion guidelines.
7c913512 366
23324ae1
FM
367 Menu items may be either normal items, check items or radio items. Normal items
368 don't have any special properties while the check items have a boolean flag
369 associated to them and they show a checkmark in the menu when the flag is set.
370 wxWidgets automatically toggles the flag value when the item is clicked and its
371 value may be retrieved using either wxMenu::IsChecked method
7c913512 372 of wxMenu or wxMenuBar itself or by using
23324ae1
FM
373 wxEvent::IsChecked when you get the menu
374 notification for the item in question.
7c913512 375
23324ae1
FM
376 The radio items are similar to the check items except that all the other items
377 in the same radio group are unchecked when a radio item is checked. The radio
378 group is formed by a contiguous range of radio items, i.e. it starts at the
379 first item of this kind and ends with the first item of a different kind (or
380 the end of the menu). Notice that because the radio groups are defined in terms
381 of the item positions inserting or removing the items in the menu containing
382 the radio items risks to not work correctly. Finally note that radio items
383 are not supported under Motif.
7c913512 384
23324ae1
FM
385 @library{wxcore}
386 @category{menus}
7c913512 387
e54c96f1 388 @see wxMenuBar, wxWindow::PopupMenu, @ref overview_eventhandlingoverview, @ref
4cc4bfaf 389 overview_wxfilehistory "wxFileHistory (most recently used files menu)"
23324ae1
FM
390*/
391class wxMenu : public wxEvtHandler
392{
393public:
394 //@{
395 /**
396 Constructs a wxMenu object.
3c4f71cc 397
7c913512 398 @param style
4cc4bfaf 399 If set to wxMENU_TEAROFF, the menu will be detachable (wxGTK only).
23324ae1
FM
400 */
401 wxMenu(const wxString& title = "", long style = 0);
7c913512 402 wxMenu(long style);
23324ae1
FM
403 //@}
404
405 /**
406 Destructor, destroying the menu.
23324ae1
FM
407 Note: under Motif, a popup menu must have a valid parent (the window
408 it was last popped up on) when being destroyed. Therefore, make sure
409 you delete or re-use the popup menu @e before destroying the
410 parent window. Re-use in this context means popping up the menu on
411 a different window from last time, which causes an implicit destruction
412 and recreation of internal data structures.
413 */
414 ~wxMenu();
415
416 //@{
417 /**
418 Adds a menu item object. This is the most generic variant of Append() method
419 because it may be used for both items (including separators) and submenus and
420 because you can also specify various extra properties of a menu item this way,
421 such as bitmaps and fonts.
3c4f71cc 422
7c913512 423 @param id
4cc4bfaf 424 The menu command identifier.
7c913512 425 @param item
4cc4bfaf 426 The string to appear on the menu item.
7c913512 427 @param menu
4cc4bfaf 428 Pull-right submenu.
7c913512 429 @param kind
4cc4bfaf
FM
430 May be wxITEM_SEPARATOR, wxITEM_NORMAL,
431 wxITEM_CHECK or wxITEM_RADIO
7c913512 432 @param helpString
4cc4bfaf
FM
433 An optional help string associated with the item.
434 By default, the handler for the wxEVT_MENU_HIGHLIGHT event displays
435 this string in the status line.
7c913512 436 @param menuItem
4cc4bfaf
FM
437 A menuitem object. It will be owned by the wxMenu object after this function
438 is called, so do not delete it yourself.
3c4f71cc 439
23324ae1 440 @remarks This command can be used after the menu has been shown, as well
4cc4bfaf 441 as on initial creation of a menu or menubar.
3c4f71cc 442
4cc4bfaf
FM
443 @see AppendSeparator(), AppendCheckItem(), AppendRadioItem(),
444 AppendSubMenu(), Insert(), SetLabel(),
445 GetHelpString(), SetHelpString(), wxMenuItem
23324ae1
FM
446 */
447 wxMenuItem* Append(int id, const wxString& item = "",
448 const wxString& helpString = "",
449 wxItemKind kind = wxITEM_NORMAL);
7c913512 450 wxMenuItem* Append(int id, const wxString& item,
4cc4bfaf 451 wxMenu* subMenu,
7c913512
FM
452 const wxString& helpString = "");
453 wxMenuItem* Append(wxMenuItem* menuItem);
23324ae1
FM
454 //@}
455
456 /**
457 Adds a checkable item to the end of the menu.
3c4f71cc 458
4cc4bfaf 459 @see Append(), InsertCheckItem()
23324ae1
FM
460 */
461 wxMenuItem* AppendCheckItem(int id, const wxString& item,
462 const wxString& helpString = "");
463
464 /**
465 Adds a radio item to the end of the menu. All consequent radio items form a
466 group and when an item in the group is checked, all the others are
467 automatically unchecked.
3c4f71cc 468
4cc4bfaf 469 @see Append(), InsertRadioItem()
23324ae1
FM
470 */
471 wxMenuItem* AppendRadioItem(int id, const wxString& item,
472 const wxString& helpString = "");
473
474 /**
475 Adds a separator to the end of the menu.
3c4f71cc 476
4cc4bfaf 477 @see Append(), InsertSeparator()
23324ae1
FM
478 */
479 wxMenuItem* AppendSeparator();
480
481 /**
4cc4bfaf
FM
482 Adds the given @a submenu to this menu. @a text is the text shown in the
483 menu for it and @a help is the help string shown in the status bar when the
23324ae1
FM
484 submenu item is selected.
485 */
4cc4bfaf
FM
486 wxMenuItem* AppendSubMenu(wxMenu* submenu, const wxString& text,
487 const wxString& help = wxEmptyString);
23324ae1
FM
488
489 /**
490 Inserts a break in a menu, causing the next appended item to appear in a new
491 column.
492 */
493 void Break();
494
495 /**
496 Checks or unchecks the menu item.
3c4f71cc 497
7c913512 498 @param id
4cc4bfaf 499 The menu item identifier.
7c913512 500 @param check
4cc4bfaf 501 If @true, the item will be checked, otherwise it will be unchecked.
3c4f71cc 502
4cc4bfaf 503 @see IsChecked()
23324ae1
FM
504 */
505 void Check(int id, const bool check);
506
507 //@{
508 /**
509 Deletes the menu item from the menu. If the item is a submenu, it will
510 @b not be deleted. Use Destroy() if you want to
511 delete a submenu.
3c4f71cc 512
7c913512 513 @param id
4cc4bfaf 514 Id of the menu item to be deleted.
7c913512 515 @param item
4cc4bfaf 516 Menu item to be deleted.
3c4f71cc 517
4cc4bfaf 518 @see FindItem(), Destroy(), Remove()
23324ae1
FM
519 */
520 void Delete(int id);
4cc4bfaf 521 void Delete(wxMenuItem* item);
23324ae1
FM
522 //@}
523
524 //@{
525 /**
526 Deletes the menu item from the menu. If the item is a submenu, it will
527 be deleted. Use Remove() if you want to keep the submenu
528 (for example, to reuse it later).
3c4f71cc 529
7c913512 530 @param id
4cc4bfaf 531 Id of the menu item to be deleted.
7c913512 532 @param item
4cc4bfaf 533 Menu item to be deleted.
3c4f71cc 534
4cc4bfaf 535 @see FindItem(), Deletes(), Remove()
23324ae1
FM
536 */
537 void Destroy(int id);
4cc4bfaf 538 void Destroy(wxMenuItem* item);
23324ae1
FM
539 //@}
540
541 /**
542 Enables or disables (greys out) a menu item.
3c4f71cc 543
7c913512 544 @param id
4cc4bfaf 545 The menu item identifier.
7c913512 546 @param enable
4cc4bfaf 547 @true to enable the menu item, @false to disable it.
3c4f71cc 548
4cc4bfaf 549 @see IsEnabled()
23324ae1
FM
550 */
551 void Enable(int id, const bool enable);
552
553 //@{
554 /**
555 Finds the menu item object associated with the given menu item identifier and,
556 optionally, the (sub)menu it belongs to.
3c4f71cc 557
7c913512 558 @param itemString
4cc4bfaf 559 Menu item string to find.
7c913512 560 @param id
4cc4bfaf 561 Menu item identifier.
7c913512 562 @param menu
4cc4bfaf
FM
563 If the pointer is not @NULL, it will be filled with the item's
564 parent menu (if the item was found)
3c4f71cc 565
23324ae1 566 @returns First form: menu item identifier, or wxNOT_FOUND if none is
4cc4bfaf 567 found.
3c4f71cc 568
23324ae1 569 @remarks Any special menu codes are stripped out of source and target
4cc4bfaf 570 strings before matching.
23324ae1 571 */
328f5751
FM
572 int FindItem(const wxString& itemString) const;
573 const wxMenuItem * FindItem(int id, wxMenu** menu = NULL) const;
23324ae1
FM
574 //@}
575
576 /**
577 Returns the wxMenuItem given a position in the menu.
578 */
328f5751 579 wxMenuItem* FindItemByPosition(size_t position) const;
23324ae1
FM
580
581 /**
582 Returns the help string associated with a menu item.
3c4f71cc 583
7c913512 584 @param id
4cc4bfaf 585 The menu item identifier.
3c4f71cc 586
23324ae1 587 @returns The help string, or the empty string if there is no help string
4cc4bfaf 588 or the item was not found.
3c4f71cc 589
4cc4bfaf 590 @see SetHelpString(), Append()
23324ae1 591 */
328f5751 592 wxString GetHelpString(int id) const;
23324ae1
FM
593
594 /**
595 Returns a menu item label.
3c4f71cc 596
7c913512 597 @param id
4cc4bfaf 598 The menu item identifier.
3c4f71cc 599
23324ae1 600 @returns The item label, or the empty string if the item was not found.
3c4f71cc 601
4cc4bfaf 602 @see GetLabelText(), SetLabel()
23324ae1 603 */
328f5751 604 wxString GetLabel(int id) const;
23324ae1
FM
605
606 /**
607 Returns a menu item label, without any of the original mnemonics and
608 accelerators.
3c4f71cc 609
7c913512 610 @param id
4cc4bfaf 611 The menu item identifier.
3c4f71cc 612
23324ae1 613 @returns The item label, or the empty string if the item was not found.
3c4f71cc 614
4cc4bfaf 615 @see GetLabel(), SetLabel()
23324ae1 616 */
328f5751 617 wxString GetLabelText(int id) const;
23324ae1
FM
618
619 /**
620 Returns the number of items in the menu.
621 */
328f5751 622 size_t GetMenuItemCount() const;
23324ae1
FM
623
624 /**
625 Returns the list of items in the menu. wxMenuItemList is a pseudo-template
626 list class containing wxMenuItem pointers, see wxList.
627 */
328f5751 628 wxMenuItemList GetMenuItems() const;
23324ae1
FM
629
630 /**
631 Returns the title of the menu.
3c4f71cc 632
7c913512 633 @remarks This is relevant only to popup menus, use
4cc4bfaf 634 wxMenuBar::GetMenuLabel for the menus in the menubar.
3c4f71cc 635
4cc4bfaf 636 @see SetTitle()
23324ae1 637 */
328f5751 638 wxString GetTitle() const;
23324ae1
FM
639
640 //@{
641 /**
4cc4bfaf 642 Inserts the given @a item before the position @e pos. Inserting the item
23324ae1
FM
643 at position GetMenuItemCount() is the same
644 as appending it.
3c4f71cc 645
4cc4bfaf 646 @see Append(), Prepend()
23324ae1 647 */
4cc4bfaf 648 wxMenuItem* Insert(size_t pos, wxMenuItem* item);
7c913512
FM
649 wxMenuItem* Insert(size_t pos, int id,
650 const wxString& item = "",
651 const wxString& helpString = "",
652 wxItemKind kind = wxITEM_NORMAL);
23324ae1
FM
653 //@}
654
655 /**
656 Inserts a checkable item at the given position.
3c4f71cc 657
4cc4bfaf 658 @see Insert(), AppendCheckItem()
23324ae1
FM
659 */
660 wxMenuItem* InsertCheckItem(size_t pos, int id,
661 const wxString& item,
662 const wxString& helpString = "");
663
664 /**
665 Inserts a radio item at the given position.
3c4f71cc 666
4cc4bfaf 667 @see Insert(), AppendRadioItem()
23324ae1
FM
668 */
669 wxMenuItem* InsertRadioItem(size_t pos, int id,
670 const wxString& item,
671 const wxString& helpString = "");
672
673 /**
674 Inserts a separator at the given position.
3c4f71cc 675
4cc4bfaf 676 @see Insert(), AppendSeparator()
23324ae1
FM
677 */
678 wxMenuItem* InsertSeparator(size_t pos);
679
680 /**
681 Determines whether a menu item is checked.
3c4f71cc 682
7c913512 683 @param id
4cc4bfaf 684 The menu item identifier.
3c4f71cc 685
23324ae1 686 @returns @true if the menu item is checked, @false otherwise.
3c4f71cc 687
4cc4bfaf 688 @see Check()
23324ae1 689 */
328f5751 690 bool IsChecked(int id) const;
23324ae1
FM
691
692 /**
693 Determines whether a menu item is enabled.
3c4f71cc 694
7c913512 695 @param id
4cc4bfaf 696 The menu item identifier.
3c4f71cc 697
23324ae1 698 @returns @true if the menu item is enabled, @false otherwise.
3c4f71cc 699
4cc4bfaf 700 @see Enable()
23324ae1 701 */
328f5751 702 bool IsEnabled(int id) const;
23324ae1
FM
703
704 //@{
705 /**
4cc4bfaf 706 Inserts the given @a item at position 0, i.e. before all the other
23324ae1 707 existing items.
3c4f71cc 708
4cc4bfaf 709 @see Append(), Insert()
23324ae1 710 */
4cc4bfaf 711 wxMenuItem* Prepend(wxMenuItem* item);
7c913512
FM
712 wxMenuItem* Prepend(int id, const wxString& item = "",
713 const wxString& helpString = "",
714 wxItemKind kind = wxITEM_NORMAL);
23324ae1
FM
715 //@}
716
717 /**
718 Inserts a checkable item at position 0.
3c4f71cc 719
4cc4bfaf 720 @see Prepend(), AppendCheckItem()
23324ae1
FM
721 */
722 wxMenuItem* PrependCheckItem(int id, const wxString& item,
723 const wxString& helpString = "");
724
725 /**
726 Inserts a radio item at position 0.
3c4f71cc 727
4cc4bfaf 728 @see Prepend(), AppendRadioItem()
23324ae1
FM
729 */
730 wxMenuItem* PrependRadioItem(int id, const wxString& item,
731 const wxString& helpString = "");
732
733 /**
734 Inserts a separator at position 0.
3c4f71cc 735
4cc4bfaf 736 @see Prepend(), AppendSeparator()
23324ae1
FM
737 */
738 wxMenuItem* PrependSeparator();
739
740 //@{
741 /**
742 Removes the menu item from the menu but doesn't delete the associated C++
743 object. This allows to reuse the same item later by adding it back to the menu
744 (especially useful with submenus).
3c4f71cc 745
7c913512 746 @param id
4cc4bfaf 747 The identifier of the menu item to remove.
7c913512 748 @param item
4cc4bfaf 749 The menu item to remove.
3c4f71cc 750
23324ae1
FM
751 @returns The item which was detached from the menu.
752 */
4cc4bfaf
FM
753 wxMenuItem* Remove(int id);
754 wxMenuItem* Remove(wxMenuItem* item);
23324ae1
FM
755 //@}
756
757 /**
758 Sets an item's help string.
3c4f71cc 759
7c913512 760 @param id
4cc4bfaf 761 The menu item identifier.
7c913512 762 @param helpString
4cc4bfaf 763 The help string to set.
3c4f71cc 764
4cc4bfaf 765 @see GetHelpString()
23324ae1
FM
766 */
767 void SetHelpString(int id, const wxString& helpString);
768
769 /**
770 Sets the label of a menu item.
3c4f71cc 771
7c913512 772 @param id
4cc4bfaf 773 The menu item identifier.
7c913512 774 @param label
4cc4bfaf 775 The menu item label to set.
3c4f71cc 776
4cc4bfaf 777 @see Append(), GetLabel()
23324ae1
FM
778 */
779 void SetLabel(int id, const wxString& label);
780
781 /**
782 Sets the title of the menu.
3c4f71cc 783
7c913512 784 @param title
4cc4bfaf 785 The title to set.
3c4f71cc 786
7c913512 787 @remarks This is relevant only to popup menus, use
4cc4bfaf 788 wxMenuBar::SetLabelTop for the menus in the menubar.
3c4f71cc 789
4cc4bfaf 790 @see GetTitle()
23324ae1
FM
791 */
792 void SetTitle(const wxString& title);
793
794 /**
4cc4bfaf 795 Sends events to @a source (or owning window if @NULL) to update the
23324ae1
FM
796 menu UI. This is called just before the menu is popped up with
797 wxWindow::PopupMenu, but
798 the application may call it at other times if required.
799 */
328f5751 800 void UpdateUI(wxEvtHandler* source = NULL) const;
23324ae1 801};
e54c96f1 802