]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/menuitem.h
Implement wxNotificationMessage using libnotify in wxGTK.
[wxWidgets.git] / include / wx / os2 / menuitem.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/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 licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _MENUITEM_H
13 #define _MENUITEM_H
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 #include "wx/defs.h"
20 #include "wx/os2/private.h" // for MENUITEM
21
22 // an exception to the general rule that a normal header doesn't include other
23 // headers - only because ownerdrw.h is not always included and I don't want
24 // to write #ifdef's everywhere...
25 #if wxUSE_OWNER_DRAWN
26 #include "wx/ownerdrw.h"
27 #include "wx/bitmap.h"
28 #endif
29
30 // ----------------------------------------------------------------------------
31 // constants
32 // ----------------------------------------------------------------------------
33
34 // ----------------------------------------------------------------------------
35 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
36 // ----------------------------------------------------------------------------
37 class WXDLLIMPEXP_CORE wxMenuItem: public wxMenuItemBase
38 #if wxUSE_OWNER_DRAWN
39 , public wxOwnerDrawn
40 #endif
41 {
42 public:
43 //
44 // ctor & dtor
45 //
46 wxMenuItem( wxMenu* pParentMenu = NULL
47 ,int nId = wxID_SEPARATOR
48 ,const wxString& rStrName = wxEmptyString
49 ,const wxString& rWxHelp = wxEmptyString
50 ,wxItemKind eKind = wxITEM_NORMAL
51 ,wxMenu* pSubMenu = NULL
52 );
53
54 //
55 // Depricated, do not use in new code
56 //
57 wxMenuItem( wxMenu* pParentMenu
58 ,int vId
59 ,const wxString& rsText
60 ,const wxString& rsHelp
61 ,bool bIsCheckable
62 ,wxMenu* pSubMenu = NULL
63 );
64 virtual ~wxMenuItem();
65
66 //
67 // Override base class virtuals
68 //
69 virtual void SetItemLabel(const wxString& rStrName);
70
71 virtual void Enable(bool bDoEnable = true);
72 virtual void Check(bool bDoCheck = true);
73 virtual bool IsChecked(void) const;
74
75 //
76 // Unfortunately needed to resolve ambiguity between
77 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
78 //
79 bool IsCheckable(void) const { return wxMenuItemBase::IsCheckable(); }
80
81 //
82 // The id for a popup menu is really its menu handle (as required by
83 // ::AppendMenu() API), so this function will return either the id or the
84 // menu handle depending on what we're
85 //
86 int GetRealId(void) const;
87
88 //
89 // Mark item as belonging to the given radio group
90 //
91 void SetAsRadioGroupStart(void);
92 void SetRadioGroupStart(int nStart);
93 void SetRadioGroupEnd(int nEnd);
94
95 //
96 // All OS/2PM Submenus and menus have one of these
97 //
98 MENUITEM m_vMenuData;
99
100 #if wxUSE_OWNER_DRAWN
101
102 void SetBitmaps(const wxBitmap& bmpChecked,
103 const wxBitmap& bmpUnchecked = wxNullBitmap)
104 {
105 m_bmpChecked = bmpChecked;
106 m_bmpUnchecked = bmpUnchecked;
107 SetOwnerDrawn(true);
108 }
109
110 void SetBitmap(const wxBitmap& bmp, bool bChecked = true)
111 {
112 if ( bChecked )
113 m_bmpChecked = bmp;
114 else
115 m_bmpUnchecked = bmp;
116 SetOwnerDrawn(true);
117 }
118
119 void SetDisabledBitmap(const wxBitmap& bmpDisabled)
120 {
121 m_bmpDisabled = bmpDisabled;
122 SetOwnerDrawn(true);
123 }
124
125 const wxBitmap& GetBitmap(bool bChecked = true) const
126 { return (bChecked ? m_bmpChecked : m_bmpUnchecked); }
127
128 const wxBitmap& GetDisabledBitmap() const
129 { return m_bmpDisabled; }
130
131
132 // override wxOwnerDrawn base class virtuals
133 virtual wxString GetName() const;
134 virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight);
135 virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat);
136
137 protected:
138 virtual void GetFontToUse(wxFont& font) const;
139
140 #endif // wxUSE_OWNER_DRAWN
141
142 private:
143 void Init();
144
145 //
146 // The positions of the first and last items of the radio group this item
147 // belongs to or -1: start is the radio group start and is valid for all
148 // but first radio group items (m_isRadioGroupStart == FALSE), end is valid
149 // only for the first one
150 //
151 union
152 {
153 int m_nStart;
154 int m_nEnd;
155 } m_vRadioGroup;
156
157 //
158 // Does this item start a radio group?
159 //
160 bool m_bIsRadioGroupStart;
161
162 #if wxUSE_OWNER_DRAWN
163 // item bitmaps
164 wxBitmap m_bmpChecked, // bitmap to put near the item
165 m_bmpUnchecked, // (checked is used also for 'uncheckable' items)
166 m_bmpDisabled;
167 #endif // wxUSE_OWNER_DRAWN
168
169 DECLARE_DYNAMIC_CLASS(wxMenuItem)
170 }; // end of CLASS wxMenuItem
171
172 #endif //_MENUITEM_H