1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MENUITEM_H_BASE_
13 #define _WX_MENUITEM_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h" // base class
21 // ----------------------------------------------------------------------------
23 // ----------------------------------------------------------------------------
25 // id for a separator line in the menu (invalid for normal item)
26 #define wxID_SEPARATOR (-1)
28 #ifndef ID_SEPARATOR // for compatibility only, don't use in new code
29 #define ID_SEPARATOR wxID_SEPARATOR
32 // ----------------------------------------------------------------------------
33 // forward declarations
34 // ----------------------------------------------------------------------------
36 class WXDLLEXPORT wxMenuItem
;
37 class WXDLLEXPORT wxMenu
;
39 // ----------------------------------------------------------------------------
40 // wxMenuItem is an item in the menu which may be either a normal item, a sub
41 // menu or a separator
42 // ----------------------------------------------------------------------------
44 class WXDLLEXPORT wxMenuItemBase
: public wxObject
48 static wxMenuItem
*New(wxMenu
*parentMenu
= (wxMenu
*)NULL
,
49 int id
= wxID_SEPARATOR
,
50 const wxString
& text
= wxEmptyString
,
51 const wxString
& help
= wxEmptyString
,
52 bool isCheckable
= FALSE
,
53 wxMenu
*subMenu
= (wxMenu
*)NULL
);
56 wxMenu
*GetMenu() const { return m_parentMenu
; }
59 void SetId(int id
) { m_id
= id
; }
60 int GetId() const { return m_id
; }
61 bool IsSeparator() const { return m_id
== wxID_SEPARATOR
; }
63 // the item's text (or name, or label...)
64 virtual void SetText(const wxString
& str
) { m_text
= str
; }
65 const wxString
& GetText() const { return m_text
; }
67 // what kind of menu item we are
68 virtual void SetCheckable(bool checkable
) { m_isCheckable
= checkable
; }
69 bool IsCheckable() const { return m_isCheckable
; }
71 bool IsSubMenu() const { return m_subMenu
!= NULL
; }
72 void SetSubMenu(wxMenu
*menu
) { m_subMenu
= menu
; }
73 wxMenu
*GetSubMenu() const { return m_subMenu
; }
76 virtual void Enable(bool enable
= TRUE
) { m_isEnabled
= enable
; }
77 virtual bool IsEnabled() const { return m_isEnabled
; }
78 virtual void Check(bool check
= TRUE
) { m_isChecked
= check
; }
79 virtual bool IsChecked() const { return m_isChecked
; }
81 // help string (displayed in the status bar by default)
82 void SetHelp(const wxString
& str
) { m_help
= str
; }
83 const wxString
& GetHelp() const { return m_help
; }
85 // compatibility only, use new functions in the new code
86 void SetName(const wxString
& str
) { SetText(str
); }
87 const wxString
& GetName() const { return GetText(); }
90 int m_id
; // numeric id of the item >= 0 or -1
91 wxMenu
*m_parentMenu
, // the menu we belong to
92 *m_subMenu
; // our sub menu or NULL
93 wxString m_text
, // label of the item
94 m_help
; // the help string for the item
95 bool m_isCheckable
; // can be checked?
96 bool m_isChecked
; // is checked?
97 bool m_isEnabled
; // is enabled?
100 // ----------------------------------------------------------------------------
101 // include the real class declaration
102 // ----------------------------------------------------------------------------
104 #ifdef wxUSE_BASE_CLASSES_ONLY
105 #define wxMenuItem wxMenuItemBase
106 #else // !wxUSE_BASE_CLASSES_ONLY
107 #if defined(__WXMSW__)
108 #include "wx/msw/menuitem.h"
109 #elif defined(__WXMOTIF__)
110 #include "wx/motif/menuitem.h"
111 #elif defined(__WXGTK__)
112 #include "wx/gtk/menuitem.h"
113 #elif defined(__WXQT__)
114 #include "wx/qt/menuitem.h"
115 #elif defined(__WXMAC__)
116 #include "wx/mac/menuitem.h"
117 #elif defined(__WXPM__)
118 #include "wx/os2/menuitem.h"
119 #elif defined(__WXSTUBS__)
120 #include "wx/stubs/menuitem.h"
122 #endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
125 // _WX_MENUITEM_H_BASE_