Warning fixes (still does not compile).
[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(__APPLE__)
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<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e) ; return &s_typeInfo ; } \
113 template<> void wxStringReadValue(const wxString& s , e &data ) \
114 { \
115 data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
116 } \
117 template<> void wxStringWriteValue(wxString &s , const e &data ) \
118 { \
119 s = s_enumData##e.GetEnumMemberName((int)data) ; \
120 }
121
122 // ----------------------------------------------------------------------------
123 // Set Support
124 //
125 // in the header :
126 //
127 // enum wxFlavor
128 // {
129 // Vanilla,
130 // Chocolate,
131 // Strawberry,
132 // };
133 //
134 // typedef wxSet<wxFlavor> wxCoupe ;
135 //
136 // in the implementation file :
137 //
138 // WX_BEGIN_ENUM( wxFlavor )
139 // WX_ENUM_MEMBER( Vanilla )
140 // WX_ENUM_MEMBER( Chocolate )
141 // WX_ENUM_MEMBER( Strawberry )
142 // WX_END_ENUM( wxFlavor )
143 //
144 // WX_IMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor )
145 //
146 // implementation note : no partial specialization for streaming, but a delegation to a
147 // different class
148 //
149 // ----------------------------------------------------------------------------
150
151 // in order to remove dependancy on string tokenizer
152 void wxSetStringToArray( const wxString &s , wxArrayString &array ) ;
153
154 template<typename e>
155 void wxSetFromString(const wxString &s , wxSet<e> &data )
156 {
157 wxEnumData* edata = wxGetEnumData((e) 0) ;
158 data.Clear() ;
159
160 wxArrayString array ;
161 wxSetStringToArray( s , array ) ;
162 wxString flag;
163 for ( int i = 0 ; i < array.Count() ; ++i )
164 {
165 flag = array[i] ;
166 int ivalue ;
167 if ( edata->HasEnumMemberValue( flag , &ivalue ) )
168 {
169 data.Set( (e) ivalue ) ;
170 }
171 }
172 }
173
174 template<typename e>
175 void wxSetToString( wxString &s , const wxSet<e> &data )
176 {
177 wxEnumData* edata = wxGetEnumData((e) 0) ;
178 int count = edata->GetEnumCount() ;
179 int i ;
180 s.Clear() ;
181 for ( i = 0 ; i < count ; i++ )
182 {
183 e value = (e) edata->GetEnumMemberValueByIndex(i) ;
184 if ( data.Contains( value ) )
185 {
186 // this could also be done by the templated calls
187 if ( !s.IsEmpty() )
188 s +="|" ;
189 s += edata->GetEnumMemberNameByIndex(i) ;
190 }
191 }
192 }
193
194 // if the wxSet specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro
195 // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; }
196
197 #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \
198 template<> void wxStringReadValue(const wxString &s , wxSet<e> &data ) \
199 { \
200 wxSetFromString( s , data ) ; \
201 } \
202 template<> void wxStringWriteValue( wxString &s , const wxSet<e> &data ) \
203 { \
204 wxSetToString( s , data ) ; \
205 } \
206
207
208 // ----------------------------------------------------------------------------
209 // Type Information
210 // ----------------------------------------------------------------------------
211
212 enum wxTypeKind
213 {
214 wxT_VOID = 0, // unknown type
215 wxT_BOOL,
216 wxT_CHAR,
217 wxT_UCHAR,
218 wxT_INT,
219 wxT_UINT,
220 wxT_LONG,
221 wxT_ULONG,
222 wxT_FLOAT,
223 wxT_DOUBLE,
224 wxT_STRING, // must be wxString
225 wxT_SET, // must be wxSet<> template
226 wxT_ENUM,
227 wxT_OBJECT, // must be a component (pointer !!!)
228 wxT_CUSTOM, // user defined type (e.g. wxPoint)
229 wxT_DELEGATE , // for connecting against an event source
230 wxT_LAST_TYPE_KIND // sentinel for bad data, asserts, debugging
231 };
232
233 class WXDLLIMPEXP_BASE wxTypeInfo
234 {
235 public :
236 wxTypeInfo() : m_kind( wxT_VOID) {}
237 virtual ~wxTypeInfo() {}
238 wxTypeKind GetKind() const { return m_kind ; }
239 protected :
240 wxTypeKind m_kind ;
241 };
242
243 class WXDLLIMPEXP_BASE wxBuiltInTypeInfo : public wxTypeInfo
244 {
245 public :
246 wxBuiltInTypeInfo( wxTypeKind kind ) { wxASSERT_MSG( kind < wxT_SET , wxT("Illegal Kind for Base Type") ) ; m_kind = kind ;}
247 } ;
248
249 class WXDLLIMPEXP_BASE wxCustomTypeInfo : public wxTypeInfo
250 {
251 public :
252 wxCustomTypeInfo( const wxChar *typeName )
253 { m_kind = wxT_CUSTOM ; m_typeName = typeName ;}
254 const wxChar *GetTypeName() const { return m_typeName ; }
255 private :
256 const wxChar *m_typeName; // Kind == wxT_CUSTOM
257 } ;
258
259 class WXDLLIMPEXP_BASE wxEnumTypeInfo : public wxTypeInfo
260 {
261 public :
262 wxEnumTypeInfo( wxTypeKind kind , wxEnumData* enumInfo )
263 { wxASSERT_MSG( kind == wxT_ENUM || kind == wxT_SET , wxT("Illegal Kind for Enum Type")) ; m_kind = kind ; m_enumInfo = enumInfo ;}
264 const wxEnumData* GetEnumData() const { return m_enumInfo ; }
265 private :
266 wxEnumData *m_enumInfo; // Kind == wxT_ENUM or Kind == wxT_SET
267 } ;
268
269 class WXDLLIMPEXP_BASE wxClassTypeInfo : public wxTypeInfo
270 {
271 public :
272 wxClassTypeInfo( wxClassInfo* classInfo )
273 { m_kind = wxT_OBJECT ; m_classInfo = classInfo ;}
274 const wxClassInfo *GetClassInfo() const { return m_classInfo ; }
275 private :
276 wxClassInfo *m_classInfo; // Kind == wxT_OBJECT - could be NULL
277 } ;
278
279 // a delegate is an exposed event source
280
281 class WXDLLIMPEXP_BASE wxDelegateTypeInfo : public wxTypeInfo
282 {
283 public :
284 wxDelegateTypeInfo( int eventType , wxClassInfo* eventClass )
285 { m_kind = wxT_DELEGATE ; m_eventClass = eventClass ; m_eventType = eventType ;}
286 const wxClassInfo *GetEventClass() const { assert( m_kind == wxT_DELEGATE ) ; return m_eventClass ; }
287 int GetEventType() const { return m_eventType ; }
288 private :
289 const wxClassInfo *m_eventClass; // (extended will merge into classinfo)
290 int m_eventType ;
291 } ;
292
293 template<typename T> const wxTypeInfo* wxGetTypeInfo( T * ) ;
294
295 template<typename T> const wxTypeInfo* wxGetTypeInfo( wxSet<T> * )
296 {
297 static wxEnumTypeInfo s_typeInfo(wxT_SET , wxGetEnumData((T) 0) ) ; return &s_typeInfo ;
298 }
299
300 // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
301
302 #define WX_CUSTOM_TYPE_INFO( e ) \
303 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e) ; return &s_typeInfo ; } \
304
305 // ----------------------------------------------------------------------------
306 // value streaming
307 //
308 // streaming is defined for xml constructs right now, the aim is to make this
309 // pluggable in the future
310 // ----------------------------------------------------------------------------
311
312 // convenience function (avoids including xml headers in users code)
313
314 class wxXmlNode ;
315 void wxXmlAddContentToNode( wxXmlNode* node , const wxString& data ) ;
316 wxString wxXmlGetContentFromNode( wxXmlNode *node ) ;
317
318 // templated streaming, every type must have their specialization for these methods
319
320 template<typename T>
321 void wxStringReadValue( const wxString &s , T &data ) ;
322
323 template<typename T>
324 void wxStringWriteValue( wxString &s , const T &data) ;
325
326 // for simple types this default implementation is ok, composited structures will have to
327 // loop through their properties
328
329 template<typename T>
330 void wxXmlReadValue( wxXmlNode *node , T &data )
331 {
332 wxStringReadValue<T>( wxXmlGetContentFromNode( node ) , data ) ;
333 }
334
335 template<typename T>
336 void wxXmlWriteValue( wxXmlNode *node , const T &data)
337 {
338 wxString s ;
339 wxStringWriteValue<T>( s, data ) ;
340 wxXmlAddContentToNode( node ,s ) ;
341 }
342
343 // ----------------------------------------------------------------------------
344 // wxxVariant as typesafe data holder
345 // ----------------------------------------------------------------------------
346
347 class WXDLLIMPEXP_BASE wxxVariantData
348 {
349 public:
350 virtual ~wxxVariantData() {}
351
352 // return a heap allocated duplicate
353 virtual wxxVariantData* Clone() const = 0 ;
354
355 // returns the type info of the contentc
356 virtual const wxTypeInfo* GetTypeInfo() const = 0 ;
357
358 // write the value into an xml node
359 virtual void Write( wxXmlNode* node ) const = 0 ;
360
361 // read the value from the xml node
362 virtual void Read( wxXmlNode* node ) = 0 ;
363
364 // write the value into a string
365 virtual void Write( wxString &s ) const = 0 ;
366
367 // read the value from a string
368 virtual void Read( const wxString &s) = 0 ;
369 } ;
370
371 template<typename T> class WXDLLIMPEXP_BASE wxxVariantDataT : public wxxVariantData
372 {
373 public:
374 wxxVariantDataT(T d) : m_data(d) {}
375 virtual ~wxxVariantDataT() {}
376
377 // get a copy of the stored data
378 T Get() const { return m_data; }
379
380 // set the data
381 void Set(T d) { m_data = d; }
382
383 // return a heap allocated duplicate
384 virtual wxxVariantData* Clone() const { return new wxxVariantDataT<T>( Get() ) ; }
385
386 // returns the type info of the contentc
387 virtual const wxTypeInfo* GetTypeInfo() const { return wxGetTypeInfo( (T*) NULL ) ; }
388
389 // write the value into an xml node
390 virtual void Write( wxXmlNode* node ) const { wxXmlWriteValue( node , m_data ) ; }
391
392 // read the value from the xml node
393 virtual void Read( wxXmlNode* node ) { wxXmlReadValue( node , m_data ) ; }
394
395 // write the value into a string
396 virtual void Write( wxString &s ) const { wxStringWriteValue( s , m_data ) ; }
397
398 // read the value from a string
399 virtual void Read( const wxString &s) { wxStringReadValue( s , m_data ) ; }
400
401 private:
402 T m_data;
403 };
404
405 class WXDLLIMPEXP_BASE wxxVariant
406 {
407 public :
408 wxxVariant() { m_data = NULL ; }
409 wxxVariant( wxxVariantData* data , const wxString& name = wxT("") ) : m_data(data) , m_name(name) {}
410 wxxVariant( const wxxVariant &d ) { if ( d.m_data ) m_data = d.m_data->Clone() ; else m_data = NULL ; m_name = d.m_name ; }
411
412 template<typename T> wxxVariant( T data , const wxString& name = wxT("") ) :
413 m_data(new wxxVariantDataT<T>(data) ), m_name(name) {}
414 ~wxxVariant() { delete m_data ; }
415
416 // get a copy of the stored data
417 template<typename T> T Get() const
418 {
419 wxxVariantDataT<T> *dataptr = dynamic_cast<wxxVariantDataT<T>*> (m_data) ;
420 wxASSERT_MSG( dataptr , "Cast not possible" ) ;
421 return dataptr->Get() ;
422 }
423
424 // stores the data
425 template<typename T> void Set(T data) const
426 {
427 delete m_data ;
428 m_data = new wxxVariantDataT<T>(data) ;
429 }
430
431 wxxVariant& operator=(const wxxVariant &d)
432 {
433 m_data = d.m_data->Clone() ;
434 m_name = d.m_name ;
435 return *this ;
436 }
437
438 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
439 wxObject* GetAsObject() const ;
440
441 // write the value into an xml node
442 void Write( wxXmlNode* node ) const { m_data->Write( node ) ; }
443
444 // read the value from the xml node
445 void Read( wxXmlNode* node ) { m_data->Read( node ) ; }
446
447 // write the value into a string
448 void Write( wxString &s ) const { m_data->Write( s ) ; }
449
450 // read the value from a string
451 void Read( const wxString &s) { m_data->Read( s ) ; }
452
453 // returns this value as string
454 wxString GetAsString() const
455 {
456 wxString s ;
457 Write( s ) ;
458 return s ;
459 }
460
461 void SetFromString( const wxString &s)
462 {
463 Read( s ) ;
464 }
465 private :
466 wxxVariantData* m_data ;
467 wxString m_name ;
468 } ;
469
470 // ----------------------------------------------------------------------------
471 // Property Support
472 //
473 // wxPropertyInfo is used to inquire of the property by name. It doesn't
474 // provide access to the property, only information about it. If you
475 // want access, look at wxPropertyAccessor.
476 // ----------------------------------------------------------------------------
477
478 class WXDLLIMPEXP_BASE wxPropertyAccessor
479 {
480 public :
481 class SetByRef ;
482 class SetAndGetByRef ;
483 class GetByRef ;
484 virtual void SetProperty(wxObject *object, const wxxVariant &value) const = 0 ;
485 virtual wxxVariant GetProperty(wxObject *object) const = 0 ;
486 virtual bool HasSetter() const = 0 ;
487 virtual bool HasGetter() const = 0 ;
488 const wxChar * GetGetterName() const { return m_setterName ; }
489 const wxChar * GetSetterName() const { return m_getterName ; }
490 virtual wxxVariant ReadValue( wxXmlNode* node ) const = 0 ;
491 virtual void WriteValue( wxXmlNode* node , wxObject *o ) const = 0 ;
492 virtual wxxVariant ReadValue( const wxString &value ) const = 0 ;
493 virtual void WriteValue( wxString& value , wxObject *o ) const = 0 ;
494 protected :
495 const wxChar *m_setterName ;
496 const wxChar *m_getterName ;
497 };
498
499 template<typename T>
500 void wxXmlReadValue( wxXmlNode *node , T &data ) ;
501
502 template<typename T>
503 void wxXmlWriteValue( wxXmlNode *node , const T &data) ;
504
505 template<class Klass, typename T>
506 class WXDLLIMPEXP_BASE wxPropertyAccessorT : public wxPropertyAccessor
507 {
508 public:
509
510 typedef void (Klass::*setter_t)(T value);
511 typedef void (Klass::*setter_ref_t)(const T& value);
512 typedef T (Klass::*getter_t)() const;
513 typedef const T& (Klass::*getter_ref_t)() const;
514
515 wxPropertyAccessorT(setter_t setter, getter_t getter, const wxChar *g, const wxChar *s)
516 : m_setter(setter), m_setter_ref(NULL), m_getter(getter) ,m_getter_ref(NULL) {m_setterName = s;m_getterName=g ;}
517
518 wxPropertyAccessorT( getter_t getter, const wxChar *g)
519 : m_setter(NULL), m_setter_ref(NULL), m_getter(getter) ,m_getter_ref(NULL) {m_setterName = "";m_getterName=g ;}
520
521 wxPropertyAccessorT(SetByRef*, setter_ref_t setter, getter_t getter, const wxChar *g, const wxChar *s)
522 : m_setter(NULL), m_setter_ref(setter), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;}
523
524 // wxPropertyAccessorT(setter_ref_t setter, getter_t getter, const wxChar *g, const wxChar *s)
525 // : m_setter(NULL), m_setter_ref(setter), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;}
526
527 wxPropertyAccessorT(SetAndGetByRef*, setter_ref_t setter, getter_ref_t getter, const wxChar *g, const wxChar *s)
528 : m_setter(NULL), m_setter_ref(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
529
530 // wxPropertyAccessorT(setter_ref_t setter, getter_ref_t getter, const wxChar *g, const wxChar *s)
531 // : m_setter(NULL), m_setter_ref(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
532
533 // wxPropertyAccessorT(setter_t setter, getter_ref_t getter, const wxChar *g, const wxChar *s)
534 // : m_setter(NULL), m_setter(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
535
536 wxPropertyAccessorT(GetByRef*, setter_t setter, getter_ref_t getter, const wxChar *g, const wxChar *s)
537 : m_setter(NULL), m_setter(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
538
539 // wxPropertyAccessorT( getter_ref_t getter, const wxChar *g)
540 // : m_setter(NULL), m_setter(NULL), m_getter(NULL) , m_getter_ref(getter){m_setterName = "";m_getterName=g ;}
541
542 // returns true if this accessor has a setter
543 bool HasSetter() const { return m_setter != NULL || m_setter_ref != NULL ; }
544
545 // return true if this accessor has a getter
546 bool HasGetter() const { return m_getter != NULL || m_getter_ref != NULL ; }
547
548 // set the property this accessor is responsible for in an object
549 void SetProperty(wxObject *o, const wxxVariant &v) const
550 {
551 Klass *obj = dynamic_cast<Klass*>(o);
552 T value = v.Get<T>();
553 if (m_setter)
554 (obj->*(m_setter))(value);
555 else
556 (obj->*(m_setter_ref))(value);
557 }
558
559 // gets the property this accessor is responsible for from an object
560 wxxVariant GetProperty(wxObject *o) const
561 {
562 return wxxVariant( (wxxVariantData* ) DoGetProperty( o ) ) ;
563 }
564
565 // write the property this accessor is responsible for from an object into
566 // a xml node
567 void WriteValue( wxXmlNode* node , wxObject *o ) const
568 {
569 DoGetProperty( o )->Write( node ) ;
570 }
571
572 // write the property this accessor is responsible for from an object into
573 // a string
574 void WriteValue( wxString& s , wxObject *o ) const
575 {
576 DoGetProperty( o )->Write( s ) ;
577 }
578
579 // read a wxxVariant having the correct type for the property this accessor
580 // is responsible for from an xml node
581 wxxVariant ReadValue( wxXmlNode* node ) const
582 {
583 T data ;
584 wxXmlReadValue( node , data ) ;
585 return wxxVariant( data ) ;
586 }
587
588 // read a wxxVariant having the correct type for the property this accessor
589 // is responsible for from a string
590 wxxVariant ReadValue( const wxString &value ) const
591 {
592 T data ;
593 wxStringReadValue( value , data ) ;
594 return wxxVariant( data ) ;
595 }
596
597 private :
598 wxxVariantDataT<T>* DoGetProperty(wxObject *o) const
599 {
600 Klass *obj = dynamic_cast<Klass*>(o);
601 if ( m_getter )
602 return new wxxVariantDataT<T>( (obj->*(m_getter))() ) ;
603 else
604 return new wxxVariantDataT<T>( (obj->*(m_getter_ref))() ) ;
605 }
606
607 setter_t m_setter;
608 setter_ref_t m_setter_ref;
609 getter_t m_getter;
610 getter_ref_t m_getter_ref ;
611 };
612
613 class WXDLLIMPEXP_BASE wxPropertyInfo
614 {
615 public :
616 wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxChar *typeName , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv ) :
617 m_name( name ) , m_typeName(typeName) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv )
618 {
619 m_next = NULL ;
620 if ( iter == NULL )
621 iter = this ;
622 else
623 {
624 wxPropertyInfo* i = iter ;
625 while( i->m_next )
626 i = i->m_next ;
627
628 i->m_next = this ;
629 }
630 }
631 // return the name of this property
632 const wxChar * GetName() const { return m_name ; }
633
634 // return the typename of this property
635 const wxChar * GetTypeName() const { return m_typeName ; }
636
637 // return the type info of this property
638 const wxTypeInfo * GetTypeInfo() const { return m_typeInfo ; }
639
640 // return the accessor for this property
641 wxPropertyAccessor* GetAccessor() const { return m_accessor ; }
642
643 // returns NULL if this is the last property of this class
644 wxPropertyInfo* GetNext() const { return m_next ; }
645
646 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
647 wxxVariant GetDefaultValue() const { return m_defaultValue ; }
648 private :
649 const wxChar * m_name;
650 const wxChar * m_typeName ;
651 const wxTypeInfo* m_typeInfo ;
652 wxPropertyAccessor* m_accessor ;
653 wxxVariant m_defaultValue;
654 // string representation of the default value
655 // to be assigned by the designer to the property
656 // when the component is dropped on the container.
657 wxPropertyInfo* m_next ;
658 };
659
660 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
661 const wxPropertyInfo *theClass::GetPropertiesStatic() \
662 { \
663 typedef theClass class_t; \
664 static wxPropertyInfo* first = NULL ;
665
666 #define WX_END_PROPERTIES_TABLE() \
667 return first ; }
668
669 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
670 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
671 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
672
673 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
674 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRef*)NULL, &setter , &getter , #setter , #getter ) ; \
675 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
676
677 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
678 static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
679 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
680
681 #define WX_DELEGATE( name , eventType , eventClass ) \
682 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
683 static wxPropertyInfo _propertyInfo##name( first , #name , NULL , &_typeInfo##name , NULL , wxxVariant() ) ; \
684
685 // ----------------------------------------------------------------------------
686 // Handler Info
687 //
688 // this is describing an event sink
689 // ----------------------------------------------------------------------------
690
691 class wxHandlerInfo
692 {
693 public :
694 wxHandlerInfo( wxHandlerInfo* &iter , const wxChar *name , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) :
695 m_eventFunction( address ) , m_name( name ) , m_eventClassInfo( eventClassInfo )
696 {
697 m_next = NULL ;
698 if ( iter == NULL )
699 iter = this ;
700 else
701 {
702 wxHandlerInfo* i = iter ;
703 while( i->m_next )
704 i = i->m_next ;
705
706 i->m_next = this ;
707 }
708 }
709
710 // get the name of the handler method
711 const wxChar * GetName() const { return m_name ; }
712
713 // return the class info of the event
714 const wxClassInfo * GetEventClassInfo() const { return m_eventClassInfo ; }
715
716 // get the handler function pointer
717 wxObjectEventFunction GetEventFunction() const { return m_eventFunction ; }
718
719 // returns NULL if this is the last handler of this class
720 wxHandlerInfo* GetNext() const { return m_next ; }
721 private :
722 wxObjectEventFunction m_eventFunction ;
723 const wxChar * m_name;
724 const wxClassInfo* m_eventClassInfo ;
725 wxHandlerInfo* m_next ;
726 };
727
728 #define WX_HANDLER(name,eventClassType) \
729 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
730
731 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
732 const wxHandlerInfo *theClass::GetHandlersStatic() \
733 { \
734 typedef theClass class_t; \
735 static wxHandlerInfo* first = NULL ;
736
737 #define WX_END_HANDLERS_TABLE() \
738 return first ; }
739
740 // ----------------------------------------------------------------------------
741 // Constructor Bridges
742 //
743 // allow to set up constructors with params during runtime
744 // ----------------------------------------------------------------------------
745
746 class WXDLLIMPEXP_BASE wxConstructorBridge
747 {
748 public :
749 virtual void Create(wxObject *o, wxxVariant *args) = 0;
750 };
751
752 // Creator Bridges for all Numbers of Params
753
754 // no params
755
756 template<typename Class>
757 struct wxConstructorBridge_0 : public wxConstructorBridge
758 {
759 void Create(wxObject *o, wxxVariant *)
760 {
761 Class *obj = dynamic_cast<Class*>(o);
762 obj->Create();
763 }
764 };
765
766 struct wxConstructorBridge_Dummy : public wxConstructorBridge
767 {
768 void Create(wxObject *, wxxVariant *)
769 {
770 }
771 } ;
772
773 #define WX_CONSTRUCTOR_0(klass) \
774 wxConstructorBridge_0<klass> constructor##klass ; \
775 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
776 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
777 const int klass::sm_constructorPropertiesCount##klass = 0 ;
778
779 #define WX_CONSTRUCTOR_DUMMY(klass) \
780 wxConstructorBridge_Dummy constructor##klass ; \
781 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
782 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
783 const int klass::sm_constructorPropertiesCount##klass = 0 ;
784
785 // 1 param
786
787 template<typename Class, typename T0>
788 struct wxConstructorBridge_1 : public wxConstructorBridge
789 {
790 void Create(wxObject *o, wxxVariant *args)
791 {
792 Class *obj = dynamic_cast<Class*>(o);
793 obj->Create(
794 args[0].Get<T0>()
795 );
796 }
797 };
798
799 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
800 wxConstructorBridge_1<klass,t0> constructor##klass ; \
801 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
802 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
803 const int klass::sm_constructorPropertiesCount##klass = 1 ;
804
805 // 2 params
806
807 template<typename Class,
808 typename T0, typename T1>
809 struct wxConstructorBridge_2 : public wxConstructorBridge
810 {
811 void Create(wxObject *o, wxxVariant *args)
812 {
813 Class *obj = dynamic_cast<Class*>(o);
814 obj->Create(
815 args[0].Get<T0>() ,
816 args[1].Get<T1>()
817 );
818 }
819 };
820
821 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
822 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
823 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
824 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
825 const int klass::sm_constructorPropertiesCount##klass = 2;
826
827 // 3 params
828
829 template<typename Class,
830 typename T0, typename T1, typename T2>
831 struct wxConstructorBridge_3 : public wxConstructorBridge
832 {
833 void Create(wxObject *o, wxxVariant *args)
834 {
835 Class *obj = dynamic_cast<Class*>(o);
836 obj->Create(
837 args[0].Get<T0>() ,
838 args[1].Get<T1>() ,
839 args[2].Get<T2>()
840 );
841 }
842 };
843
844 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
845 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
846 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
847 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
848 const int klass::sm_constructorPropertiesCount##klass = 3 ;
849
850 // 4 params
851
852 template<typename Class,
853 typename T0, typename T1, typename T2, typename T3>
854 struct wxConstructorBridge_4 : public wxConstructorBridge
855 {
856 void Create(wxObject *o, wxxVariant *args)
857 {
858 Class *obj = dynamic_cast<Class*>(o);
859 obj->Create(
860 args[0].Get<T0>() ,
861 args[1].Get<T1>() ,
862 args[2].Get<T2>() ,
863 args[3].Get<T3>()
864 );
865 }
866 };
867
868 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
869 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
870 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
871 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
872 const int klass::sm_constructorPropertiesCount##klass = 4 ;
873
874 // 5 params
875
876 template<typename Class,
877 typename T0, typename T1, typename T2, typename T3, typename T4>
878 struct wxConstructorBridge_5 : public wxConstructorBridge
879 {
880 void Create(wxObject *o, wxxVariant *args)
881 {
882 Class *obj = dynamic_cast<Class*>(o);
883 obj->Create(
884 args[0].Get<T0>() ,
885 args[1].Get<T1>() ,
886 args[2].Get<T2>() ,
887 args[3].Get<T3>() ,
888 args[4].Get<T4>()
889 );
890 }
891 };
892
893 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
894 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
895 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
896 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
897 const int klass::sm_constructorPropertiesCount##klass = 5;
898
899 // ----------------------------------------------------------------------------
900 // wxClassInfo
901 // ----------------------------------------------------------------------------
902
903 typedef wxObject *(*wxObjectConstructorFn)(void);
904 typedef wxObject* (*wxVariantToObjectConverter)( const wxxVariant &data ) ;
905 typedef wxxVariant (*wxObjectToVariantConverter)( wxObject* ) ;
906
907 class WXDLLIMPEXP_BASE wxClassInfo
908 {
909 public:
910 wxClassInfo(const wxClassInfo **_Parents,
911 const wxChar *_UnitName,
912 const wxChar *_ClassName,
913 int size,
914 wxObjectConstructorFn ctor ,
915 const wxPropertyInfo *_Props ,
916 const wxHandlerInfo *_Handlers ,
917 wxConstructorBridge* _Constructor ,
918 const wxChar ** _ConstructorProperties ,
919 const int _ConstructorPropertiesCount ,
920 wxVariantToObjectConverter _Converter1 ,
921 wxObjectToVariantConverter _Converter2
922 ) : m_className(_ClassName), m_objectSize(size),
923 m_objectConstructor(ctor), m_next(sm_first),
924 m_parents(_Parents), m_firstProperty(_Props ),
925 m_firstHandler(_Handlers), m_unitName(_UnitName),
926 m_constructor( _Constructor ),
927 m_constructorProperties(_ConstructorProperties),
928 m_constructorPropertiesCount(_ConstructorPropertiesCount),
929 m_variantToObjectConverter( _Converter1 ),
930 m_objectToVariantConverter( _Converter2 )
931 {
932 sm_first = this;
933 Register( m_className , this ) ;
934 }
935
936 virtual ~wxClassInfo() ;
937
938 wxObject *CreateObject() { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
939
940 const wxChar *GetClassName() const { return m_className; }
941 const wxClassInfo **GetParents() const { return m_parents; }
942 int GetSize() const { return m_objectSize; }
943
944 wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
945 static const wxClassInfo *GetFirst() { return sm_first; }
946 const wxClassInfo *GetNext() const { return m_next; }
947 static wxClassInfo *FindClass(const wxChar *className);
948
949 // Climb upwards through inheritance hierarchy.
950 // Dual inheritance is catered for.
951
952 bool IsKindOf(const wxClassInfo *info) const
953 {
954 if ( info != 0 )
955 {
956 if ( info == this )
957 return true ;
958
959 for ( int i = 0 ; m_parents[i] ; ++ i )
960 {
961 if ( m_parents[i]->IsKindOf( info ) )
962 return true ;
963 }
964 }
965 return false ;
966 }
967
968 // Initializes parent pointers and hash table for fast searching.
969 // this is going to be removed by Register/Unregister calls
970 // in Constructor / Destructor together with making the hash map private
971
972 static void InitializeClasses();
973
974 // Cleans up hash table used for fast searching.
975
976 static void CleanUpClasses();
977
978 // returns the first property
979 const wxPropertyInfo* GetFirstProperty() const { return m_firstProperty ; }
980
981 // returns the first handler
982 const wxHandlerInfo* GetFirstHandler() const { return m_firstHandler ; }
983
984 // Call the Create method for a class
985 virtual void Create (wxObject *object, int ParamCount, wxxVariant *Params)
986 {
987 wxASSERT_MSG( ParamCount == m_constructorPropertiesCount , wxT("Illegal Parameter Count for Create Method")) ;
988 m_constructor->Create( object , Params ) ;
989 }
990
991 // get number of parameters for constructor
992 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount; }
993
994 // get i-th constructor parameter
995 virtual const wxChar* GetCreateParamName(int i) const { return m_constructorProperties[i] ; }
996
997 // Runtime access to objects by property name, and variant data
998 virtual void SetProperty (wxObject *object, const wxChar *PropertyName, const wxxVariant &Value);
999 virtual wxxVariant GetProperty (wxObject *object, const wxChar *PropertyName);
1000
1001 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1002 wxObject* VariantToInstance( const wxxVariant &data ) const { return m_variantToObjectConverter( data ) ; }
1003 wxxVariant InstanceToVariant( wxObject *object ) const { return m_objectToVariantConverter( object ) ; }
1004
1005 // find property by name
1006 virtual const wxPropertyInfo *FindPropertyInfo (const wxChar *PropertyName) const ;
1007
1008 // find handler by name
1009 virtual const wxHandlerInfo *FindHandlerInfo (const wxChar *PropertyName) const ;
1010
1011 public:
1012 const wxChar *m_className;
1013 int m_objectSize;
1014 wxObjectConstructorFn m_objectConstructor;
1015
1016 // class info object live in a linked list:
1017 // pointers to its head and the next element in it
1018
1019 static wxClassInfo *sm_first;
1020 wxClassInfo *m_next;
1021
1022 // FIXME: this should be private (currently used directly by way too
1023 // many clients)
1024 static wxHashTable *sm_classTable;
1025
1026 private:
1027 const wxClassInfo** m_parents ;
1028 const wxPropertyInfo * m_firstProperty ;
1029 const wxHandlerInfo * m_firstHandler ;
1030 const wxChar* m_unitName;
1031
1032 wxConstructorBridge* m_constructor ;
1033 const wxChar ** m_constructorProperties ;
1034 const int m_constructorPropertiesCount ;
1035 wxVariantToObjectConverter m_variantToObjectConverter ;
1036 wxObjectToVariantConverter m_objectToVariantConverter ;
1037
1038 const wxPropertyAccessor *FindAccessor (const wxChar *propertyName);
1039
1040 // registers the class
1041 static void Register(const wxChar *name, wxClassInfo *info);
1042
1043 static void Unregister(const wxChar *name);
1044
1045 // InitializeClasses() helper
1046 static wxClassInfo *GetBaseByName(const wxChar *name);
1047
1048 DECLARE_NO_COPY_CLASS(wxClassInfo)
1049 };
1050
1051 WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxChar *name);
1052
1053 // ----------------------------------------------------------------------------
1054 // Dynamic class macros
1055 // ----------------------------------------------------------------------------
1056
1057 #define _DECLARE_DYNAMIC_CLASS(name) \
1058 public: \
1059 static wxClassInfo sm_class##name; \
1060 static const wxClassInfo* sm_classParents##name[] ; \
1061 static const wxPropertyInfo* GetPropertiesStatic() ; \
1062 static const wxHandlerInfo* GetHandlersStatic() ; \
1063 virtual wxClassInfo *GetClassInfo() const \
1064 { return &name::sm_class##name; }
1065
1066 #define DECLARE_DYNAMIC_CLASS(name) \
1067 _DECLARE_DYNAMIC_CLASS(name) \
1068 static wxConstructorBridge* sm_constructor##name ; \
1069 static const wxChar * sm_constructorProperties##name[] ; \
1070 static const int sm_constructorPropertiesCount##name ;
1071
1072 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1073 DECLARE_NO_ASSIGN_CLASS(name) \
1074 DECLARE_DYNAMIC_CLASS(name)
1075
1076 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1077 DECLARE_NO_COPY_CLASS(name) \
1078 DECLARE_DYNAMIC_CLASS(name)
1079
1080 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1081 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1082
1083 // -----------------------------------
1084 // for concrete classes
1085 // -----------------------------------
1086
1087 // Single inheritance with one base class
1088
1089 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
1090 wxObject* wxConstructorFor##name() \
1091 { return new name; } \
1092 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1093 wxObject* wxVariantToObjectConverter##name ( const wxxVariant &data ) { return data.Get<name*>() ; } \
1094 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1095 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1096 (int) sizeof(name), \
1097 (wxObjectConstructorFn) wxConstructorFor##name , \
1098 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1099 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1100 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1101 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1102 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(&name::sm_class##name) ; return &s_typeInfo ; }
1103
1104 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1105 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
1106 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1107 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1108 WX_CONSTRUCTOR_DUMMY( name )
1109
1110 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1111 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
1112
1113 // this is for classes that do not derive from wxobject, there are no creators for these
1114
1115 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1116 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1117 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1118 (int) sizeof(name), \
1119 (wxObjectConstructorFn) 0 , \
1120 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1121 0 , 0 , 0 ); \
1122 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1123 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1124 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(&name::sm_class##name) ; return &s_typeInfo ; }
1125
1126 // this is for subclasses that still do not derive from wxobject
1127
1128 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1129 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1130 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1131 (int) sizeof(name), \
1132 (wxObjectConstructorFn) 0 , \
1133 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1134 0 , 0 , 0 ); \
1135 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1136 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1137 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(&name::sm_class##name) ; return &s_typeInfo ; }
1138
1139 // Multiple inheritance with two base classes
1140
1141 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1142 wxObject* wxConstructorFor##name() \
1143 { return new name; } \
1144 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1145 wxObject* wxVariantToObjectConverter##name ( const wxxVariant &data ) { return data.Get<name*>() ; } \
1146 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1147 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1148 (int) sizeof(name), \
1149 (wxObjectConstructorFn) wxConstructorFor##name , \
1150 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1151 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1152 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1153 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1154 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(&name::sm_class##name) ; return &s_typeInfo ; }
1155
1156 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1157 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1158 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1159 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1160 WX_CONSTRUCTOR_DUMMY( name )
1161
1162 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1163 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1164
1165 // -----------------------------------
1166 // for abstract classes
1167 // -----------------------------------
1168
1169 // Single inheritance with one base class
1170
1171 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1172 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1173 wxObject* wxVariantToObjectConverter##name ( const wxxVariant &data ) { return data.Get<name*>() ; } \
1174 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1175 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1176 (int) sizeof(name), \
1177 (wxObjectConstructorFn) 0 , \
1178 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1179 0 , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1180 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1181 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1182 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(&name::sm_class##name) ; return &s_typeInfo ; }
1183
1184 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1185 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1186 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1187 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1188
1189 // Multiple inheritance with two base classes
1190
1191 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1192 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1193 wxT(#basename2), (int) sizeof(name), \
1194 (wxObjectConstructorFn) 0);
1195
1196 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1197 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
1198
1199 #endif