]> git.saurik.com Git - wxWidgets.git/blame_incremental - 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
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/os2/menuitem.h
3// Purpose: wxMenuItem class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 11.11.97
7// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _MENUITEM_H
12#define _MENUITEM_H
13
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
18#include "wx/defs.h"
19#include "wx/os2/private.h" // for MENUITEM
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
25 #include "wx/ownerdrw.h"
26 #include "wx/bitmap.h"
27#endif
28
29// ----------------------------------------------------------------------------
30// constants
31// ----------------------------------------------------------------------------
32
33// ----------------------------------------------------------------------------
34// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
35// ----------------------------------------------------------------------------
36class WXDLLIMPEXP_CORE wxMenuItem: public wxMenuItemBase
37#if wxUSE_OWNER_DRAWN
38 , public wxOwnerDrawn
39#endif
40{
41public:
42 //
43 // ctor & dtor
44 //
45 wxMenuItem( wxMenu* pParentMenu = NULL
46 ,int nId = wxID_SEPARATOR
47 ,const wxString& rStrName = wxEmptyString
48 ,const wxString& rWxHelp = wxEmptyString
49 ,wxItemKind eKind = wxITEM_NORMAL
50 ,wxMenu* pSubMenu = NULL
51 );
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
61 ,wxMenu* pSubMenu = NULL
62 );
63 virtual ~wxMenuItem();
64
65 //
66 // Override base class virtuals
67 //
68 virtual void SetItemLabel(const wxString& rStrName);
69
70 virtual void Enable(bool bDoEnable = true);
71 virtual void Check(bool bDoCheck = true);
72 virtual bool IsChecked(void) const;
73
74 //
75 // Unfortunately needed to resolve ambiguity between
76 // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable()
77 //
78 bool IsCheckable(void) const { return wxMenuItemBase::IsCheckable(); }
79
80 //
81 // The id for a popup menu is really its menu handle (as required by
82 // ::AppendMenu() API), so this function will return either the id or the
83 // menu handle depending on what we're
84 //
85 int GetRealId(void) const;
86
87 //
88 // Mark item as belonging to the given radio group
89 //
90 void SetAsRadioGroupStart(void);
91 void SetRadioGroupStart(int nStart);
92 void SetRadioGroupEnd(int nEnd);
93
94 //
95 // All OS/2PM Submenus and menus have one of these
96 //
97 MENUITEM m_vMenuData;
98
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
141private:
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;
154 } m_vRadioGroup;
155
156 //
157 // Does this item start a radio group?
158 //
159 bool m_bIsRadioGroupStart;
160
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
168 DECLARE_DYNAMIC_CLASS(wxMenuItem)
169}; // end of CLASS wxMenuItem
170
171#endif //_MENUITEM_H