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