]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/menuitem.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / msw / menuitem.h
CommitLineData
23d1d521 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/msw/menuitem.h
23d1d521
JS
3// Purpose: wxMenuItem class
4// Author: Vadim Zeitlin
c626a8b7 5// Modified by:
23d1d521 6// Created: 11.11.97
23d1d521 7// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 8// Licence: wxWindows licence
23d1d521
JS
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _MENUITEM_H
12#define _MENUITEM_H
13
23d1d521
JS
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
47d67540 18#if wxUSE_OWNER_DRAWN
98fbab9e
VZ
19 #include "wx/ownerdrw.h"
20 #include "wx/bitmap.h"
9d043a92
VZ
21
22 struct tagRECT;
23d1d521
JS
23#endif
24
23d1d521
JS
25// ----------------------------------------------------------------------------
26// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
27// ----------------------------------------------------------------------------
974e8d94 28
53a2db12 29class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase
47d67540 30#if wxUSE_OWNER_DRAWN
974e8d94 31 , public wxOwnerDrawn
23d1d521
JS
32#endif
33{
23d1d521 34public:
974e8d94 35 // ctor & dtor
d3b9f782 36 wxMenuItem(wxMenu *parentMenu = NULL,
974e8d94
VZ
37 int id = wxID_SEPARATOR,
38 const wxString& name = wxEmptyString,
39 const wxString& help = wxEmptyString,
546bfbea 40 wxItemKind kind = wxITEM_NORMAL,
d3b9f782 41 wxMenu *subMenu = NULL);
974e8d94
VZ
42 virtual ~wxMenuItem();
43
44 // override base class virtuals
52af3158 45 virtual void SetItemLabel(const wxString& strName);
974e8d94 46
598ddd96
WS
47 virtual void Enable(bool bDoEnable = true);
48 virtual void Check(bool bDoCheck = true);
a8cfd0cb 49 virtual bool IsChecked() const;
974e8d94
VZ
50
51 // unfortunately needed to resolve ambiguity between
52 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
53 bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); }
54
55 // the id for a popup menu is really its menu handle (as required by
56 // ::AppendMenu() API), so this function will return either the id or the
660e7fda
VZ
57 // menu handle depending on what we are
58 //
59 // notice that it also returns the id as an unsigned int, as required by
60 // Win32 API
dca0f651 61 WXWPARAM GetMSWId() const;
974e8d94 62
efebabb7 63#if WXWIN_COMPATIBILITY_2_8
2368dcda 64 // compatibility only, don't use in new code
efebabb7 65 wxDEPRECATED(
2368dcda
VZ
66 wxMenuItem(wxMenu *parentMenu,
67 int id,
68 const wxString& text,
69 const wxString& help,
70 bool isCheckable,
efebabb7
PC
71 wxMenu *subMenu = NULL)
72 );
73#endif
2368dcda 74
98fbab9e
VZ
75#if wxUSE_OWNER_DRAWN
76
77 void SetBitmaps(const wxBitmap& bmpChecked,
78 const wxBitmap& bmpUnchecked = wxNullBitmap)
79 {
80 m_bmpChecked = bmpChecked;
81 m_bmpUnchecked = bmpUnchecked;
82 SetOwnerDrawn(true);
83 }
84
85 void SetBitmap(const wxBitmap& bmp, bool bChecked = true)
86 {
87 if ( bChecked )
88 m_bmpChecked = bmp;
89 else
90 m_bmpUnchecked = bmp;
91 SetOwnerDrawn(true);
92 }
93
94 void SetDisabledBitmap(const wxBitmap& bmpDisabled)
95 {
96 m_bmpDisabled = bmpDisabled;
97 SetOwnerDrawn(true);
98 }
99
100 const wxBitmap& GetBitmap(bool bChecked = true) const
101 { return (bChecked ? m_bmpChecked : m_bmpUnchecked); }
102
103 const wxBitmap& GetDisabledBitmap() const
104 { return m_bmpDisabled; }
105
9c32ed26 106 int MeasureAccelWidth() const;
98fbab9e
VZ
107
108 // override wxOwnerDrawn base class virtuals
109 virtual wxString GetName() const;
110 virtual bool OnMeasureItem(size_t *pwidth, size_t *pheight);
111 virtual bool OnDrawItem(wxDC& dc, const wxRect& rc, wxODAction act, wxODStatus stat);
112
113protected:
114 virtual void GetFontToUse(wxFont& font) const;
aa4919ed 115 virtual void GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const;
98fbab9e 116
ee009313
VZ
117private:
118 // helper function for draw std menu check mark
9d043a92 119 void DrawStdCheckMark(WXHDC hdc, const tagRECT* rc, wxODStatus stat);
ee009313 120
1580a10d
VZ
121#else // !wxUSE_OWNER_DRAWN
122 // Provide stubs for the public functions above to ensure that the code
123 // still compiles without wxUSE_OWNER_DRAWN -- it makes sense to just drop
124 // the bitmaps then instead of failing compilation.
125 void SetBitmaps(const wxBitmap& WXUNUSED(bmpChecked),
126 const wxBitmap& WXUNUSED(bmpUnchecked) = wxNullBitmap) { }
127 void SetBitmap(const wxBitmap& WXUNUSED(bmp),
128 bool WXUNUSED(bChecked) = true) { }
129 const wxBitmap& GetBitmap() const { return wxNullBitmap; }
130#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
98fbab9e 131
23d1d521 132private:
2368dcda
VZ
133 // common part of all ctors
134 void Init();
135
0472ece7 136
98fbab9e
VZ
137#if wxUSE_OWNER_DRAWN
138 // item bitmaps
139 wxBitmap m_bmpChecked, // bitmap to put near the item
140 m_bmpUnchecked, // (checked is used also for 'uncheckable' items)
141 m_bmpDisabled;
98fbab9e
VZ
142#endif // wxUSE_OWNER_DRAWN
143
fc7a2a60 144 DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem)
23d1d521
JS
145};
146
147#endif //_MENUITEM_H