1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/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/ownerdrw.h"
21 #include "wx/bitmap.h"
26 // ----------------------------------------------------------------------------
27 // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
28 // ----------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxMenuItem
: public wxMenuItemBase
37 wxMenuItem(wxMenu
*parentMenu
= NULL
,
38 int id
= wxID_SEPARATOR
,
39 const wxString
& name
= wxEmptyString
,
40 const wxString
& help
= wxEmptyString
,
41 wxItemKind kind
= wxITEM_NORMAL
,
42 wxMenu
*subMenu
= NULL
);
43 virtual ~wxMenuItem();
45 // override base class virtuals
46 virtual void SetItemLabel(const wxString
& strName
);
48 virtual void Enable(bool bDoEnable
= true);
49 virtual void Check(bool bDoCheck
= true);
50 virtual bool IsChecked() const;
52 // unfortunately needed to resolve ambiguity between
53 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
54 bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); }
56 // the id for a popup menu is really its menu handle (as required by
57 // ::AppendMenu() API), so this function will return either the id or the
58 // menu handle depending on what we are
60 // notice that it also returns the id as an unsigned int, as required by
62 WXWPARAM
GetMSWId() const;
64 #if WXWIN_COMPATIBILITY_2_8
65 // compatibility only, don't use in new code
67 wxMenuItem(wxMenu
*parentMenu
,
72 wxMenu
*subMenu
= NULL
)
78 void SetBitmaps(const wxBitmap
& bmpChecked
,
79 const wxBitmap
& bmpUnchecked
= wxNullBitmap
)
81 m_bmpChecked
= bmpChecked
;
82 m_bmpUnchecked
= bmpUnchecked
;
86 void SetBitmap(const wxBitmap
& bmp
, bool bChecked
= true)
95 void SetDisabledBitmap(const wxBitmap
& bmpDisabled
)
97 m_bmpDisabled
= bmpDisabled
;
101 const wxBitmap
& GetBitmap(bool bChecked
= true) const
102 { return (bChecked
? m_bmpChecked
: m_bmpUnchecked
); }
104 const wxBitmap
& GetDisabledBitmap() const
105 { return m_bmpDisabled
; }
107 int MeasureAccelWidth() const;
109 // override wxOwnerDrawn base class virtuals
110 virtual wxString
GetName() const;
111 virtual bool OnMeasureItem(size_t *pwidth
, size_t *pheight
);
112 virtual bool OnDrawItem(wxDC
& dc
, const wxRect
& rc
, wxODAction act
, wxODStatus stat
);
115 virtual void GetFontToUse(wxFont
& font
) const;
116 virtual void GetColourToUse(wxODStatus stat
, wxColour
& colText
, wxColour
& colBack
) const;
119 // helper function for draw std menu check mark
120 void DrawStdCheckMark(WXHDC hdc
, const tagRECT
* rc
, wxODStatus stat
);
122 #endif // wxUSE_OWNER_DRAWN
125 // common part of all ctors
129 #if wxUSE_OWNER_DRAWN
131 wxBitmap m_bmpChecked
, // bitmap to put near the item
132 m_bmpUnchecked
, // (checked is used also for 'uncheckable' items)
134 #endif // wxUSE_OWNER_DRAWN
136 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem
)