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