]> git.saurik.com Git - wxWidgets.git/blame - include/wx/menu.h
Applied rowspan patch #15276 (dghart)
[wxWidgets.git] / include / wx / menu.h
CommitLineData
3dfac970
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/menu.h
3// Purpose: wxMenu and wxMenuBar classes
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 26.10.99
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
3dfac970
VZ
10///////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_MENU_H_BASE_
13#define _WX_MENU_H_BASE_
c801d85f 14
997176a3
VZ
15#include "wx/defs.h"
16
1e6feb95
VZ
17#if wxUSE_MENUS
18
3dfac970
VZ
19// ----------------------------------------------------------------------------
20// headers
21// ----------------------------------------------------------------------------
22
717a57c2 23#include "wx/list.h" // for "template" list classes
3dfac970
VZ
24#include "wx/window.h" // base class for wxMenuBar
25
717a57c2
VZ
26// also include this one to ensure compatibility with old code which only
27// included wx/menu.h
28#include "wx/menuitem.h"
29
7118e711 30class WXDLLIMPEXP_FWD_CORE wxFrame;
b5dbe15d
VS
31class WXDLLIMPEXP_FWD_CORE wxMenu;
32class WXDLLIMPEXP_FWD_CORE wxMenuBarBase;
33class WXDLLIMPEXP_FWD_CORE wxMenuBar;
34class WXDLLIMPEXP_FWD_CORE wxMenuItem;
3dfac970 35
717a57c2 36// pseudo template list classes
f6bcfd97
BP
37WX_DECLARE_EXPORTED_LIST(wxMenu, wxMenuList);
38WX_DECLARE_EXPORTED_LIST(wxMenuItem, wxMenuItemList);
717a57c2 39
3dfac970
VZ
40// ----------------------------------------------------------------------------
41// wxMenu
42// ----------------------------------------------------------------------------
43
53a2db12 44class WXDLLIMPEXP_CORE wxMenuBase : public wxEvtHandler
717a57c2
VZ
45{
46public:
47 // create a menu
48 static wxMenu *New(const wxString& title = wxEmptyString, long style = 0);
49
50 // ctors
51 wxMenuBase(const wxString& title, long style = 0) : m_title(title)
52 { Init(style); }
53 wxMenuBase(long style = 0)
54 { Init(style); }
55
56 // dtor deletes all the menu items we own
57 virtual ~wxMenuBase();
58
59 // menu construction
60 // -----------------
61
d65c269b 62 // append any kind of item (normal/check/radio/separator)
9add9367 63 wxMenuItem* Append(int itemid,
ee0a94cf 64 const wxString& text = wxEmptyString,
9add9367
RD
65 const wxString& help = wxEmptyString,
66 wxItemKind kind = wxITEM_NORMAL)
717a57c2 67 {
9add9367 68 return DoAppend(wxMenuItem::New((wxMenu *)this, itemid, text, help, kind));
717a57c2
VZ
69 }
70
0e528b99 71 // append a separator to the menu
fa7134b0 72 wxMenuItem* AppendSeparator() { return Append(wxID_SEPARATOR); }
0e528b99 73
d65c269b 74 // append a check item
9add9367
RD
75 wxMenuItem* AppendCheckItem(int itemid,
76 const wxString& text,
77 const wxString& help = wxEmptyString)
d65c269b 78 {
9add9367 79 return Append(itemid, text, help, wxITEM_CHECK);
d65c269b
VZ
80 }
81
82 // append a radio item
9add9367
RD
83 wxMenuItem* AppendRadioItem(int itemid,
84 const wxString& text,
85 const wxString& help = wxEmptyString)
d65c269b 86 {
9add9367 87 return Append(itemid, text, help, wxITEM_RADIO);
d65c269b
VZ
88 }
89
717a57c2 90 // append a submenu
3786c8b5
VZ
91 wxMenuItem* AppendSubMenu(wxMenu *submenu,
92 const wxString& text,
93 const wxString& help = wxEmptyString)
717a57c2 94 {
3786c8b5 95 return DoAppend(wxMenuItem::New((wxMenu *)this, wxID_ANY, text, help,
9add9367 96 wxITEM_NORMAL, submenu));
717a57c2
VZ
97 }
98
99 // the most generic form of Append() - append anything
9add9367 100 wxMenuItem* Append(wxMenuItem *item) { return DoAppend(item); }
717a57c2
VZ
101
102 // insert a break in the menu (only works when appending the items, not
103 // inserting them)
104 virtual void Break() { }
105
106 // insert an item before given position
9add9367 107 wxMenuItem* Insert(size_t pos, wxMenuItem *item);
d65c269b
VZ
108
109 // insert an item before given position
9add9367
RD
110 wxMenuItem* Insert(size_t pos,
111 int itemid,
ee0a94cf 112 const wxString& text = wxEmptyString,
9add9367
RD
113 const wxString& help = wxEmptyString,
114 wxItemKind kind = wxITEM_NORMAL)
f6bcfd97 115 {
9add9367 116 return Insert(pos, wxMenuItem::New((wxMenu *)this, itemid, text, help, kind));
f6bcfd97
BP
117 }
118
119 // insert a separator
9add9367 120 wxMenuItem* InsertSeparator(size_t pos)
f6bcfd97 121 {
9add9367 122 return Insert(pos, wxMenuItem::New((wxMenu *)this, wxID_SEPARATOR));
f6bcfd97
BP
123 }
124
d65c269b 125 // insert a check item
9add9367
RD
126 wxMenuItem* InsertCheckItem(size_t pos,
127 int itemid,
128 const wxString& text,
129 const wxString& help = wxEmptyString)
d65c269b 130 {
9add9367 131 return Insert(pos, itemid, text, help, wxITEM_CHECK);
d65c269b
VZ
132 }
133
134 // insert a radio item
9add9367
RD
135 wxMenuItem* InsertRadioItem(size_t pos,
136 int itemid,
137 const wxString& text,
138 const wxString& help = wxEmptyString)
d65c269b 139 {
9add9367 140 return Insert(pos, itemid, text, help, wxITEM_RADIO);
d65c269b
VZ
141 }
142
f6bcfd97 143 // insert a submenu
9add9367
RD
144 wxMenuItem* Insert(size_t pos,
145 int itemid,
146 const wxString& text,
147 wxMenu *submenu,
148 const wxString& help = wxEmptyString)
f6bcfd97 149 {
9add9367
RD
150 return Insert(pos, wxMenuItem::New((wxMenu *)this, itemid, text, help,
151 wxITEM_NORMAL, submenu));
f6bcfd97
BP
152 }
153
154 // prepend an item to the menu
9add9367 155 wxMenuItem* Prepend(wxMenuItem *item)
f6bcfd97 156 {
9add9367 157 return Insert(0u, item);
f6bcfd97
BP
158 }
159
d65c269b 160 // prepend any item to the menu
9add9367 161 wxMenuItem* Prepend(int itemid,
ee0a94cf 162 const wxString& text = wxEmptyString,
9add9367
RD
163 const wxString& help = wxEmptyString,
164 wxItemKind kind = wxITEM_NORMAL)
f6bcfd97 165 {
9add9367 166 return Insert(0u, itemid, text, help, kind);
f6bcfd97
BP
167 }
168
d65c269b 169 // prepend a separator
9add9367 170 wxMenuItem* PrependSeparator()
f6bcfd97 171 {
9add9367 172 return InsertSeparator(0u);
f6bcfd97
BP
173 }
174
d65c269b 175 // prepend a check item
9add9367
RD
176 wxMenuItem* PrependCheckItem(int itemid,
177 const wxString& text,
178 const wxString& help = wxEmptyString)
d65c269b 179 {
9add9367 180 return InsertCheckItem(0u, itemid, text, help);
d65c269b
VZ
181 }
182
183 // prepend a radio item
9add9367
RD
184 wxMenuItem* PrependRadioItem(int itemid,
185 const wxString& text,
186 const wxString& help = wxEmptyString)
d65c269b 187 {
9add9367 188 return InsertRadioItem(0u, itemid, text, help);
d65c269b
VZ
189 }
190
191 // prepend a submenu
9add9367
RD
192 wxMenuItem* Prepend(int itemid,
193 const wxString& text,
194 wxMenu *submenu,
195 const wxString& help = wxEmptyString)
f6bcfd97 196 {
9add9367 197 return Insert(0u, itemid, text, submenu, help);
f6bcfd97 198 }
717a57c2
VZ
199
200 // detach an item from the menu, but don't delete it so that it can be
201 // added back later (but if it's not, the caller is responsible for
202 // deleting it!)
d9e2e4c2 203 wxMenuItem *Remove(int itemid) { return Remove(FindChildItem(itemid)); }
717a57c2
VZ
204 wxMenuItem *Remove(wxMenuItem *item);
205
206 // delete an item from the menu (submenus are not destroyed by this
207 // function, see Destroy)
d9e2e4c2 208 bool Delete(int itemid) { return Delete(FindChildItem(itemid)); }
717a57c2
VZ
209 bool Delete(wxMenuItem *item);
210
211 // delete the item from menu and destroy it (if it's a submenu)
d9e2e4c2 212 bool Destroy(int itemid) { return Destroy(FindChildItem(itemid)); }
717a57c2
VZ
213 bool Destroy(wxMenuItem *item);
214
215 // menu items access
216 // -----------------
217
218 // get the items
219 size_t GetMenuItemCount() const { return m_items.GetCount(); }
220
221 const wxMenuItemList& GetMenuItems() const { return m_items; }
222 wxMenuItemList& GetMenuItems() { return m_items; }
223
224 // search
1e6feb95 225 virtual int FindItem(const wxString& item) const;
d9e2e4c2 226 wxMenuItem* FindItem(int itemid, wxMenu **menu = NULL) const;
717a57c2 227
bd582574
JS
228 // find by position
229 wxMenuItem* FindItemByPosition(size_t position) const;
230
717a57c2 231 // get/set items attributes
d9e2e4c2
DE
232 void Enable(int itemid, bool enable);
233 bool IsEnabled(int itemid) const;
3dfac970 234
d9e2e4c2
DE
235 void Check(int itemid, bool check);
236 bool IsChecked(int itemid) const;
717a57c2 237
d9e2e4c2
DE
238 void SetLabel(int itemid, const wxString& label);
239 wxString GetLabel(int itemid) const;
717a57c2 240
52af3158
JS
241 // Returns the stripped label
242 wxString GetLabelText(int itemid) const { return wxMenuItem::GetLabelText(GetLabel(itemid)); }
243
d9e2e4c2
DE
244 virtual void SetHelpString(int itemid, const wxString& helpString);
245 virtual wxString GetHelpString(int itemid) const;
717a57c2
VZ
246
247 // misc accessors
248 // --------------
249
250 // the title
251 virtual void SetTitle(const wxString& title) { m_title = title; }
56454c15 252 const wxString& GetTitle() const { return m_title; }
717a57c2 253
717a57c2
VZ
254 // event handler
255 void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
256 wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
257
e3f5caa2 258 // Invoking window: this is set by wxWindow::PopupMenu() before showing a
394cfde3
VZ
259 // popup menu and reset after it's hidden. Notice that you probably want to
260 // use GetWindow() below instead of GetInvokingWindow() as the latter only
261 // returns non-NULL for the top level menus
c59aa14a
VZ
262 //
263 // NB: avoid calling SetInvokingWindow() directly if possible, use
264 // wxMenuInvokingWindowSetter class below instead
e3f5caa2 265 void SetInvokingWindow(wxWindow *win);
394cfde3 266 wxWindow *GetInvokingWindow() const { return m_invokingWindow; }
717a57c2 267
7118e711
VZ
268 // the window associated with this menu: this is the invoking window for
269 // popup menus or the top level window to which the menu bar is attached
270 // for menus which are part of a menu bar
271 wxWindow *GetWindow() const;
272
717a57c2
VZ
273 // style
274 long GetStyle() const { return m_style; }
275
276 // implementation helpers
277 // ----------------------
278
279 // Updates the UI for a menu and all submenus recursively. source is the
280 // object that has the update event handlers defined for it. If NULL, the
281 // menu or associated window will be used.
d3b9f782 282 void UpdateUI(wxEvtHandler* source = NULL);
717a57c2 283
1e6feb95 284 // get the menu bar this menu is attached to (may be NULL, always NULL for
dbdf9a17
DE
285 // popup menus). Traverse up the menu hierarchy to find it.
286 wxMenuBar *GetMenuBar() const;
1e6feb95
VZ
287
288 // called when the menu is attached/detached to/from a menu bar
289 virtual void Attach(wxMenuBarBase *menubar);
290 virtual void Detach();
291
717a57c2 292 // is the menu attached to a menu bar (or is it a popup one)?
dbdf9a17 293 bool IsAttached() const { return GetMenuBar() != NULL; }
717a57c2
VZ
294
295 // set/get the parent of this menu
296 void SetParent(wxMenu *parent) { m_menuParent = parent; }
297 wxMenu *GetParent() const { return m_menuParent; }
298
d65c269b
VZ
299 // implementation only from now on
300 // -------------------------------
301
302 // unlike FindItem(), this function doesn't recurse but only looks through
303 // our direct children and also may return the index of the found child if
304 // pos != NULL
d9e2e4c2 305 wxMenuItem *FindChildItem(int itemid, size_t *pos = NULL) const;
d65c269b 306
4e32eea1
WS
307 // called to generate a wxCommandEvent, return true if it was processed,
308 // false otherwise
d65c269b
VZ
309 //
310 // the checked parameter may have boolean value or -1 for uncheckable items
d9e2e4c2 311 bool SendEvent(int itemid, int checked = -1);
d65c269b 312
717a57c2 313 // compatibility: these functions are deprecated, use the new ones instead
d65c269b
VZ
314 // -----------------------------------------------------------------------
315
316 // use the versions taking wxItem_XXX now instead, they're more readable
317 // and allow adding the radio items as well
d9e2e4c2 318 void Append(int itemid,
d65c269b
VZ
319 const wxString& text,
320 const wxString& help,
321 bool isCheckable)
322 {
d9e2e4c2 323 Append(itemid, text, help, isCheckable ? wxITEM_CHECK : wxITEM_NORMAL);
d65c269b
VZ
324 }
325
3786c8b5
VZ
326 // use more readable and not requiring unused itemid AppendSubMenu() instead
327 wxMenuItem* Append(int itemid,
328 const wxString& text,
329 wxMenu *submenu,
330 const wxString& help = wxEmptyString)
331 {
332 return DoAppend(wxMenuItem::New((wxMenu *)this, itemid, text, help,
333 wxITEM_NORMAL, submenu));
334 }
335
d65c269b 336 void Insert(size_t pos,
d9e2e4c2 337 int itemid,
d65c269b
VZ
338 const wxString& text,
339 const wxString& help,
340 bool isCheckable)
341 {
d9e2e4c2 342 Insert(pos, itemid, text, help, isCheckable ? wxITEM_CHECK : wxITEM_NORMAL);
d65c269b
VZ
343 }
344
d9e2e4c2 345 void Prepend(int itemid,
d65c269b
VZ
346 const wxString& text,
347 const wxString& help,
348 bool isCheckable)
349 {
d9e2e4c2 350 Insert(0u, itemid, text, help, isCheckable);
d65c269b
VZ
351 }
352
6d971354
RR
353 static void LockAccels(bool locked)
354 {
355 ms_locked = locked;
356 }
4e32eea1 357
717a57c2
VZ
358protected:
359 // virtuals to override in derived classes
360 // ---------------------------------------
361
9add9367
RD
362 virtual wxMenuItem* DoAppend(wxMenuItem *item);
363 virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
717a57c2
VZ
364
365 virtual wxMenuItem *DoRemove(wxMenuItem *item);
366 virtual bool DoDelete(wxMenuItem *item);
367 virtual bool DoDestroy(wxMenuItem *item);
368
369 // helpers
370 // -------
371
372 // common part of all ctors
373 void Init(long style);
374
1e6feb95
VZ
375 // associate the submenu with this menu
376 void AddSubMenu(wxMenu *submenu);
377
717a57c2
VZ
378 wxMenuBar *m_menuBar; // menubar we belong to or NULL
379 wxMenu *m_menuParent; // parent menu or NULL
380
381 wxString m_title; // the menu title or label
382 wxMenuItemList m_items; // the list of menu items
383
384 wxWindow *m_invokingWindow; // for popup menus
717a57c2
VZ
385
386 long m_style; // combination of wxMENU_XXX flags
387
388 wxEvtHandler *m_eventHandler; // a pluggable in event handler
22f3361e 389
6d971354 390 static bool ms_locked;
4e32eea1 391
c0c133e1 392 wxDECLARE_NO_COPY_CLASS(wxMenuBase);
717a57c2 393};
3dfac970 394
28953245
SC
395#if wxUSE_EXTENDED_RTTI
396
397// ----------------------------------------------------------------------------
398// XTI accessor
399// ----------------------------------------------------------------------------
400
54912101 401class WXDLLEXPORT wxMenuInfoHelper : public wxObject
28953245
SC
402{
403public:
54912101
SC
404 wxMenuInfoHelper() { m_menu = NULL; }
405 virtual ~wxMenuInfoHelper() { }
28953245
SC
406
407 bool Create( wxMenu *menu, const wxString &title )
408 {
409 m_menu = menu;
410 m_title = title;
411 return true;
412 }
413
414 wxMenu* GetMenu() const { return m_menu; }
415 wxString GetTitle() const { return m_title; }
416
417private:
418 wxMenu *m_menu;
419 wxString m_title;
420
54912101 421 DECLARE_DYNAMIC_CLASS(wxMenuInfoHelper)
28953245
SC
422};
423
54912101 424WX_DECLARE_EXPORTED_LIST(wxMenuInfoHelper, wxMenuInfoHelperList );
28953245
SC
425
426#endif
427
3dfac970
VZ
428// ----------------------------------------------------------------------------
429// wxMenuBar
430// ----------------------------------------------------------------------------
431
53a2db12 432class WXDLLIMPEXP_CORE wxMenuBarBase : public wxWindow
3dfac970
VZ
433{
434public:
435 // default ctor
436 wxMenuBarBase();
437
438 // dtor will delete all menus we own
439 virtual ~wxMenuBarBase();
440
441 // menu bar construction
442 // ---------------------
443
4e32eea1 444 // append a menu to the end of menubar, return true if ok
3dfac970
VZ
445 virtual bool Append(wxMenu *menu, const wxString& title);
446
4e32eea1 447 // insert a menu before the given position into the menubar, return true
3dfac970
VZ
448 // if inserted ok
449 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
450
451 // menu bar items access
452 // ---------------------
453
454 // get the number of menus in the menu bar
455 size_t GetMenuCount() const { return m_menus.GetCount(); }
456
457 // get the menu at given position
458 wxMenu *GetMenu(size_t pos) const;
459
460 // replace the menu at given position with another one, returns the
461 // previous menu (which should be deleted by the caller)
462 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
463
464 // delete the menu at given position from the menu bar, return the pointer
465 // to the menu (which should be deleted by the caller)
466 virtual wxMenu *Remove(size_t pos);
467
468 // enable or disable a submenu
469 virtual void EnableTop(size_t pos, bool enable) = 0;
470
1e6feb95 471 // is the menu enabled?
4e32eea1 472 virtual bool IsEnabledTop(size_t WXUNUSED(pos)) const { return true; }
1e6feb95 473
3dfac970 474 // get or change the label of the menu at given position
52af3158
JS
475 virtual void SetMenuLabel(size_t pos, const wxString& label) = 0;
476 virtual wxString GetMenuLabel(size_t pos) const = 0;
477
478 // get the stripped label of the menu at given position
479 virtual wxString GetMenuLabelText(size_t pos) const { return wxMenuItem::GetLabelText(GetMenuLabel(pos)); }
3dfac970
VZ
480
481 // item search
482 // -----------
483
484 // by menu and item names, returns wxNOT_FOUND if not found or id of the
485 // found item
1e6feb95 486 virtual int FindMenuItem(const wxString& menu, const wxString& item) const;
3dfac970
VZ
487
488 // find item by id (in any menu), returns NULL if not found
489 //
490 // if menu is !NULL, it will be filled with wxMenu this item belongs to
d9e2e4c2 491 virtual wxMenuItem* FindItem(int itemid, wxMenu **menu = NULL) const;
3dfac970 492
52130557 493 // find menu by its caption, return wxNOT_FOUND on failure
270e8b6a 494 int FindMenu(const wxString& title) const;
52130557 495
3dfac970
VZ
496 // item access
497 // -----------
498
499 // all these functions just use FindItem() and then call an appropriate
500 // method on it
501 //
502 // NB: under MSW, these methods can only be used after the menubar had
503 // been attached to the frame
504
d9e2e4c2
DE
505 void Enable(int itemid, bool enable);
506 void Check(int itemid, bool check);
507 bool IsChecked(int itemid) const;
508 bool IsEnabled(int itemid) const;
b1c741f8 509 virtual bool IsEnabled() const { return wxWindow::IsEnabled(); }
3dfac970 510
d9e2e4c2
DE
511 void SetLabel(int itemid, const wxString &label);
512 wxString GetLabel(int itemid) const;
3dfac970 513
d9e2e4c2
DE
514 void SetHelpString(int itemid, const wxString& helpString);
515 wxString GetHelpString(int itemid) const;
3dfac970 516
1e6feb95
VZ
517 // implementation helpers
518
519 // get the frame we are attached to (may return NULL)
520 wxFrame *GetFrame() const { return m_menuBarFrame; }
521
4e32eea1 522 // returns true if we're attached to a frame
1e6feb95
VZ
523 bool IsAttached() const { return GetFrame() != NULL; }
524
525 // associate the menubar with the frame
526 virtual void Attach(wxFrame *frame);
527
528 // called before deleting the menubar normally
529 virtual void Detach();
530
9874b4ee 531 // need to override these ones to avoid virtual function hiding
4e32eea1 532 virtual bool Enable(bool enable = true) { return wxWindow::Enable(enable); }
9874b4ee 533 virtual void SetLabel(const wxString& s) { wxWindow::SetLabel(s); }
3dfac970
VZ
534 virtual wxString GetLabel() const { return wxWindow::GetLabel(); }
535
1e6feb95 536 // don't want menu bars to accept the focus by tabbing to them
4e32eea1 537 virtual bool AcceptsFocusFromKeyboard() const { return false; }
1e6feb95 538
4d538595
DS
539 // update all menu item states in all menus
540 virtual void UpdateMenus();
541
c04c7a3d
VS
542 virtual bool CanBeOutsideClientArea() const { return true; }
543
28953245
SC
544#if wxUSE_EXTENDED_RTTI
545 // XTI helpers:
54912101 546 bool AppendMenuInfo( const wxMenuInfoHelper *info )
28953245 547 { return Append( info->GetMenu(), info->GetTitle() ); }
54912101 548 const wxMenuInfoHelperList& GetMenuInfos() const;
28953245
SC
549#endif
550
52af3158
JS
551#if WXWIN_COMPATIBILITY_2_8
552 // get or change the label of the menu at given position
0253bbba 553 // Deprecated in favour of SetMenuLabel
03647350 554 wxDEPRECATED( void SetLabelTop(size_t pos, const wxString& label) );
0253bbba 555 // Deprecated in favour of GetMenuLabelText
52af3158
JS
556 wxDEPRECATED( wxString GetLabelTop(size_t pos) const );
557#endif
558
3dfac970
VZ
559protected:
560 // the list of all our menus
561 wxMenuList m_menus;
1e6feb95 562
28953245
SC
563#if wxUSE_EXTENDED_RTTI
564 // used by XTI
54912101 565 wxMenuInfoHelperList m_menuInfos;
28953245
SC
566#endif
567
1e6feb95
VZ
568 // the frame we are attached to (may be NULL)
569 wxFrame *m_menuBarFrame;
22f3361e 570
c0c133e1 571 wxDECLARE_NO_COPY_CLASS(wxMenuBarBase);
3dfac970
VZ
572};
573
574// ----------------------------------------------------------------------------
575// include the real class declaration
576// ----------------------------------------------------------------------------
577
578#ifdef wxUSE_BASE_CLASSES_ONLY
579 #define wxMenuItem wxMenuItemBase
580#else // !wxUSE_BASE_CLASSES_ONLY
1e6feb95
VZ
581#if defined(__WXUNIVERSAL__)
582 #include "wx/univ/menu.h"
583#elif defined(__WXMSW__)
3dfac970 584 #include "wx/msw/menu.h"
2049ba38 585#elif defined(__WXMOTIF__)
3dfac970 586 #include "wx/motif/menu.h"
1be7a35c 587#elif defined(__WXGTK20__)
3dfac970 588 #include "wx/gtk/menu.h"
1be7a35c
MR
589#elif defined(__WXGTK__)
590 #include "wx/gtk1/menu.h"
34138703 591#elif defined(__WXMAC__)
ef0e9220 592 #include "wx/osx/menu.h"
e64df9bc
DE
593#elif defined(__WXCOCOA__)
594 #include "wx/cocoa/menu.h"
1777b9bb 595#elif defined(__WXPM__)
3dfac970 596 #include "wx/os2/menu.h"
c801d85f 597#endif
3dfac970
VZ
598#endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
599
c59aa14a
VZ
600// ----------------------------------------------------------------------------
601// Helper class used in the implementation only: sets the invoking window of
602// the given menu in its ctor and resets it in dtor.
603// ----------------------------------------------------------------------------
604
605class wxMenuInvokingWindowSetter
606{
607public:
608 // Ctor sets the invoking window for the given menu.
609 //
610 // The menu lifetime must be greater than that of this class.
611 wxMenuInvokingWindowSetter(wxMenu& menu, wxWindow *win)
612 : m_menu(menu)
613 {
614 menu.SetInvokingWindow(win);
615 }
616
617 // Dtor resets the invoking window.
618 ~wxMenuInvokingWindowSetter()
619 {
620 m_menu.SetInvokingWindow(NULL);
621 }
622
623private:
624 wxMenu& m_menu;
625
626 wxDECLARE_NO_COPY_CLASS(wxMenuInvokingWindowSetter);
627};
628
1e6feb95
VZ
629#endif // wxUSE_MENUS
630
c59aa14a 631#endif // _WX_MENU_H_BASE_