1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: runtime metadata information (extended class info)
4 // Author: Stefan Csomor
8 // Copyright: (c) 1997 Julian Smart
9 // (c) 2003 Stefan Csomor
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
16 #if defined(__GNUG__) && !defined(__APPLE__)
17 #pragma interface "xti.h"
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.
24 // This means we have the following domains :
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
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
40 #include "wx/memory.h"
42 #include "wx/string.h"
43 #include "wx/arrstr.h"
45 // some compilers have troubles getting the correct wxPropertyAccessorT constructor
46 // set this to 1 to make things work for these, too
48 #define WX_XTI_TEMPLATE_FIX 0
50 #if WX_XTI_TEMPLATE_FIX
51 #define WX_XTI_PARAM_FIX(a,b) a,b
53 #define WX_XTI_PARAM_FIX(a,b)
56 class WXDLLIMPEXP_BASE wxObject
;
57 class WXDLLIMPEXP_BASE wxClassInfo
;
58 class WXDLLIMPEXP_BASE wxHashTable
;
59 class WXDLLIMPEXP_BASE wxObjectRefData
;
60 class WXDLLIMPEXP_BASE wxEvent
;
62 typedef void (wxObject
::*wxObjectEventFunction
)(wxEvent
&);
64 // ----------------------------------------------------------------------------
67 // In the header files there would no change from pure c++ code, in the
68 // implementation, an enum would have
69 // to be enumerated eg :
71 // WX_BEGIN_ENUM( wxFlavor )
72 // WX_ENUM_MEMBER( Vanilla )
73 // WX_ENUM_MEMBER( Chocolate )
74 // WX_ENUM_MEMBER( Strawberry )
75 // WX_END_ENUM( wxFlavor )
76 // ----------------------------------------------------------------------------
78 struct WXDLLIMPEXP_BASE wxEnumMemberData
84 class WXDLLIMPEXP_BASE wxEnumData
87 wxEnumData( wxEnumMemberData
* data
) ;
89 // returns true if the member has been found and sets the int value
90 // pointed to accordingly (if ptr != null )
91 // if not found returns false, value left unchanged
92 bool HasEnumMemberValue( const wxChar
*name
, int *value
= NULL
) ;
94 // returns the value of the member, if not found in debug mode an
95 // assert is issued, in release 0 is returned
96 int GetEnumMemberValue(const wxChar
*name
);
98 // returns the name of the enum member having the passed in value
99 // returns an emtpy string if not found
100 const wxChar
*GetEnumMemberName(int value
);
102 // returns the number of members in this enum
103 int GetEnumCount() { return m_count
; }
105 // returns the value of the nth member
106 int GetEnumMemberValueByIndex( int n
) ;
108 // returns the value of the nth member
109 const wxChar
*GetEnumMemberNameByIndex( int n
) ;
111 wxEnumMemberData
*m_members
;
115 #define WX_BEGIN_ENUM( e ) \
116 wxEnumMemberData s_enumDataMembers##e[] = {
118 #define WX_ENUM_MEMBER( v ) { #v, v } ,
120 #define WX_END_ENUM( e ) { NULL , 0 } } ; \
121 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
122 wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \
123 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e) ; return &s_typeInfo ; } \
124 template<> void wxStringReadValue(const wxString& s , e &data ) \
126 data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
128 template<> void wxStringWriteValue(wxString &s , const e &data ) \
130 s = s_enumData##e.GetEnumMemberName((int)data) ; \
132 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \
133 template<> void wxStringReadValue(const wxString& , e* & ) \
137 template<> void wxStringWriteValue(wxString &s , e* const & ) \
142 // ----------------------------------------------------------------------------
154 // typedef wxSet<wxFlavor> wxCoupe ;
156 // in the implementation file :
158 // WX_BEGIN_ENUM( wxFlavor )
159 // WX_ENUM_MEMBER( Vanilla )
160 // WX_ENUM_MEMBER( Chocolate )
161 // WX_ENUM_MEMBER( Strawberry )
162 // WX_END_ENUM( wxFlavor )
164 // WX_IMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor )
166 // implementation note : no partial specialization for streaming, but a delegation to a
169 // ----------------------------------------------------------------------------
171 // in order to remove dependancy on string tokenizer
172 void wxSetStringToArray( const wxString
&s
, wxArrayString
&array
) ;
175 void wxSetFromString(const wxString
&s
, wxSet
<e
> &data
)
177 wxEnumData
* edata
= wxGetEnumData((e
) 0) ;
180 wxArrayString array
;
181 wxSetStringToArray( s
, array
) ;
183 for ( int i
= 0 ; i
< array
.Count() ; ++i
)
187 if ( edata
->HasEnumMemberValue( flag
, &ivalue
) )
189 data
.Set( (e
) ivalue
) ;
195 void wxSetToString( wxString
&s
, const wxSet
<e
> &data
)
197 wxEnumData
* edata
= wxGetEnumData((e
) 0) ;
198 int count
= edata
->GetEnumCount() ;
201 for ( i
= 0 ; i
< count
; i
++ )
203 e value
= (e
) edata
->GetEnumMemberValueByIndex(i
) ;
204 if ( data
.Contains( value
) )
206 // this could also be done by the templated calls
209 s
+= edata
->GetEnumMemberNameByIndex(i
) ;
214 // if the wxSet specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro
215 // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; }
217 #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \
218 template<> void wxStringReadValue(const wxString &s , wxSet<e> &data ) \
220 wxSetFromString( s , data ) ; \
222 template<> void wxStringWriteValue( wxString &s , const wxSet<e> &data ) \
224 wxSetToString( s , data ) ; \
228 // ----------------------------------------------------------------------------
230 // ----------------------------------------------------------------------------
234 wxT_VOID
= 0, // unknown type
244 wxT_STRING
, // must be wxString
245 wxT_SET
, // must be wxSet<> template
247 wxT_OBJECT_PTR
, // pointer to wxObject
248 wxT_OBJECT
, // wxObject
249 wxT_CUSTOM
, // user defined type (e.g. wxPoint)
250 wxT_DELEGATE
, // for connecting against an event source
251 wxT_LAST_TYPE_KIND
// sentinel for bad data, asserts, debugging
254 class WXDLLIMPEXP_BASE wxTypeInfo
257 wxTypeInfo() : m_kind( wxT_VOID
) {}
258 virtual ~wxTypeInfo() {}
259 wxTypeKind
GetKind() const { return m_kind
; }
260 bool IsDelegateType() const { return m_kind
== wxT_DELEGATE
; }
261 bool IsCustomType() const { return m_kind
== wxT_CUSTOM
; }
262 bool IsObjectType() const { return m_kind
== wxT_OBJECT
|| m_kind
== wxT_OBJECT_PTR
; }
267 class WXDLLIMPEXP_BASE wxBuiltInTypeInfo
: public wxTypeInfo
270 wxBuiltInTypeInfo( wxTypeKind kind
) { wxASSERT_MSG( kind
< wxT_SET
, wxT("Illegal Kind for Base Type") ) ; m_kind
= kind
;}
273 class WXDLLIMPEXP_BASE wxCustomTypeInfo
: public wxTypeInfo
276 wxCustomTypeInfo( const wxChar
*typeName
)
277 { m_kind
= wxT_CUSTOM
; m_typeName
= typeName
;}
278 const wxChar
*GetTypeName() const { return m_typeName
; }
280 const wxChar
*m_typeName
; // Kind == wxT_CUSTOM
283 class WXDLLIMPEXP_BASE wxEnumTypeInfo
: public wxTypeInfo
286 wxEnumTypeInfo( wxTypeKind kind
, wxEnumData
* enumInfo
)
287 { wxASSERT_MSG( kind
== wxT_ENUM
|| kind
== wxT_SET
, wxT("Illegal Kind for Enum Type")) ; m_kind
= kind
; m_enumInfo
= enumInfo
;}
288 const wxEnumData
* GetEnumData() const { return m_enumInfo
; }
290 wxEnumData
*m_enumInfo
; // Kind == wxT_ENUM or Kind == wxT_SET
293 class WXDLLIMPEXP_BASE wxClassTypeInfo
: public wxTypeInfo
296 wxClassTypeInfo( wxTypeKind kind
, wxClassInfo
* classInfo
)
297 { wxASSERT_MSG( kind
== wxT_OBJECT_PTR
|| kind
== wxT_OBJECT
, wxT("Illegal Kind for Enum Type")) ; m_kind
= kind
; m_classInfo
= classInfo
;}
298 const wxClassInfo
*GetClassInfo() const { return m_classInfo
; }
300 wxClassInfo
*m_classInfo
; // Kind == wxT_OBJECT - could be NULL
303 // a delegate is an exposed event source
305 class WXDLLIMPEXP_BASE wxDelegateTypeInfo
: public wxTypeInfo
308 wxDelegateTypeInfo( int eventType
, wxClassInfo
* eventClass
)
309 { m_kind
= wxT_DELEGATE
; m_eventClass
= eventClass
; m_eventType
= eventType
;}
310 const wxClassInfo
*GetEventClass() const { assert( m_kind
== wxT_DELEGATE
) ; return m_eventClass
; }
311 int GetEventType() const { return m_eventType
; }
313 const wxClassInfo
*m_eventClass
; // (extended will merge into classinfo)
317 template<typename T
> const wxTypeInfo
* wxGetTypeInfo( T
* ) ;
319 template<typename T
> const wxTypeInfo
* wxGetTypeInfo( wxSet
<T
> * )
321 static wxEnumTypeInfo
s_typeInfo(wxT_SET
, wxGetEnumData((T
) 0) ) ; return &s_typeInfo
;
324 // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
326 #define WX_CUSTOM_TYPE_INFO( e ) \
327 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \
328 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e) ; return &s_typeInfo ; }
330 // templated streaming, every type must have their specialization for these methods
333 void wxStringReadValue( const wxString
&s
, T
&data
);
336 void wxStringWriteValue( wxString
&s
, const T
&data
);
338 // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
340 #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \
341 template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
342 static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
343 template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
344 template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
346 // ----------------------------------------------------------------------------
347 // wxxVariant as typesafe data holder
348 // ----------------------------------------------------------------------------
350 class WXDLLIMPEXP_BASE wxxVariantData
353 virtual ~wxxVariantData() {}
355 // return a heap allocated duplicate
356 virtual wxxVariantData
* Clone() const = 0 ;
358 // returns the type info of the contentc
359 virtual const wxTypeInfo
* GetTypeInfo() const = 0 ;
361 // write the value into a string
362 virtual void Write( wxString
&s
) const = 0 ;
364 // read the value from a string
365 virtual void Read( const wxString
&s
) = 0 ;
368 template<typename T
> class WXDLLIMPEXP_BASE wxxVariantDataT
: public wxxVariantData
371 wxxVariantDataT(const T
& d
) : m_data(d
) {}
372 virtual ~wxxVariantDataT() {}
374 // get a ref to the stored data
375 T
& Get() { return m_data
; }
377 // get a const ref to the stored data
378 const T
& Get() const { return m_data
; }
381 void Set(const T
& d
) { m_data
= d
; }
383 // return a heap allocated duplicate
384 virtual wxxVariantData
* Clone() const { return new wxxVariantDataT
<T
>( Get() ) ; }
386 // returns the type info of the contentc
387 virtual const wxTypeInfo
* GetTypeInfo() const { return wxGetTypeInfo( (T
*) NULL
) ; }
389 // write the value into a string
390 virtual void Write( wxString
&s
) const { wxStringWriteValue( s
, m_data
) ; }
392 // read the value from a string
393 virtual void Read( const wxString
&s
) { wxStringReadValue( s
, m_data
) ; }
399 class WXDLLIMPEXP_BASE wxxVariant
402 wxxVariant() { m_data
= NULL
; }
403 wxxVariant( wxxVariantData
* data
, const wxString
& name
= wxT("") ) : m_data(data
) , m_name(name
) {}
404 wxxVariant( const wxxVariant
&d
) { if ( d
.m_data
) m_data
= d
.m_data
->Clone() ; else m_data
= NULL
; m_name
= d
.m_name
; }
406 template<typename T
> wxxVariant( T data
, const wxString
& name
= wxT("") ) :
407 m_data(new wxxVariantDataT
<T
>(data
) ), m_name(name
) {}
408 ~wxxVariant() { delete m_data
; }
410 // get a ref to the stored data
411 template<typename T
> T
& Get()
413 wxxVariantDataT
<T
> *dataptr
= dynamic_cast<wxxVariantDataT
<T
>*> (m_data
) ;
414 wxASSERT_MSG( dataptr
, "Cast not possible" ) ;
415 return dataptr
->Get() ;
418 // get a ref to the stored data
419 template<typename T
> const T
& Get() const
421 const wxxVariantDataT
<T
> *dataptr
= dynamic_cast<const wxxVariantDataT
<T
>*> (m_data
) ;
422 wxASSERT_MSG( dataptr
, "Cast not possible" ) ;
423 return dataptr
->Get() ;
427 template<typename T
> void Set(const T
& data
) const
430 m_data
= new wxxVariantDataT
<T
>(data
) ;
433 wxxVariant
& operator=(const wxxVariant
&d
)
435 m_data
= d
.m_data
->Clone() ;
440 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
441 wxObject
* GetAsObject() ;
443 // get the typeinfo of the stored object
444 const wxTypeInfo
* GetTypeInfo() const { return m_data
->GetTypeInfo() ; }
446 // write the value into a string
447 void Write( wxString
&s
) const { m_data
->Write( s
) ; }
449 // read the value from a string
450 void Read( const wxString
&s
) { m_data
->Read( s
) ; }
452 // returns this value as string
453 wxString
GetAsString() const
460 void SetFromString( const wxString
&s
)
465 wxxVariantData
* m_data
;
469 // ----------------------------------------------------------------------------
472 // wxPropertyInfo is used to inquire of the property by name. It doesn't
473 // provide access to the property, only information about it. If you
474 // want access, look at wxPropertyAccessor.
475 // ----------------------------------------------------------------------------
477 class WXDLLIMPEXP_BASE wxPropertyAccessor
480 #if WX_XTI_TEMPLATE_FIX
482 class SetByRefRetBool
;
484 class SetAndGetByRef
;
485 class SetAndGetByRefRetBool
;
488 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const = 0 ;
489 virtual wxxVariant
GetProperty(const wxObject
*object
) const = 0 ;
490 virtual bool HasSetter() const = 0 ;
491 virtual bool HasGetter() const = 0 ;
492 const wxChar
* GetGetterName() const { return m_setterName
; }
493 const wxChar
* GetSetterName() const { return m_getterName
; }
494 virtual wxxVariant
ReadValue( const wxString
&value
) const = 0 ;
495 virtual void WriteValue( wxString
& value
, const wxObject
*o
) const = 0 ;
497 const wxChar
*m_setterName
;
498 const wxChar
*m_getterName
;
501 template<class Klass
, typename T
>
502 class WXDLLIMPEXP_BASE wxPropertyAccessorT
: public wxPropertyAccessor
506 typedef void (Klass
::*setter_t
)(T value
);
507 typedef bool (Klass
::*setter_bool_t
)(T value
);
508 typedef void (Klass
::*setter_ref_t
)(const T
& value
);
509 typedef bool (Klass
::*setter_ref_bool_t
)(const T
& value
);
510 typedef T (Klass
::*getter_t
)() const;
511 typedef const T
& (Klass
::*getter_ref_t
)() const;
513 wxPropertyAccessorT(setter_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
514 : 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
;}
516 wxPropertyAccessorT( getter_t getter
, const wxChar
*g
)
517 : 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
;}
519 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetRetBool
*,) setter_bool_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
520 : 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
;}
522 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRef
*,) setter_ref_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
523 : 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
;}
525 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRefRetBool
*,) setter_ref_bool_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
526 : 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
;}
528 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRef
*,) setter_ref_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
529 : 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
;}
531 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRefRetBool
*,) setter_ref_bool_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
532 : 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
;}
534 wxPropertyAccessorT(WX_XTI_PARAM_FIX(GetByRef
*,) setter_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
535 : 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
;}
537 // returns true if this accessor has a setter
538 bool HasSetter() const { return m_setter
!= NULL
|| m_setter_ref
!= NULL
; }
540 // return true if this accessor has a getter
541 bool HasGetter() const { return m_getter
!= NULL
|| m_getter_ref
!= NULL
; }
543 // set the property this accessor is responsible for in an object
544 void SetProperty(wxObject
*o
, const wxxVariant
&v
) const
546 Klass
*obj
= dynamic_cast<Klass
*>(o
);
549 if ( wxGetTypeInfo((T
*)NULL
)->GetKind() == wxT_OBJECT
&& v
.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR
)
550 value
= *v
.Get
<T
*>();
554 (obj
->*(m_setter
))(value
);
555 else if ( m_setter_ref
)
556 (obj
->*(m_setter_ref
))(value
);
557 else if ( m_setter_ref_bool
)
558 (obj
->*(m_setter_ref_bool
))(value
);
559 else if ( m_setter_bool
)
560 (obj
->*(m_setter_bool
))(value
);
563 wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ;
567 // gets the property this accessor is responsible for from an object
568 wxxVariant
GetProperty(const wxObject
*o
) const
570 return wxxVariant( (wxxVariantData
* ) DoGetProperty( o
) ) ;
573 // write the property this accessor is responsible for from an object into
575 void WriteValue( wxString
& s
, const wxObject
*o
) const
577 DoGetProperty( o
)->Write( s
) ;
580 // read a wxxVariant having the correct type for the property this accessor
581 // is responsible for from a string
582 wxxVariant
ReadValue( const wxString
&value
) const
585 wxStringReadValue( value
, data
) ;
586 return wxxVariant( data
) ;
590 wxxVariantDataT
<T
>* DoGetProperty(const wxObject
*o
) const
592 const Klass
*obj
= dynamic_cast<const Klass
*>(o
);
594 return new wxxVariantDataT
<T
>( (obj
->*(m_getter
))() ) ;
596 return new wxxVariantDataT
<T
>( (obj
->*(m_getter_ref
))() ) ;
600 setter_ref_t m_setter_ref
;
601 setter_ref_bool_t m_setter_ref_bool
;
602 setter_bool_t m_setter_bool
;
604 getter_ref_t m_getter_ref
;
607 class WXDLLIMPEXP_BASE wxPropertyInfo
610 wxPropertyInfo( wxPropertyInfo
* &iter
, const wxChar
*name
, const wxChar
*typeName
, const wxTypeInfo
* typeInfo
, wxPropertyAccessor
*accessor
, wxxVariant dv
) :
611 m_name( name
) , m_typeName(typeName
) , m_typeInfo( typeInfo
) , m_accessor( accessor
) , m_defaultValue( dv
)
618 wxPropertyInfo
* i
= iter
;
625 // return the name of this property
626 const wxChar
* GetName() const { return m_name
; }
628 // return the typename of this property
629 const wxChar
* GetTypeName() const { return m_typeName
; }
631 // return the type info of this property
632 const wxTypeInfo
* GetTypeInfo() const { return m_typeInfo
; }
634 // return the accessor for this property
635 wxPropertyAccessor
* GetAccessor() const { return m_accessor
; }
637 // returns NULL if this is the last property of this class
638 wxPropertyInfo
* GetNext() const { return m_next
; }
640 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
641 wxxVariant
GetDefaultValue() const { return m_defaultValue
; }
643 const wxChar
* m_name
;
644 const wxChar
* m_typeName
;
645 const wxTypeInfo
* m_typeInfo
;
646 wxPropertyAccessor
* m_accessor
;
647 wxxVariant m_defaultValue
;
648 // string representation of the default value
649 // to be assigned by the designer to the property
650 // when the component is dropped on the container.
651 wxPropertyInfo
* m_next
;
654 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
655 const wxPropertyInfo *theClass::GetPropertiesStatic() \
657 typedef theClass class_t; \
658 static wxPropertyInfo* first = NULL ;
660 #define WX_END_PROPERTIES_TABLE() \
664 #if WX_XTI_TEMPLATE_FIX
666 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
667 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
668 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
670 #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
671 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetRetBool*)NULL , &setter , &getter , #setter , #getter ) ; \
672 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
674 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
675 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRef*)NULL, &setter , &getter , #setter , #getter ) ; \
676 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
678 #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
679 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
680 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
682 #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
683 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetAndGetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
684 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
688 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
689 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
690 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
692 #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
693 WX_PROPERTY( name , type , setter , getter , defaultValue )
695 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
696 WX_PROPERTY( name , type , setter , getter , defaultValue )
698 #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
699 WX_PROPERTY( name , type , setter , getter , defaultValue )
701 #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
702 WX_PROPERTY( name , type , setter , getter , defaultValue )
706 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
707 static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
708 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
710 #define WX_DELEGATE( name , eventType , eventClass ) \
711 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
712 static wxPropertyInfo _propertyInfo##name( first , #name , NULL , &_typeInfo##name , NULL , wxxVariant() ) ; \
714 // ----------------------------------------------------------------------------
717 // this is describing an event sink
718 // ----------------------------------------------------------------------------
723 wxHandlerInfo( wxHandlerInfo
* &iter
, const wxChar
*name
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) :
724 m_name( name
) , m_eventClassInfo( eventClassInfo
) , m_eventFunction( address
)
731 wxHandlerInfo
* i
= iter
;
739 // get the name of the handler method
740 const wxChar
* GetName() const { return m_name
; }
742 // return the class info of the event
743 const wxClassInfo
* GetEventClassInfo() const { return m_eventClassInfo
; }
745 // get the handler function pointer
746 wxObjectEventFunction
GetEventFunction() const { return m_eventFunction
; }
748 // returns NULL if this is the last handler of this class
749 wxHandlerInfo
* GetNext() const { return m_next
; }
751 wxObjectEventFunction m_eventFunction
;
752 const wxChar
* m_name
;
753 const wxClassInfo
* m_eventClassInfo
;
754 wxHandlerInfo
* m_next
;
757 #define WX_HANDLER(name,eventClassType) \
758 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
760 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
761 const wxHandlerInfo *theClass::GetHandlersStatic() \
763 typedef theClass class_t; \
764 static wxHandlerInfo* first = NULL ;
766 #define WX_END_HANDLERS_TABLE() \
769 // ----------------------------------------------------------------------------
770 // Constructor Bridges
772 // allow to set up constructors with params during runtime
773 // ----------------------------------------------------------------------------
775 class WXDLLIMPEXP_BASE wxConstructorBridge
778 virtual void Create(wxObject
*o
, wxxVariant
*args
) = 0;
781 // Creator Bridges for all Numbers of Params
785 template<typename Class
>
786 struct wxConstructorBridge_0
: public wxConstructorBridge
788 void Create(wxObject
*o
, wxxVariant
*)
790 Class
*obj
= dynamic_cast<Class
*>(o
);
795 struct wxConstructorBridge_Dummy
: public wxConstructorBridge
797 void Create(wxObject
*, wxxVariant
*)
802 #define WX_CONSTRUCTOR_0(klass) \
803 wxConstructorBridge_0<klass> constructor##klass ; \
804 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
805 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
806 const int klass::sm_constructorPropertiesCount##klass = 0 ;
808 #define WX_CONSTRUCTOR_DUMMY(klass) \
809 wxConstructorBridge_Dummy constructor##klass ; \
810 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
811 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
812 const int klass::sm_constructorPropertiesCount##klass = 0 ;
816 template<typename Class
, typename T0
>
817 struct wxConstructorBridge_1
: public wxConstructorBridge
819 void Create(wxObject
*o
, wxxVariant
*args
)
821 Class
*obj
= dynamic_cast<Class
*>(o
);
828 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
829 wxConstructorBridge_1<klass,t0> constructor##klass ; \
830 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
831 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
832 const int klass::sm_constructorPropertiesCount##klass = 1 ;
836 template<typename Class
,
837 typename T0
, typename T1
>
838 struct wxConstructorBridge_2
: public wxConstructorBridge
840 void Create(wxObject
*o
, wxxVariant
*args
)
842 Class
*obj
= dynamic_cast<Class
*>(o
);
850 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
851 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
852 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
853 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
854 const int klass::sm_constructorPropertiesCount##klass = 2;
858 template<typename Class
,
859 typename T0
, typename T1
, typename T2
>
860 struct wxConstructorBridge_3
: public wxConstructorBridge
862 void Create(wxObject
*o
, wxxVariant
*args
)
864 Class
*obj
= dynamic_cast<Class
*>(o
);
873 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
874 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
875 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
876 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
877 const int klass::sm_constructorPropertiesCount##klass = 3 ;
881 template<typename Class
,
882 typename T0
, typename T1
, typename T2
, typename T3
>
883 struct wxConstructorBridge_4
: public wxConstructorBridge
885 void Create(wxObject
*o
, wxxVariant
*args
)
887 Class
*obj
= dynamic_cast<Class
*>(o
);
897 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
898 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
899 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
900 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
901 const int klass::sm_constructorPropertiesCount##klass = 4 ;
905 template<typename Class
,
906 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
>
907 struct wxConstructorBridge_5
: public wxConstructorBridge
909 void Create(wxObject
*o
, wxxVariant
*args
)
911 Class
*obj
= dynamic_cast<Class
*>(o
);
922 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
923 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
924 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
925 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
926 const int klass::sm_constructorPropertiesCount##klass = 5;
930 template<typename Class
,
931 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
>
932 struct wxConstructorBridge_6
: public wxConstructorBridge
934 void Create(wxObject
*o
, wxxVariant
*args
)
936 Class
*obj
= dynamic_cast<Class
*>(o
);
948 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
949 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
950 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
951 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
952 const int klass::sm_constructorPropertiesCount##klass = 6;
955 // ----------------------------------------------------------------------------
957 // ----------------------------------------------------------------------------
959 typedef wxObject
*(*wxObjectConstructorFn
)(void);
960 typedef wxObject
* (*wxVariantToObjectConverter
)( wxxVariant
&data
) ;
961 typedef wxxVariant (*wxObjectToVariantConverter
)( wxObject
* ) ;
963 class WXDLLIMPEXP_BASE wxClassInfo
966 wxClassInfo(const wxClassInfo
**_Parents
,
967 const wxChar
*_UnitName
,
968 const wxChar
*_ClassName
,
970 wxObjectConstructorFn ctor
,
971 const wxPropertyInfo
*_Props
,
972 const wxHandlerInfo
*_Handlers
,
973 wxConstructorBridge
* _Constructor
,
974 const wxChar
** _ConstructorProperties
,
975 const int _ConstructorPropertiesCount
,
976 wxVariantToObjectConverter _PtrConverter1
,
977 wxVariantToObjectConverter _Converter2
,
978 wxObjectToVariantConverter _Converter3
979 ) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
980 m_objectSize(size
), m_objectConstructor(ctor
) , m_firstProperty(_Props
) , m_firstHandler(_Handlers
) , m_constructor( _Constructor
) ,
981 m_constructorProperties(_ConstructorProperties
) , m_constructorPropertiesCount(_ConstructorPropertiesCount
),
982 m_variantOfPtrToObjectConverter( _PtrConverter1
) , m_variantToObjectConverter( _Converter2
) , m_objectToVariantConverter( _Converter3
) , m_next(sm_first
)
988 virtual ~wxClassInfo() ;
990 wxObject
*CreateObject() const { return m_objectConstructor ?
(*m_objectConstructor
)() : 0; }
992 const wxChar
*GetClassName() const { return m_className
; }
993 const wxClassInfo
**GetParents() const { return m_parents
; }
994 int GetSize() const { return m_objectSize
; }
996 wxObjectConstructorFn
GetConstructor() const { return m_objectConstructor
; }
997 static const wxClassInfo
*GetFirst() { return sm_first
; }
998 const wxClassInfo
*GetNext() const { return m_next
; }
999 static wxClassInfo
*FindClass(const wxChar
*className
);
1001 // Climb upwards through inheritance hierarchy.
1002 // Dual inheritance is catered for.
1004 bool IsKindOf(const wxClassInfo
*info
) const
1011 for ( int i
= 0 ; m_parents
[i
] ; ++ i
)
1013 if ( m_parents
[i
]->IsKindOf( info
) )
1020 #ifdef WXWIN_COMPATIBILITY_2_4
1021 // Initializes parent pointers and hash table for fast searching.
1022 wxDEPRECATED( static void InitializeClasses() );
1023 // Cleans up hash table used for fast searching.
1024 wxDEPRECATED( static void CleanUpClasses() );
1026 static void CleanUp();
1028 // returns the first property
1029 const wxPropertyInfo
* GetFirstProperty() const { return m_firstProperty
; }
1031 // returns the first handler
1032 const wxHandlerInfo
* GetFirstHandler() const { return m_firstHandler
; }
1034 // Call the Create method for a class
1035 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const
1037 wxASSERT_MSG( ParamCount
== m_constructorPropertiesCount
, wxT("Illegal Parameter Count for Create Method")) ;
1038 m_constructor
->Create( object
, Params
) ;
1041 // get number of parameters for constructor
1042 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount
; }
1044 // get i-th constructor parameter
1045 virtual const wxChar
* GetCreateParamName(int i
) const { return m_constructorProperties
[i
] ; }
1047 // Runtime access to objects by property name, and variant data
1048 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
);
1049 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
);
1051 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1052 wxObject
* VariantToInstance( wxxVariant
&data
) const
1053 { if ( data
.GetTypeInfo()->GetKind() == wxT_OBJECT
)
1054 return m_variantToObjectConverter( data
) ;
1056 return m_variantOfPtrToObjectConverter( data
) ;
1059 wxxVariant
InstanceToVariant( wxObject
*object
) const { return m_objectToVariantConverter( object
) ; }
1061 // find property by name
1062 virtual const wxPropertyInfo
*FindPropertyInfo (const wxChar
*PropertyName
) const ;
1064 // find handler by name
1065 virtual const wxHandlerInfo
*FindHandlerInfo (const wxChar
*PropertyName
) const ;
1068 const wxChar
*m_className
;
1070 wxObjectConstructorFn m_objectConstructor
;
1072 // class info object live in a linked list:
1073 // pointers to its head and the next element in it
1075 static wxClassInfo
*sm_first
;
1076 wxClassInfo
*m_next
;
1078 // FIXME: this should be private (currently used directly by way too
1080 static wxHashTable
*sm_classTable
;
1083 const wxClassInfo
** m_parents
;
1084 const wxPropertyInfo
* m_firstProperty
;
1085 const wxHandlerInfo
* m_firstHandler
;
1086 const wxChar
* m_unitName
;
1088 wxConstructorBridge
* m_constructor
;
1089 const wxChar
** m_constructorProperties
;
1090 const int m_constructorPropertiesCount
;
1091 wxVariantToObjectConverter m_variantOfPtrToObjectConverter
;
1092 wxVariantToObjectConverter m_variantToObjectConverter
;
1093 wxObjectToVariantConverter m_objectToVariantConverter
;
1095 const wxPropertyAccessor
*FindAccessor (const wxChar
*propertyName
);
1098 // InitializeClasses() helper
1099 static wxClassInfo
*GetBaseByName(const wxChar
*name
);
1102 // registers the class
1106 DECLARE_NO_COPY_CLASS(wxClassInfo
)
1109 WXDLLIMPEXP_BASE wxObject
*wxCreateDynamicObject(const wxChar
*name
);
1111 // ----------------------------------------------------------------------------
1112 // Dynamic class macros
1113 // ----------------------------------------------------------------------------
1115 #define _DECLARE_DYNAMIC_CLASS(name) \
1117 static wxClassInfo sm_class##name; \
1118 static const wxClassInfo* sm_classParents##name[] ; \
1119 static const wxPropertyInfo* GetPropertiesStatic() ; \
1120 static const wxHandlerInfo* GetHandlersStatic() ; \
1121 virtual wxClassInfo *GetClassInfo() const \
1122 { return &name::sm_class##name; }
1124 #define DECLARE_DYNAMIC_CLASS(name) \
1125 static wxConstructorBridge* sm_constructor##name ; \
1126 static const wxChar * sm_constructorProperties##name[] ; \
1127 static const int sm_constructorPropertiesCount##name ; \
1128 _DECLARE_DYNAMIC_CLASS(name)
1130 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1131 DECLARE_NO_ASSIGN_CLASS(name) \
1132 DECLARE_DYNAMIC_CLASS(name)
1134 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1135 DECLARE_NO_COPY_CLASS(name) \
1136 DECLARE_DYNAMIC_CLASS(name)
1138 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1139 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1141 // -----------------------------------
1142 // for concrete classes
1143 // -----------------------------------
1145 // Single inheritance with one base class
1147 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
1148 wxObject* wxConstructorFor##name() \
1149 { return new name; } \
1150 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1151 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1152 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1153 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1154 (int) sizeof(name), \
1155 (wxObjectConstructorFn) wxConstructorFor##name , \
1156 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1157 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name); \
1158 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1159 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1160 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1161 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1162 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1163 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1164 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1165 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1166 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1168 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \
1169 wxObject* wxConstructorFor##name() \
1170 { return new name; } \
1171 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1172 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1173 wxObject* wxVariantOfPtrToObjectConverter##name ( 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(unit) , wxT(#name), \
1176 (int) sizeof(name), \
1177 (wxObjectConstructorFn) wxConstructorFor##name , \
1178 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1179 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , 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<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1183 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1184 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1185 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1186 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1187 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1188 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1190 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1191 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \
1192 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1193 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1194 WX_CONSTRUCTOR_DUMMY( name )
1196 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1197 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
1198 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1199 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1200 WX_CONSTRUCTOR_DUMMY( name )
1202 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1203 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
1205 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1206 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
1208 // this is for classes that do not derive from wxobject, there are no creators for these
1210 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1211 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1212 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1213 (int) sizeof(name), \
1214 (wxObjectConstructorFn) 0 , \
1215 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1217 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1218 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1219 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1220 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1221 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1222 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1223 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1225 // this is for subclasses that still do not derive from wxobject
1227 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1228 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1229 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1230 (int) sizeof(name), \
1231 (wxObjectConstructorFn) 0 , \
1232 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1234 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1235 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1236 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1237 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1238 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1239 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1240 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1243 // Multiple inheritance with two base classes
1245 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1246 wxObject* wxConstructorFor##name() \
1247 { return new name; } \
1248 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1249 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1250 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1251 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1252 (int) sizeof(name), \
1253 (wxObjectConstructorFn) wxConstructorFor##name , \
1254 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1255 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1256 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1257 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1258 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1259 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1260 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1261 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1262 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1264 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1265 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1266 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1267 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1268 WX_CONSTRUCTOR_DUMMY( name )
1270 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1271 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1273 // -----------------------------------
1274 // for abstract classes
1275 // -----------------------------------
1277 // Single inheritance with one base class
1279 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1280 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1281 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1282 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1283 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1284 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1285 (int) sizeof(name), \
1286 (wxObjectConstructorFn) 0 , \
1287 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1288 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1289 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1290 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1291 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1292 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1293 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1294 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1295 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1297 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1298 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1299 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1300 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1302 // Multiple inheritance with two base classes
1304 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1305 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1306 wxT(#basename2), (int) sizeof(name), \
1307 (wxObjectConstructorFn) 0);
1309 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1310 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2