]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/menuitem.cpp
Honous initial position for wxSpinCtrl.
[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
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
72bool wxMenuItemStreamingCallback( const wxObject *object, wxWriter * , wxPersister * , wxxVariantArray & )
73{
74 const wxMenuItem * mitem = dynamic_cast<const wxMenuItem*>(object) ;
17131ffd 75 if ( mitem->GetMenu() && !mitem->GetMenu()->GetTitle().empty() )
ffecfa5a
JS
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
84wxBEGIN_ENUM( wxItemKind )
e2731512
WS
85 wxENUM_MEMBER( wxITEM_SEPARATOR )
86 wxENUM_MEMBER( wxITEM_NORMAL )
87 wxENUM_MEMBER( wxITEM_CHECK )
88 wxENUM_MEMBER( wxITEM_RADIO )
ffecfa5a
JS
89wxEND_ENUM( wxItemKind )
90
91IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuItem, wxObject,"wx/menuitem.h",wxMenuItemStreamingCallback)
92
93wxBEGIN_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"))
103wxEND_PROPERTIES_TABLE()
104
105wxBEGIN_HANDLERS_TABLE(wxMenuItem)
106wxEND_HANDLERS_TABLE()
107
108wxDIRECT_CONSTRUCTOR_6( wxMenuItem , wxMenu* , Parent , int , Id , wxString , Text , wxString , Help , wxItemKind , Kind , wxMenu* , SubMenu )
109#else
110IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
111#endif
112
113// ----------------------------------------------------------------------------
114// wxMenuItem
115// ----------------------------------------------------------------------------
116
117// ctor & dtor
118// -----------
119
120wxMenuItem::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
133wxMenuItem::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
147void wxMenuItem::Init()
148{
149}
150
151wxMenuItem::~wxMenuItem()
152{
153}
154
155// misc
156// ----
157
ffecfa5a
JS
158// get item state
159// --------------
160
161bool wxMenuItem::IsChecked() const
162{
163 return false;
164}
165
166/* static */
167wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
168{
169 return wxStripMenuCodes(text);
170}
171
172// radio group stuff
173// -----------------
174
175void wxMenuItem::SetAsRadioGroupStart()
176{
177}
178
179void wxMenuItem::SetRadioGroupStart(int start)
180{
181}
182
183void wxMenuItem::SetRadioGroupEnd(int end)
184{
185}
186
187// change item state
188// -----------------
189
190void wxMenuItem::Enable(bool enable)
191{
192}
193
194void wxMenuItem::Check(bool check)
195{
196}
197
198void wxMenuItem::SetText(const wxString& text)
199{
200}
201
202void wxMenuItem::SetCheckable(bool checkable)
203{
204}
205
206// ----------------------------------------------------------------------------
207// wxMenuItemBase
208// ----------------------------------------------------------------------------
209
210wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu,
211 int id,
212 const wxString& name,
213 const wxString& help,
214 wxItemKind kind,
215 wxMenu *subMenu)
216{
217 return new wxMenuItem(parentMenu, id, name, help, kind, subMenu);
218}
219
220#endif // wxUSE_MENUS