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 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const = 0 ;
491 virtual wxxVariant
GetProperty(const wxObject
*object
) const = 0 ;
492 virtual bool HasSetter() const = 0 ;
493 virtual bool HasGetter() const = 0 ;
494 const wxChar
* GetGetterName() const { return m_setterName
; }
495 const wxChar
* GetSetterName() const { return m_getterName
; }
496 virtual wxxVariant
ReadValue( const wxString
&value
) const = 0 ;
497 virtual void WriteValue( wxString
& value
, const wxObject
*o
) const = 0 ;
499 const wxChar
*m_setterName
;
500 const wxChar
*m_getterName
;
503 template<class Klass
, typename T
>
504 class WXDLLIMPEXP_BASE wxPropertyAccessorT
: public wxPropertyAccessor
508 typedef void (Klass::*setter_t
)(T value
);
509 typedef bool (Klass::*setter_bool_t
)(T value
);
510 typedef void (Klass::*setter_ref_t
)(const T
& value
);
511 typedef bool (Klass::*setter_ref_bool_t
)(const T
& value
);
512 typedef T (Klass::*getter_t
)() const;
513 typedef const T
& (Klass::*getter_ref_t
)() const;
515 wxPropertyAccessorT(setter_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
516 : 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
;}
518 wxPropertyAccessorT( getter_t getter
, const wxChar
*g
)
519 : 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
;}
521 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetRetBool
*,) setter_bool_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
522 : 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
;}
524 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRef
*,) setter_ref_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
525 : 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
;}
527 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRefRetBool
*,) setter_ref_bool_t setter
, getter_t getter
, const wxChar
*g
, const wxChar
*s
)
528 : 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
;}
530 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRef
*,) setter_ref_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
531 : 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
;}
533 wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRefRetBool
*,) setter_ref_bool_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
534 : 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
;}
536 wxPropertyAccessorT(WX_XTI_PARAM_FIX(GetByRef
*,) setter_t setter
, getter_ref_t getter
, const wxChar
*g
, const wxChar
*s
)
537 : 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
;}
539 // returns true if this accessor has a setter
540 bool HasSetter() const { return m_setter
!= NULL
|| m_setter_ref
!= NULL
; }
542 // return true if this accessor has a getter
543 bool HasGetter() const { return m_getter
!= NULL
|| m_getter_ref
!= NULL
; }
545 // set the property this accessor is responsible for in an object
546 void SetProperty(wxObject
*o
, const wxxVariant
&v
) const
548 Klass
*obj
= dynamic_cast<Klass
*>(o
);
551 if ( wxGetTypeInfo((T
*)NULL
)->GetKind() == wxT_OBJECT
&& v
.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR
)
552 value
= *v
.Get
<T
*>();
556 (obj
->*(m_setter
))(value
);
557 else if ( m_setter_ref
)
558 (obj
->*(m_setter_ref
))(value
);
559 else if ( m_setter_ref_bool
)
560 (obj
->*(m_setter_ref_bool
))(value
);
561 else if ( m_setter_bool
)
562 (obj
->*(m_setter_bool
))(value
);
565 wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ;
569 // gets the property this accessor is responsible for from an object
570 wxxVariant
GetProperty(const wxObject
*o
) const
572 return wxxVariant( (wxxVariantData
* ) DoGetProperty( o
) ) ;
575 // write the property this accessor is responsible for from an object into
577 void WriteValue( wxString
& s
, const wxObject
*o
) const
579 DoGetProperty( o
)->Write( s
) ;
582 // read a wxxVariant having the correct type for the property this accessor
583 // is responsible for from a string
584 wxxVariant
ReadValue( const wxString
&value
) const
587 wxStringReadValue( value
, data
) ;
588 return wxxVariant( data
) ;
592 wxxVariantDataT
<T
>* DoGetProperty(const wxObject
*o
) const
594 const Klass
*obj
= dynamic_cast<const Klass
*>(o
);
596 return new wxxVariantDataT
<T
>( (obj
->*(m_getter
))() ) ;
598 return new wxxVariantDataT
<T
>( (obj
->*(m_getter_ref
))() ) ;
602 setter_ref_t m_setter_ref
;
603 setter_ref_bool_t m_setter_ref_bool
;
604 setter_bool_t m_setter_bool
;
606 getter_ref_t m_getter_ref
;
609 class WXDLLIMPEXP_BASE wxPropertyInfo
612 wxPropertyInfo( wxPropertyInfo
* &iter
, const wxChar
*name
, const wxChar
*typeName
, const wxTypeInfo
* typeInfo
, wxPropertyAccessor
*accessor
, wxxVariant dv
) :
613 m_name( name
) , m_typeName(typeName
) , m_typeInfo( typeInfo
) , m_accessor( accessor
) , m_defaultValue( dv
)
620 wxPropertyInfo
* i
= iter
;
627 // return the name of this property
628 const wxChar
* GetName() const { return m_name
; }
630 // return the typename of this property
631 const wxChar
* GetTypeName() const { return m_typeName
; }
633 // return the type info of this property
634 const wxTypeInfo
* GetTypeInfo() const { return m_typeInfo
; }
636 // return the accessor for this property
637 wxPropertyAccessor
* GetAccessor() const { return m_accessor
; }
639 // returns NULL if this is the last property of this class
640 wxPropertyInfo
* GetNext() const { return m_next
; }
642 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
643 wxxVariant
GetDefaultValue() const { return m_defaultValue
; }
645 const wxChar
* m_name
;
646 const wxChar
* m_typeName
;
647 const wxTypeInfo
* m_typeInfo
;
648 wxPropertyAccessor
* m_accessor
;
649 wxxVariant m_defaultValue
;
650 // string representation of the default value
651 // to be assigned by the designer to the property
652 // when the component is dropped on the container.
653 wxPropertyInfo
* m_next
;
656 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
657 const wxPropertyInfo *theClass::GetPropertiesStatic() \
659 typedef theClass class_t; \
660 static wxPropertyInfo* first = NULL ;
662 #define WX_END_PROPERTIES_TABLE() \
666 #if WX_XTI_TEMPLATE_FIX
668 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
669 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
670 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
672 #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
673 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetRetBool*)NULL , &setter , &getter , #setter , #getter ) ; \
674 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
676 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
677 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRef*)NULL, &setter , &getter , #setter , #getter ) ; \
678 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
680 #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
681 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
682 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
684 #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
685 static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetAndGetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
686 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
690 #define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
691 static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
692 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
694 #define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
695 WX_PROPERTY( name , type , setter , getter , defaultValue )
697 #define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
698 WX_PROPERTY( name , type , setter , getter , defaultValue )
700 #define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
701 WX_PROPERTY( name , type , setter , getter , defaultValue )
703 #define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
704 WX_PROPERTY( name , type , setter , getter , defaultValue )
708 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
709 static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
710 static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
712 #define WX_DELEGATE( name , eventType , eventClass ) \
713 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
714 static wxPropertyInfo _propertyInfo##name( first , #name , NULL , &_typeInfo##name , NULL , wxxVariant() ) ; \
716 // ----------------------------------------------------------------------------
719 // this is describing an event sink
720 // ----------------------------------------------------------------------------
725 wxHandlerInfo( wxHandlerInfo
* &iter
, const wxChar
*name
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) :
726 m_name( name
) , m_eventClassInfo( eventClassInfo
) , m_eventFunction( address
)
733 wxHandlerInfo
* i
= iter
;
741 // get the name of the handler method
742 const wxChar
* GetName() const { return m_name
; }
744 // return the class info of the event
745 const wxClassInfo
* GetEventClassInfo() const { return m_eventClassInfo
; }
747 // get the handler function pointer
748 wxObjectEventFunction
GetEventFunction() const { return m_eventFunction
; }
750 // returns NULL if this is the last handler of this class
751 wxHandlerInfo
* GetNext() const { return m_next
; }
753 wxObjectEventFunction m_eventFunction
;
754 const wxChar
* m_name
;
755 const wxClassInfo
* m_eventClassInfo
;
756 wxHandlerInfo
* m_next
;
759 #define WX_HANDLER(name,eventClassType) \
760 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
762 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
763 const wxHandlerInfo *theClass::GetHandlersStatic() \
765 typedef theClass class_t; \
766 static wxHandlerInfo* first = NULL ;
768 #define WX_END_HANDLERS_TABLE() \
771 // ----------------------------------------------------------------------------
772 // Constructor Bridges
774 // allow to set up constructors with params during runtime
775 // ----------------------------------------------------------------------------
777 class WXDLLIMPEXP_BASE wxConstructorBridge
780 virtual void Create(wxObject
*o
, wxxVariant
*args
) = 0;
783 // Creator Bridges for all Numbers of Params
787 template<typename Class
>
788 struct wxConstructorBridge_0
: public wxConstructorBridge
790 void Create(wxObject
*o
, wxxVariant
*)
792 Class
*obj
= dynamic_cast<Class
*>(o
);
797 struct wxConstructorBridge_Dummy
: public wxConstructorBridge
799 void Create(wxObject
*, wxxVariant
*)
804 #define WX_CONSTRUCTOR_0(klass) \
805 wxConstructorBridge_0<klass> constructor##klass ; \
806 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
807 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
808 const int klass::sm_constructorPropertiesCount##klass = 0 ;
810 #define WX_CONSTRUCTOR_DUMMY(klass) \
811 wxConstructorBridge_Dummy constructor##klass ; \
812 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
813 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
814 const int klass::sm_constructorPropertiesCount##klass = 0 ;
818 template<typename Class
, typename T0
>
819 struct wxConstructorBridge_1
: public wxConstructorBridge
821 void Create(wxObject
*o
, wxxVariant
*args
)
823 Class
*obj
= dynamic_cast<Class
*>(o
);
830 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
831 wxConstructorBridge_1<klass,t0> constructor##klass ; \
832 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
833 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
834 const int klass::sm_constructorPropertiesCount##klass = 1 ;
838 template<typename Class
,
839 typename T0
, typename T1
>
840 struct wxConstructorBridge_2
: public wxConstructorBridge
842 void Create(wxObject
*o
, wxxVariant
*args
)
844 Class
*obj
= dynamic_cast<Class
*>(o
);
852 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
853 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
854 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
855 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
856 const int klass::sm_constructorPropertiesCount##klass = 2;
860 template<typename Class
,
861 typename T0
, typename T1
, typename T2
>
862 struct wxConstructorBridge_3
: public wxConstructorBridge
864 void Create(wxObject
*o
, wxxVariant
*args
)
866 Class
*obj
= dynamic_cast<Class
*>(o
);
875 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
876 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
877 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
878 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
879 const int klass::sm_constructorPropertiesCount##klass = 3 ;
883 template<typename Class
,
884 typename T0
, typename T1
, typename T2
, typename T3
>
885 struct wxConstructorBridge_4
: public wxConstructorBridge
887 void Create(wxObject
*o
, wxxVariant
*args
)
889 Class
*obj
= dynamic_cast<Class
*>(o
);
899 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
900 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
901 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
902 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
903 const int klass::sm_constructorPropertiesCount##klass = 4 ;
907 template<typename Class
,
908 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
>
909 struct wxConstructorBridge_5
: public wxConstructorBridge
911 void Create(wxObject
*o
, wxxVariant
*args
)
913 Class
*obj
= dynamic_cast<Class
*>(o
);
924 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
925 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
926 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
927 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
928 const int klass::sm_constructorPropertiesCount##klass = 5;
932 template<typename Class
,
933 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
>
934 struct wxConstructorBridge_6
: public wxConstructorBridge
936 void Create(wxObject
*o
, wxxVariant
*args
)
938 Class
*obj
= dynamic_cast<Class
*>(o
);
950 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
951 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
952 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
953 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
954 const int klass::sm_constructorPropertiesCount##klass = 6;
957 // ----------------------------------------------------------------------------
959 // ----------------------------------------------------------------------------
961 typedef wxObject
*(*wxObjectConstructorFn
)(void);
962 typedef wxObject
* (*wxVariantToObjectConverter
)( wxxVariant
&data
) ;
963 typedef wxxVariant (*wxObjectToVariantConverter
)( wxObject
* ) ;
965 class WXDLLIMPEXP_BASE wxClassInfo
968 wxClassInfo(const wxClassInfo
**_Parents
,
969 const wxChar
*_UnitName
,
970 const wxChar
*_ClassName
,
972 wxObjectConstructorFn ctor
,
973 const wxPropertyInfo
*_Props
,
974 const wxHandlerInfo
*_Handlers
,
975 wxConstructorBridge
* _Constructor
,
976 const wxChar
** _ConstructorProperties
,
977 const int _ConstructorPropertiesCount
,
978 wxVariantToObjectConverter _PtrConverter1
,
979 wxVariantToObjectConverter _Converter2
,
980 wxObjectToVariantConverter _Converter3
981 ) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
982 m_objectSize(size
), m_objectConstructor(ctor
) , m_firstProperty(_Props
) , m_firstHandler(_Handlers
) , m_constructor( _Constructor
) ,
983 m_constructorProperties(_ConstructorProperties
) , m_constructorPropertiesCount(_ConstructorPropertiesCount
),
984 m_variantOfPtrToObjectConverter( _PtrConverter1
) , m_variantToObjectConverter( _Converter2
) , m_objectToVariantConverter( _Converter3
) , m_next(sm_first
)
990 virtual ~wxClassInfo() ;
992 wxObject
*CreateObject() const { return m_objectConstructor
? (*m_objectConstructor
)() : 0; }
994 const wxChar
*GetClassName() const { return m_className
; }
995 const wxClassInfo
**GetParents() const { return m_parents
; }
996 int GetSize() const { return m_objectSize
; }
998 wxObjectConstructorFn
GetConstructor() const { return m_objectConstructor
; }
999 static const wxClassInfo
*GetFirst() { return sm_first
; }
1000 const wxClassInfo
*GetNext() const { return m_next
; }
1001 static wxClassInfo
*FindClass(const wxChar
*className
);
1003 // Climb upwards through inheritance hierarchy.
1004 // Dual inheritance is catered for.
1006 bool IsKindOf(const wxClassInfo
*info
) const
1013 for ( int i
= 0 ; m_parents
[i
] ; ++ i
)
1015 if ( m_parents
[i
]->IsKindOf( info
) )
1022 #ifdef WXWIN_COMPATIBILITY_2_4
1023 // Initializes parent pointers and hash table for fast searching.
1024 wxDEPRECATED( static void InitializeClasses() );
1025 // Cleans up hash table used for fast searching.
1026 wxDEPRECATED( static void CleanUpClasses() );
1028 static void CleanUp();
1030 // returns the first property
1031 const wxPropertyInfo
* GetFirstProperty() const { return m_firstProperty
; }
1033 // returns the first handler
1034 const wxHandlerInfo
* GetFirstHandler() const { return m_firstHandler
; }
1036 // Call the Create method for a class
1037 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const
1039 wxASSERT_MSG( ParamCount
== m_constructorPropertiesCount
, wxT("Illegal Parameter Count for Create Method")) ;
1040 m_constructor
->Create( object
, Params
) ;
1043 // get number of parameters for constructor
1044 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount
; }
1046 // get i-th constructor parameter
1047 virtual const wxChar
* GetCreateParamName(int i
) const { return m_constructorProperties
[i
] ; }
1049 // Runtime access to objects by property name, and variant data
1050 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
);
1051 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
);
1053 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1054 wxObject
* VariantToInstance( wxxVariant
&data
) const
1055 { if ( data
.GetTypeInfo()->GetKind() == wxT_OBJECT
)
1056 return m_variantToObjectConverter( data
) ;
1058 return m_variantOfPtrToObjectConverter( data
) ;
1061 wxxVariant
InstanceToVariant( wxObject
*object
) const { return m_objectToVariantConverter( object
) ; }
1063 // find property by name
1064 virtual const wxPropertyInfo
*FindPropertyInfo (const wxChar
*PropertyName
) const ;
1066 // find handler by name
1067 virtual const wxHandlerInfo
*FindHandlerInfo (const wxChar
*PropertyName
) const ;
1070 const wxChar
*m_className
;
1072 wxObjectConstructorFn m_objectConstructor
;
1074 // class info object live in a linked list:
1075 // pointers to its head and the next element in it
1077 static wxClassInfo
*sm_first
;
1078 wxClassInfo
*m_next
;
1080 // FIXME: this should be private (currently used directly by way too
1082 static wxHashTable
*sm_classTable
;
1085 const wxClassInfo
** m_parents
;
1086 const wxPropertyInfo
* m_firstProperty
;
1087 const wxHandlerInfo
* m_firstHandler
;
1088 const wxChar
* m_unitName
;
1090 wxConstructorBridge
* m_constructor
;
1091 const wxChar
** m_constructorProperties
;
1092 const int m_constructorPropertiesCount
;
1093 wxVariantToObjectConverter m_variantOfPtrToObjectConverter
;
1094 wxVariantToObjectConverter m_variantToObjectConverter
;
1095 wxObjectToVariantConverter m_objectToVariantConverter
;
1097 const wxPropertyAccessor
*FindAccessor (const wxChar
*propertyName
);
1100 // InitializeClasses() helper
1101 static wxClassInfo
*GetBaseByName(const wxChar
*name
);
1104 // registers the class
1108 DECLARE_NO_COPY_CLASS(wxClassInfo
)
1111 WXDLLIMPEXP_BASE wxObject
*wxCreateDynamicObject(const wxChar
*name
);
1113 // ----------------------------------------------------------------------------
1114 // Dynamic class macros
1115 // ----------------------------------------------------------------------------
1117 #define _DECLARE_DYNAMIC_CLASS(name) \
1119 static wxClassInfo sm_class##name; \
1120 static const wxClassInfo* sm_classParents##name[] ; \
1121 static const wxPropertyInfo* GetPropertiesStatic() ; \
1122 static const wxHandlerInfo* GetHandlersStatic() ; \
1123 virtual wxClassInfo *GetClassInfo() const \
1124 { return &name::sm_class##name; }
1126 #define DECLARE_DYNAMIC_CLASS(name) \
1127 static wxConstructorBridge* sm_constructor##name ; \
1128 static const wxChar * sm_constructorProperties##name[] ; \
1129 static const int sm_constructorPropertiesCount##name ; \
1130 _DECLARE_DYNAMIC_CLASS(name)
1132 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1133 DECLARE_NO_ASSIGN_CLASS(name) \
1134 DECLARE_DYNAMIC_CLASS(name)
1136 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1137 DECLARE_NO_COPY_CLASS(name) \
1138 DECLARE_DYNAMIC_CLASS(name)
1140 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1141 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1143 // -----------------------------------
1144 // for concrete classes
1145 // -----------------------------------
1147 // Single inheritance with one base class
1149 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
1150 wxObject* wxConstructorFor##name() \
1151 { return new name; } \
1152 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1153 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1154 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1155 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1156 (int) sizeof(name), \
1157 (wxObjectConstructorFn) wxConstructorFor##name , \
1158 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1159 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name); \
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<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1165 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1166 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1167 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1168 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1170 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \
1171 wxObject* wxConstructorFor##name() \
1172 { return new name; } \
1173 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1174 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1175 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1176 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1177 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1178 (int) sizeof(name), \
1179 (wxObjectConstructorFn) wxConstructorFor##name , \
1180 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1181 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
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<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1187 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1188 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1189 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1190 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1192 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1193 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \
1194 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1195 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1196 WX_CONSTRUCTOR_DUMMY( name )
1198 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1199 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
1200 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1201 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1202 WX_CONSTRUCTOR_DUMMY( name )
1204 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1205 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
1207 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1208 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
1210 // this is for classes that do not derive from wxobject, there are no creators for these
1212 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1213 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1214 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1215 (int) sizeof(name), \
1216 (wxObjectConstructorFn) 0 , \
1217 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
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<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1222 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1223 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1224 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1225 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1227 // this is for subclasses that still do not derive from wxobject
1229 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1230 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1231 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1232 (int) sizeof(name), \
1233 (wxObjectConstructorFn) 0 , \
1234 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
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<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1239 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1240 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1241 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1242 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1245 // Multiple inheritance with two base classes
1247 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1248 wxObject* wxConstructorFor##name() \
1249 { return new name; } \
1250 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1251 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1252 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1253 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1254 (int) sizeof(name), \
1255 (wxObjectConstructorFn) wxConstructorFor##name , \
1256 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1257 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
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<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1261 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1262 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1263 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1264 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1266 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1267 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1268 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1269 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1270 WX_CONSTRUCTOR_DUMMY( name )
1272 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1273 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1275 // -----------------------------------
1276 // for abstract classes
1277 // -----------------------------------
1279 // Single inheritance with one base class
1281 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1282 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1283 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1284 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1285 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1286 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1287 (int) sizeof(name), \
1288 (wxObjectConstructorFn) 0 , \
1289 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1290 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
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<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1294 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1295 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1296 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1297 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1299 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1300 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1301 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1302 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1304 // Multiple inheritance with two base classes
1306 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1307 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1308 wxT(#basename2), (int) sizeof(name), \
1309 (wxObjectConstructorFn) 0);
1311 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1312 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2