]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/menuitem.h
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 ///////////////////////////////////////////////////////////////////////////////
16 #pragma interface "menuitem.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
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...
29 #include "wx/ownerdrw.h"
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 // id for a separator line in the menu (invalid for normal item)
37 #define ID_SEPARATOR (-1)
39 // ----------------------------------------------------------------------------
40 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
41 // ----------------------------------------------------------------------------
42 class WXDLLEXPORT wxMenuItem
: public wxObject
47 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
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();
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
; }
61 int GetId() const { return m_idItem
; }
62 const wxString
& GetHelp() const { return m_strHelp
; }
63 wxMenu
*GetSubMenu() const { return m_pSubMenu
; }
66 void SetName(const wxString
& strName
) { m_strName
= strName
; }
67 void SetHelp(const wxString
& strHelp
) { m_strHelp
= strHelp
; }
69 void Enable(bool bDoEnable
= TRUE
);
70 void Check(bool bDoCheck
= TRUE
);
76 // These two should probably exist for all ports
77 void SetLabel(const wxString
& label
);
78 wxString
GetLabel() const { return m_strName
; }
79 void CreateItem (WXWidget menu
, wxMenuBar
* menuBar
, wxMenu
* topMenu
);
80 void DestroyItem(bool full
);
82 inline WXWidget
GetButtonWidget() const { return m_buttonWidget
; }
83 inline void SetChecked(bool check
) { m_bChecked
= check
; }
84 inline wxMenuBar
* GetMenuBar() const { return m_menuBar
; }
85 inline void SetMenuBar(wxMenuBar
* menuBar
) { m_menuBar
= menuBar
; }
86 inline wxMenu
* GetTopMenu() const { return m_topMenu
; }
87 inline void SetTopMenu(wxMenu
* menu
) { m_topMenu
= menu
; }
90 int m_idItem
; // numeric id of the item
91 wxString m_strHelp
; // associated help string
92 wxMenu
*m_pSubMenu
, // may be NULL
93 *m_pParentMenu
; // menu this item is contained in
94 bool m_bEnabled
, // enabled or greyed?
95 m_bChecked
; // checked? (only if checkable)
98 WXWidget m_buttonWidget
;
100 wxMenu
* m_topMenu
; // Top-level menu e.g. popup-menu
102 #if wxUSE_OWNER_DRAWN
103 // wxOwnerDrawn base class already has these variables - nothing to do
106 bool m_bCheckable
; // can be checked?
107 wxString m_strName
; // name or label of the item
110 const wxString
& GetName() const { return m_strName
; }
111 bool IsCheckable() const { return m_bCheckable
; }