]>
Commit | Line | Data |
---|---|---|
23d1d521 | 1 | /////////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/msw/menuitem.h |
23d1d521 JS |
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" | |
9d043a92 VZ |
22 | |
23 | struct tagRECT; | |
23d1d521 JS |
24 | #endif |
25 | ||
23d1d521 JS |
26 | // ---------------------------------------------------------------------------- |
27 | // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour | |
28 | // ---------------------------------------------------------------------------- | |
974e8d94 | 29 | |
53a2db12 | 30 | class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase |
47d67540 | 31 | #if wxUSE_OWNER_DRAWN |
974e8d94 | 32 | , public wxOwnerDrawn |
23d1d521 JS |
33 | #endif |
34 | { | |
23d1d521 | 35 | public: |
974e8d94 | 36 | // ctor & dtor |
d3b9f782 | 37 | wxMenuItem(wxMenu *parentMenu = NULL, |
974e8d94 VZ |
38 | int id = wxID_SEPARATOR, |
39 | const wxString& name = wxEmptyString, | |
40 | const wxString& help = wxEmptyString, | |
546bfbea | 41 | wxItemKind kind = wxITEM_NORMAL, |
d3b9f782 | 42 | wxMenu *subMenu = NULL); |
974e8d94 VZ |
43 | virtual ~wxMenuItem(); |
44 | ||
45 | // override base class virtuals | |
52af3158 | 46 | virtual void SetItemLabel(const wxString& strName); |
974e8d94 | 47 | |
598ddd96 WS |
48 | virtual void Enable(bool bDoEnable = true); |
49 | virtual void Check(bool bDoCheck = true); | |
a8cfd0cb | 50 | virtual bool IsChecked() const; |
974e8d94 VZ |
51 | |
52 | // unfortunately needed to resolve ambiguity between | |
53 | // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable() | |
54 | bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); } | |
55 | ||
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 | |
660e7fda VZ |
58 | // menu handle depending on what we are |
59 | // | |
60 | // notice that it also returns the id as an unsigned int, as required by | |
61 | // Win32 API | |
dca0f651 | 62 | WXWPARAM GetMSWId() const; |
974e8d94 | 63 | |
efebabb7 | 64 | #if WXWIN_COMPATIBILITY_2_8 |
2368dcda | 65 | // compatibility only, don't use in new code |
efebabb7 | 66 | wxDEPRECATED( |
2368dcda VZ |
67 | wxMenuItem(wxMenu *parentMenu, |
68 | int id, | |
69 | const wxString& text, | |
70 | const wxString& help, | |
71 | bool isCheckable, | |
efebabb7 PC |
72 | wxMenu *subMenu = NULL) |
73 | ); | |
74 | #endif | |
2368dcda | 75 | |
98fbab9e VZ |
76 | #if wxUSE_OWNER_DRAWN |
77 | ||
78 | void SetBitmaps(const wxBitmap& bmpChecked, | |
79 | const wxBitmap& bmpUnchecked = wxNullBitmap) | |
80 | { | |
81 | m_bmpChecked = bmpChecked; | |
82 | m_bmpUnchecked = bmpUnchecked; | |
83 | SetOwnerDrawn(true); | |
84 | } | |
85 | ||
86 | void SetBitmap(const wxBitmap& bmp, bool bChecked = true) | |
87 | { | |
88 | if ( bChecked ) | |
89 | m_bmpChecked = bmp; | |
90 | else | |
91 | m_bmpUnchecked = bmp; | |
92 | SetOwnerDrawn(true); | |
93 | } | |
94 | ||
95 | void SetDisabledBitmap(const wxBitmap& bmpDisabled) | |
96 | { | |
97 | m_bmpDisabled = bmpDisabled; | |
98 | SetOwnerDrawn(true); | |
99 | } | |
100 | ||
101 | const wxBitmap& GetBitmap(bool bChecked = true) const | |
102 | { return (bChecked ? m_bmpChecked : m_bmpUnchecked); } | |
103 | ||
104 | const wxBitmap& GetDisabledBitmap() const | |
105 | { return m_bmpDisabled; } | |
106 | ||
9c32ed26 | 107 | int MeasureAccelWidth() const; |
98fbab9e VZ |
108 | |
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); | |
113 | ||
114 | protected: | |
115 | virtual void GetFontToUse(wxFont& font) const; | |
aa4919ed | 116 | virtual void GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& colBack) const; |
98fbab9e | 117 | |
ee009313 VZ |
118 | private: |
119 | // helper function for draw std menu check mark | |
9d043a92 | 120 | void DrawStdCheckMark(WXHDC hdc, const tagRECT* rc, wxODStatus stat); |
ee009313 | 121 | |
98fbab9e VZ |
122 | #endif // wxUSE_OWNER_DRAWN |
123 | ||
23d1d521 | 124 | private: |
2368dcda VZ |
125 | // common part of all ctors |
126 | void Init(); | |
127 | ||
0472ece7 | 128 | |
98fbab9e VZ |
129 | #if wxUSE_OWNER_DRAWN |
130 | // item bitmaps | |
131 | wxBitmap m_bmpChecked, // bitmap to put near the item | |
132 | m_bmpUnchecked, // (checked is used also for 'uncheckable' items) | |
133 | m_bmpDisabled; | |
98fbab9e VZ |
134 | #endif // wxUSE_OWNER_DRAWN |
135 | ||
fc7a2a60 | 136 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem) |
23d1d521 JS |
137 | }; |
138 | ||
139 | #endif //_MENUITEM_H |