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