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