]> git.saurik.com Git - wxWidgets.git/blob - include/wx/menuitem.h
Bool replaced by bool (I hope I got it right this time!)
[wxWidgets.git] / include / wx / menuitem.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
5 // Modified by:
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 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // an exception to the general rule that a normal header doesn't include other
20 // headers - only because ownerdrw.h is not always included and I don't want
21 // to write #ifdef's everywhere...
22 #if USE_OWNER_DRAWN
23 #include "wx/ownerdrw.h"
24 #endif
25
26 // ----------------------------------------------------------------------------
27 // constants
28 // ----------------------------------------------------------------------------
29
30 // id for a separator line in the menu (invalid for normal item)
31 #define ID_SEPARATOR (-1)
32
33 // ----------------------------------------------------------------------------
34 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
35 // ----------------------------------------------------------------------------
36 class WXDLLEXPORT wxMenuItem: public wxObject
37 #if USE_OWNER_DRAWN
38 , public wxOwnerDrawn
39 #endif
40 {
41 DECLARE_DYNAMIC_CLASS(wxMenuItem)
42
43 public:
44 // ctor & dtor
45 wxMenuItem(wxMenu *pParentMenu = NULL, int id = ID_SEPARATOR,
46 const wxTString& strName = "", const wxTString& wxHelp = "",
47 bool bCheckable = FALSE, wxMenu *pSubMenu = NULL);
48 virtual ~wxMenuItem();
49
50 // accessors (some more are inherited from wxOwnerDrawn or are below)
51 bool IsSeparator() const { return m_idItem == ID_SEPARATOR; }
52 bool IsEnabled() const { return m_bEnabled; }
53 bool IsChecked() const { return m_bChecked; }
54
55 int GetId() const { return m_idItem; }
56 const wxString& GetHelp() const { return m_strHelp; }
57 wxMenu *GetSubMenu() const { return m_pSubMenu; }
58
59 // operations
60 void SetName(const wxString& strName) { m_strName = strName; }
61 void SetHelp(const wxString& strHelp) { m_strHelp = strHelp; }
62
63 void Enable(bool bDoEnable = TRUE);
64 void Check(bool bDoCheck = TRUE);
65
66 void DeleteSubMenu();
67
68 private:
69 int m_idItem; // numeric id of the item
70 wxString m_strHelp; // associated help string
71 wxMenu *m_pSubMenu, // may be NULL
72 *m_pParentMenu; // menu this item is contained in
73 bool m_bEnabled, // enabled or greyed?
74 m_bChecked; // checked? (only if checkable)
75
76 #if USE_OWNER_DRAWN
77 // wxOwnerDrawn base class already has these variables - nothing to do
78
79 #else //!owner drawn
80 bool m_bCheckable; // can be checked?
81 wxString m_strName; // name or label of the item
82
83 public:
84 const wxString& GetName() const { return m_strName; }
85 bool IsCheckable() const { return m_bCheckable; }
86 #endif //owner drawn
87 };
88
89 #endif //_MENUITEM_H