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