1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/menuitem.h
3 // Purpose: wxMenuItem class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #include "wx/os2/private.h" // for MENUITEM
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...
26 #include "wx/ownerdrw.h"
27 #include "wx/bitmap.h"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
35 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
36 // ----------------------------------------------------------------------------
37 class WXDLLIMPEXP_CORE wxMenuItem
: public wxMenuItemBase
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
55 // Depricated, do not use in new code
57 wxMenuItem( wxMenu
* pParentMenu
59 ,const wxString
& rsText
60 ,const wxString
& rsHelp
62 ,wxMenu
* pSubMenu
= NULL
64 virtual ~wxMenuItem();
67 // Override base class virtuals
69 virtual void SetItemLabel(const wxString
& rStrName
);
71 virtual void Enable(bool bDoEnable
= true);
72 virtual void Check(bool bDoCheck
= true);
73 virtual bool IsChecked(void) const;
76 // Unfortunately needed to resolve ambiguity between
77 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
79 bool IsCheckable(void) const { return wxMenuItemBase::IsCheckable(); }
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
86 int GetRealId(void) const;
89 // Mark item as belonging to the given radio group
91 void SetAsRadioGroupStart(void);
92 void SetRadioGroupStart(int nStart
);
93 void SetRadioGroupEnd(int nEnd
);
96 // All OS/2PM Submenus and menus have one of these
100 #if wxUSE_OWNER_DRAWN
102 void SetBitmaps(const wxBitmap
& bmpChecked
,
103 const wxBitmap
& bmpUnchecked
= wxNullBitmap
)
105 m_bmpChecked
= bmpChecked
;
106 m_bmpUnchecked
= bmpUnchecked
;
110 void SetBitmap(const wxBitmap
& bmp
, bool bChecked
= true)
115 m_bmpUnchecked
= bmp
;
119 void SetDisabledBitmap(const wxBitmap
& bmpDisabled
)
121 m_bmpDisabled
= bmpDisabled
;
125 const wxBitmap
& GetBitmap(bool bChecked
= true) const
126 { return (bChecked
? m_bmpChecked
: m_bmpUnchecked
); }
128 const wxBitmap
& GetDisabledBitmap() const
129 { return m_bmpDisabled
; }
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
);
138 virtual void GetFontToUse(wxFont
& font
) const;
140 #endif // wxUSE_OWNER_DRAWN
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
158 // Does this item start a radio group?
160 bool m_bIsRadioGroupStart
;
162 #if wxUSE_OWNER_DRAWN
164 wxBitmap m_bmpChecked
, // bitmap to put near the item
165 m_bmpUnchecked
, // (checked is used also for 'uncheckable' items)
167 #endif // wxUSE_OWNER_DRAWN
169 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
170 }; // end of CLASS wxMenuItem