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