]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/menuitem.cpp
[ 1509599 ] 'Split pickers page in widgets sample' with more icons and rebaking.
[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
3b3dc801 29#include "wx/menuitem.h"
e4db172a 30
ffecfa5a
JS
31#ifndef WX_PRECOMP
32 #include "wx/font.h"
33 #include "wx/bitmap.h"
34 #include "wx/settings.h"
ffecfa5a
JS
35 #include "wx/window.h"
36 #include "wx/accel.h"
ffecfa5a 37 #include "wx/string.h"
e4db172a 38 #include "wx/log.h"
3b3dc801 39 #include "wx/menu.h"
ffecfa5a
JS
40#endif
41
ffecfa5a
JS
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
67bool wxMenuItemStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & )
68{
69 const wxMenuItem * mitem = dynamic_cast<const wxMenuItem*>(object) ;
17131ffd 70 if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().empty() )
ffecfa5a
JS
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
79wxBEGIN_ENUM( wxItemKind )
e2731512
WS
80 wxENUM_MEMBER( wxITEM_SEPARATOR )
81 wxENUM_MEMBER( wxITEM_NORMAL )
82 wxENUM_MEMBER( wxITEM_CHECK )
83 wxENUM_MEMBER( wxITEM_RADIO )
ffecfa5a
JS
84wxEND_ENUM( wxItemKind )
85
86IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem, wxObject,"wx/menuitem.h",wxMenuItemStreamingCallback)
87
88wxBEGIN_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"))
98wxEND_PROPERTIES_TABLE()
99
100wxBEGIN_HANDLERS_TABLE(wxMenuItem)
101wxEND_HANDLERS_TABLE()
102
103wxDIRECT_CONSTRUCTOR_6( wxMenuItem , wxMenu* , Parent , int , Id , wxString , Text , wxString , Help , wxItemKind , Kind , wxMenu* , SubMenu )
104#else
105IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
106#endif
107
108// ----------------------------------------------------------------------------
109// wxMenuItem
110// ----------------------------------------------------------------------------
111
112// ctor & dtor
113// -----------
114
115wxMenuItem::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
128wxMenuItem::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
142void wxMenuItem::Init()
143{
144}
145
146wxMenuItem::~wxMenuItem()
147{
148}
149
150// misc
151// ----
152
ffecfa5a
JS
153// get item state
154// --------------
155
156bool wxMenuItem::IsChecked() const
157{
158 return false;
159}
160
161/* static */
162wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
163{
164 return wxStripMenuCodes(text);
165}
166
167// radio group stuff
168// -----------------
169
170void wxMenuItem::SetAsRadioGroupStart()
171{
172}
173
174void wxMenuItem::SetRadioGroupStart(int start)
175{
176}
177
178void wxMenuItem::SetRadioGroupEnd(int end)
179{
180}
181
182// change item state
183// -----------------
184
185void wxMenuItem::Enable(bool enable)
186{
187}
188
189void wxMenuItem::Check(bool check)
190{
191}
192
193void wxMenuItem::SetText(const wxString& text)
194{
195}
196
197void wxMenuItem::SetCheckable(bool checkable)
198{
199}
200
201// ----------------------------------------------------------------------------
202// wxMenuItemBase
203// ----------------------------------------------------------------------------
204
205wxMenuItem *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