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(NO_GCC_PRAGMA)
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 #ifndef WX_XTI_TEMPLATE_FIX
49 #define WX_XTI_TEMPLATE_FIX 0
52 #if WX_XTI_TEMPLATE_FIX
53 #define WX_XTI_PARAM_FIX(a,b) a,b
55 #define WX_XTI_PARAM_FIX(a,b)
58 class WXDLLIMPEXP_BASE wxObject
;
59 class WXDLLIMPEXP_BASE wxClassInfo
;
60 class WXDLLIMPEXP_BASE wxHashTable
;
61 class WXDLLIMPEXP_BASE wxObjectRefData
;
62 class WXDLLIMPEXP_BASE wxEvent
;
64 typedef void (wxObject::*wxObjectEventFunction
)(wxEvent
&);
66 // ----------------------------------------------------------------------------
69 // In the header files there would no change from pure c++ code, in the
70 // implementation, an enum would have
71 // to be enumerated eg :
73 // WX_BEGIN_ENUM( wxFlavor )
74 // WX_ENUM_MEMBER( Vanilla )
75 // WX_ENUM_MEMBER( Chocolate )
76 // WX_ENUM_MEMBER( Strawberry )
77 // WX_END_ENUM( wxFlavor )
78 // ----------------------------------------------------------------------------
80 struct WXDLLIMPEXP_BASE wxEnumMemberData
86 class WXDLLIMPEXP_BASE wxEnumData
89 wxEnumData( wxEnumMemberData
* data
) ;
91 // returns true if the member has been found and sets the int value
92 // pointed to accordingly (if ptr != null )
93 // if not found returns false, value left unchanged
94 bool HasEnumMemberValue( const wxChar
*name
, int *value
= NULL
) ;
96 // returns the value of the member, if not found in debug mode an
97 // assert is issued, in release 0 is returned
98 int GetEnumMemberValue(const wxChar
*name
);
100 // returns the name of the enum member having the passed in value
101 // returns an emtpy string if not found
102 const wxChar
*GetEnumMemberName(int value
);
104 // returns the number of members in this enum
105 int GetEnumCount() { return m_count
; }
107 // returns the value of the nth member
108 int GetEnumMemberValueByIndex( int n
) ;
110 // returns the value of the nth member
111 const wxChar
*GetEnumMemberNameByIndex( int n
) ;
113 wxEnumMemberData
*m_members
;
117 #define WX_BEGIN_ENUM( e ) \
118 wxEnumMemberData s_enumDataMembers##e[] = {
120 #define WX_ENUM_MEMBER( v ) { #v, v } ,
122 #define WX_END_ENUM( e ) { NULL , 0 } } ; \
123 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
124 wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \
125 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e) ; return &s_typeInfo ; } \
126 template<> void wxStringReadValue(const wxString& s , e &data ) \
128 data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
130 template<> void wxStringWriteValue(wxString &s , const e &data ) \
132 s = s_enumData##e.GetEnumMemberName((int)data) ; \
134 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \
135 template<> void wxStringReadValue(const wxString& , e* & ) \
139 template<> void wxStringWriteValue(wxString &s , e* const & ) \
144 // ----------------------------------------------------------------------------
156 // typedef wxSet<wxFlavor> wxCoupe ;
158 // in the implementation file :
160 // WX_BEGIN_ENUM( wxFlavor )
161 // WX_ENUM_MEMBER( Vanilla )
162 // WX_ENUM_MEMBER( Chocolate )
163 // WX_ENUM_MEMBER( Strawberry )
164 // WX_END_ENUM( wxFlavor )
166 // WX_IMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor )
168 // implementation note : no partial specialization for streaming, but a delegation to a
171 // ----------------------------------------------------------------------------
173 // in order to remove dependancy on string tokenizer
174 void wxSetStringToArray( const wxString
&s
, wxArrayString
&array
) ;
177 void wxSetFromString(const wxString
&s
, wxSet
<e
> &data
)
179 wxEnumData
* edata
= wxGetEnumData((e
) 0) ;
182 wxArrayString array
;
183 wxSetStringToArray( s
, array
) ;
185 for ( int i
= 0 ; i
< array
.Count() ; ++i
)
189 if ( edata
->HasEnumMemberValue( flag
, &ivalue
) )
191 data
.Set( (e
) ivalue
) ;
197 void wxSetToString( wxString
&s
, const wxSet
<e
> &data
)
199 wxEnumData
* edata
= wxGetEnumData((e
) 0) ;
200 int count
= edata
->GetEnumCount() ;
203 for ( i
= 0 ; i
< count
; i
++ )
205 e value
= (e
) edata
->GetEnumMemberValueByIndex(i
) ;
206 if ( data
.Contains( value
) )
208 // this could also be done by the templated calls
211 s
+= edata
->GetEnumMemberNameByIndex(i
) ;
216 // if the wxSet specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro
217 // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; }
219 #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \
220 template<> void wxStringReadValue(const wxString &s , wxSet<e> &data ) \
222 wxSetFromString( s , data ) ; \
224 template<> void wxStringWriteValue( wxString &s , const wxSet<e> &data ) \
226 wxSetToString( s , data ) ; \
230 // ----------------------------------------------------------------------------
232 // ----------------------------------------------------------------------------
236 wxT_VOID
= 0, // unknown type
246 wxT_STRING
, // must be wxString
247 wxT_SET
, // must be wxSet<> template
249 wxT_OBJECT_PTR
, // pointer to wxObject
250 wxT_OBJECT
, // wxObject
251 wxT_CUSTOM
, // user defined type (e.g. wxPoint)
252 wxT_DELEGATE
, // for connecting against an event source
253 wxT_LAST_TYPE_KIND
// sentinel for bad data, asserts, debugging
256 class WXDLLIMPEXP_BASE wxTypeInfo
259 wxTypeInfo() : m_kind( wxT_VOID
) {}
260 virtual ~wxTypeInfo() {}
261 wxTypeKind
GetKind() const { return m_kind
; }
262 bool IsDelegateType() const { return m_kind
== wxT_DELEGATE
; }
263 bool IsCustomType() const { return m_kind
== wxT_CUSTOM
; }
264 bool IsObjectType() const { return m_kind
== wxT_OBJECT
|| m_kind
== wxT_OBJECT_PTR
; }
269 class WXDLLIMPEXP_BASE wxBuiltInTypeInfo
: public wxTypeInfo
272 wxBuiltInTypeInfo( wxTypeKind kind
) { wxASSERT_MSG( kind
< wxT_SET
, wxT("Illegal Kind for Base Type") ) ; m_kind
= kind
;}
275 class WXDLLIMPEXP_BASE wxCustomTypeInfo
: public wxTypeInfo
278 wxCustomTypeInfo( const wxChar
*typeName
)
279 { m_kind
= wxT_CUSTOM
; m_typeName
= typeName
;}
280 const wxChar
*GetTypeName() const { return m_typeName
; }
282 const wxChar
*m_typeName
; // Kind == wxT_CUSTOM
285 class WXDLLIMPEXP_BASE wxEnumTypeInfo
: public wxTypeInfo
288 wxEnumTypeInfo( wxTypeKind kind
, wxEnumData
* enumInfo
)
289 { wxASSERT_MSG( kind
== wxT_ENUM
|| kind
== wxT_SET
, wxT("Illegal Kind for Enum Type")) ; m_kind
= kind
; m_enumInfo
= enumInfo
;}
290 const wxEnumData
* GetEnumData() const { return m_enumInfo
; }
292 wxEnumData
*m_enumInfo
; // Kind == wxT_ENUM or Kind == wxT_SET
295 class WXDLLIMPEXP_BASE wxClassTypeInfo
: public wxTypeInfo
298 wxClassTypeInfo( wxTypeKind kind
, wxClassInfo
* classInfo
)
299 { wxASSERT_MSG( kind
== wxT_OBJECT_PTR
|| kind
== wxT_OBJECT
, wxT("Illegal Kind for Enum Type")) ; m_kind
= kind
; m_classInfo
= classInfo
;}
300 const wxClassInfo
*GetClassInfo() const { return m_classInfo
; }
302 wxClassInfo
*m_classInfo
; // Kind == wxT_OBJECT - could be NULL
305 // a delegate is an exposed event source
307 class WXDLLIMPEXP_BASE wxDelegateTypeInfo
: public wxTypeInfo
310 wxDelegateTypeInfo( int eventType
, wxClassInfo
* eventClass
)
311 { m_kind
= wxT_DELEGATE
; m_eventClass
= eventClass
; m_eventType
= eventType
;}
312 const wxClassInfo
*GetEventClass() const { assert( m_kind
== wxT_DELEGATE
) ; return m_eventClass
; }
313 int GetEventType() const { return m_eventType
; }
315 const wxClassInfo
*m_eventClass
; // (extended will merge into classinfo)
319 template<typename T
> const wxTypeInfo
* wxGetTypeInfo( T
* ) ;
321 template<typename T
> const wxTypeInfo
* wxGetTypeInfo( wxSet
<T
> * )
323 static wxEnumTypeInfo
s_typeInfo(wxT_SET
, wxGetEnumData((T
) 0) ) ; return &s_typeInfo
;
326 // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
328 #define WX_CUSTOM_TYPE_INFO( e ) \
329 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \
330 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e) ; return &s_typeInfo ; }
332 // templated streaming, every type must have their specialization for these methods
335 void wxStringReadValue( const wxString
&s
, T
&data
);
338 void wxStringWriteValue( wxString
&s
, const T
&data
);
340 // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
342 #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \
343 template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
344 static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
345 template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
346 template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
348 // ----------------------------------------------------------------------------
349 // wxxVariant as typesafe data holder
350 // ----------------------------------------------------------------------------
352 class WXDLLIMPEXP_BASE wxxVariantData
355 virtual ~wxxVariantData() {}
357 // return a heap allocated duplicate
358 virtual wxxVariantData
* Clone() const = 0 ;
360 // returns the type info of the contentc
361 virtual const wxTypeInfo
* GetTypeInfo() const = 0 ;
363 // write the value into a string
364 virtual void Write( wxString
&s
) const = 0 ;
366 // read the value from a string
367 virtual void Read( const wxString
&s
) = 0 ;
370 template<typename T
> class WXDLLIMPEXP_BASE wxxVariantDataT
: public wxxVariantData
373 wxxVariantDataT(const T
& d
) : m_data(d
) {}
374 virtual ~wxxVariantDataT() {}
376 // get a ref to the stored data
377 T
& Get() { return m_data
; }
379 // get a const ref to the stored data
380 const T
& Get() const { return m_data
; }
383 void Set(const T
& d
) { m_data
= d
; }
385 // return a heap allocated duplicate
386 virtual wxxVariantData
* Clone() const { return new wxxVariantDataT
<T
>( Get() ) ; }
388 // returns the type info of the contentc
389 virtual const wxTypeInfo
* GetTypeInfo() const { return wxGetTypeInfo( (T
*) NULL
) ; }
391 // write the value into a string
392 virtual void Write( wxString
&s
) const { wxStringWriteValue( s
, m_data
) ; }
394 // read the value from a string
395 virtual void Read( const wxString
&s
) { wxStringReadValue( s
, m_data
) ; }
401 class WXDLLIMPEXP_BASE wxxVariant
404 wxxVariant() { m_data
= NULL
; }
405 wxxVariant( wxxVariantData
* data
, const wxString
& name
= wxT("") ) : m_data(data
) , m_name(name
) {}
406 wxxVariant( const wxxVariant
&d
) { if ( d
.m_data
) m_data
= d
.m_data
->Clone() ; else m_data
= NULL
; m_name
= d
.m_name
; }
408 template<typename T
> wxxVariant( T data
, const wxString
& name
= wxT("") ) :
409 m_data(new wxxVariantDataT
<T
>(data
) ), m_name(name
) {}
410 ~wxxVariant() { delete m_data
; }
412 // get a ref to the stored data
413 template<typename T
> T
& Get()
415 wxxVariantDataT
<T
> *dataptr
= dynamic_cast<wxxVariantDataT
<T
>*> (m_data
) ;
416 wxASSERT_MSG( dataptr
, "Cast not possible" ) ;
417 return dataptr
->Get() ;
420 // get a ref to the stored data
421 template<typename T
> const T
& Get() const
423 const wxxVariantDataT
<T
> *dataptr
= dynamic_cast<const wxxVariantDataT
<T
>*> (m_data
) ;
424 wxASSERT_MSG( dataptr
, "Cast not possible" ) ;
425 return dataptr
->Get() ;
429 template<typename T
> void Set(const T
& data
) const
432 m_data
= new wxxVariantDataT
<T
>(data
) ;
435 wxxVariant
& operator=(const wxxVariant
&d
)
437 m_data
= d
.m_data
->Clone() ;
442 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
443 wxObject
* GetAsObject() ;
445 // get the typeinfo of the stored object
446 const wxTypeInfo
* GetTypeInfo() const { return m_data
->GetTypeInfo() ; }
448 // write the value into a string
449 void Write( wxString
&s
) const { m_data
->Write( s
) ; }
451 // read the value from a string
452 void Read( const wxString
&s
) { m_data
->Read( s
) ; }
454 // returns this value as string
455 wxString
GetAsString() const
462 void SetFromString( const wxString
&s
)
467 wxxVariantData
* m_data
;
471 // ----------------------------------------------------------------------------
474 // wxPropertyInfo is used to inquire of the property by name. It doesn't
475 // provide access to the property, only information about it. If you
476 // want access, look at wxPropertyAccessor.
477 // ----------------------------------------------------------------------------
479 class WXDLLIMPEXP_BASE wxPropertyAccessor
482 #if WX_XTI_TEMPLATE_FIX
484 class SetByRefRetBool
;
486 class SetAndGetByRef
;
487 class SetAndGetByRefRetBool
;
490 wxPropertyAccessor() { m_setterName
= NULL
; m_getterName
= NULL
; }
491 virtual ~wxPropertyAccessor() {}
492 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const = 0 ;
493 virtual wxxVariant
GetProperty(const wxObject
*object
) const = 0 ;
494 virtual bool HasSetter() const = 0 ;
495 virtual bool HasGetter() const = 0 ;
496 const wxChar
* GetGetterName() const { return m_setterName
; }
497 const wxChar
* GetSetterName() const { return m_getterName
; }
498 virtual wxxVariant
ReadValue( const wxString
&value
) const = 0 ;
499 virtual void WriteValue( wxString
& value
, const wxObject
*o
) const = 0 ;
501 const wxChar
*m_setterName
;
502 const wxChar
*m_getterName
;
505 class WXDLLIMPEXP_BASE wxGenericPropertyAccessor
: public wxPropertyAccessor
508 wxGenericPropertyAccessor( const wxChar
* propertyName
) ;
509 ~wxGenericPropertyAccessor() ;
510 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const ;
511 virtual wxxVariant
GetProperty(const wxObject
*object
) const ;
512 virtual bool HasSetter() const { return true ; }
513 virtual bool HasGetter() const { return true ; }
514 virtual wxxVariant
ReadValue( const wxString
&value
) const ;
515 virtual void WriteValue( wxString
& value
, const wxObject
*o
) const ;
517 struct wxGenericPropertyAccessorInternal
;
518 wxGenericPropertyAccessorInternal
* m_data
;
521 template<class Klass
, typename T
>
522 class WXDLLIMPEXP_BASE wxPropertyAccessorT
: public wxPropertyAccessor
526 typedef void (Klass::*setter_t
)(T value
);
527 typedef bool (Klass::*setter_bool_t
)(T value
);
528 typedef void (Klass::*setter_ref_t
)(const T
& value
);
529 typedef bool (Klass::*setter_ref_bool_t
)(const T
& value
);
530 typedef T (Klass::*getter_t
)() const;
531 typedef const T
& (Klass::*getter_ref_t
)() const;
533 wxPropertyAccessorT(setter_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
534 : 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
;}
536 wxPropertyAccessorT( getter_t getter
, const wxChar
*g
)
537 : 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
;}
539 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetRetBool
*,) setter_bool_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
540 : 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
;}
542 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRef
*,) setter_ref_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
543 : 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
;}
545 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRefRetBool
*,) setter_ref_bool_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
546 : 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
;}
548 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRef
*,) setter_ref_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
549 : 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
;}
551 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRefRetBool
*,) setter_ref_bool_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
552 : 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
;}
554 wxPropertyAccessorT(WX_XTI_PARAM_FIX(GetByRef
*,) setter_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
555 : 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
;}
557 // returns true if this accessor has a setter
558 bool HasSetter() const { return m_setter
!= NULL
|| m_setter_ref
!= NULL
|| m_setter_ref_bool
!= NULL
|| m_setter_bool
; }
560 // return true if this accessor has a getter
561 bool HasGetter() const { return m_getter
!= NULL
|| m_getter_ref
!= NULL
; }
563 // set the property this accessor is responsible for in an object
564 void SetProperty(wxObject
*o
, const wxxVariant
&v
) const
566 Klass
*obj
= dynamic_cast<Klass
*>(o
);
569 if ( wxGetTypeInfo((T
*)NULL
)->GetKind() == wxT_OBJECT
&& v
.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR
)
570 value
= *v
.Get
<T
*>();
574 (obj
->*(m_setter
))(value
);
575 else if ( m_setter_ref
)
576 (obj
->*(m_setter_ref
))(value
);
577 else if ( m_setter_ref_bool
)
578 (obj
->*(m_setter_ref_bool
))(value
);
579 else if ( m_setter_bool
)
580 (obj
->*(m_setter_bool
))(value
);
583 wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ;
587 // gets the property this accessor is responsible for from an object
588 wxxVariant
GetProperty(const wxObject
*o
) const
590 return wxxVariant( (wxxVariantData
* ) DoGetProperty( o
) ) ;
593 // write the property this accessor is responsible for from an object into
595 void WriteValue( wxString
& s
, const wxObject
*o
) const
597 DoGetProperty( o
)->Write( s
) ;
600 // read a wxxVariant having the correct type for the property this accessor
601 // is responsible for from a string
602 wxxVariant
ReadValue( const wxString
&value
) const
605 wxStringReadValue( value
, data
) ;
606 return wxxVariant( data
) ;
610 wxxVariantDataT
<T
>* DoGetProperty(const wxObject
*o
) const
612 const Klass
*obj
= dynamic_cast<const Klass
*>(o
);
614 return new wxxVariantDataT
<T
>( (obj
->*(m_getter
))() ) ;
616 return new wxxVariantDataT
<T
>( (obj
->*(m_getter_ref
))() ) ;
620 setter_ref_t m_setter_ref
;
621 setter_ref_bool_t m_setter_ref_bool
;
622 setter_bool_t m_setter_bool
;
624 getter_ref_t m_getter_ref
;
627 class WXDLLIMPEXP_BASE wxPropertyInfo
630 wxPropertyInfo( wxPropertyInfo
* &iter
, const wxChar
*name
, const wxChar
*typeName
, const wxTypeInfo
* typeInfo
, wxPropertyAccessor
*accessor
, wxxVariant dv
) :
631 m_name( name
) , m_typeName(typeName
) , m_typeInfo( typeInfo
) , m_accessor( accessor
) , m_defaultValue( dv
)
638 wxPropertyInfo
* i
= iter
;
645 // return the name of this property
646 const wxChar
* GetName() const { return m_name
; }
648 // return the typename of this property
649 const wxChar
* GetTypeName() const { return m_typeName
; }
651 // return the type info of this property
652 const wxTypeInfo
* GetTypeInfo() const { return m_typeInfo
; }
654 // return the accessor for this property
655 wxPropertyAccessor
* GetAccessor() const { return m_accessor
; }
657 // returns NULL if this is the last property of this class
658 wxPropertyInfo
* GetNext() const { return m_next
; }
660 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
661 wxxVariant
GetDefaultValue() const { return m_defaultValue
; }
663 const wxChar
* m_name
;
664 const wxChar
* m_typeName
;
665 const wxTypeInfo
* m_typeInfo
;
666 wxPropertyAccessor
* m_accessor
;
667 wxxVariant m_defaultValue
;
668 // string representation of the default value
669 // to be assigned by the designer to the property
670 // when the component is dropped on the container.
671 wxPropertyInfo
* m_next
;
674 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
675 wxPropertyInfo *theClass::GetPropertiesStatic() \
677 typedef theClass class_t; \
678 static wxPropertyInfo* first = NULL ;
680 #define WX_END_PROPERTIES_TABLE() \
684 #if WX_XTI_TEMPLATE_FIX
686 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
687 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
688 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
690 #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
691 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetRetBool*)NULL , &setter , &getter , #setter , #getter ) ; \
692 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
694 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
695 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRef*)NULL, &setter , &getter , #setter , #getter ) ; \
696 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
698 #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
699 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
700 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
702 #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
703 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetAndGetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
704 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
708 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
709 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
710 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
712 #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
713 WX_PROPERTY( name , type , setter , getter , defaultValue )
715 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
716 WX_PROPERTY( name , type , setter , getter , defaultValue )
718 #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
719 WX_PROPERTY( name , type , setter , getter , defaultValue )
721 #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
722 WX_PROPERTY( name , type , setter , getter , defaultValue )
726 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
727 static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
728 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
730 #define WX_DELEGATE( name , eventType , eventClass ) \
731 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
732 static wxPropertyInfo _propertyInfo##name( first , #name , NULL , &_typeInfo##name , NULL , wxxVariant() ) ; \
734 // ----------------------------------------------------------------------------
737 // this is describing an event sink
738 // ----------------------------------------------------------------------------
743 wxHandlerInfo( wxHandlerInfo
* &iter
, const wxChar
*name
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) :
744 m_name( name
) , m_eventClassInfo( eventClassInfo
) , m_eventFunction( address
)
751 wxHandlerInfo
* i
= iter
;
759 // get the name of the handler method
760 const wxChar
* GetName() const { return m_name
; }
762 // return the class info of the event
763 const wxClassInfo
* GetEventClassInfo() const { return m_eventClassInfo
; }
765 // get the handler function pointer
766 wxObjectEventFunction
GetEventFunction() const { return m_eventFunction
; }
768 // returns NULL if this is the last handler of this class
769 wxHandlerInfo
* GetNext() const { return m_next
; }
771 wxObjectEventFunction m_eventFunction
;
772 const wxChar
* m_name
;
773 const wxClassInfo
* m_eventClassInfo
;
774 wxHandlerInfo
* m_next
;
777 #define WX_HANDLER(name,eventClassType) \
778 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
780 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
781 wxHandlerInfo *theClass::GetHandlersStatic() \
783 typedef theClass class_t; \
784 static wxHandlerInfo* first = NULL ;
786 #define WX_END_HANDLERS_TABLE() \
789 // ----------------------------------------------------------------------------
790 // Constructor Bridges
792 // allow to set up constructors with params during runtime
793 // ----------------------------------------------------------------------------
795 class WXDLLIMPEXP_BASE wxConstructorBridge
798 virtual void Create(wxObject
*o
, wxxVariant
*args
) = 0;
801 // Creator Bridges for all Numbers of Params
805 template<typename Class
>
806 struct wxConstructorBridge_0
: public wxConstructorBridge
808 void Create(wxObject
*o
, wxxVariant
*)
810 Class
*obj
= dynamic_cast<Class
*>(o
);
815 struct wxConstructorBridge_Dummy
: public wxConstructorBridge
817 void Create(wxObject
*, wxxVariant
*)
822 #define WX_CONSTRUCTOR_0(klass) \
823 wxConstructorBridge_0<klass> constructor##klass ; \
824 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
825 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
826 const int klass::sm_constructorPropertiesCount##klass = 0 ;
828 #define WX_CONSTRUCTOR_DUMMY(klass) \
829 wxConstructorBridge_Dummy constructor##klass ; \
830 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
831 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
832 const int klass::sm_constructorPropertiesCount##klass = 0 ;
836 template<typename Class
, typename T0
>
837 struct wxConstructorBridge_1
: public wxConstructorBridge
839 void Create(wxObject
*o
, wxxVariant
*args
)
841 Class
*obj
= dynamic_cast<Class
*>(o
);
848 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
849 wxConstructorBridge_1<klass,t0> constructor##klass ; \
850 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
851 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
852 const int klass::sm_constructorPropertiesCount##klass = 1 ;
856 template<typename Class
,
857 typename T0
, typename T1
>
858 struct wxConstructorBridge_2
: public wxConstructorBridge
860 void Create(wxObject
*o
, wxxVariant
*args
)
862 Class
*obj
= dynamic_cast<Class
*>(o
);
870 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
871 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
872 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
873 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
874 const int klass::sm_constructorPropertiesCount##klass = 2;
878 template<typename Class
,
879 typename T0
, typename T1
, typename T2
>
880 struct wxConstructorBridge_3
: public wxConstructorBridge
882 void Create(wxObject
*o
, wxxVariant
*args
)
884 Class
*obj
= dynamic_cast<Class
*>(o
);
893 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
894 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
895 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
896 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
897 const int klass::sm_constructorPropertiesCount##klass = 3 ;
901 template<typename Class
,
902 typename T0
, typename T1
, typename T2
, typename T3
>
903 struct wxConstructorBridge_4
: public wxConstructorBridge
905 void Create(wxObject
*o
, wxxVariant
*args
)
907 Class
*obj
= dynamic_cast<Class
*>(o
);
917 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
918 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
919 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
920 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
921 const int klass::sm_constructorPropertiesCount##klass = 4 ;
925 template<typename Class
,
926 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
>
927 struct wxConstructorBridge_5
: public wxConstructorBridge
929 void Create(wxObject
*o
, wxxVariant
*args
)
931 Class
*obj
= dynamic_cast<Class
*>(o
);
942 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
943 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
944 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
945 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
946 const int klass::sm_constructorPropertiesCount##klass = 5;
950 template<typename Class
,
951 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
>
952 struct wxConstructorBridge_6
: public wxConstructorBridge
954 void Create(wxObject
*o
, wxxVariant
*args
)
956 Class
*obj
= dynamic_cast<Class
*>(o
);
968 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
969 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
970 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
971 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
972 const int klass::sm_constructorPropertiesCount##klass = 6;
975 // ----------------------------------------------------------------------------
977 // ----------------------------------------------------------------------------
979 typedef wxObject
*(*wxObjectConstructorFn
)(void);
980 typedef wxObject
* (*wxVariantToObjectConverter
)( wxxVariant
&data
) ;
981 typedef wxxVariant (*wxObjectToVariantConverter
)( wxObject
* ) ;
983 class WXDLLIMPEXP_BASE wxClassInfo
986 wxClassInfo(const wxClassInfo
**_Parents
,
987 const wxChar
*_UnitName
,
988 const wxChar
*_ClassName
,
990 wxObjectConstructorFn ctor
,
991 wxPropertyInfo
*_Props
,
992 wxHandlerInfo
*_Handlers
,
993 wxConstructorBridge
* _Constructor
,
994 const wxChar
** _ConstructorProperties
,
995 const int _ConstructorPropertiesCount
,
996 wxVariantToObjectConverter _PtrConverter1
,
997 wxVariantToObjectConverter _Converter2
,
998 wxObjectToVariantConverter _Converter3
999 ) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1000 m_objectSize(size
), m_objectConstructor(ctor
) , m_firstProperty(_Props
) , m_firstHandler(_Handlers
) , m_constructor( _Constructor
) ,
1001 m_constructorProperties(_ConstructorProperties
) , m_constructorPropertiesCount(_ConstructorPropertiesCount
),
1002 m_variantOfPtrToObjectConverter( _PtrConverter1
) , m_variantToObjectConverter( _Converter2
) , m_objectToVariantConverter( _Converter3
) , m_next(sm_first
)
1008 wxClassInfo(const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
**_Parents
) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1009 m_objectSize(0), m_objectConstructor(NULL
) , m_firstProperty(NULL
) , m_firstHandler(NULL
) , m_constructor( NULL
) ,
1010 m_constructorProperties(NULL
) , m_constructorPropertiesCount(NULL
),
1011 m_variantOfPtrToObjectConverter( NULL
) , m_variantToObjectConverter( NULL
) , m_objectToVariantConverter( NULL
) , m_next(sm_first
)
1017 virtual ~wxClassInfo() ;
1019 virtual wxObject
*CreateObject() const { return m_objectConstructor
? (*m_objectConstructor
)() : 0; }
1021 const wxChar
*GetClassName() const { return m_className
; }
1022 const wxClassInfo
**GetParents() const { return m_parents
; }
1023 int GetSize() const { return m_objectSize
; }
1025 wxObjectConstructorFn
GetConstructor() const { return m_objectConstructor
; }
1026 static const wxClassInfo
*GetFirst() { return sm_first
; }
1027 const wxClassInfo
*GetNext() const { return m_next
; }
1028 static wxClassInfo
*FindClass(const wxChar
*className
);
1030 // Climb upwards through inheritance hierarchy.
1031 // Dual inheritance is catered for.
1033 bool IsKindOf(const wxClassInfo
*info
) const
1040 for ( int i
= 0 ; m_parents
[i
] ; ++ i
)
1042 if ( m_parents
[i
]->IsKindOf( info
) )
1049 #ifdef WXWIN_COMPATIBILITY_2_4
1050 // Initializes parent pointers and hash table for fast searching.
1051 wxDEPRECATED( static void InitializeClasses() );
1052 // Cleans up hash table used for fast searching.
1053 wxDEPRECATED( static void CleanUpClasses() );
1055 static void CleanUp();
1057 // returns the first property
1058 const wxPropertyInfo
* GetFirstProperty() const { return m_firstProperty
; }
1060 // returns the first handler
1061 const wxHandlerInfo
* GetFirstHandler() const { return m_firstHandler
; }
1063 // Call the Create method for a class
1064 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const
1066 wxASSERT_MSG( ParamCount
== m_constructorPropertiesCount
, wxT("Illegal Parameter Count for Create Method")) ;
1067 m_constructor
->Create( object
, Params
) ;
1070 // get number of parameters for constructor
1071 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount
; }
1073 // get i-th constructor parameter
1074 virtual const wxChar
* GetCreateParamName(int i
) const { return m_constructorProperties
[i
] ; }
1076 // Runtime access to objects by property name, and variant data
1077 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
) const ;
1078 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
) const;
1080 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1081 wxObject
* VariantToInstance( wxxVariant
&data
) const
1082 { if ( data
.GetTypeInfo()->GetKind() == wxT_OBJECT
)
1083 return m_variantToObjectConverter( data
) ;
1085 return m_variantOfPtrToObjectConverter( data
) ;
1088 wxxVariant
InstanceToVariant( wxObject
*object
) const { return m_objectToVariantConverter( object
) ; }
1090 // find property by name
1091 virtual const wxPropertyInfo
*FindPropertyInfo (const wxChar
*PropertyName
) const ;
1093 // find handler by name
1094 virtual const wxHandlerInfo
*FindHandlerInfo (const wxChar
*PropertyName
) const ;
1096 // find property by name
1097 virtual const wxPropertyInfo
*FindPropertyInfoInThisClass (const wxChar
*PropertyName
) const ;
1099 // find handler by name
1100 virtual const wxHandlerInfo
*FindHandlerInfoInThisClass (const wxChar
*PropertyName
) const ;
1102 const wxChar
*m_className
;
1104 wxObjectConstructorFn m_objectConstructor
;
1106 // class info object live in a linked list:
1107 // pointers to its head and the next element in it
1109 static wxClassInfo
*sm_first
;
1110 wxClassInfo
*m_next
;
1112 // FIXME: this should be private (currently used directly by way too
1114 static wxHashTable
*sm_classTable
;
1117 wxPropertyInfo
* m_firstProperty
;
1118 wxHandlerInfo
* m_firstHandler
;
1120 const wxClassInfo
** m_parents
;
1121 const wxChar
* m_unitName
;
1123 wxConstructorBridge
* m_constructor
;
1124 const wxChar
** m_constructorProperties
;
1125 const int m_constructorPropertiesCount
;
1126 wxVariantToObjectConverter m_variantOfPtrToObjectConverter
;
1127 wxVariantToObjectConverter m_variantToObjectConverter
;
1128 wxObjectToVariantConverter m_objectToVariantConverter
;
1130 const wxPropertyAccessor
*FindAccessor (const wxChar
*propertyName
) const ;
1133 // InitializeClasses() helper
1134 static wxClassInfo
*GetBaseByName(const wxChar
*name
) ;
1137 // registers the class
1141 DECLARE_NO_COPY_CLASS(wxClassInfo
)
1145 WXDLLIMPEXP_BASE wxObject
*wxCreateDynamicObject(const wxChar
*name
);
1147 // ----------------------------------------------------------------------------
1149 // ----------------------------------------------------------------------------
1151 // this object leads to having a pure runtime-instantiation
1153 class wxDynamicClassInfo
: public wxClassInfo
1156 wxDynamicClassInfo( const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
* superClass
) ;
1157 virtual ~wxDynamicClassInfo() ;
1159 // constructs a wxDynamicObject with an instance
1160 virtual wxObject
*CreateObject() const ;
1162 // Call the Create method for a class
1163 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const ;
1165 // get number of parameters for constructor
1166 virtual int GetCreateParamCount() const ;
1168 // get i-th constructor parameter
1169 virtual const wxChar
* GetCreateParamName(int i
) const ;
1171 // Runtime access to objects by property name, and variant data
1172 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
) const ;
1173 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
) const ;
1175 void AddProperty( const wxChar
*propertyName
, const wxTypeInfo
* typeInfo
) ;
1176 void AddHandler( const wxChar
*handlerName
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) ;
1179 // ----------------------------------------------------------------------------
1180 // Dynamic class macros
1181 // ----------------------------------------------------------------------------
1183 #define _DECLARE_DYNAMIC_CLASS(name) \
1185 static wxClassInfo sm_class##name; \
1186 static const wxClassInfo* sm_classParents##name[] ; \
1187 static wxPropertyInfo* GetPropertiesStatic() ; \
1188 static wxHandlerInfo* GetHandlersStatic() ; \
1189 virtual wxClassInfo *GetClassInfo() const \
1190 { return &name::sm_class##name; }
1192 #define DECLARE_DYNAMIC_CLASS(name) \
1193 static wxConstructorBridge* sm_constructor##name ; \
1194 static const wxChar * sm_constructorProperties##name[] ; \
1195 static const int sm_constructorPropertiesCount##name ; \
1196 _DECLARE_DYNAMIC_CLASS(name)
1198 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1199 DECLARE_NO_ASSIGN_CLASS(name) \
1200 DECLARE_DYNAMIC_CLASS(name)
1202 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1203 DECLARE_NO_COPY_CLASS(name) \
1204 DECLARE_DYNAMIC_CLASS(name)
1206 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1207 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1209 // -----------------------------------
1210 // for concrete classes
1211 // -----------------------------------
1213 // Single inheritance with one base class
1215 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
1216 wxObject* wxConstructorFor##name() \
1217 { return new name; } \
1218 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1219 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1220 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1221 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1222 (int) sizeof(name), \
1223 (wxObjectConstructorFn) wxConstructorFor##name , \
1224 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1225 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name); \
1226 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1227 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1228 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1229 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1230 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1231 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1232 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1233 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1234 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1236 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \
1237 wxObject* wxConstructorFor##name() \
1238 { return new name; } \
1239 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1240 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1241 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1242 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1243 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1244 (int) sizeof(name), \
1245 (wxObjectConstructorFn) wxConstructorFor##name , \
1246 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1247 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1248 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1249 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1250 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1251 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1252 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1253 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1254 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1255 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1256 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1258 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1259 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \
1260 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1261 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1262 WX_CONSTRUCTOR_DUMMY( name )
1264 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1265 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
1266 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1267 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1268 WX_CONSTRUCTOR_DUMMY( name )
1270 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1271 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
1273 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1274 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
1276 // this is for classes that do not derive from wxobject, there are no creators for these
1278 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1279 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1280 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1281 (int) sizeof(name), \
1282 (wxObjectConstructorFn) 0 , \
1283 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1285 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1286 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1287 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1288 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1289 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1290 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1291 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1293 // this is for subclasses that still do not derive from wxobject
1295 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1296 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1297 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1298 (int) sizeof(name), \
1299 (wxObjectConstructorFn) 0 , \
1300 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1302 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1303 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1304 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1305 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1306 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1307 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1308 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1311 // Multiple inheritance with two base classes
1313 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1314 wxObject* wxConstructorFor##name() \
1315 { return new name; } \
1316 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1317 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1318 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1319 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1320 (int) sizeof(name), \
1321 (wxObjectConstructorFn) wxConstructorFor##name , \
1322 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1323 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1324 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1325 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1326 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1327 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1328 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1329 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1330 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1332 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1333 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1334 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1335 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1336 WX_CONSTRUCTOR_DUMMY( name )
1338 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1339 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1341 // -----------------------------------
1342 // for abstract classes
1343 // -----------------------------------
1345 // Single inheritance with one base class
1347 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1348 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1349 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1350 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1351 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1352 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1353 (int) sizeof(name), \
1354 (wxObjectConstructorFn) 0 , \
1355 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1356 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1357 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1358 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1359 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1360 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1361 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1362 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1363 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1365 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1366 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1367 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1368 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1370 // Multiple inheritance with two base classes
1372 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1373 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1374 wxT(#basename2), (int) sizeof(name), \
1375 (wxObjectConstructorFn) 0);
1377 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1378 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2