metadata support for metadata
[wxWidgets.git] / include / wx / xti.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/xti.h
3 // Purpose: runtime metadata information (extended class info)
4 // Author: Stefan Csomor
5 // Modified by:
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 _WX_XTIH__
14 #define _WX_XTIH__
15
16 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
17 #pragma interface "xti.h"
18 #endif
19
20 // We want to support properties, event sources and events sinks through
21 // explicit declarations, using templates and specialization to make the
22 // effort as painless as possible.
23 //
24 // This means we have the following domains :
25 //
26 // - Type Information for categorizing built in types as well as custom types
27 // this includes information about enums, their values and names
28 // - Type safe value storage : a kind of wxVariant, called right now wxxVariant
29 // which will be merged with wxVariant
30 // - Property Information and Property Accessors providing access to a class'
31 // values and exposed event delegates
32 // - Information about event handlers
33 // - extended Class Information for accessing all these
34
35 // ----------------------------------------------------------------------------
36 // headers
37 // ----------------------------------------------------------------------------
38
39 #include "wx/defs.h"
40 #include "wx/memory.h"
41 #include "wx/set.h"
42 #include "wx/string.h"
43 #include "wx/arrstr.h"
44
45 class WXDLLIMPEXP_BASE wxObject;
46 class WXDLLIMPEXP_BASE wxClassInfo;
47 class WXDLLIMPEXP_BASE wxHashTable;
48 class WXDLLIMPEXP_BASE wxObjectRefData;
49 class WXDLLIMPEXP_BASE wxEvent;
50
51 typedef void (wxObject::*wxObjectEventFunction)(wxEvent&);
52
53 // ----------------------------------------------------------------------------
54 // Enum Support
55 //
56 // In the header files there would no change from pure c++ code, in the
57 // implementation, an enum would have
58 // to be enumerated eg :
59 //
60 // WX_BEGIN_ENUM( wxFlavor )
61 // WX_ENUM_MEMBER( Vanilla )
62 // WX_ENUM_MEMBER( Chocolate )
63 // WX_ENUM_MEMBER( Strawberry )
64 // WX_END_ENUM( wxFlavor )
65 // ----------------------------------------------------------------------------
66
67 struct WXDLLIMPEXP_BASE wxEnumMemberData
68 {
69 const wxChar* m_name;
70 int m_value;
71 };
72
73 class WXDLLIMPEXP_BASE wxEnumData
74 {
75 public :
76 wxEnumData( wxEnumMemberData* data ) ;
77
78 // returns true if the member has been found and sets the int value
79 // pointed to accordingly (if ptr != null )
80 // if not found returns false, value left unchanged
81 bool HasEnumMemberValue( const wxChar *name , int *value = NULL ) ;
82
83 // returns the value of the member, if not found in debug mode an
84 // assert is issued, in release 0 is returned
85 int GetEnumMemberValue(const wxChar *name );
86
87 // returns the name of the enum member having the passed in value
88 // returns an emtpy string if not found
89 const wxChar *GetEnumMemberName(int value);
90
91 // returns the number of members in this enum
92 int GetEnumCount() { return m_count ; }
93
94 // returns the value of the nth member
95 int GetEnumMemberValueByIndex( int n ) ;
96
97 // returns the value of the nth member
98 const wxChar *GetEnumMemberNameByIndex( int n ) ;
99 private :
100 wxEnumMemberData *m_members;
101 int m_count ;
102 };
103
104 #define WX_BEGIN_ENUM( e ) \
105 wxEnumMemberData s_enumDataMembers##e[] = {
106
107 #define WX_ENUM_MEMBER( v ) { #v, v } ,
108
109 #define WX_END_ENUM( e ) { NULL , 0 } } ; \
110 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
111 wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \
112 template<> void wxStringReadValue(const wxString& s , e &data ) \
113 { \
114 data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
115 } \
116 template<> void wxStringWriteValue(wxString &s , const e &data ) \
117 { \
118 s = s_enumData##e.GetEnumMemberName((int)data) ; \
119 } \
120 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e , &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; } \
121 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \
122 template<> void wxStringReadValue(const wxString& , e* & ) \
123 { \
124 assert(0) ; \
125 } \
126 template<> void wxStringWriteValue(wxString &s , e* const & ) \
127 { \
128 assert(0) ; \
129 }
130
131 // ----------------------------------------------------------------------------
132 // Set Support
133 //
134 // in the header :
135 //
136 // enum wxFlavor
137 // {
138 // Vanilla,
139 // Chocolate,
140 // Strawberry,
141 // };
142 //
143 // typedef wxSet<wxFlavor> wxCoupe ;
144 //
145 // in the implementation file :
146 //
147 // WX_BEGIN_ENUM( wxFlavor )
148 // WX_ENUM_MEMBER( Vanilla )
149 // WX_ENUM_MEMBER( Chocolate )
150 // WX_ENUM_MEMBER( Strawberry )
151 // WX_END_ENUM( wxFlavor )
152 //
153 // WX_IMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor )
154 //
155 // implementation note : no partial specialization for streaming, but a delegation to a
156 // different class
157 //
158 // ----------------------------------------------------------------------------
159
160 // in order to remove dependancy on string tokenizer
161 void wxSetStringToArray( const wxString &s , wxArrayString &array ) ;
162
163 template<typename e>
164 void wxSetFromString(const wxString &s , wxSet<e> &data )
165 {
166 wxEnumData* edata = wxGetEnumData((e) 0) ;
167 data.Clear() ;
168
169 wxArrayString array ;
170 wxSetStringToArray( s , array ) ;
171 wxString flag;
172 for ( int i = 0 ; i < array.Count() ; ++i )
173 {
174 flag = array[i] ;
175 int ivalue ;
176 if ( edata->HasEnumMemberValue( flag , &ivalue ) )
177 {
178 data.Set( (e) ivalue ) ;
179 }
180 }
181 }
182
183 template<typename e>
184 void wxSetToString( wxString &s , const wxSet<e> &data )
185 {
186 wxEnumData* edata = wxGetEnumData((e) 0) ;
187 int count = edata->GetEnumCount() ;
188 int i ;
189 s.Clear() ;
190 for ( i = 0 ; i < count ; i++ )
191 {
192 e value = (e) edata->GetEnumMemberValueByIndex(i) ;
193 if ( data.Contains( value ) )
194 {
195 // this could also be done by the templated calls
196 if ( !s.IsEmpty() )
197 s +="|" ;
198 s += edata->GetEnumMemberNameByIndex(i) ;
199 }
200 }
201 }
202
203 // if the wxSet specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro
204 // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; }
205
206 #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \
207 template<> void wxStringReadValue(const wxString &s , wxSet<e> &data ) \
208 { \
209 wxSetFromString( s , data ) ; \
210 } \
211 template<> void wxStringWriteValue( wxString &s , const wxSet<e> &data ) \
212 { \
213 wxSetToString( s , data ) ; \
214 }
215
216
217 // ----------------------------------------------------------------------------
218 // Type Information
219 // ----------------------------------------------------------------------------
220 //
221 //
222 // All data exposed by the RTTI is characterized using the following classes.
223 // The first characterization is done by wxTypeKind. All enums up to and including
224 // wxT_CUSTOM represent so called simple types. These cannot be divided any further.
225 // They can be converted to and from wxStrings, that's all.
226
227
228 enum wxTypeKind
229 {
230 wxT_VOID = 0, // unknown type
231 wxT_BOOL,
232 wxT_CHAR,
233 wxT_UCHAR,
234 wxT_INT,
235 wxT_UINT,
236 wxT_LONG,
237 wxT_ULONG,
238 wxT_FLOAT,
239 wxT_DOUBLE,
240 wxT_STRING, // must be wxString
241 wxT_SET, // must be wxSet<> template
242 wxT_ENUM,
243 wxT_CUSTOM, // user defined type (e.g. wxPoint)
244
245 wxT_LAST_SIMPLE_TYPE_KIND = wxT_CUSTOM ,
246
247 wxT_OBJECT_PTR, // object reference
248 wxT_OBJECT , // embedded object
249 wxT_COLLECTION , // collection
250
251 wxT_DELEGATE , // for connecting against an event source
252
253 wxT_LAST_TYPE_KIND = wxT_DELEGATE // sentinel for bad data, asserts, debugging
254 };
255
256 class wxxVariant ;
257
258 class WXDLLIMPEXP_BASE wxTypeInfo
259 {
260 public :
261 wxTypeInfo() : m_kind( wxT_VOID) , m_toString(NULL) , m_fromString(NULL) {}
262 virtual ~wxTypeInfo() {}
263 wxTypeKind GetKind() const { return m_kind ; }
264 bool IsDelegateType() const { return m_kind == wxT_DELEGATE ; }
265 bool IsCustomType() const { return m_kind == wxT_CUSTOM ; }
266 bool IsObjectType() const { return m_kind == wxT_OBJECT || m_kind == wxT_OBJECT_PTR ; }
267 bool HasStringConverters() const { return m_toString != NULL && m_fromString != NULL ; }
268 void ConvertToString( const wxxVariant& data , wxString &result ) const
269 { wxASSERT_MSG( m_toString , wxT("String conversions not supported") ) ; (*m_toString)( data , result ) ; }
270 void ConvertFromString( const wxString& data , wxxVariant &result ) const
271 { wxASSERT_MSG( m_fromString , wxT("String conversions not supported") ) ; (*m_fromString)( data , result ) ; }
272
273 protected :
274 typedef void (*converterToString_t)( const wxxVariant& data , wxString &result ) ;
275 typedef void (*converterFromString_t)( const wxString& data , wxxVariant &result ) ;
276
277 converterToString_t m_toString ;
278 converterFromString_t m_fromString ;
279
280 wxTypeKind m_kind ;
281 };
282
283 class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo
284 {
285 public :
286 wxBuiltInTypeInfo( wxTypeKind kind , converterToString_t to = NULL , converterFromString_t from= NULL )
287 { wxASSERT_MSG( kind < wxT_SET , wxT("Illegal Kind for Base Type") ) ; m_kind = kind ; m_toString = to ; m_fromString = from ;}
288 } ;
289
290 class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo
291 {
292 public :
293 wxCustomTypeInfo( const wxChar *typeName , converterToString_t to= NULL , converterFromString_t from= NULL )
294 { m_kind = wxT_CUSTOM ; m_typeName = typeName ;m_toString = to ; m_fromString = from ;}
295 const wxChar *GetTypeName() const { return m_typeName ; }
296 private :
297 const wxChar *m_typeName; // Kind == wxT_CUSTOM
298 } ;
299
300 class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo
301 {
302 public :
303 wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo , converterToString_t to = NULL , converterFromString_t from= NULL )
304 { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_enumInfo = enumInfo ;m_toString = to ; m_fromString = from ;}
305 const wxEnumData* GetEnumData() const { return m_enumInfo ; }
306 private :
307 wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET
308 } ;
309
310 class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo
311 {
312 public :
313 wxClassTypeInfo( wxTypeKind kind , wxClassInfo* classInfo , converterToString_t to = NULL , converterFromString_t from = NULL )
314 { wxASSERT_MSG( kind == wxT_OBJECT_PTR || kind == wxT_OBJECT , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_classInfo = classInfo ;}
315 const wxClassInfo *GetClassInfo() const { return m_classInfo ; }
316 private :
317 wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL
318 } ;
319
320 class WXDLLIMPEXP_BASE wxCollectionTypeInfo : public wxTypeInfo
321 {
322 public :
323 wxCollectionTypeInfo( wxTypeInfo *elementType , converterToString_t to = NULL , converterFromString_t from = NULL )
324 { m_kind = wxT_COLLECTION , m_elementType = elementType ; m_toString = to ; m_fromString = from ;}
325
326 const wxTypeInfo* GetElementType() const { return m_elementType ; }
327 private :
328 wxTypeInfo * m_elementType ;
329 } ;
330
331 // a delegate is an exposed event source
332
333 class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo
334 {
335 public :
336 wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass , converterToString_t to = NULL , converterFromString_t from = NULL )
337 { m_kind = wxT_DELEGATE ; m_eventClass = eventClass ; m_eventType = eventType ;m_toString = to ; m_fromString = from ;}
338 const wxClassInfo *GetEventClass() const { assert( m_kind == wxT_DELEGATE ) ; return m_eventClass ; }
339 int GetEventType() const { return m_eventType ; }
340 private :
341 const wxClassInfo *m_eventClass; // (extended will merge into classinfo)
342 int m_eventType ;
343 } ;
344
345 template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) ;
346
347 template<typename T> const wxTypeInfo* wxGetTypeInfo( wxSet<T> * )
348 {
349 static wxEnumTypeInfo s_typeInfo(wxT_SET , wxGetEnumData((T) 0) ) ; return &s_typeInfo ;
350 }
351
352 // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
353
354 #define WX_CUSTOM_TYPE_INFO( e ) \
355 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \
356 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e, &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; }
357
358 // templated streaming, every type must have their specialization for these methods
359
360 template<typename T>
361 void wxStringReadValue( const wxString &s , T &data );
362
363 template<typename T>
364 void wxStringWriteValue( wxString &s , const T &data);
365
366 template<typename T>
367 void wxToStringConverter( const wxxVariant &v, wxString &s) { wxStringWriteValue( s , v.Get<T>() ) ; }
368
369 template<typename T>
370 void wxFromStringConverter( const wxString &s, wxxVariant &v) { T d ; wxStringReadValue( s , d ) ; v = wxxVariant(d) ; } \
371
372 // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
373
374 #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \
375 template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
376 static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
377 template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
378 template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
379
380 // ----------------------------------------------------------------------------
381 // wxxVariant as typesafe data holder
382 // ----------------------------------------------------------------------------
383
384 class WXDLLIMPEXP_BASE wxxVariantData
385 {
386 public:
387 virtual ~wxxVariantData() {}
388
389 // return a heap allocated duplicate
390 virtual wxxVariantData* Clone() const = 0 ;
391
392 // returns the type info of the contentc
393 virtual const wxTypeInfo* GetTypeInfo() const = 0 ;
394 } ;
395
396 template<typename T> class WXDLLIMPEXP_BASE wxxVariantDataT : public wxxVariantData
397 {
398 public:
399 wxxVariantDataT(const T& d) : m_data(d) {}
400 virtual ~wxxVariantDataT() {}
401
402 // get a ref to the stored data
403 T & Get() { return m_data; }
404
405 // get a const ref to the stored data
406 const T & Get() const { return m_data; }
407
408 // set the data
409 void Set(const T& d) { m_data = d; }
410
411 // return a heap allocated duplicate
412 virtual wxxVariantData* Clone() const { return new wxxVariantDataT<T>( Get() ) ; }
413
414 // returns the type info of the contentc
415 virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( (T*) NULL ) ; }
416 private:
417 T m_data;
418 };
419
420 class WXDLLIMPEXP_BASE wxxVariant
421 {
422 public :
423 wxxVariant() { m_data = NULL ; }
424 wxxVariant( wxxVariantData* data , const wxString& name = wxT("") ) : m_data(data) , m_name(name) {}
425 wxxVariant( const wxxVariant &d ) { if ( d.m_data ) m_data = d.m_data->Clone() ; else m_data = NULL ; m_name = d.m_name ; }
426
427 template<typename T> wxxVariant( const T& data , const wxString& name = wxT("") ) :
428 m_data(new wxxVariantDataT<T>(data) ), m_name(name) {}
429
430 ~wxxVariant() { delete m_data ; }
431
432 // get a ref to the stored data
433 template<typename T> T& Get()
434 {
435 wxxVariantDataT<T> *dataptr = dynamic_cast<wxxVariantDataT<T>*> (m_data) ;
436 wxASSERT_MSG( dataptr , "Cast not possible" ) ;
437 return dataptr->Get() ;
438 }
439
440 // get a ref to the stored data
441 template<typename T> const T& Get() const
442 {
443 const wxxVariantDataT<T> *dataptr = dynamic_cast<const wxxVariantDataT<T>*> (m_data) ;
444 wxASSERT_MSG( dataptr , "Cast not possible" ) ;
445 return dataptr->Get() ;
446 }
447
448 template<typename T> bool HasData() const
449 {
450 const wxxVariantDataT<T> *dataptr = dynamic_cast<const wxxVariantDataT<T>*> (m_data) ;
451 return dataptr != NULL ;
452 }
453
454 // stores the data
455 template<typename T> void Set(const T& data) const
456 {
457 delete m_data ;
458 m_data = new wxxVariantDataT<T>(data) ;
459 }
460
461 wxxVariant& operator=(const wxxVariant &d)
462 {
463 m_data = d.m_data->Clone() ;
464 m_name = d.m_name ;
465 return *this ;
466 }
467
468 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
469 wxObject* GetAsObject() ;
470
471 // get the typeinfo of the stored object
472 const wxTypeInfo* GetTypeInfo() const { return m_data->GetTypeInfo() ; }
473
474 // returns this value as string
475 wxString GetAsString() const
476 {
477 wxString s ;
478 GetTypeInfo()->ConvertToString( *this , s ) ;
479 return s ;
480 }
481 const wxString& GetName() const { return m_name ; }
482 private :
483 wxxVariantData* m_data ;
484 wxString m_name ;
485 } ;
486
487 #include <wx/dynarray.h>
488
489 WX_DECLARE_OBJARRAY_WITH_DECL(wxxVariant, wxxVariantArray, class WXDLLIMPEXP_BASE);
490
491 // ----------------------------------------------------------------------------
492 // Property Support
493 //
494 // wxPropertyInfo is used to inquire of the property by name. It doesn't
495 // provide access to the property, only information about it. If you
496 // want access, look at wxPropertyAccessor.
497 // ----------------------------------------------------------------------------
498
499 class wxSetter
500 {
501 public :
502 wxSetter( const wxString name ) { m_name = name ; }
503 virtual void Set( wxObject *object, const wxxVariant &variantValue ) const = 0;
504 const wxString& GetName() const { return m_name ; }
505 private :
506 wxString m_name ;
507 } ;
508
509 class wxGetter
510 {
511 public :
512 wxGetter( const wxString name ) { m_name = name ; }
513 virtual void Get( const wxObject *object , wxxVariant& result) const = 0;
514 const wxString& GetName() const { return m_name ; }
515 private :
516 wxString m_name ;
517 } ;
518
519 class wxCollectionGetter
520 {
521 public :
522 wxCollectionGetter( const wxString name ) { m_name = name ; }
523 virtual void Get( const wxObject *object , wxxVariantArray& result) const = 0;
524 const wxString& GetName() const { return m_name ; }
525 private :
526 wxString m_name ;
527 } ;
528
529 template<typename coll_t> void wxCollectionToVariantArray( const coll_t& coll , wxxVariantArray& result ) ;
530
531 class wxAdder
532 {
533 public :
534 wxAdder( const wxString name ) { m_name = name ; }
535 virtual void Add( wxObject *object, const wxxVariant &variantValue ) const= 0;
536 const wxString& GetName() const { return m_name ; }
537 private :
538 wxString m_name ;
539 } ;
540
541
542
543 #define WX_SETTER( property, Klass, valueType, setterMethod ) \
544 class wxSetter##property : public wxSetter \
545 { \
546 public: \
547 wxSetter##property() : wxSetter( #setterMethod ) {} \
548 void Set( wxObject *object, const wxxVariant &variantValue ) const \
549 { \
550 Klass *obj = dynamic_cast<Klass*>(object) ; \
551 if ( variantValue.HasData<valueType>() ) \
552 obj->setterMethod(variantValue.Get<valueType>()) ; \
553 else \
554 obj->setterMethod(*variantValue.Get<valueType*>()) ; \
555 } \
556 } ;
557
558 #define WX_GETTER( property, Klass, valueType , gettermethod ) \
559 class wxGetter##property : public wxGetter \
560 { \
561 public : \
562 wxGetter##property() : wxGetter( #gettermethod ) {} \
563 void Get( const wxObject *object , wxxVariant &result) const \
564 { \
565 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
566 result = wxxVariant( obj->gettermethod() ) ; \
567 } \
568 } ;
569
570 #define WX_ADDER( property, Klass, valueType , addermethod ) \
571 class wxAdder##property : public wxAdder \
572 { \
573 public: \
574 wxAdder##property() : wxAdder( #addermethod ) {} \
575 void Add( wxObject *object, const wxxVariant &variantValue ) const \
576 { \
577 Klass *obj = dynamic_cast<Klass*>(object) ; \
578 if ( variantValue.HasData<valueType>() ) \
579 obj->addermethod(variantValue.Get<valueType>()) ; \
580 else \
581 obj->addermethod(*variantValue.Get<valueType*>()) ; \
582 } \
583 } ;
584
585 #define WX_COLLECTION_GETTER( property, Klass, valueType , gettermethod ) \
586 class wxCollectionGetter##property : public wxCollectionGetter \
587 { \
588 public : \
589 wxCollectionGetter##property() : wxCollectionGetter( #gettermethod ) {} \
590 void Get( const wxObject *object , wxxVariantArray &result) const \
591 { \
592 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
593 wxCollectionToVariantArray( obj->gettermethod() , result ) ; \
594 } \
595 } ;
596
597 class WXDLLIMPEXP_BASE wxPropertyAccessor
598 {
599 public :
600 wxPropertyAccessor( wxSetter *setter , wxGetter *getter , wxAdder *adder , wxCollectionGetter *collectionGetter )
601 { m_setter = setter ; m_getter = getter ; m_adder = adder ; m_collectionGetter = collectionGetter ;}
602
603 virtual ~wxPropertyAccessor() {}
604
605 // Setting a simple property (non-collection)
606 virtual void SetProperty(wxObject *object, const wxxVariant &value) const
607 { wxASSERT_MSG(m_setter,wxT("SetProperty called w/o valid setter") ) ; m_setter->Set( object , value ) ;}
608
609 // Getting a simple property (non-collection)
610 virtual void GetProperty(const wxObject *object, wxxVariant &result) const
611 { wxASSERT_MSG(m_getter,wxT("GetProperty called w/o valid getter") ) ; return m_getter->Get( object , result ) ;}
612
613 // Adding an element to a collection property
614 virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const
615 { wxASSERT_MSG(m_adder,wxT("AddToPropertyCollection called w/o valid adder") ) ; m_adder->Add( object , value ) ;}
616
617 // Getting a collection property
618 virtual void GetPropertyCollection( const wxObject *obj, wxxVariantArray &result) const
619 { wxASSERT_MSG(m_collectionGetter,wxT("GetPropertyCollection called w/o valid collection getter") ) ; return m_collectionGetter->Get( obj , result) ;}
620
621 virtual bool HasSetter() const { return m_setter != NULL ; }
622 virtual bool HasCollectionGetter() const { return m_collectionGetter != NULL ; }
623 virtual bool HasGetter() const { return m_getter != NULL ; }
624 virtual bool HasAdder() const { return m_adder != NULL ; }
625
626 virtual const wxString& GetCollectionGetterName() const
627 { return m_collectionGetter->GetName() ; }
628 virtual const wxString& GetGetterName() const
629 { return m_getter->GetName() ; }
630 virtual const wxString& GetSetterName() const
631 { return m_setter->GetName() ; }
632 virtual const wxString& GetAdderName() const
633 { return m_adder->GetName() ; }
634 /*
635 virtual wxxVariant ReadValue( const wxString &value ) const ;
636 virtual void WriteValue( wxString& value , const wxObject *o ) const ;
637 */
638 protected :
639 wxSetter *m_setter ;
640 wxAdder *m_adder ;
641 wxGetter *m_getter ;
642 wxCollectionGetter* m_collectionGetter ;
643 };
644
645 class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor
646 {
647 public :
648 wxGenericPropertyAccessor( const wxString &propName ) ;
649 ~wxGenericPropertyAccessor() ;
650
651 virtual bool HasSetter() const { return true ; }
652 virtual bool HasGetter() const { return true ; }
653 virtual bool HasAdder() const { return false ; }
654 virtual bool HasCollectionGetter() const { return false ; }
655
656 virtual const wxString& GetGetterName() const
657 { return m_getterName ; }
658 virtual const wxString& GetSetterName() const
659 { return m_setterName ; }
660
661 virtual void SetProperty(wxObject *object, const wxxVariant &value) const ;
662 virtual void GetProperty(const wxObject *object, wxxVariant &value) const ;
663
664 // Adding an element to a collection property
665 virtual void AddToPropertyCollection(wxObject *object, const wxxVariant &value) const
666 { wxASSERT_MSG(0,wxT("AddToPropertyCollection called on a generic accessor") ) ;}
667
668 // Getting a collection property
669 virtual void GetPropertyCollection( const wxObject *obj, wxxVariantArray &result) const
670 { wxASSERT_MSG(0,wxT("GetPropertyCollection called on a generic accessor") ) ;}
671 private :
672 struct wxGenericPropertyAccessorInternal ;
673 wxGenericPropertyAccessorInternal* m_data ;
674 wxString m_propertyName ;
675 wxString m_setterName ;
676 wxString m_getterName ;
677 } ;
678
679 class WXDLLIMPEXP_BASE wxPropertyInfo
680 {
681 public :
682 wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv ) :
683 m_name( name ) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv ) , m_collectionElementTypeInfo(NULL)
684 {
685 Insert(iter) ;
686 }
687
688 wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* collTypeInfo , const wxTypeInfo* elemTypeInfo , wxPropertyAccessor *accessor ) :
689 m_name( name ) , m_typeInfo( collTypeInfo ) , m_accessor( accessor ) , m_collectionElementTypeInfo(elemTypeInfo)
690 {
691 Insert(iter) ;
692 }
693
694 // return the name of this property
695 const wxChar * GetName() const { return m_name ; }
696
697 // return the element type info of this property (for collections, otherwise NULL)
698 const wxTypeInfo * GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo ; }
699
700 // return the type info of this property
701 const wxTypeInfo * GetTypeInfo() const { return m_typeInfo ; }
702
703 // return the accessor for this property
704 wxPropertyAccessor* GetAccessor() const { return m_accessor ; }
705
706 // returns NULL if this is the last property of this class
707 wxPropertyInfo* GetNext() const { return m_next ; }
708
709 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
710 wxxVariant GetDefaultValue() const { return m_defaultValue ; }
711 private :
712 void Insert(wxPropertyInfo* &iter)
713 {
714 m_next = NULL ;
715 if ( iter == NULL )
716 iter = this ;
717 else
718 {
719 wxPropertyInfo* i = iter ;
720 while( i->m_next )
721 i = i->m_next ;
722
723 i->m_next = this ;
724 }
725 }
726
727 const wxChar * m_name;
728 const wxChar * m_typeName ;
729 const wxTypeInfo* m_typeInfo ;
730 const wxTypeInfo* m_collectionElementTypeInfo ;
731 wxPropertyAccessor* m_accessor ;
732 wxxVariant m_defaultValue;
733 // string representation of the default value
734 // to be assigned by the designer to the property
735 // when the component is dropped on the container.
736 wxPropertyInfo* m_next ;
737 };
738
739 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
740 wxPropertyInfo *theClass::GetPropertiesStatic() \
741 { \
742 typedef theClass class_t; \
743 static wxPropertyInfo* first = NULL ;
744
745 #define WX_END_PROPERTIES_TABLE() \
746 return first ; }
747
748
749
750 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
751 WX_SETTER( name , class_t , type , setter ) \
752 static wxSetter##name _setter##name ; \
753 WX_GETTER( name , class_t , type , getter ) \
754 static wxGetter##name _getter##name ; \
755 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
756 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
757
758 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
759 WX_GETTER( name , class_t , type , getter ) \
760 static wxGetter##name _getter##name ; \
761 static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \
762 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
763
764 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
765 WX_ADDER( name , class_t , addelemtype , adder ) \
766 static wxAdder##name _adder##name ; \
767 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
768 static wxCollectionGetter##name _collectionGetter##name ; \
769 static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \
770 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
771
772 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
773 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
774 static wxCollectionGetter##name _collectionGetter##name ; \
775 static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \
776 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
777 /*
778 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
779 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
780 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
781
782 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
783 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &getter , #getter ) ; \
784 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
785 */
786
787
788
789 #define WX_DELEGATE( name , eventType , eventClass ) \
790 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
791 static wxPropertyInfo _propertyInfo##name( first , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
792
793 // ----------------------------------------------------------------------------
794 // Handler Info
795 //
796 // this is describing an event sink
797 // ----------------------------------------------------------------------------
798
799 class wxHandlerInfo
800 {
801 public :
802 wxHandlerInfo( wxHandlerInfo* &iter , const wxChar *name , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) :
803 m_name( name ) , m_eventClassInfo( eventClassInfo ) , m_eventFunction( address )
804 {
805 m_next = NULL ;
806 if ( iter == NULL )
807 iter = this ;
808 else
809 {
810 wxHandlerInfo* i = iter ;
811 while( i->m_next )
812 i = i->m_next ;
813
814 i->m_next = this ;
815 }
816 }
817
818 // get the name of the handler method
819 const wxChar * GetName() const { return m_name ; }
820
821 // return the class info of the event
822 const wxClassInfo * GetEventClassInfo() const { return m_eventClassInfo ; }
823
824 // get the handler function pointer
825 wxObjectEventFunction GetEventFunction() const { return m_eventFunction ; }
826
827 // returns NULL if this is the last handler of this class
828 wxHandlerInfo* GetNext() const { return m_next ; }
829 private :
830 wxObjectEventFunction m_eventFunction ;
831 const wxChar * m_name;
832 const wxClassInfo* m_eventClassInfo ;
833 wxHandlerInfo* m_next ;
834 };
835
836 #define WX_HANDLER(name,eventClassType) \
837 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
838
839 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
840 wxHandlerInfo *theClass::GetHandlersStatic() \
841 { \
842 typedef theClass class_t; \
843 static wxHandlerInfo* first = NULL ;
844
845 #define WX_END_HANDLERS_TABLE() \
846 return first ; }
847
848 // ----------------------------------------------------------------------------
849 // Constructor Bridges
850 //
851 // allow to set up constructors with params during runtime
852 // ----------------------------------------------------------------------------
853
854 class WXDLLIMPEXP_BASE wxConstructorBridge
855 {
856 public :
857 virtual void Create(wxObject *o, wxxVariant *args) = 0;
858 };
859
860 // Creator Bridges for all Numbers of Params
861
862 // no params
863
864 template<typename Class>
865 struct wxConstructorBridge_0 : public wxConstructorBridge
866 {
867 void Create(wxObject *o, wxxVariant *)
868 {
869 Class *obj = dynamic_cast<Class*>(o);
870 obj->Create();
871 }
872 };
873
874 struct wxConstructorBridge_Dummy : public wxConstructorBridge
875 {
876 void Create(wxObject *, wxxVariant *)
877 {
878 }
879 } ;
880
881 #define WX_CONSTRUCTOR_0(klass) \
882 wxConstructorBridge_0<klass> constructor##klass ; \
883 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
884 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
885 const int klass::sm_constructorPropertiesCount##klass = 0 ;
886
887 #define WX_CONSTRUCTOR_DUMMY(klass) \
888 wxConstructorBridge_Dummy constructor##klass ; \
889 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
890 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
891 const int klass::sm_constructorPropertiesCount##klass = 0 ;
892
893 // 1 param
894
895 template<typename Class, typename T0>
896 struct wxConstructorBridge_1 : public wxConstructorBridge
897 {
898 void Create(wxObject *o, wxxVariant *args)
899 {
900 Class *obj = dynamic_cast<Class*>(o);
901 obj->Create(
902 args[0].Get<T0>()
903 );
904 }
905 };
906
907 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
908 wxConstructorBridge_1<klass,t0> constructor##klass ; \
909 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
910 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
911 const int klass::sm_constructorPropertiesCount##klass = 1 ;
912
913 // 2 params
914
915 template<typename Class,
916 typename T0, typename T1>
917 struct wxConstructorBridge_2 : public wxConstructorBridge
918 {
919 void Create(wxObject *o, wxxVariant *args)
920 {
921 Class *obj = dynamic_cast<Class*>(o);
922 obj->Create(
923 args[0].Get<T0>() ,
924 args[1].Get<T1>()
925 );
926 }
927 };
928
929 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
930 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
931 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
932 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
933 const int klass::sm_constructorPropertiesCount##klass = 2;
934
935 // 3 params
936
937 template<typename Class,
938 typename T0, typename T1, typename T2>
939 struct wxConstructorBridge_3 : public wxConstructorBridge
940 {
941 void Create(wxObject *o, wxxVariant *args)
942 {
943 Class *obj = dynamic_cast<Class*>(o);
944 obj->Create(
945 args[0].Get<T0>() ,
946 args[1].Get<T1>() ,
947 args[2].Get<T2>()
948 );
949 }
950 };
951
952 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
953 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
954 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
955 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
956 const int klass::sm_constructorPropertiesCount##klass = 3 ;
957
958 // 4 params
959
960 template<typename Class,
961 typename T0, typename T1, typename T2, typename T3>
962 struct wxConstructorBridge_4 : public wxConstructorBridge
963 {
964 void Create(wxObject *o, wxxVariant *args)
965 {
966 Class *obj = dynamic_cast<Class*>(o);
967 obj->Create(
968 args[0].Get<T0>() ,
969 args[1].Get<T1>() ,
970 args[2].Get<T2>() ,
971 args[3].Get<T3>()
972 );
973 }
974 };
975
976 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
977 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
978 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
979 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
980 const int klass::sm_constructorPropertiesCount##klass = 4 ;
981
982 // 5 params
983
984 template<typename Class,
985 typename T0, typename T1, typename T2, typename T3, typename T4>
986 struct wxConstructorBridge_5 : public wxConstructorBridge
987 {
988 void Create(wxObject *o, wxxVariant *args)
989 {
990 Class *obj = dynamic_cast<Class*>(o);
991 obj->Create(
992 args[0].Get<T0>() ,
993 args[1].Get<T1>() ,
994 args[2].Get<T2>() ,
995 args[3].Get<T3>() ,
996 args[4].Get<T4>()
997 );
998 }
999 };
1000
1001 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
1002 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
1003 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1004 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
1005 const int klass::sm_constructorPropertiesCount##klass = 5;
1006
1007 // 6 params
1008
1009 template<typename Class,
1010 typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
1011 struct wxConstructorBridge_6 : public wxConstructorBridge
1012 {
1013 void Create(wxObject *o, wxxVariant *args)
1014 {
1015 Class *obj = dynamic_cast<Class*>(o);
1016 obj->Create(
1017 args[0].Get<T0>() ,
1018 args[1].Get<T1>() ,
1019 args[2].Get<T2>() ,
1020 args[3].Get<T3>() ,
1021 args[4].Get<T4>() ,
1022 args[5].Get<T5>()
1023 );
1024 }
1025 };
1026
1027 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
1028 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
1029 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1030 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
1031 const int klass::sm_constructorPropertiesCount##klass = 6;
1032
1033 // 7 params
1034
1035 template<typename Class,
1036 typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
1037 struct wxConstructorBridge_7 : public wxConstructorBridge
1038 {
1039 void Create(wxObject *o, wxxVariant *args)
1040 {
1041 Class *obj = dynamic_cast<Class*>(o);
1042 obj->Create(
1043 args[0].Get<T0>() ,
1044 args[1].Get<T1>() ,
1045 args[2].Get<T2>() ,
1046 args[3].Get<T3>() ,
1047 args[4].Get<T4>() ,
1048 args[5].Get<T5>() ,
1049 args[6].Get<T6>()
1050 );
1051 }
1052 };
1053
1054 #define WX_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
1055 wxConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass ; \
1056 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1057 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6} ; \
1058 const int klass::sm_constructorPropertiesCount##klass = 7;
1059
1060 // 8 params
1061
1062 template<typename Class,
1063 typename T0, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
1064 struct wxConstructorBridge_8 : public wxConstructorBridge
1065 {
1066 void Create(wxObject *o, wxxVariant *args)
1067 {
1068 Class *obj = dynamic_cast<Class*>(o);
1069 obj->Create(
1070 args[0].Get<T0>() ,
1071 args[1].Get<T1>() ,
1072 args[2].Get<T2>() ,
1073 args[3].Get<T3>() ,
1074 args[4].Get<T4>() ,
1075 args[5].Get<T5>() ,
1076 args[6].Get<T6>() ,
1077 args[7].Get<T7>()
1078 );
1079 }
1080 };
1081
1082 #define WX_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
1083 wxConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass ; \
1084 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1085 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6 , #v7} ; \
1086 const int klass::sm_constructorPropertiesCount##klass = 8;
1087 // ----------------------------------------------------------------------------
1088 // wxClassInfo
1089 // ----------------------------------------------------------------------------
1090
1091 typedef wxObject *(*wxObjectConstructorFn)(void);
1092 typedef wxObject* (*wxVariantToObjectConverter)( wxxVariant &data ) ;
1093 typedef wxxVariant (*wxObjectToVariantConverter)( wxObject* ) ;
1094
1095 class WXDLLIMPEXP_BASE wxClassInfo
1096 {
1097 public:
1098 wxClassInfo(const wxClassInfo **_Parents,
1099 const wxChar *_UnitName,
1100 const wxChar *_ClassName,
1101 int size,
1102 wxObjectConstructorFn ctor ,
1103 wxPropertyInfo *_Props ,
1104 wxHandlerInfo *_Handlers ,
1105 wxConstructorBridge* _Constructor ,
1106 const wxChar ** _ConstructorProperties ,
1107 const int _ConstructorPropertiesCount ,
1108 wxVariantToObjectConverter _PtrConverter1 ,
1109 wxVariantToObjectConverter _Converter2 ,
1110 wxObjectToVariantConverter _Converter3
1111 ) : m_parents(_Parents) , m_unitName(_UnitName) ,m_className(_ClassName),
1112 m_objectSize(size), m_objectConstructor(ctor) , m_firstProperty(_Props ) , m_firstHandler(_Handlers ) , m_constructor( _Constructor ) ,
1113 m_constructorProperties(_ConstructorProperties) , m_constructorPropertiesCount(_ConstructorPropertiesCount),
1114 m_variantOfPtrToObjectConverter( _PtrConverter1 ) , m_variantToObjectConverter( _Converter2 ) , m_objectToVariantConverter( _Converter3 ) , m_next(sm_first)
1115 {
1116 sm_first = this;
1117 Register() ;
1118 }
1119
1120 wxClassInfo(const wxChar *_UnitName, const wxChar *_ClassName, const wxClassInfo **_Parents) : m_parents(_Parents) , m_unitName(_UnitName) ,m_className(_ClassName),
1121 m_objectSize(0), m_objectConstructor(NULL) , m_firstProperty(NULL ) , m_firstHandler(NULL ) , m_constructor( NULL ) ,
1122 m_constructorProperties(NULL) , m_constructorPropertiesCount(NULL),
1123 m_variantOfPtrToObjectConverter( NULL ) , m_variantToObjectConverter( NULL ) , m_objectToVariantConverter( NULL ) , m_next(sm_first)
1124 {
1125 sm_first = this;
1126 Register() ;
1127 }
1128
1129 virtual ~wxClassInfo() ;
1130
1131 // allocates an instance of this class, this object does not have to be initialized or fully constructed
1132 // as this call will be followed by a call to Create
1133 virtual wxObject *AllocateObject() const { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
1134
1135 // 'old naming' for AllocateObject staying here for backward compatibility
1136 wxObject *CreateObject() const { return AllocateObject() ; }
1137
1138 const wxChar *GetClassName() const { return m_className; }
1139 const wxClassInfo **GetParents() const { return m_parents; }
1140 int GetSize() const { return m_objectSize; }
1141
1142 wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
1143 static const wxClassInfo *GetFirst() { return sm_first; }
1144 const wxClassInfo *GetNext() const { return m_next; }
1145 static wxClassInfo *FindClass(const wxChar *className);
1146
1147 // Climb upwards through inheritance hierarchy.
1148 // Dual inheritance is catered for.
1149
1150 bool IsKindOf(const wxClassInfo *info) const
1151 {
1152 if ( info != 0 )
1153 {
1154 if ( info == this )
1155 return true ;
1156
1157 for ( int i = 0 ; m_parents[i] ; ++ i )
1158 {
1159 if ( m_parents[i]->IsKindOf( info ) )
1160 return true ;
1161 }
1162 }
1163 return false ;
1164 }
1165
1166 #ifdef WXWIN_COMPATIBILITY_2_4
1167 // Initializes parent pointers and hash table for fast searching.
1168 wxDEPRECATED( static void InitializeClasses() );
1169 // Cleans up hash table used for fast searching.
1170 wxDEPRECATED( static void CleanUpClasses() );
1171 #endif
1172 static void CleanUp();
1173
1174 // returns the first property
1175 const wxPropertyInfo* GetFirstProperty() const { return m_firstProperty ; }
1176
1177 // returns the first handler
1178 const wxHandlerInfo* GetFirstHandler() const { return m_firstHandler ; }
1179
1180 // Call the Create upon an instance of the class, in the end the object is fully
1181 // initialized
1182 virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const
1183 {
1184 wxASSERT_MSG( ParamCount == m_constructorPropertiesCount , wxT("Illegal Parameter Count for Create Method")) ;
1185 m_constructor->Create( object , Params ) ;
1186 }
1187
1188 // get number of parameters for constructor
1189 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount; }
1190
1191 // get n-th constructor parameter
1192 virtual const wxChar* GetCreateParamName(int n) const { return m_constructorProperties[n] ; }
1193
1194 // Runtime access to objects for simple properties (get/set) by property name, and variant data
1195 virtual void SetProperty (wxObject *object, const wxChar *propertyName, const wxxVariant &value) const ;
1196 virtual wxxVariant GetProperty (wxObject *object, const wxChar *propertyName) const;
1197
1198 // Runtime access to objects for collection properties by property name
1199 virtual wxxVariantArray GetPropertyCollection(wxObject *object, const wxChar *propertyName) const ;
1200 virtual void AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const ;
1201
1202 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1203 wxObject* VariantToInstance( wxxVariant &data ) const
1204 { if ( data.GetTypeInfo()->GetKind() == wxT_OBJECT )
1205 return m_variantToObjectConverter( data ) ;
1206 else
1207 return m_variantOfPtrToObjectConverter( data ) ;
1208 }
1209
1210 wxxVariant InstanceToVariant( wxObject *object ) const { return m_objectToVariantConverter( object ) ; }
1211
1212 // find property by name
1213 virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const ;
1214
1215 // find handler by name
1216 virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *PropertyName) const ;
1217
1218 // find property by name
1219 virtual const wxPropertyInfo *FindPropertyInfoInThisClass (const wxChar *PropertyName) const ;
1220
1221 // find handler by name
1222 virtual const wxHandlerInfo *FindHandlerInfoInThisClass (const wxChar *PropertyName) const ;
1223 public:
1224 const wxChar *m_className;
1225 int m_objectSize;
1226 wxObjectConstructorFn m_objectConstructor;
1227
1228 // class info object live in a linked list:
1229 // pointers to its head and the next element in it
1230
1231 static wxClassInfo *sm_first;
1232 wxClassInfo *m_next;
1233
1234 // FIXME: this should be private (currently used directly by way too
1235 // many clients)
1236 static wxHashTable *sm_classTable;
1237
1238 protected :
1239 wxPropertyInfo * m_firstProperty ;
1240 wxHandlerInfo * m_firstHandler ;
1241 private:
1242 const wxClassInfo** m_parents ;
1243 const wxChar* m_unitName;
1244
1245 wxConstructorBridge* m_constructor ;
1246 const wxChar ** m_constructorProperties ;
1247 const int m_constructorPropertiesCount ;
1248 wxVariantToObjectConverter m_variantOfPtrToObjectConverter ;
1249 wxVariantToObjectConverter m_variantToObjectConverter ;
1250 wxObjectToVariantConverter m_objectToVariantConverter ;
1251
1252 const wxPropertyAccessor *FindAccessor (const wxChar *propertyName) const ;
1253
1254
1255 // InitializeClasses() helper
1256 static wxClassInfo *GetBaseByName(const wxChar *name) ;
1257
1258 protected:
1259 // registers the class
1260 void Register();
1261 void Unregister();
1262
1263 DECLARE_NO_COPY_CLASS(wxClassInfo)
1264 };
1265
1266
1267 WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name);
1268
1269 // ----------------------------------------------------------------------------
1270 // wxDynamicObject
1271 // ----------------------------------------------------------------------------
1272 //
1273 // this object leads to having a pure runtime-instantiation
1274
1275 class wxDynamicClassInfo : public wxClassInfo
1276 {
1277 public :
1278 wxDynamicClassInfo( const wxChar *_UnitName, const wxChar *_ClassName , const wxClassInfo* superClass ) ;
1279 virtual ~wxDynamicClassInfo() ;
1280
1281 // constructs a wxDynamicObject with an instance
1282 virtual wxObject *AllocateObject() const ;
1283
1284 // Call the Create method for a class
1285 virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params) const ;
1286
1287 // get number of parameters for constructor
1288 virtual int GetCreateParamCount() const ;
1289
1290 // get i-th constructor parameter
1291 virtual const wxChar* GetCreateParamName(int i) const ;
1292
1293 // Runtime access to objects by property name, and variant data
1294 virtual void SetProperty (wxObject *object, const wxChar *PropertyName, const wxxVariant &Value) const ;
1295 virtual wxxVariant GetProperty (wxObject *object, const wxChar *PropertyName) const ;
1296
1297 void AddProperty( const wxChar *propertyName , const wxTypeInfo* typeInfo ) ;
1298 void AddHandler( const wxChar *handlerName , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) ;
1299 } ;
1300
1301 // ----------------------------------------------------------------------------
1302 // Dynamic class macros
1303 // ----------------------------------------------------------------------------
1304
1305 #define _DECLARE_DYNAMIC_CLASS(name) \
1306 public: \
1307 static wxClassInfo sm_class##name; \
1308 static const wxClassInfo* sm_classParents##name[] ; \
1309 static wxPropertyInfo* GetPropertiesStatic() ; \
1310 static wxHandlerInfo* GetHandlersStatic() ; \
1311 virtual wxClassInfo *GetClassInfo() const \
1312 { return &name::sm_class##name; }
1313
1314 #define DECLARE_DYNAMIC_CLASS(name) \
1315 static wxConstructorBridge* sm_constructor##name ; \
1316 static const wxChar * sm_constructorProperties##name[] ; \
1317 static const int sm_constructorPropertiesCount##name ; \
1318 _DECLARE_DYNAMIC_CLASS(name)
1319
1320 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1321 DECLARE_NO_ASSIGN_CLASS(name) \
1322 DECLARE_DYNAMIC_CLASS(name)
1323
1324 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1325 DECLARE_NO_COPY_CLASS(name) \
1326 DECLARE_DYNAMIC_CLASS(name)
1327
1328 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1329 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1330
1331 // -----------------------------------
1332 // for concrete classes
1333 // -----------------------------------
1334
1335 // Single inheritance with one base class
1336
1337 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
1338 wxObject* wxConstructorFor##name() \
1339 { return new name; } \
1340 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1341 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1342 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1343 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1344 (int) sizeof(name), \
1345 (wxObjectConstructorFn) wxConstructorFor##name , \
1346 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1347 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name); \
1348 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1349 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1350 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1351 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1352 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1353 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1354 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1355 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1356 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1357
1358 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \
1359 wxObject* wxConstructorFor##name() \
1360 { return new name; } \
1361 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1362 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1363 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1364 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1365 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1366 (int) sizeof(name), \
1367 (wxObjectConstructorFn) wxConstructorFor##name , \
1368 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1369 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1370 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1371 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1372 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1373 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1374 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1375 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1376 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1377 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1378 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1379
1380 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1381 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \
1382 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1383 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1384 WX_CONSTRUCTOR_DUMMY( name )
1385
1386 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1387 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
1388 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1389 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1390 WX_CONSTRUCTOR_DUMMY( name )
1391
1392 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1393 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
1394
1395 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1396 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
1397
1398 // this is for classes that do not derive from wxobject, there are no creators for these
1399
1400 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1401 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1402 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1403 (int) sizeof(name), \
1404 (wxObjectConstructorFn) 0 , \
1405 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1406 0 , 0 , 0 ); \
1407 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1408 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1409 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1410 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1411 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1412 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1413 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1414
1415 // this is for subclasses that still do not derive from wxobject
1416
1417 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1418 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1419 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1420 (int) sizeof(name), \
1421 (wxObjectConstructorFn) 0 , \
1422 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1423 0 , 0 , 0 ); \
1424 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1425 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1426 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1427 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1428 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1429 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1430 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1431
1432
1433 // Multiple inheritance with two base classes
1434
1435 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1436 wxObject* wxConstructorFor##name() \
1437 { return new name; } \
1438 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1439 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1440 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1441 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1442 (int) sizeof(name), \
1443 (wxObjectConstructorFn) wxConstructorFor##name , \
1444 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1445 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1446 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1447 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1448 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1449 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1450 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1451 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1452 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1453
1454 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1455 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1456 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1457 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1458 WX_CONSTRUCTOR_DUMMY( name )
1459
1460 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1461 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1462
1463 // -----------------------------------
1464 // for abstract classes
1465 // -----------------------------------
1466
1467 // Single inheritance with one base class
1468
1469 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1470 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1471 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1472 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1473 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1474 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1475 (int) sizeof(name), \
1476 (wxObjectConstructorFn) 0 , \
1477 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1478 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1479 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1480 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1481 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1482 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1483 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1484 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1485 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1486
1487 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1488 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1489 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1490 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1491
1492 // Multiple inheritance with two base classes
1493
1494 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1495 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1496 wxT(#basename2), (int) sizeof(name), \
1497 (wxObjectConstructorFn) 0);
1498
1499 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1500 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
1501
1502 // --------------------------------------------------------------------------
1503 // Collection Support
1504 // --------------------------------------------------------------------------
1505
1506 template<typename collection_t> void wxListCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value )
1507 {
1508 collection_t::compatibility_iterator current = coll.GetFirst() ;
1509 while (current)
1510 {
1511 value.Add( new wxxVariant(current->GetData()) ) ;
1512 current = current->GetNext();
1513 }
1514 }
1515
1516 template<typename collection_t> void wxArrayCollectionToVariantArray( const collection_t& coll , wxxVariantArray &value )
1517 {
1518 for( int i = 0 ; i < coll.GetCount() ; i++ )
1519 {
1520 value.Add( new wxxVariant(coll[i]) ) ;
1521 }
1522 }
1523
1524
1525 #endif