1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
21 // an exception to the general rule that a normal header doesn't include other
22 // headers - only because ownerdrw.h is not always included and I don't want
23 // to write #ifdef's everywhere...
25 #include "wx/ownerdrw.h"
28 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 // id for a separator line in the menu (invalid for normal item)
33 #define ID_SEPARATOR (-1)
35 // ----------------------------------------------------------------------------
36 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
37 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxMenuItem
: public wxObject
43 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
47 wxMenuItem(wxMenu
*pParentMenu
= NULL
, int id
= ID_SEPARATOR
,
48 const wxTString
& strName
= "", const wxTString
& wxHelp
= "",
49 bool bCheckable
= FALSE
, wxMenu
*pSubMenu
= NULL
);
50 virtual ~wxMenuItem();
52 // accessors (some more are inherited from wxOwnerDrawn or are below)
53 bool IsSeparator() const { return m_idItem
== ID_SEPARATOR
; }
54 bool IsEnabled() const { return m_bEnabled
; }
55 bool IsChecked() const { return m_bChecked
; }
57 int GetId() const { return m_idItem
; }
58 const wxString
& GetHelp() const { return m_strHelp
; }
59 wxMenu
*GetSubMenu() const { return m_pSubMenu
; }
62 void SetName(const wxString
& strName
) { m_strName
= strName
; }
63 void SetHelp(const wxString
& strHelp
) { m_strHelp
= strHelp
; }
65 void Enable(bool bDoEnable
= TRUE
);
66 void Check(bool bDoCheck
= TRUE
);
71 int m_idItem
; // numeric id of the item
72 wxString m_strHelp
; // associated help string
73 wxMenu
*m_pSubMenu
, // may be NULL
74 *m_pParentMenu
; // menu this item is contained in
75 bool m_bEnabled
, // enabled or greyed?
76 m_bChecked
; // checked? (only if checkable)
79 // wxOwnerDrawn base class already has these variables - nothing to do
82 bool m_bCheckable
; // can be checked?
83 wxString m_strName
; // name or label of the item
86 const wxString
& GetName() const { return m_strName
; }
87 bool IsCheckable() const { return m_bCheckable
; }