1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
19 #include "wx/os2/private.h" // for MENUITEM
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"
26 #include "wx/bitmap.h"
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
34 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
35 // ----------------------------------------------------------------------------
36 class WXDLLIMPEXP_CORE wxMenuItem
: public wxMenuItemBase
45 wxMenuItem( wxMenu
* pParentMenu
= NULL
46 ,int nId
= wxID_SEPARATOR
47 ,const wxString
& rStrName
= wxEmptyString
48 ,const wxString
& rWxHelp
= wxEmptyString
49 ,wxItemKind eKind
= wxITEM_NORMAL
50 ,wxMenu
* pSubMenu
= NULL
54 // Depricated, do not use in new code
56 wxMenuItem( wxMenu
* pParentMenu
58 ,const wxString
& rsText
59 ,const wxString
& rsHelp
61 ,wxMenu
* pSubMenu
= NULL
63 virtual ~wxMenuItem();
66 // Override base class virtuals
68 virtual void SetItemLabel(const wxString
& rStrName
);
70 virtual void Enable(bool bDoEnable
= true);
71 virtual void Check(bool bDoCheck
= true);
72 virtual bool IsChecked(void) const;
75 // Unfortunately needed to resolve ambiguity between
76 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
78 bool IsCheckable(void) const { return wxMenuItemBase::IsCheckable(); }
81 // The id for a popup menu is really its menu handle (as required by
82 // ::AppendMenu() API), so this function will return either the id or the
83 // menu handle depending on what we're
85 int GetRealId(void) const;
88 // Mark item as belonging to the given radio group
90 void SetAsRadioGroupStart(void);
91 void SetRadioGroupStart(int nStart
);
92 void SetRadioGroupEnd(int nEnd
);
95 // All OS/2PM Submenus and menus have one of these
101 void SetBitmaps(const wxBitmap
& bmpChecked
,
102 const wxBitmap
& bmpUnchecked
= wxNullBitmap
)
104 m_bmpChecked
= bmpChecked
;
105 m_bmpUnchecked
= bmpUnchecked
;
109 void SetBitmap(const wxBitmap
& bmp
, bool bChecked
= true)
114 m_bmpUnchecked
= bmp
;
118 void SetDisabledBitmap(const wxBitmap
& bmpDisabled
)
120 m_bmpDisabled
= bmpDisabled
;
124 const wxBitmap
& GetBitmap(bool bChecked
= true) const
125 { return (bChecked
? m_bmpChecked
: m_bmpUnchecked
); }
127 const wxBitmap
& GetDisabledBitmap() const
128 { return m_bmpDisabled
; }
131 // override wxOwnerDrawn base class virtuals
132 virtual wxString
GetName() const;
133 virtual bool OnMeasureItem(size_t *pwidth
, size_t *pheight
);
134 virtual bool OnDrawItem(wxDC
& dc
, const wxRect
& rc
, wxODAction act
, wxODStatus stat
);
137 virtual void GetFontToUse(wxFont
& font
) const;
139 #endif // wxUSE_OWNER_DRAWN
145 // The positions of the first and last items of the radio group this item
146 // belongs to or -1: start is the radio group start and is valid for all
147 // but first radio group items (m_isRadioGroupStart == FALSE), end is valid
148 // only for the first one
157 // Does this item start a radio group?
159 bool m_bIsRadioGroupStart
;
161 #if wxUSE_OWNER_DRAWN
163 wxBitmap m_bmpChecked
, // bitmap to put near the item
164 m_bmpUnchecked
, // (checked is used also for 'uncheckable' items)
166 #endif // wxUSE_OWNER_DRAWN
168 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
169 }; // end of CLASS wxMenuItem