]>
Commit | Line | Data |
---|---|---|
23d1d521 JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: menuitem.h | |
3 | // Purpose: wxMenuItem class | |
4 | // Author: Vadim Zeitlin | |
c626a8b7 | 5 | // Modified by: |
23d1d521 JS |
6 | // Created: 11.11.97 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows license | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _MENUITEM_H | |
13 | #define _MENUITEM_H | |
14 | ||
15 | #ifdef __GNUG__ | |
c626a8b7 | 16 | #pragma interface "menuitem.h" |
23d1d521 JS |
17 | #endif |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // headers | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #include "wx/setup.h" | |
24 | ||
25 | // an exception to the general rule that a normal header doesn't include other | |
26 | // headers - only because ownerdrw.h is not always included and I don't want | |
27 | // to write #ifdef's everywhere... | |
47d67540 | 28 | #if wxUSE_OWNER_DRAWN |
c626a8b7 | 29 | #include "wx/ownerdrw.h" |
23d1d521 JS |
30 | #endif |
31 | ||
32 | // ---------------------------------------------------------------------------- | |
33 | // constants | |
34 | // ---------------------------------------------------------------------------- | |
35 | ||
36 | // id for a separator line in the menu (invalid for normal item) | |
37 | #define ID_SEPARATOR (-1) | |
38 | ||
39 | // ---------------------------------------------------------------------------- | |
40 | // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour | |
41 | // ---------------------------------------------------------------------------- | |
42 | class WXDLLEXPORT wxMenuItem: public wxObject | |
47d67540 | 43 | #if wxUSE_OWNER_DRAWN |
23d1d521 JS |
44 | , public wxOwnerDrawn |
45 | #endif | |
46 | { | |
47 | DECLARE_DYNAMIC_CLASS(wxMenuItem) | |
48 | ||
49 | public: | |
50 | // ctor & dtor | |
51 | wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR, | |
52 | const wxString& strName = "", const wxString& wxHelp = "", | |
53 | bool bCheckable = FALSE, wxMenu *pSubMenu = NULL); | |
54 | virtual ~wxMenuItem(); | |
55 | ||
56 | // accessors (some more are inherited from wxOwnerDrawn or are below) | |
57 | bool IsSeparator() const { return m_idItem == ID_SEPARATOR; } | |
58 | bool IsEnabled() const { return m_bEnabled; } | |
59 | bool IsChecked() const { return m_bChecked; } | |
60 | ||
61 | int GetId() const { return m_idItem; } | |
62 | const wxString& GetHelp() const { return m_strHelp; } | |
63 | wxMenu *GetSubMenu() const { return m_pSubMenu; } | |
64 | ||
65 | // operations | |
66 | void SetName(const wxString& strName) { m_strName = strName; } | |
67 | void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; } | |
68 | ||
69 | void Enable(bool bDoEnable = TRUE); | |
70 | void Check(bool bDoCheck = TRUE); | |
71 | ||
72 | void DeleteSubMenu(); | |
73 | ||
74 | private: | |
75 | int m_idItem; // numeric id of the item | |
76 | wxString m_strHelp; // associated help string | |
77 | wxMenu *m_pSubMenu, // may be NULL | |
78 | *m_pParentMenu; // menu this item is contained in | |
79 | bool m_bEnabled, // enabled or greyed? | |
80 | m_bChecked; // checked? (only if checkable) | |
81 | ||
47d67540 | 82 | #if wxUSE_OWNER_DRAWN |
23d1d521 JS |
83 | // wxOwnerDrawn base class already has these variables - nothing to do |
84 | ||
85 | #else //!owner drawn | |
86 | bool m_bCheckable; // can be checked? | |
87 | wxString m_strName; // name or label of the item | |
88 | ||
89 | public: | |
90 | const wxString& GetName() const { return m_strName; } | |
91 | bool IsCheckable() const { return m_bCheckable; } | |
92 | #endif //owner drawn | |
93 | }; | |
94 | ||
95 | #endif //_MENUITEM_H |