]>
Commit | Line | Data |
---|---|---|
cc3977bf SC |
1 | /////////////////////////////////////////////////////////////////////////////\r |
2 | // Name: wx/xtiprop.h\r | |
3 | // Purpose: XTI properties\r | |
4 | // Author: Stefan Csomor\r | |
5 | // Modified by: Francesco Montorsi\r | |
6 | // Created: 27/07/03\r | |
7 | // RCS-ID: $Id: xti.h 47299 2007-07-10 15:58:27Z FM $\r | |
8 | // Copyright: (c) 1997 Julian Smart\r | |
9 | // (c) 2003 Stefan Csomor\r | |
10 | // Licence: wxWindows licence\r | |
11 | /////////////////////////////////////////////////////////////////////////////\r | |
12 | \r | |
13 | #ifndef _XTIPROP_H_\r | |
14 | #define _XTIPROP_H_\r | |
15 | \r | |
16 | #include "wx/defs.h"\r | |
17 | \r | |
18 | #if wxUSE_EXTENDED_RTTI\r | |
19 | \r | |
20 | #include "wx/string.h"\r | |
21 | #include "wx/variant.h"\r | |
22 | #include "wx/intl.h"\r | |
23 | #include "wx/log.h"\r | |
24 | #include "wx/xtitypes.h"\r | |
25 | \r | |
26 | class WXDLLIMPEXP_BASE wxObject;\r | |
27 | class WXDLLIMPEXP_BASE wxClassInfo;\r | |
28 | class WXDLLIMPEXP_BASE wxDynamicClassInfo;\r | |
29 | class WXDLLIMPEXP_BASE wxHashTable;\r | |
30 | class WXDLLIMPEXP_BASE wxHashTable_Node;\r | |
31 | class WXDLLIMPEXP_BASE wxObjectRefData;\r | |
32 | class WXDLLIMPEXP_BASE wxEvent;\r | |
33 | class WXDLLIMPEXP_BASE wxEvtHandler;\r | |
34 | \r | |
35 | // ----------------------------------------------------------------------------\r | |
36 | // Property Accessors\r | |
37 | //\r | |
38 | // wxPropertySetter/Getter/CollectionGetter/CollectionAdder are all property\r | |
39 | // accessors which are managed by wxPropertyAccessor class which in turn is\r | |
40 | // handled by wxPropertyInfo.\r | |
41 | // ----------------------------------------------------------------------------\r | |
42 | \r | |
43 | class WXDLLIMPEXP_BASE wxPropertySetter\r | |
44 | {\r | |
45 | public:\r | |
46 | wxPropertySetter( const wxString name ) { m_name = name; }\r | |
47 | virtual ~wxPropertySetter() {}\r | |
48 | \r | |
49 | virtual void Set( wxObject *object, const wxVariantBase &variantValue ) const = 0;\r | |
50 | const wxString& GetName() const { return m_name; }\r | |
51 | \r | |
52 | private:\r | |
53 | wxString m_name;\r | |
54 | };\r | |
55 | \r | |
56 | class WXDLLIMPEXP_BASE wxPropertyGetter\r | |
57 | {\r | |
58 | public:\r | |
59 | wxPropertyGetter( const wxString name ) { m_name = name; }\r | |
60 | virtual ~wxPropertyGetter() {}\r | |
61 | \r | |
62 | virtual void Get( const wxObject *object, wxVariantBase& result) const = 0;\r | |
63 | const wxString& GetName() const { return m_name; }\r | |
64 | \r | |
65 | private:\r | |
66 | wxString m_name;\r | |
67 | };\r | |
68 | \r | |
69 | class WXDLLIMPEXP_BASE wxPropertyCollectionGetter\r | |
70 | {\r | |
71 | public:\r | |
72 | wxPropertyCollectionGetter( const wxString name ) { m_name = name; }\r | |
73 | virtual ~wxPropertyCollectionGetter() {}\r | |
74 | \r | |
75 | virtual void Get( const wxObject *object, wxVariantBaseArray& result) const = 0;\r | |
76 | const wxString& GetName() const { return m_name; }\r | |
77 | \r | |
78 | private:\r | |
79 | wxString m_name;\r | |
80 | };\r | |
81 | \r | |
82 | template<typename coll_t> void WXDLLIMPEXP_BASE \\r | |
83 | wxCollectionToVariantArray( const coll_t& coll, wxVariantBaseArray& result );\r | |
84 | \r | |
85 | class WXDLLIMPEXP_BASE wxPropertyCollectionAdder\r | |
86 | {\r | |
87 | public:\r | |
88 | wxPropertyCollectionAdder( const wxString name ) { m_name = name; }\r | |
89 | virtual ~wxPropertyCollectionAdder() {}\r | |
90 | \r | |
91 | virtual void Add( wxObject *object, const wxVariantBase &variantValue ) const= 0;\r | |
92 | const wxString& GetName() const { return m_name; }\r | |
93 | \r | |
94 | private:\r | |
95 | wxString m_name;\r | |
96 | };\r | |
97 | \r | |
98 | #define wxPROPERTY_SETTER( property, Klass, valueType, setterMethod ) \\r | |
99 | class wxPropertySetter##property : public wxPropertySetter \\r | |
100 | { \\r | |
101 | public: \\r | |
102 | wxINFUNC_CLASS_TYPE_FIX(Klass) \\r | |
103 | wxPropertySetter##property() : wxPropertySetter( wxT(#setterMethod) ) {} \\r | |
104 | virtual ~wxPropertySetter##property() {} \\r | |
105 | \\r | |
106 | void Set( wxObject *object, const wxVariantBase &variantValue ) const \\r | |
107 | { \\r | |
108 | Klass *obj = dynamic_cast<Klass*>(object); \\r | |
109 | if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \\r | |
110 | obj->setterMethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType)); \\r | |
111 | else \\r | |
112 | obj->setterMethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType*)); \\r | |
113 | } \\r | |
114 | };\r | |
115 | \r | |
116 | #define wxPROPERTY_GETTER( property, Klass, valueType, gettermethod ) \\r | |
117 | class wxPropertyGetter##property : public wxPropertyGetter \\r | |
118 | { \\r | |
119 | public: \\r | |
120 | wxINFUNC_CLASS_TYPE_FIX(Klass) \\r | |
121 | wxPropertyGetter##property() : wxPropertyGetter( wxT(#gettermethod) ) {} \\r | |
122 | virtual ~wxPropertyGetter##property() {} \\r | |
123 | \\r | |
124 | void Get( const wxObject *object, wxVariantBase &result) const \\r | |
125 | { \\r | |
126 | const Klass *obj = dynamic_cast<const Klass*>(object); \\r | |
127 | result = wxVariantBase( obj->gettermethod() ); \\r | |
128 | } \\r | |
129 | };\r | |
130 | \r | |
131 | #define wxPROPERTY_COLLECTION_ADDER( property, Klass, valueType, addermethod ) \\r | |
132 | class wxPropertyCollectionAdder##property : public wxPropertyCollectionAdder \\r | |
133 | { \\r | |
134 | public: \\r | |
135 | wxINFUNC_CLASS_TYPE_FIX(Klass) \\r | |
136 | wxPropertyCollectionAdder##property() : wxPropertyCollectionAdder( wxT(#addermethod) ) {} \\r | |
137 | virtual ~wxPropertyCollectionAdder##property() {} \\r | |
138 | \\r | |
139 | void Add( wxObject *object, const wxVariantBase &variantValue ) const \\r | |
140 | { \\r | |
141 | Klass *obj = dynamic_cast<Klass*>(object); \\r | |
142 | if ( variantValue.wxTEMPLATED_MEMBER_CALL(HasData, valueType) ) \\r | |
143 | obj->addermethod(variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType)); \\r | |
144 | else \\r | |
145 | obj->addermethod(*variantValue.wxTEMPLATED_MEMBER_CALL(Get, valueType*)); \\r | |
146 | } \\r | |
147 | };\r | |
148 | \r | |
149 | #define wxPROPERTY_COLLECTION_GETTER( property, Klass, valueType, gettermethod ) \\r | |
150 | class wxPropertyCollectionGetter##property : public wxPropertyCollectionGetter \\r | |
151 | { \\r | |
152 | public: \\r | |
153 | wxINFUNC_CLASS_TYPE_FIX(Klass) \\r | |
154 | wxPropertyCollectionGetter##property() : wxPropertyCollectionGetter( wxT(#gettermethod) ) {} \\r | |
155 | virtual ~wxPropertyCollectionGetter##property() {} \\r | |
156 | \\r | |
157 | void Get( const wxObject *object, wxVariantBaseArray &result) const \\r | |
158 | { \\r | |
159 | const Klass *obj = dynamic_cast<const Klass*>(object); \\r | |
160 | wxCollectionToVariantArray( obj->gettermethod(), result ); \\r | |
161 | } \\r | |
162 | };\r | |
163 | \r | |
164 | class WXDLLIMPEXP_BASE wxPropertyAccessor\r | |
165 | {\r | |
166 | public:\r | |
167 | wxPropertyAccessor( wxPropertySetter *setter, wxPropertyGetter *getter, \r | |
168 | wxPropertyCollectionAdder *adder, wxPropertyCollectionGetter *collectionGetter )\r | |
169 | { m_setter = setter; m_getter = getter; m_adder = adder; \r | |
170 | m_collectionGetter = collectionGetter; }\r | |
171 | \r | |
172 | virtual ~wxPropertyAccessor() {}\r | |
173 | \r | |
174 | // Setting a simple property (non-collection)\r | |
175 | virtual void SetProperty(wxObject *object, const wxVariantBase &value) const\r | |
176 | { \r | |
177 | if ( m_setter ) \r | |
178 | m_setter->Set( object, value ); \r | |
179 | else \r | |
180 | wxLogError( _("SetProperty called w/o valid setter") ); \r | |
181 | }\r | |
182 | \r | |
183 | // Getting a simple property (non-collection)\r | |
184 | virtual void GetProperty(const wxObject *object, wxVariantBase &result) const\r | |
185 | { \r | |
186 | if ( m_getter ) \r | |
187 | m_getter->Get( object, result ); \r | |
188 | else \r | |
189 | wxLogError( _("GetProperty called w/o valid getter") ); \r | |
190 | }\r | |
191 | \r | |
192 | // Adding an element to a collection property\r | |
193 | virtual void AddToPropertyCollection(wxObject *object, const wxVariantBase &value) const\r | |
194 | { \r | |
195 | if ( m_adder ) \r | |
196 | m_adder->Add( object, value ); \r | |
197 | else \r | |
198 | wxLogError( _("AddToPropertyCollection called w/o valid adder") ); \r | |
199 | }\r | |
200 | \r | |
201 | // Getting a collection property\r | |
202 | virtual void GetPropertyCollection( const wxObject *obj, wxVariantBaseArray &result) const\r | |
203 | { \r | |
204 | if ( m_collectionGetter ) \r | |
205 | m_collectionGetter->Get( obj, result); \r | |
206 | else \r | |
207 | wxLogError( _("GetPropertyCollection called w/o valid collection getter") ); \r | |
208 | }\r | |
209 | \r | |
210 | virtual bool HasSetter() const { return m_setter != NULL; }\r | |
211 | virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL; }\r | |
212 | virtual bool HasGetter() const { return m_getter != NULL; }\r | |
213 | virtual bool HasAdder() const { return m_adder != NULL; }\r | |
214 | \r | |
215 | virtual const wxString& GetCollectionGetterName() const\r | |
216 | { return m_collectionGetter->GetName(); }\r | |
217 | virtual const wxString& GetGetterName() const\r | |
218 | { return m_getter->GetName(); }\r | |
219 | virtual const wxString& GetSetterName() const\r | |
220 | { return m_setter->GetName(); }\r | |
221 | virtual const wxString& GetAdderName() const\r | |
222 | { return m_adder->GetName(); }\r | |
223 | \r | |
224 | protected:\r | |
225 | wxPropertySetter *m_setter;\r | |
226 | wxPropertyCollectionAdder *m_adder;\r | |
227 | wxPropertyGetter *m_getter;\r | |
228 | wxPropertyCollectionGetter* m_collectionGetter;\r | |
229 | };\r | |
230 | \r | |
231 | class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor\r | |
232 | {\r | |
233 | public:\r | |
234 | wxGenericPropertyAccessor( const wxString &propName );\r | |
235 | virtual ~wxGenericPropertyAccessor();\r | |
236 | \r | |
237 | void RenameProperty( const wxString& WXUNUSED_UNLESS_DEBUG(oldName),\r | |
238 | const wxString& newName )\r | |
239 | {\r | |
240 | wxASSERT( oldName == m_propertyName ); m_propertyName = newName;\r | |
241 | }\r | |
242 | \r | |
243 | virtual bool HasSetter() const { return true; }\r | |
244 | virtual bool HasGetter() const { return true; }\r | |
245 | virtual bool HasAdder() const { return false; }\r | |
246 | virtual bool HasCollectionGetter() const { return false; }\r | |
247 | \r | |
248 | virtual const wxString& GetGetterName() const\r | |
249 | { return m_getterName; }\r | |
250 | virtual const wxString& GetSetterName() const\r | |
251 | { return m_setterName; }\r | |
252 | \r | |
253 | virtual void SetProperty(wxObject *object, const wxVariantBase &value) const;\r | |
254 | virtual void GetProperty(const wxObject *object, wxVariantBase &value) const;\r | |
255 | \r | |
256 | // Adding an element to a collection property\r | |
257 | virtual void AddToPropertyCollection(wxObject *WXUNUSED(object), \r | |
258 | const wxVariantBase &WXUNUSED(value)) const\r | |
259 | { \r | |
260 | wxLogError( _("AddToPropertyCollection called on a generic accessor") ); \r | |
261 | }\r | |
262 | \r | |
263 | // Getting a collection property\r | |
264 | virtual void GetPropertyCollection( const wxObject *WXUNUSED(obj), \r | |
265 | wxVariantBaseArray &WXUNUSED(result)) const\r | |
266 | { \r | |
267 | wxLogError ( _("GetPropertyCollection called on a generic accessor") ); \r | |
268 | }\r | |
269 | \r | |
270 | private:\r | |
271 | struct wxGenericPropertyAccessorInternal;\r | |
272 | wxGenericPropertyAccessorInternal* m_data;\r | |
273 | wxString m_propertyName;\r | |
274 | wxString m_setterName;\r | |
275 | wxString m_getterName;\r | |
276 | };\r | |
277 | \r | |
278 | typedef long wxPropertyInfoFlags;\r | |
279 | enum \r | |
280 | {\r | |
281 | // will be removed in future releases\r | |
282 | wxPROP_DEPRECATED = 0x00000001,\r | |
283 | \r | |
284 | // object graph property, will be streamed with priority (after constructor properties)\r | |
285 | wxPROP_OBJECT_GRAPH = 0x00000002,\r | |
286 | \r | |
287 | // this will only be streamed out and in as enum/set, the internal representation \r | |
288 | // is still a long\r | |
289 | wxPROP_ENUM_STORE_LONG = 0x00000004,\r | |
290 | \r | |
291 | // don't stream out this property, needed eg to avoid streaming out children \r | |
292 | // that are always created by their parents\r | |
293 | wxPROP_DONT_STREAM = 0x00000008\r | |
294 | };\r | |
295 | \r | |
296 | \r | |
297 | // ----------------------------------------------------------------------------\r | |
298 | // Property Support\r | |
299 | //\r | |
300 | // wxPropertyInfo is used to inquire of the property by name. It doesn't\r | |
301 | // provide access to the property, only information about it. If you\r | |
302 | // want access, look at wxPropertyAccessor.\r | |
303 | // ----------------------------------------------------------------------------\r | |
304 | \r | |
305 | class WXDLLIMPEXP_BASE wxPropertyInfo\r | |
306 | {\r | |
307 | friend class WXDLLIMPEXP_BASE wxDynamicClassInfo;\r | |
308 | \r | |
309 | public:\r | |
310 | wxPropertyInfo(wxPropertyInfo* &iter,\r | |
311 | wxClassInfo* itsClass,\r | |
312 | const wxString& name,\r | |
313 | const wxString& typeName,\r | |
314 | wxPropertyAccessor *accessor,\r | |
315 | wxVariantBase dv,\r | |
316 | wxPropertyInfoFlags flags = 0,\r | |
317 | const wxString& helpString = wxEmptyString,\r | |
318 | const wxString& groupString = wxEmptyString) :\r | |
319 | m_itsClass(itsClass),\r | |
320 | m_name(name),\r | |
321 | m_typeInfo(NULL),\r | |
322 | m_typeName(typeName),\r | |
323 | m_collectionElementTypeInfo(NULL),\r | |
324 | m_accessor(accessor),\r | |
325 | m_defaultValue(dv),\r | |
326 | m_flags(flags),\r | |
327 | m_helpString(helpString),\r | |
328 | m_groupString(groupString)\r | |
329 | {\r | |
330 | Insert(iter);\r | |
331 | }\r | |
332 | \r | |
333 | #if wxUSE_UNICODE\r | |
334 | wxPropertyInfo(wxPropertyInfo* &iter,\r | |
335 | wxClassInfo* itsClass,\r | |
336 | const wxString& name,\r | |
337 | const char* typeName,\r | |
338 | wxPropertyAccessor *accessor,\r | |
339 | wxVariantBase dv,\r | |
340 | wxPropertyInfoFlags flags = 0,\r | |
341 | const wxString& helpString = wxEmptyString,\r | |
342 | const wxString& groupString = wxEmptyString) :\r | |
343 | m_itsClass(itsClass),\r | |
344 | m_name(name),\r | |
345 | m_typeInfo(NULL),\r | |
346 | m_typeName(wxString::FromAscii(typeName)),\r | |
347 | m_collectionElementTypeInfo(NULL),\r | |
348 | m_accessor(accessor),\r | |
349 | m_defaultValue(dv),\r | |
350 | m_flags(flags),\r | |
351 | m_helpString(helpString),\r | |
352 | m_groupString(groupString)\r | |
353 | {\r | |
354 | Insert(iter);\r | |
355 | }\r | |
356 | #endif\r | |
357 | wxPropertyInfo(wxPropertyInfo* &iter,\r | |
358 | wxClassInfo* itsClass,\r | |
359 | const wxString& name,\r | |
360 | wxEventSourceTypeInfo* type,\r | |
361 | wxPropertyAccessor *accessor,\r | |
362 | wxVariantBase dv,\r | |
363 | wxPropertyInfoFlags flags = 0,\r | |
364 | const wxString& helpString = wxEmptyString,\r | |
365 | const wxString& groupString = wxEmptyString) :\r | |
366 | m_itsClass(itsClass),\r | |
367 | m_name(name),\r | |
368 | m_typeInfo(type),\r | |
369 | m_collectionElementTypeInfo(NULL),\r | |
370 | m_accessor(accessor),\r | |
371 | m_defaultValue(dv),\r | |
372 | m_flags(flags),\r | |
373 | m_helpString(helpString),\r | |
374 | m_groupString(groupString)\r | |
375 | {\r | |
376 | Insert(iter);\r | |
377 | }\r | |
378 | \r | |
379 | wxPropertyInfo(wxPropertyInfo* &iter,\r | |
380 | wxClassInfo* itsClass, const wxString& name,\r | |
381 | const wxString& collectionTypeName,\r | |
382 | const wxString& elementTypeName,\r | |
383 | wxPropertyAccessor *accessor,\r | |
384 | wxPropertyInfoFlags flags = 0,\r | |
385 | const wxString& helpString = wxEmptyString,\r | |
386 | const wxString& groupString = wxEmptyString) :\r | |
387 | m_itsClass(itsClass),\r | |
388 | m_name(name),\r | |
389 | m_typeInfo(NULL),\r | |
390 | m_typeName(collectionTypeName),\r | |
391 | m_collectionElementTypeInfo(NULL),\r | |
392 | m_collectionElementTypeName(elementTypeName),\r | |
393 | m_accessor(accessor),\r | |
394 | m_flags(flags),\r | |
395 | m_helpString(helpString),\r | |
396 | m_groupString(groupString)\r | |
397 | {\r | |
398 | Insert(iter);\r | |
399 | }\r | |
400 | \r | |
401 | #if wxUSE_UNICODE\r | |
402 | wxPropertyInfo(wxPropertyInfo* &iter,\r | |
403 | wxClassInfo* itsClass, const wxString& name,\r | |
404 | const char* collectionTypeName,\r | |
405 | const char* elementTypeName,\r | |
406 | wxPropertyAccessor *accessor,\r | |
407 | wxPropertyInfoFlags flags = 0,\r | |
408 | const wxString& helpString = wxEmptyString,\r | |
409 | const wxString& groupString = wxEmptyString) :\r | |
410 | m_itsClass(itsClass),\r | |
411 | m_name(name),\r | |
412 | m_typeInfo(NULL),\r | |
413 | m_typeName(wxString::FromAscii(collectionTypeName)),\r | |
414 | m_collectionElementTypeInfo(NULL),\r | |
415 | m_collectionElementTypeName(wxString::FromAscii(elementTypeName)),\r | |
416 | m_accessor(accessor),\r | |
417 | m_flags(flags),\r | |
418 | m_helpString(helpString),\r | |
419 | m_groupString(groupString)\r | |
420 | {\r | |
421 | Insert(iter);\r | |
422 | }\r | |
423 | #endif\r | |
424 | ~wxPropertyInfo()\r | |
425 | { Remove(); }\r | |
426 | \r | |
427 | // return the class this property is declared in\r | |
428 | const wxClassInfo* GetDeclaringClass() const { return m_itsClass; }\r | |
429 | \r | |
430 | // return the name of this property\r | |
431 | const wxString& GetName() const { return m_name; }\r | |
432 | \r | |
433 | // returns the flags of this property\r | |
434 | wxPropertyInfoFlags GetFlags() const { return m_flags; }\r | |
435 | \r | |
436 | // returns the short help string of this property\r | |
437 | const wxString& GetHelpString() const { return m_helpString; }\r | |
438 | \r | |
439 | // returns the group string of this property\r | |
440 | const wxString& GetGroupString() const { return m_groupString; }\r | |
441 | \r | |
442 | // return the element type info of this property (for collections, otherwise NULL)\r | |
443 | const wxTypeInfo * GetCollectionElementTypeInfo() const\r | |
444 | {\r | |
445 | if ( m_collectionElementTypeInfo == NULL )\r | |
446 | m_collectionElementTypeInfo = wxTypeInfo::FindType(m_collectionElementTypeName);\r | |
447 | return m_collectionElementTypeInfo;\r | |
448 | }\r | |
449 | \r | |
450 | // return the type info of this property\r | |
451 | const wxTypeInfo * GetTypeInfo() const\r | |
452 | {\r | |
453 | if ( m_typeInfo == NULL )\r | |
454 | m_typeInfo = wxTypeInfo::FindType(m_typeName);\r | |
455 | return m_typeInfo;\r | |
456 | }\r | |
457 | \r | |
458 | // return the accessor for this property\r | |
459 | wxPropertyAccessor* GetAccessor() const { return m_accessor; }\r | |
460 | \r | |
461 | // returns NULL if this is the last property of this class\r | |
462 | wxPropertyInfo* GetNext() const { return m_next; }\r | |
463 | \r | |
464 | // returns the default value of this property, its kind may be wxT_VOID if it is not valid\r | |
465 | wxVariantBase GetDefaultValue() const { return m_defaultValue; }\r | |
466 | \r | |
467 | private:\r | |
468 | \r | |
469 | // inserts this property at the end of the linked chain which begins\r | |
470 | // with "iter" property.\r | |
471 | void Insert(wxPropertyInfo* &iter);\r | |
472 | \r | |
473 | // removes this property from the linked chain of the m_itsClass properties.\r | |
474 | void Remove();\r | |
475 | \r | |
476 | wxClassInfo* m_itsClass;\r | |
477 | wxString m_name;\r | |
478 | mutable wxTypeInfo* m_typeInfo;\r | |
479 | wxString m_typeName;\r | |
480 | mutable wxTypeInfo* m_collectionElementTypeInfo;\r | |
481 | wxString m_collectionElementTypeName;\r | |
482 | wxPropertyAccessor* m_accessor;\r | |
483 | wxVariantBase m_defaultValue;\r | |
484 | wxPropertyInfoFlags m_flags;\r | |
485 | wxString m_helpString;\r | |
486 | wxString m_groupString;\r | |
487 | wxPropertyInfo* m_next;\r | |
488 | \r | |
489 | // FIXME: what's this comment about??\r | |
490 | // string representation of the default value\r | |
491 | // to be assigned by the designer to the property\r | |
492 | // when the component is dropped on the container.\r | |
493 | };\r | |
494 | \r | |
495 | WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxPropertyInfo*, wxPropertyInfoMap, \r | |
496 | class WXDLLIMPEXP_BASE );\r | |
497 | \r | |
498 | #define wxBEGIN_PROPERTIES_TABLE(theClass) \\r | |
499 | wxPropertyInfo *theClass::GetPropertiesStatic() \\r | |
500 | { \\r | |
501 | typedef theClass class_t; \\r | |
502 | static wxPropertyInfo* first = NULL;\r | |
503 | \r | |
504 | #define wxEND_PROPERTIES_TABLE() \\r | |
505 | return first; }\r | |
506 | \r | |
507 | #define wxHIDE_PROPERTY( pname ) \\r | |
508 | static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \\r | |
509 | wxT(#pname), typeid(void).name(), NULL, wxVariantBase(), wxPROP_DONT_STREAM, \\r | |
510 | wxEmptyString, wxEmptyString );\r | |
511 | \r | |
512 | #define wxPROPERTY( pname, type, setter, getter, defaultValue, flags, help, group) \\r | |
513 | wxPROPERTY_SETTER( pname, class_t, type, setter ) \\r | |
514 | static wxPropertySetter##pname _setter##pname; \\r | |
515 | wxPROPERTY_GETTER( pname, class_t, type, getter ) \\r | |
516 | static wxPropertyGetter##pname _getter##pname; \\r | |
517 | static wxPropertyAccessor _accessor##pname( &_setter##pname, \\r | |
518 | &_getter##pname, NULL, NULL ); \\r | |
519 | static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \\r | |
520 | wxT(#pname), typeid(type).name(), &_accessor##pname, \\r | |
521 | wxVariantBase(defaultValue), flags, group, help );\r | |
522 | \r | |
523 | #define wxPROPERTY_FLAGS( pname, flags, type, setter, getter,defaultValue, \\r | |
524 | pflags, help, group) \\r | |
525 | wxPROPERTY_SETTER( pname, class_t, type, setter ) \\r | |
526 | static wxPropertySetter##pname _setter##pname; \\r | |
527 | wxPROPERTY_GETTER( pname, class_t, type, getter ) \\r | |
528 | static wxPropertyGetter##pname _getter##pname; \\r | |
529 | static wxPropertyAccessor _accessor##pname( &_setter##pname, \\r | |
530 | &_getter##pname, NULL, NULL ); \\r | |
531 | static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \\r | |
532 | wxT(#pname), typeid(flags).name(), &_accessor##pname, \\r | |
533 | wxVariantBase(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group );\r | |
534 | \r | |
535 | #define wxREADONLY_PROPERTY( pname, type, getter,defaultValue, flags, help, group) \\r | |
536 | wxPROPERTY_GETTER( pname, class_t, type, getter ) \\r | |
537 | static wxPropertyGetter##pname _getter##pname; \\r | |
538 | static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \\r | |
539 | static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \\r | |
540 | wxT(#pname), typeid(type).name(),&_accessor##pname, \\r | |
541 | wxVariantBase(defaultValue), flags, help, group );\r | |
542 | \r | |
543 | #define wxREADONLY_PROPERTY_FLAGS( pname, flags, type, getter,defaultValue, \\r | |
544 | pflags, help, group) \\r | |
545 | wxPROPERTY_GETTER( pname, class_t, type, getter ) \\r | |
546 | static wxPropertyGetter##pname _getter##pname; \\r | |
547 | static wxPropertyAccessor _accessor##pname( NULL, &_getter##pname, NULL, NULL ); \\r | |
548 | static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \\r | |
549 | wxT(#pname), typeid(flags).name(),&_accessor##pname, \\r | |
550 | wxVariantBase(defaultValue), wxPROP_ENUM_STORE_LONG | pflags, help, group );\r | |
551 | \r | |
552 | #define wxPROPERTY_COLLECTION( pname, colltype, addelemtype, adder, getter, \\r | |
553 | flags, help, group ) \\r | |
554 | wxPROPERTY_COLLECTION_ADDER( pname, class_t, addelemtype, adder ) \\r | |
555 | static wxPropertyCollectionAdder##pname _adder##pname; \\r | |
556 | wxPROPERTY_COLLECTION_GETTER( pname, class_t, colltype, getter ) \\r | |
557 | static wxPropertyCollectionGetter##pname _collectionGetter##pname; \\r | |
558 | static wxPropertyAccessor _accessor##pname( NULL, NULL,&_adder##pname, \\r | |
559 | &_collectionGetter##pname ); \\r | |
560 | static wxPropertyInfo _propertyInfo##pname( first, class_t::GetClassInfoStatic(), \\r | |
561 | wxT(#pname), typeid(colltype).name(),typeid(addelemtype).name(), \\r | |
562 | &_accessor##pname, flags, help, group );\r | |
563 | \r | |
564 | #define wxREADONLY_PROPERTY_COLLECTION( pname, colltype, addelemtype, getter, \\r | |
565 | flags, help, group) \\r | |
566 | wxPROPERTY_COLLECTION_GETTER( pname, class_t, colltype, getter ) \\r | |
567 | static wxPropertyCollectionGetter##pname _collectionGetter##pname; \\r | |
568 | static wxPropertyAccessor _accessor##pname( NULL, NULL, NULL, \\r | |
569 | &_collectionGetter##pname ); \\r | |
570 | static wxPropertyInfo _propertyInfo##pname( first,class_t::GetClassInfoStatic(), \\r | |
571 | wxT(#pname), typeid(colltype).name(),typeid(addelemtype).name(), \\r | |
572 | &_accessor##pname, flags, help, group );\r | |
573 | \r | |
574 | #define wxEVENT_PROPERTY( name, eventType, eventClass ) \\r | |
575 | static wxEventSourceTypeInfo _typeInfo##name( eventType, CLASSINFO( eventClass ) ); \\r | |
576 | static wxPropertyInfo _propertyInfo##name( first,class_t::GetClassInfoStatic(), \\r | |
577 | wxT(#name), &_typeInfo##name, NULL, wxVariantBase() );\r | |
578 | \r | |
579 | #define wxEVENT_RANGE_PROPERTY( name, eventType, lastEventType, eventClass ) \\r | |
580 | static wxEventSourceTypeInfo _typeInfo##name( eventType, lastEventType, \\r | |
581 | CLASSINFO( eventClass ) ); \\r | |
582 | static wxPropertyInfo _propertyInfo##name( first, class_t::GetClassInfoStatic(), \\r | |
583 | wxT(#name), &_typeInfo##name, NULL, wxVariantBase() );\r | |
584 | \r | |
585 | // ----------------------------------------------------------------------------\r | |
586 | // Implementation Helper for Simple Properties\r | |
587 | // ----------------------------------------------------------------------------\r | |
588 | \r | |
589 | #define wxIMPLEMENT_PROPERTY(name, type) \\r | |
590 | private: \\r | |
591 | type m_##name; \\r | |
592 | public: \\r | |
593 | void Set##name( type const & p) { m_##name = p; } \\r | |
594 | type const & Get##name() const { return m_##name; }\r | |
595 | \r | |
596 | #endif // wxUSE_EXTENDED_RTTI\r | |
597 | #endif // _XTIPROP_H_\r |