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