]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/menuitem.h
Use correct reload flags on all platforms to avoid compilation errors
[wxWidgets.git] / include / wx / os2 / menuitem.h
CommitLineData
0e320a79 1///////////////////////////////////////////////////////////////////////////////
b73e73f9 2// Name: wx/os2/menuitem.h
0e320a79
DW
3// Purpose: wxMenuItem class
4// Author: Vadim Zeitlin
75f11ad7 5// Modified by:
0e320a79
DW
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
0e320a79
DW
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _MENUITEM_H
13#define _MENUITEM_H
14
0e320a79
DW
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
b73e73f9 19#include "wx/defs.h"
b1b09544 20#include "wx/os2/private.h" // for MENUITEM
0e320a79
DW
21
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...
25#if wxUSE_OWNER_DRAWN
98fbab9e
VZ
26 #include "wx/ownerdrw.h"
27 #include "wx/bitmap.h"
0e320a79
DW
28#endif
29
30// ----------------------------------------------------------------------------
31// constants
32// ----------------------------------------------------------------------------
33
0e320a79
DW
34// ----------------------------------------------------------------------------
35// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
36// ----------------------------------------------------------------------------
53a2db12 37class WXDLLIMPEXP_CORE wxMenuItem: public wxMenuItemBase
0e320a79
DW
38#if wxUSE_OWNER_DRAWN
39 , public wxOwnerDrawn
40#endif
41{
0e320a79 42public:
ab4fece8 43 //
e92f266c 44 // ctor & dtor
ab4fece8 45 //
22e90769 46 wxMenuItem( wxMenu* pParentMenu = NULL
4a277ceb 47 ,int nId = wxID_SEPARATOR
edf1dfa1
DW
48 ,const wxString& rStrName = wxEmptyString
49 ,const wxString& rWxHelp = wxEmptyString
598d8cac 50 ,wxItemKind eKind = wxITEM_NORMAL
22e90769
DW
51 ,wxMenu* pSubMenu = NULL
52 );
ab4fece8
DW
53
54 //
55 // Depricated, do not use in new code
56 //
57 wxMenuItem( wxMenu* pParentMenu
58 ,int vId
59 ,const wxString& rsText
60 ,const wxString& rsHelp
61 ,bool bIsCheckable
d3b9f782 62 ,wxMenu* pSubMenu = NULL
ab4fece8 63 );
e92f266c 64 virtual ~wxMenuItem();
0e320a79 65
ab4fece8
DW
66 //
67 // Override base class virtuals
68 //
52af3158 69 virtual void SetItemLabel(const wxString& rStrName);
0e320a79 70
b73e73f9
WS
71 virtual void Enable(bool bDoEnable = true);
72 virtual void Check(bool bDoCheck = true);
22e90769 73 virtual bool IsChecked(void) const;
75f11ad7 74
ab4fece8
DW
75 //
76 // Unfortunately needed to resolve ambiguity between
e92f266c 77 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
ab4fece8 78 //
22e90769 79 bool IsCheckable(void) const { return wxMenuItemBase::IsCheckable(); }
0e320a79 80
ab4fece8
DW
81 //
82 // The id for a popup menu is really its menu handle (as required by
e92f266c
DW
83 // ::AppendMenu() API), so this function will return either the id or the
84 // menu handle depending on what we're
ab4fece8 85 //
22e90769 86 int GetRealId(void) const;
0e320a79 87
598d8cac
DW
88 //
89 // Mark item as belonging to the given radio group
90 //
ab4fece8
DW
91 void SetAsRadioGroupStart(void);
92 void SetRadioGroupStart(int nStart);
93 void SetRadioGroupEnd(int nEnd);
94
3e282d33
DW
95 //
96 // All OS/2PM Submenus and menus have one of these
97 //
98 MENUITEM m_vMenuData;
99
98fbab9e
VZ
100#if wxUSE_OWNER_DRAWN
101
102 void SetBitmaps(const wxBitmap& bmpChecked,
103 const wxBitmap& bmpUnchecked = wxNullBitmap)
104 {
105 m_bmpChecked = bmpChecked;
106 m_bmpUnchecked = bmpUnchecked;
107 SetOwnerDrawn(true);
108 }
109
110 void SetBitmap(const wxBitmap& bmp, bool bChecked = true)
111 {
112 if ( bChecked )
113 m_bmpChecked = bmp;
114 else
115 m_bmpUnchecked = bmp;
116 SetOwnerDrawn(true);
117 }
118
119 void SetDisabledBitmap(const wxBitmap& bmpDisabled)
120 {
121 m_bmpDisabled = bmpDisabled;
122 SetOwnerDrawn(true);
123 }
124
125 const wxBitmap& GetBitmap(bool bChecked = true) const
126 { return (bChecked ? m_bmpChecked : m_bmpUnchecked); }
127
128 const wxBitmap& GetDisabledBitmap() const
129 { return m_bmpDisabled; }
130
131
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);
136
137protected:
138 virtual void GetFontToUse(wxFont& font) const;
139
140#endif // wxUSE_OWNER_DRAWN
141
0e320a79 142private:
ab4fece8
DW
143 void Init();
144
145 //
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
150 //
151 union
152 {
153 int m_nStart;
154 int m_nEnd;
598d8cac
DW
155 } m_vRadioGroup;
156
157 //
158 // Does this item start a radio group?
159 //
ab4fece8 160 bool m_bIsRadioGroupStart;
598d8cac 161
98fbab9e
VZ
162#if wxUSE_OWNER_DRAWN
163 // item bitmaps
164 wxBitmap m_bmpChecked, // bitmap to put near the item
165 m_bmpUnchecked, // (checked is used also for 'uncheckable' items)
166 m_bmpDisabled;
167#endif // wxUSE_OWNER_DRAWN
168
e92f266c 169 DECLARE_DYNAMIC_CLASS(wxMenuItem)
22e90769 170}; // end of CLASS wxMenuItem
0e320a79
DW
171
172#endif //_MENUITEM_H