1. small dnd compilation fixes (no attempt to make icon setting work though)
[wxWidgets.git] / include / wx / menuitem.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 25.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MENUITEM_H_BASE_
13 #define _WX_MENUITEM_H_BASE_
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/object.h" // base class
20
21 // ----------------------------------------------------------------------------
22 // constants
23 // ----------------------------------------------------------------------------
24
25 // id for a separator line in the menu (invalid for normal item)
26 #define wxID_SEPARATOR (-1)
27
28 #ifndef ID_SEPARATOR // for compatibility only, don't use in new code
29 #define ID_SEPARATOR wxID_SEPARATOR
30 #endif
31
32 // ----------------------------------------------------------------------------
33 // forward declarations
34 // ----------------------------------------------------------------------------
35
36 class WXDLLEXPORT wxMenuItem;
37 class WXDLLEXPORT wxMenu;
38
39 // ----------------------------------------------------------------------------
40 // wxMenuItem is an item in the menu which may be either a normal item, a sub
41 // menu or a separator
42 // ----------------------------------------------------------------------------
43
44 class WXDLLEXPORT wxMenuItemBase : public wxObject
45 {
46 public:
47 // creation
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);
54
55 // get/set id
56 void SetId(int id) { m_id = id; }
57 int GetId() const { return m_id; }
58 bool IsSeparator() const { return m_id == wxID_SEPARATOR; }
59
60 // the item's text (or name, or label...)
61 virtual void SetText(const wxString& str) { m_text = str; }
62 const wxString& GetText() const { return m_text; }
63
64 // what kind of menu item we are
65 virtual void SetCheckable(bool checkable) { m_isCheckable = checkable; }
66 bool IsCheckable() const { return m_isCheckable; }
67
68 bool IsSubMenu() const { return m_subMenu != NULL; }
69 void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
70 wxMenu *GetSubMenu() const { return m_subMenu; }
71
72 // state
73 virtual void Enable(bool enable = TRUE) { m_isEnabled = enable; }
74 virtual bool IsEnabled() const { return m_isEnabled; }
75 virtual void Check(bool check = TRUE) { m_isChecked = check; }
76 virtual bool IsChecked() const { return m_isChecked; }
77
78 // help string (displayed in the status bar by default)
79 void SetHelp(const wxString& str) { m_help = str; }
80 const wxString& GetHelp() const { return m_help; }
81
82 // compatibility only, use new functions in the new code
83 void SetName(const wxString& str) { SetText(str); }
84 const wxString& GetName() const { return GetText(); }
85
86 protected:
87 int m_id; // numeric id of the item >= 0 or -1
88 wxMenu *m_parentMenu, // the menu we belong to
89 *m_subMenu; // our sub menu or NULL
90 wxString m_text, // label of the item
91 m_help; // the help string for the item
92 bool m_isCheckable; // can be checked?
93 bool m_isChecked; // is checked?
94 bool m_isEnabled; // is enabled?
95 };
96
97 // ----------------------------------------------------------------------------
98 // include the real class declaration
99 // ----------------------------------------------------------------------------
100
101 #ifdef wxUSE_BASE_CLASSES_ONLY
102 #define wxMenuItem wxMenuItemBase
103 #else // !wxUSE_BASE_CLASSES_ONLY
104 #if defined(__WXMSW__)
105 #include "wx/msw/menuitem.h"
106 #elif defined(__WXMOTIF__)
107 #include "wx/motif/menuitem.h"
108 #elif defined(__WXGTK__)
109 #include "wx/gtk/menuitem.h"
110 #elif defined(__WXQT__)
111 #include "wx/qt/menuitem.h"
112 #elif defined(__WXMAC__)
113 #include "wx/mac/menuitem.h"
114 #elif defined(__WXPM__)
115 #include "wx/os2/menuitem.h"
116 #elif defined(__WXSTUBS__)
117 #include "wx/stubs/menuitem.h"
118 #endif
119 #endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
120
121 #endif
122 // _WX_MENUITEM_H_BASE_