]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/menuitem.cpp
use correct colour for the toolbar initially (patch 1150657)
[wxWidgets.git] / src / palmos / menuitem.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/menuitem.cpp
3 // Purpose: wxMenuItem implementation
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ===========================================================================
13 // declarations
14 // ===========================================================================
15
16 // ---------------------------------------------------------------------------
17 // headers
18 // ---------------------------------------------------------------------------
19
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "menuitem.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #if wxUSE_MENUS
32
33 #ifndef WX_PRECOMP
34 #include "wx/font.h"
35 #include "wx/bitmap.h"
36 #include "wx/settings.h"
37 #include "wx/font.h"
38 #include "wx/window.h"
39 #include "wx/accel.h"
40 #include "wx/menu.h"
41 #include "wx/string.h"
42 #endif
43
44 #include "wx/menuitem.h"
45 #include "wx/log.h"
46
47 #if wxUSE_ACCEL
48 #include "wx/accel.h"
49 #endif // wxUSE_ACCEL
50
51 // ---------------------------------------------------------------------------
52 // macro
53 // ---------------------------------------------------------------------------
54
55 // conditional compilation
56 #if wxUSE_OWNER_DRAWN
57 #define OWNER_DRAWN_ONLY( code ) if ( IsOwnerDrawn() ) code
58 #else // !wxUSE_OWNER_DRAWN
59 #define OWNER_DRAWN_ONLY( code )
60 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
61
62 // ============================================================================
63 // implementation
64 // ============================================================================
65
66 // ----------------------------------------------------------------------------
67 // dynamic classes implementation
68 // ----------------------------------------------------------------------------
69
70 #if wxUSE_EXTENDED_RTTI
71
72 bool wxMenuItemStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & )
73 {
74 const wxMenuItem * mitem = dynamic_cast<const wxMenuItem*>(object) ;
75 if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().IsEmpty() )
76 {
77 // we don't stream out the first two items for menus with a title, they will be reconstructed
78 if ( mitem->GetMenu()->FindItemByPosition(0) == mitem || mitem->GetMenu()->FindItemByPosition(1) == mitem )
79 return false ;
80 }
81 return true ;
82 }
83
84 wxBEGIN_ENUM( wxItemKind )
85 wxENUM_MEMBER( wxITEM_SEPARATOR )
86 wxENUM_MEMBER( wxITEM_NORMAL )
87 wxENUM_MEMBER( wxITEM_CHECK )
88 wxENUM_MEMBER( wxITEM_RADIO )
89 wxEND_ENUM( wxItemKind )
90
91 IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem, wxObject,"wx/menuitem.h",wxMenuItemStreamingCallback)
92
93 wxBEGIN_PROPERTIES_TABLE(wxMenuItem)
94 wxPROPERTY( Parent,wxMenu*, SetMenu, GetMenu, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
95 wxPROPERTY( Id,int, SetId, GetId, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
96 wxPROPERTY( Text, wxString , SetText, GetText, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
97 wxPROPERTY( Help, wxString , SetHelp, GetHelp, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
98 wxREADONLY_PROPERTY( Kind, wxItemKind , GetKind , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
99 wxPROPERTY( SubMenu,wxMenu*, SetSubMenu, GetSubMenu, EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
100 wxPROPERTY( Enabled , bool , Enable , IsEnabled , wxxVariant((bool)true) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
101 wxPROPERTY( Checked , bool , Check , IsChecked , wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
102 wxPROPERTY( Checkable , bool , SetCheckable , IsCheckable , wxxVariant((bool)false) , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
103 wxEND_PROPERTIES_TABLE()
104
105 wxBEGIN_HANDLERS_TABLE(wxMenuItem)
106 wxEND_HANDLERS_TABLE()
107
108 wxDIRECT_CONSTRUCTOR_6( wxMenuItem , wxMenu* , Parent , int , Id , wxString , Text , wxString , Help , wxItemKind , Kind , wxMenu* , SubMenu )
109 #else
110 IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
111 #endif
112
113 // ----------------------------------------------------------------------------
114 // wxMenuItem
115 // ----------------------------------------------------------------------------
116
117 // ctor & dtor
118 // -----------
119
120 wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
121 int id,
122 const wxString& text,
123 const wxString& strHelp,
124 wxItemKind kind,
125 wxMenu *pSubMenu)
126 : wxMenuItemBase(pParentMenu, id, text, strHelp, kind, pSubMenu)
127 #if wxUSE_OWNER_DRAWN
128 , wxOwnerDrawn(text, kind == wxITEM_CHECK, true)
129 #endif // owner drawn
130 {
131 }
132
133 wxMenuItem::wxMenuItem(wxMenu *parentMenu,
134 int id,
135 const wxString& text,
136 const wxString& help,
137 bool isCheckable,
138 wxMenu *subMenu)
139 : wxMenuItemBase(parentMenu, id, text, help,
140 isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu)
141 #if wxUSE_OWNER_DRAWN
142 , wxOwnerDrawn(text, isCheckable, true)
143 #endif // owner drawn
144 {
145 }
146
147 void wxMenuItem::Init()
148 {
149 }
150
151 wxMenuItem::~wxMenuItem()
152 {
153 }
154
155 // misc
156 // ----
157
158 // return the id for calling Win32 API functions
159 int wxMenuItem::GetRealId() const
160 {
161 return 0;
162 }
163
164 // get item state
165 // --------------
166
167 bool wxMenuItem::IsChecked() const
168 {
169 return false;
170 }
171
172 /* static */
173 wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
174 {
175 return wxStripMenuCodes(text);
176 }
177
178 // radio group stuff
179 // -----------------
180
181 void wxMenuItem::SetAsRadioGroupStart()
182 {
183 }
184
185 void wxMenuItem::SetRadioGroupStart(int start)
186 {
187 }
188
189 void wxMenuItem::SetRadioGroupEnd(int end)
190 {
191 }
192
193 // change item state
194 // -----------------
195
196 void wxMenuItem::Enable(bool enable)
197 {
198 }
199
200 void wxMenuItem::Check(bool check)
201 {
202 }
203
204 void wxMenuItem::SetText(const wxString& text)
205 {
206 }
207
208 void wxMenuItem::SetCheckable(bool checkable)
209 {
210 }
211
212 // ----------------------------------------------------------------------------
213 // wxMenuItemBase
214 // ----------------------------------------------------------------------------
215
216 wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
217 int id,
218 const wxString& name,
219 const wxString& help,
220 wxItemKind kind,
221 wxMenu *subMenu)
222 {
223 return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
224 }
225
226 #endif // wxUSE_MENUS