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