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