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"
44 #include "wx/hashmap.h"
46 class WXDLLIMPEXP_BASE wxObject
;
47 class WXDLLIMPEXP_BASE wxClassInfo
;
48 class WXDLLIMPEXP_BASE wxHashTable
;
49 class WXDLLIMPEXP_BASE wxObjectRefData
;
50 class WXDLLIMPEXP_BASE wxEvent
;
52 typedef void (wxObject
::*wxObjectEventFunction
)(wxEvent
&);
54 // ----------------------------------------------------------------------------
57 // In the header files there would no change from pure c++ code, in the
58 // implementation, an enum would have
59 // to be enumerated eg :
61 // WX_BEGIN_ENUM( wxFlavor )
62 // WX_ENUM_MEMBER( Vanilla )
63 // WX_ENUM_MEMBER( Chocolate )
64 // WX_ENUM_MEMBER( Strawberry )
65 // WX_END_ENUM( wxFlavor )
66 // ----------------------------------------------------------------------------
68 struct WXDLLIMPEXP_BASE wxEnumMemberData
74 class WXDLLIMPEXP_BASE wxEnumData
77 wxEnumData( wxEnumMemberData
* data
) ;
79 // returns true if the member has been found and sets the int value
80 // pointed to accordingly (if ptr != null )
81 // if not found returns false, value left unchanged
82 bool HasEnumMemberValue( const wxChar
*name
, int *value
= NULL
) ;
84 // returns the value of the member, if not found in debug mode an
85 // assert is issued, in release 0 is returned
86 int GetEnumMemberValue(const wxChar
*name
);
88 // returns the name of the enum member having the passed in value
89 // returns an emtpy string if not found
90 const wxChar
*GetEnumMemberName(int value
);
92 // returns the number of members in this enum
93 int GetEnumCount() { return m_count
; }
95 // returns the value of the nth member
96 int GetEnumMemberValueByIndex( int n
) ;
98 // returns the value of the nth member
99 const wxChar
*GetEnumMemberNameByIndex( int n
) ;
101 wxEnumMemberData
*m_members
;
105 #define WX_BEGIN_ENUM( e ) \
106 wxEnumMemberData s_enumDataMembers##e[] = {
108 #define WX_ENUM_MEMBER( v ) { #v, v } ,
110 #define WX_END_ENUM( e ) { NULL , 0 } } ; \
111 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
112 wxEnumData *wxGetEnumData(e) { return &s_enumData##e ; } \
113 template<> void wxStringReadValue(const wxString& s , e &data ) \
115 data = (e) s_enumData##e.GetEnumMemberValue(s) ; \
117 template<> void wxStringWriteValue(wxString &s , const e &data ) \
119 s = s_enumData##e.GetEnumMemberName((int)data) ; \
121 void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant((e)data) ;} \
122 void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.Get<e>() ;} \
123 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxEnumTypeInfo s_typeInfo(wxT_ENUM , &s_enumData##e , &wxToStringConverter<e> , &wxFromStringConverter<e> , &ToLong##e , &FromLong##e , #e) ; return &s_typeInfo ; } \
124 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; assert(0) ; return &s_typeInfo ; } \
125 template<> void wxStringReadValue(const wxString& , e* & ) \
129 template<> void wxStringWriteValue(wxString &s , e* const & ) \
134 // ----------------------------------------------------------------------------
146 // typedef wxFlags<wxFlavor> wxCoupe ;
148 // in the implementation file :
150 // WX_BEGIN_ENUM( wxFlavor )
151 // WX_ENUM_MEMBER( Vanilla )
152 // WX_ENUM_MEMBER( Chocolate )
153 // WX_ENUM_MEMBER( Strawberry )
154 // WX_END_ENUM( wxFlavor )
156 // WX_IMPLEMENT_SET_STREAMING( wxCoupe , wxFlavor )
158 // implementation note : no partial specialization for streaming, but a delegation to a
161 // ----------------------------------------------------------------------------
163 // in order to remove dependancy on string tokenizer
164 void wxSetStringToArray( const wxString
&s
, wxArrayString
&array
) ;
167 void wxSetFromString(const wxString
&s
, wxFlags
<e
> &data
)
169 wxEnumData
* edata
= wxGetEnumData((e
) 0) ;
172 wxArrayString array
;
173 wxSetStringToArray( s
, array
) ;
175 for ( int i
= 0 ; i
< array
.Count() ; ++i
)
179 if ( edata
->HasEnumMemberValue( flag
, &ivalue
) )
181 data
.set( (e
) ivalue
) ;
187 void wxSetToString( wxString
&s
, const wxFlags
<e
> &data
)
189 wxEnumData
* edata
= wxGetEnumData((e
) 0) ;
190 int count
= edata
->GetEnumCount() ;
193 for ( i
= 0 ; i
< count
; i
++ )
195 e value
= (e
) edata
->GetEnumMemberValueByIndex(i
) ;
196 if ( data
.test( value
) )
198 // this could also be done by the templated calls
201 s
+= edata
->GetEnumMemberNameByIndex(i
) ;
206 // if the wxFlags specialization above does not work for all compilers, add this to the WX_IMPLEMENT_SET_STREAMING macro
207 // template<> const wxTypeInfo* wxGetTypeInfo( SetName * ){ static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e) ; return &s_typeInfo ; }
209 #define WX_IMPLEMENT_SET_STREAMING(SetName,e) \
210 template<> void wxStringReadValue(const wxString &s , wxFlags<e> &data ) \
212 wxSetFromString( s , data ) ; \
214 template<> void wxStringWriteValue( wxString &s , const wxFlags<e> &data ) \
216 wxSetToString( s , data ) ; \
218 void FromLong##SetName( long data , wxxVariant& result ) { result = wxxVariant(SetName((unsigned long)data)) ;} \
219 void ToLong##SetName( const wxxVariant& data , long &result ) { result = (long) data.Get<SetName>().to_ulong() ;} \
220 template<> const wxTypeInfo* wxGetTypeInfo( SetName * ) \
222 static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e , &wxToStringConverter<SetName> , &wxFromStringConverter<SetName> , &ToLong##SetName , &FromLong##SetName, #SetName ) ; return &s_typeInfo ; \
226 // ----------------------------------------------------------------------------
228 // ----------------------------------------------------------------------------
231 // All data exposed by the RTTI is characterized using the following classes.
232 // The first characterization is done by wxTypeKind. All enums up to and including
233 // wxT_CUSTOM represent so called simple types. These cannot be divided any further.
234 // They can be converted to and from wxStrings, that's all.
239 wxT_VOID
= 0, // unknown type
249 wxT_STRING
, // must be wxString
250 wxT_SET
, // must be wxFlags<> template
252 wxT_CUSTOM
, // user defined type (e.g. wxPoint)
254 wxT_LAST_SIMPLE_TYPE_KIND
= wxT_CUSTOM
,
256 wxT_OBJECT_PTR
, // object reference
257 wxT_OBJECT
, // embedded object
258 wxT_COLLECTION
, // collection
260 wxT_DELEGATE
, // for connecting against an event source
262 wxT_LAST_TYPE_KIND
= wxT_DELEGATE
// sentinel for bad data, asserts, debugging
268 WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxTypeInfo
* , wxTypeInfoMap
) ;
270 class WXDLLIMPEXP_BASE wxTypeInfo
273 typedef void (*converterToString_t
)( const wxxVariant
& data
, wxString
&result
) ;
274 typedef void (*converterFromString_t
)( const wxString
& data
, wxxVariant
&result
) ;
276 wxTypeInfo(wxTypeKind kind
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
, const wxString
&name
= wxEmptyString
) :
277 m_kind( kind
) , m_toString(to
) , m_fromString(from
) , m_name(name
)
282 virtual ~wxTypeInfo()
287 // return the kind of this type (wxT_... constants)
288 wxTypeKind
GetKind() const { return m_kind
; }
290 // returns the unique name of this type
291 const wxString
& GetTypeName() const { return m_name
; }
293 // is this type a delegate type
294 bool IsDelegateType() const { return m_kind
== wxT_DELEGATE
; }
296 // is this type a custom type
297 bool IsCustomType() const { return m_kind
== wxT_CUSTOM
; }
299 // is this type an object type
300 bool IsObjectType() const { return m_kind
== wxT_OBJECT
|| m_kind
== wxT_OBJECT_PTR
; }
302 // can the content of this type be converted to and from strings ?
303 bool HasStringConverters() const { return m_toString
!= NULL
&& m_fromString
!= NULL
; }
305 // convert a wxxVariant holding data of this type into a string
306 void ConvertToString( const wxxVariant
& data
, wxString
&result
) const
308 { wxASSERT_MSG( m_toString
, wxT("String conversions not supported") ) ; (*m_toString
)( data
, result
) ; }
310 // convert a string into a wxxVariant holding the corresponding data in this type
311 void ConvertFromString( const wxString
& data
, wxxVariant
&result
) const
312 { wxASSERT_MSG( m_fromString
, wxT("String conversions not supported") ) ; (*m_fromString
)( data
, result
) ; }
314 static wxTypeInfo
*FindType(const wxChar
*typeName
);
321 converterToString_t m_toString
;
322 converterFromString_t m_fromString
;
324 static wxTypeInfoMap
* sm_typeTable
;
330 class WXDLLIMPEXP_BASE wxBuiltInTypeInfo
: public wxTypeInfo
333 wxBuiltInTypeInfo( wxTypeKind kind
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
, const wxString
&name
= wxEmptyString
) :
334 wxTypeInfo( kind
, to
, from
, name
)
335 { wxASSERT_MSG( GetKind() < wxT_SET
, wxT("Illegal Kind for Base Type") ) ; }
338 class WXDLLIMPEXP_BASE wxCustomTypeInfo
: public wxTypeInfo
341 wxCustomTypeInfo( const wxString
&name
, converterToString_t to
, converterFromString_t from
) :
342 wxTypeInfo( wxT_CUSTOM
, to
, from
, name
)
346 class WXDLLIMPEXP_BASE wxEnumTypeInfo
: public wxTypeInfo
349 typedef void (*converterToLong_t
)( const wxxVariant
& data
, long &result
) ;
350 typedef void (*converterFromLong_t
)( long data
, wxxVariant
&result
) ;
352 wxEnumTypeInfo( wxTypeKind kind
, wxEnumData
* enumInfo
, converterToString_t to
, converterFromString_t from
,
353 converterToLong_t toLong
, converterFromLong_t fromLong
, const wxString
&name
) :
354 wxTypeInfo( kind
, to
, from
, name
) , m_toLong( toLong
) , m_fromLong( fromLong
)
355 { wxASSERT_MSG( kind
== wxT_ENUM
|| kind
== wxT_SET
, wxT("Illegal Kind for Enum Type")) ; m_enumInfo
= enumInfo
;}
356 const wxEnumData
* GetEnumData() const { return m_enumInfo
; }
358 // convert a wxxVariant holding data of this type into a long
359 void ConvertToLong( const wxxVariant
& data
, long &result
) const
361 { wxASSERT_MSG( m_toLong
, wxT("Long conversions not supported") ) ; (*m_toLong
)( data
, result
) ; }
363 // convert a long into a wxxVariant holding the corresponding data in this type
364 void ConvertFromLong( long data
, wxxVariant
&result
) const
365 { wxASSERT_MSG( m_fromLong
, wxT("Long conversions not supported") ) ; (*m_fromLong
)( data
, result
) ; }
368 converterToLong_t m_toLong
;
369 converterFromLong_t m_fromLong
;
371 wxEnumData
*m_enumInfo
; // Kind == wxT_ENUM or Kind == wxT_SET
374 class WXDLLIMPEXP_BASE wxClassTypeInfo
: public wxTypeInfo
377 wxClassTypeInfo( wxTypeKind kind
, wxClassInfo
* classInfo
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
) ;
378 const wxClassInfo
*GetClassInfo() const { return m_classInfo
; }
380 wxClassInfo
*m_classInfo
; // Kind == wxT_OBJECT - could be NULL
383 class WXDLLIMPEXP_BASE wxCollectionTypeInfo
: public wxTypeInfo
386 wxCollectionTypeInfo( wxTypeInfo
*elementType
, converterToString_t to
, converterFromString_t from
, const wxString
&name
) :
387 wxTypeInfo( wxT_COLLECTION
, to
, from
, name
)
388 { m_elementType
= elementType
;}
390 const wxTypeInfo
* GetElementType() const { return m_elementType
; }
392 wxTypeInfo
* m_elementType
;
395 // a delegate is an exposed event source
397 class WXDLLIMPEXP_BASE wxDelegateTypeInfo
: public wxTypeInfo
400 wxDelegateTypeInfo( int eventType
, wxClassInfo
* eventClass
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
) ;
401 int GetEventType() const { return m_eventType
; }
403 const wxClassInfo
*m_eventClass
; // (extended will merge into classinfo)
407 template<typename T
> const wxTypeInfo
* wxGetTypeInfo( T
* ) ;
409 // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
411 #define WX_CUSTOM_TYPE_INFO( e ) \
412 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \
413 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e, &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; }
415 #define WX_COLLECTION_TYPE_INFO( element , collection ) \
416 template<> const wxTypeInfo* wxGetTypeInfo( collection * ) \
418 static wxCollectionTypeInfo s_typeInfo( (wxTypeInfo*) wxGetTypeInfo( (element *) NULL) , NULL , NULL , #collection ) ; \
419 return &s_typeInfo ; \
423 // templated streaming, every type must have their specialization for these methods
426 void wxStringReadValue( const wxString
&s
, T
&data
);
429 void wxStringWriteValue( wxString
&s
, const T
&data
);
432 void wxToStringConverter( const wxxVariant
&v
, wxString
&s
) { wxStringWriteValue( s
, v
.Get
<T
>() ) ; }
435 void wxFromStringConverter( const wxString
&s
, wxxVariant
&v
) { T d
; wxStringReadValue( s
, d
) ; v
= wxxVariant(d
) ; } \
437 // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
439 #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \
440 template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
441 static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
442 template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
443 template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
445 // ----------------------------------------------------------------------------
446 // wxxVariant as typesafe data holder
447 // ----------------------------------------------------------------------------
449 class WXDLLIMPEXP_BASE wxxVariantData
452 virtual ~wxxVariantData() {}
454 // return a heap allocated duplicate
455 virtual wxxVariantData
* Clone() const = 0 ;
457 // returns the type info of the contentc
458 virtual const wxTypeInfo
* GetTypeInfo() const = 0 ;
461 template<typename T
> class WXDLLIMPEXP_BASE wxxVariantDataT
: public wxxVariantData
464 wxxVariantDataT(const T
& d
) : m_data(d
) {}
465 virtual ~wxxVariantDataT() {}
467 // get a ref to the stored data
468 T
& Get() { return m_data
; }
470 // get a const ref to the stored data
471 const T
& Get() const { return m_data
; }
474 void Set(const T
& d
) { m_data
= d
; }
476 // return a heap allocated duplicate
477 virtual wxxVariantData
* Clone() const { return new wxxVariantDataT
<T
>( Get() ) ; }
479 // returns the type info of the contentc
480 virtual const wxTypeInfo
* GetTypeInfo() const { return wxGetTypeInfo( (T
*) NULL
) ; }
485 class WXDLLIMPEXP_BASE wxxVariant
488 wxxVariant() { m_data
= NULL
; }
489 wxxVariant( wxxVariantData
* data
, const wxString
& name
= wxT("") ) : m_data(data
) , m_name(name
) {}
490 wxxVariant( const wxxVariant
&d
) { if ( d
.m_data
) m_data
= d
.m_data
->Clone() ; else m_data
= NULL
; m_name
= d
.m_name
; }
492 template<typename T
> wxxVariant( const T
& data
, const wxString
& name
= wxT("") ) :
493 m_data(new wxxVariantDataT
<T
>(data
) ), m_name(name
) {}
495 ~wxxVariant() { delete m_data
; }
497 // get a ref to the stored data
498 template<typename T
> T
& Get()
500 wxxVariantDataT
<T
> *dataptr
= dynamic_cast<wxxVariantDataT
<T
>*> (m_data
) ;
501 wxASSERT_MSG( dataptr
, "Cast not possible" ) ;
502 return dataptr
->Get() ;
505 // get a ref to the stored data
506 template<typename T
> const T
& Get() const
508 const wxxVariantDataT
<T
> *dataptr
= dynamic_cast<const wxxVariantDataT
<T
>*> (m_data
) ;
509 wxASSERT_MSG( dataptr
, "Cast not possible" ) ;
510 return dataptr
->Get() ;
513 template<typename T
> bool HasData() const
515 const wxxVariantDataT
<T
> *dataptr
= dynamic_cast<const wxxVariantDataT
<T
>*> (m_data
) ;
516 return dataptr
!= NULL
;
520 template<typename T
> void Set(const T
& data
) const
523 m_data
= new wxxVariantDataT
<T
>(data
) ;
526 wxxVariant
& operator=(const wxxVariant
&d
)
528 m_data
= d
.m_data
->Clone() ;
533 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
534 wxObject
* GetAsObject() ;
536 // get the typeinfo of the stored object
537 const wxTypeInfo
* GetTypeInfo() const { return m_data
->GetTypeInfo() ; }
539 // returns this value as string
540 wxString
GetAsString() const
543 GetTypeInfo()->ConvertToString( *this , s
) ;
546 const wxString
& GetName() const { return m_name
; }
548 wxxVariantData
* m_data
;
552 #include <wx/dynarray.h>
554 WX_DECLARE_OBJARRAY_WITH_DECL(wxxVariant
, wxxVariantArray
, class WXDLLIMPEXP_BASE
);
556 // ----------------------------------------------------------------------------
559 // wxPropertyInfo is used to inquire of the property by name. It doesn't
560 // provide access to the property, only information about it. If you
561 // want access, look at wxPropertyAccessor.
562 // ----------------------------------------------------------------------------
567 wxSetter( const wxString name
) { m_name
= name
; }
568 virtual void Set( wxObject
*object
, const wxxVariant
&variantValue
) const = 0;
569 const wxString
& GetName() const { return m_name
; }
577 wxGetter( const wxString name
) { m_name
= name
; }
578 virtual void Get( const wxObject
*object
, wxxVariant
& result
) const = 0;
579 const wxString
& GetName() const { return m_name
; }
584 class wxCollectionGetter
587 wxCollectionGetter( const wxString name
) { m_name
= name
; }
588 virtual void Get( const wxObject
*object
, wxxVariantArray
& result
) const = 0;
589 const wxString
& GetName() const { return m_name
; }
594 template<typename coll_t
> void wxCollectionToVariantArray( const coll_t
& coll
, wxxVariantArray
& result
) ;
599 wxAdder( const wxString name
) { m_name
= name
; }
600 virtual void Add( wxObject
*object
, const wxxVariant
&variantValue
) const= 0;
601 const wxString
& GetName() const { return m_name
; }
608 #define WX_SETTER( property, Klass, valueType, setterMethod ) \
609 class wxSetter##property : public wxSetter \
612 wxSetter##property() : wxSetter( #setterMethod ) {} \
613 void Set( wxObject *object, const wxxVariant &variantValue ) const \
615 Klass *obj = dynamic_cast<Klass*>(object) ; \
616 if ( variantValue.HasData<valueType>() ) \
617 obj->setterMethod(variantValue.Get<valueType>()) ; \
619 obj->setterMethod(*variantValue.Get<valueType*>()) ; \
623 #define WX_GETTER( property, Klass, valueType , gettermethod ) \
624 class wxGetter##property : public wxGetter \
627 wxGetter##property() : wxGetter( #gettermethod ) {} \
628 void Get( const wxObject *object , wxxVariant &result) const \
630 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
631 result = wxxVariant( obj->gettermethod() ) ; \
635 #define WX_ADDER( property, Klass, valueType , addermethod ) \
636 class wxAdder##property : public wxAdder \
639 wxAdder##property() : wxAdder( #addermethod ) {} \
640 void Add( wxObject *object, const wxxVariant &variantValue ) const \
642 Klass *obj = dynamic_cast<Klass*>(object) ; \
643 if ( variantValue.HasData<valueType>() ) \
644 obj->addermethod(variantValue.Get<valueType>()) ; \
646 obj->addermethod(*variantValue.Get<valueType*>()) ; \
650 #define WX_COLLECTION_GETTER( property, Klass, valueType , gettermethod ) \
651 class wxCollectionGetter##property : public wxCollectionGetter \
654 wxCollectionGetter##property() : wxCollectionGetter( #gettermethod ) {} \
655 void Get( const wxObject *object , wxxVariantArray &result) const \
657 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
658 wxCollectionToVariantArray( obj->gettermethod() , result ) ; \
662 class WXDLLIMPEXP_BASE wxPropertyAccessor
665 wxPropertyAccessor( wxSetter
*setter
, wxGetter
*getter
, wxAdder
*adder
, wxCollectionGetter
*collectionGetter
)
666 { m_setter
= setter
; m_getter
= getter
; m_adder
= adder
; m_collectionGetter
= collectionGetter
;}
668 virtual ~wxPropertyAccessor() {}
670 // Setting a simple property (non-collection)
671 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const
672 { wxASSERT_MSG(m_setter
,wxT("SetProperty called w/o valid setter") ) ; m_setter
->Set( object
, value
) ;}
674 // Getting a simple property (non-collection)
675 virtual void GetProperty(const wxObject
*object
, wxxVariant
&result
) const
676 { wxASSERT_MSG(m_getter
,wxT("GetProperty called w/o valid getter") ) ; m_getter
->Get( object
, result
) ;}
678 // Adding an element to a collection property
679 virtual void AddToPropertyCollection(wxObject
*object
, const wxxVariant
&value
) const
680 { wxASSERT_MSG(m_adder
,wxT("AddToPropertyCollection called w/o valid adder") ) ; m_adder
->Add( object
, value
) ;}
682 // Getting a collection property
683 virtual void GetPropertyCollection( const wxObject
*obj
, wxxVariantArray
&result
) const
684 { wxASSERT_MSG(m_collectionGetter
,wxT("GetPropertyCollection called w/o valid collection getter") ) ; m_collectionGetter
->Get( obj
, result
) ;}
686 virtual bool HasSetter() const { return m_setter
!= NULL
; }
687 virtual bool HasCollectionGetter() const { return m_collectionGetter
!= NULL
; }
688 virtual bool HasGetter() const { return m_getter
!= NULL
; }
689 virtual bool HasAdder() const { return m_adder
!= NULL
; }
691 virtual const wxString
& GetCollectionGetterName() const
692 { return m_collectionGetter
->GetName() ; }
693 virtual const wxString
& GetGetterName() const
694 { return m_getter
->GetName() ; }
695 virtual const wxString
& GetSetterName() const
696 { return m_setter
->GetName() ; }
697 virtual const wxString
& GetAdderName() const
698 { return m_adder
->GetName() ; }
700 virtual wxxVariant ReadValue( const wxString &value ) const ;
701 virtual void WriteValue( wxString& value , const wxObject *o ) const ;
707 wxCollectionGetter
* m_collectionGetter
;
710 class WXDLLIMPEXP_BASE wxGenericPropertyAccessor
: public wxPropertyAccessor
713 wxGenericPropertyAccessor( const wxString
&propName
) ;
714 ~wxGenericPropertyAccessor() ;
716 virtual bool HasSetter() const { return true ; }
717 virtual bool HasGetter() const { return true ; }
718 virtual bool HasAdder() const { return false ; }
719 virtual bool HasCollectionGetter() const { return false ; }
721 virtual const wxString
& GetGetterName() const
722 { return m_getterName
; }
723 virtual const wxString
& GetSetterName() const
724 { return m_setterName
; }
726 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const ;
727 virtual void GetProperty(const wxObject
*object
, wxxVariant
&value
) const ;
729 // Adding an element to a collection property
730 virtual void AddToPropertyCollection(wxObject
*WXUNUSED(object
), const wxxVariant
&WXUNUSED(value
)) const
731 { wxASSERT_MSG(0,wxT("AddToPropertyCollection called on a generic accessor") ) ;}
733 // Getting a collection property
734 virtual void GetPropertyCollection( const wxObject
*WXUNUSED(obj
), wxxVariantArray
&WXUNUSED(result
)) const
735 { wxASSERT_MSG(0,wxT("GetPropertyCollection called on a generic accessor") ) ;}
737 struct wxGenericPropertyAccessorInternal
;
738 wxGenericPropertyAccessorInternal
* m_data
;
739 wxString m_propertyName
;
740 wxString m_setterName
;
741 wxString m_getterName
;
744 typedef long wxPropertyInfoFlags
;
746 // will be removed in future releases
747 wxPROP_DEPRECATED
= 0x00000001 ,
748 // object graph property, will be streamed with priority (after constructor properties)
749 wxPROP_OBJECT_GRAPH
= 0x00000002 ,
750 // this will only be streamed out and in as enum/set, the internal representation is still a long
751 wxPROP_ENUM_STORE_LONG
= 0x00000004 ,
752 // don't stream out this property, needed eg to avoid streaming out children that are always created by their parents
753 wxPROP_DONT_STREAM
= 0x00000008 ,
756 class WXDLLIMPEXP_BASE wxPropertyInfo
759 wxPropertyInfo( wxPropertyInfo
* &iter
, const wxClassInfo
* itsClass
, const wxString
& name
, const wxTypeInfo
* typeInfo
, wxPropertyAccessor
*accessor
, wxxVariant dv
, wxPropertyInfoFlags flags
= 0 , const wxString
& helpString
=wxEmptyString
, const wxString
& groupString
=wxEmptyString
) :
760 m_name( name
) , m_itsClass( itsClass
) , m_typeInfo( typeInfo
) , m_accessor( accessor
) , m_defaultValue( dv
) , m_collectionElementTypeInfo(NULL
) , m_helpString (helpString
) , m_groupString( groupString
) , m_flags(flags
)
765 wxPropertyInfo( wxPropertyInfo
* &iter
, const wxClassInfo
* itsClass
, const wxString
& name
, const wxTypeInfo
* collTypeInfo
, const wxTypeInfo
* elemTypeInfo
, wxPropertyAccessor
*accessor
, wxPropertyInfoFlags flags
= 0 , const wxString
& helpString
=wxEmptyString
, const wxString
& groupString
=wxEmptyString
) :
766 m_name( name
) , m_itsClass( itsClass
) , m_typeInfo( collTypeInfo
) , m_accessor( accessor
) , m_collectionElementTypeInfo(elemTypeInfo
) , m_helpString (helpString
) , m_groupString( groupString
) , m_flags(flags
)
771 // return the class this property is declared in
772 const wxClassInfo
* GetDeclaringClass() const { return m_itsClass
; }
774 // return the name of this property
775 const wxString
& GetName() const { return m_name
; }
777 // returns the flags of this property
778 wxPropertyInfoFlags
GetFlags() const { return m_flags
;}
780 // returns the short help string of this property
781 const wxString
& GetHelpString() const { return m_helpString
; }
783 // returns the group string of this property
784 const wxString
& GetGroupString() const { return m_groupString
; }
786 // return the element type info of this property (for collections, otherwise NULL)
787 const wxTypeInfo
* GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo
; }
789 // return the type info of this property
790 const wxTypeInfo
* GetTypeInfo() const { return m_typeInfo
; }
792 // return the accessor for this property
793 wxPropertyAccessor
* GetAccessor() const { return m_accessor
; }
795 // returns NULL if this is the last property of this class
796 wxPropertyInfo
* GetNext() const { return m_next
; }
798 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
799 wxxVariant
GetDefaultValue() const { return m_defaultValue
; }
801 void Insert(wxPropertyInfo
* &iter
)
808 wxPropertyInfo
* i
= iter
;
817 wxString m_typeName
;
818 wxString m_groupString
;
819 wxString m_helpString
;
820 const wxClassInfo
* m_itsClass
;
821 wxPropertyInfoFlags m_flags
;
822 const wxTypeInfo
* m_typeInfo
;
823 const wxTypeInfo
* m_collectionElementTypeInfo
;
824 wxPropertyAccessor
* m_accessor
;
825 wxxVariant m_defaultValue
;
826 // string representation of the default value
827 // to be assigned by the designer to the property
828 // when the component is dropped on the container.
829 wxPropertyInfo
* m_next
;
832 WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxPropertyInfo
* , wxPropertyInfoMap
) ;
834 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
835 wxPropertyInfo *theClass::GetPropertiesStatic() \
837 typedef theClass class_t; \
838 static wxPropertyInfo* first = NULL ;
840 #define WX_END_PROPERTIES_TABLE() \
843 #define WX_HIDE_PROPERTY( name ) \
844 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (void*) NULL ) ,NULL , wxxVariant() , wxPROP_DONT_STREAM , wxEmptyString , wxEmptyString ) ;
846 #define WX_PROPERTY( name , type , setter , getter ,defaultValue , flags , help , group) \
847 WX_SETTER( name , class_t , type , setter ) \
848 static wxSetter##name _setter##name ; \
849 WX_GETTER( name , class_t , type , getter ) \
850 static wxGetter##name _getter##name ; \
851 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
852 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) , flags , group , help ) ;
854 #define WX_PROPERTY_FLAGS( name , flags , type , setter , getter ,defaultValue , pflags , help , group) \
855 WX_SETTER( name , class_t , type , setter ) \
856 static wxSetter##name _setter##name ; \
857 WX_GETTER( name , class_t , type , getter ) \
858 static wxGetter##name _getter##name ; \
859 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
860 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (flags*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ;
862 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue , flags , help , group) \
863 WX_GETTER( name , class_t , type , getter ) \
864 static wxGetter##name _getter##name ; \
865 static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \
866 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), flags , help , group ) ;
868 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter , flags , help , group ) \
869 WX_ADDER( name , class_t , addelemtype , adder ) \
870 static wxAdder##name _adder##name ; \
871 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
872 static wxCollectionGetter##name _collectionGetter##name ; \
873 static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \
874 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
876 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter , flags , help , group) \
877 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
878 static wxCollectionGetter##name _collectionGetter##name ; \
879 static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \
880 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
882 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
883 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
884 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
886 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
887 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &getter , #getter ) ; \
888 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
893 #define WX_DELEGATE( name , eventType , eventClass ) \
894 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
895 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
897 // ----------------------------------------------------------------------------
900 // this is describing an event sink
901 // ----------------------------------------------------------------------------
906 wxHandlerInfo( wxHandlerInfo
* &iter
, const wxString
& name
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) :
907 m_name( name
) , m_eventClassInfo( eventClassInfo
) , m_eventFunction( address
)
914 wxHandlerInfo
* i
= iter
;
922 // return the name of this handler
923 const wxString
& GetName() const { return m_name
; }
925 // return the class info of the event
926 const wxClassInfo
* GetEventClassInfo() const { return m_eventClassInfo
; }
928 // get the handler function pointer
929 wxObjectEventFunction
GetEventFunction() const { return m_eventFunction
; }
931 // returns NULL if this is the last handler of this class
932 wxHandlerInfo
* GetNext() const { return m_next
; }
934 wxObjectEventFunction m_eventFunction
;
936 const wxClassInfo
* m_eventClassInfo
;
937 wxHandlerInfo
* m_next
;
940 #define WX_HANDLER(name,eventClassType) \
941 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
943 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
944 wxHandlerInfo *theClass::GetHandlersStatic() \
946 typedef theClass class_t; \
947 static wxHandlerInfo* first = NULL ;
949 #define WX_END_HANDLERS_TABLE() \
952 // ----------------------------------------------------------------------------
953 // Constructor Bridges
955 // allow to set up constructors with params during runtime
956 // ----------------------------------------------------------------------------
958 class WXDLLIMPEXP_BASE wxConstructorBridge
961 virtual void Create(wxObject
*o
, wxxVariant
*args
) = 0;
964 // Creator Bridges for all Numbers of Params
968 template<typename Class
>
969 struct wxConstructorBridge_0
: public wxConstructorBridge
971 void Create(wxObject
*o
, wxxVariant
*)
973 Class
*obj
= dynamic_cast<Class
*>(o
);
978 struct wxConstructorBridge_Dummy
: public wxConstructorBridge
980 void Create(wxObject
*, wxxVariant
*)
985 #define WX_CONSTRUCTOR_0(klass) \
986 wxConstructorBridge_0<klass> constructor##klass ; \
987 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
988 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
989 const int klass::sm_constructorPropertiesCount##klass = 0 ;
991 #define WX_CONSTRUCTOR_DUMMY(klass) \
992 wxConstructorBridge_Dummy constructor##klass ; \
993 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
994 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
995 const int klass::sm_constructorPropertiesCount##klass = 0 ;
999 template<typename Class
, typename T0
>
1000 struct wxConstructorBridge_1
: public wxConstructorBridge
1002 void Create(wxObject
*o
, wxxVariant
*args
)
1004 Class
*obj
= dynamic_cast<Class
*>(o
);
1011 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
1012 wxConstructorBridge_1<klass,t0> constructor##klass ; \
1013 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1014 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
1015 const int klass::sm_constructorPropertiesCount##klass = 1 ;
1019 template<typename Class
,
1020 typename T0
, typename T1
>
1021 struct wxConstructorBridge_2
: public wxConstructorBridge
1023 void Create(wxObject
*o
, wxxVariant
*args
)
1025 Class
*obj
= dynamic_cast<Class
*>(o
);
1033 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
1034 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
1035 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1036 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
1037 const int klass::sm_constructorPropertiesCount##klass = 2;
1041 template<typename Class
,
1042 typename T0
, typename T1
, typename T2
>
1043 struct wxConstructorBridge_3
: public wxConstructorBridge
1045 void Create(wxObject
*o
, wxxVariant
*args
)
1047 Class
*obj
= dynamic_cast<Class
*>(o
);
1056 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
1057 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
1058 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1059 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
1060 const int klass::sm_constructorPropertiesCount##klass = 3 ;
1064 template<typename Class
,
1065 typename T0
, typename T1
, typename T2
, typename T3
>
1066 struct wxConstructorBridge_4
: public wxConstructorBridge
1068 void Create(wxObject
*o
, wxxVariant
*args
)
1070 Class
*obj
= dynamic_cast<Class
*>(o
);
1080 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
1081 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
1082 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1083 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
1084 const int klass::sm_constructorPropertiesCount##klass = 4 ;
1088 template<typename Class
,
1089 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
>
1090 struct wxConstructorBridge_5
: public wxConstructorBridge
1092 void Create(wxObject
*o
, wxxVariant
*args
)
1094 Class
*obj
= dynamic_cast<Class
*>(o
);
1105 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
1106 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
1107 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1108 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
1109 const int klass::sm_constructorPropertiesCount##klass = 5;
1113 template<typename Class
,
1114 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
>
1115 struct wxConstructorBridge_6
: public wxConstructorBridge
1117 void Create(wxObject
*o
, wxxVariant
*args
)
1119 Class
*obj
= dynamic_cast<Class
*>(o
);
1131 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
1132 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
1133 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1134 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
1135 const int klass::sm_constructorPropertiesCount##klass = 6;
1139 template<typename Class
,
1140 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
, typename T6
>
1141 struct wxConstructorBridge_7
: public wxConstructorBridge
1143 void Create(wxObject
*o
, wxxVariant
*args
)
1145 Class
*obj
= dynamic_cast<Class
*>(o
);
1158 #define WX_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
1159 wxConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass ; \
1160 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1161 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6} ; \
1162 const int klass::sm_constructorPropertiesCount##klass = 7;
1166 template<typename Class
,
1167 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
, typename T6
, typename T7
>
1168 struct wxConstructorBridge_8
: public wxConstructorBridge
1170 void Create(wxObject
*o
, wxxVariant
*args
)
1172 Class
*obj
= dynamic_cast<Class
*>(o
);
1186 #define WX_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
1187 wxConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass ; \
1188 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1189 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6 , #v7} ; \
1190 const int klass::sm_constructorPropertiesCount##klass = 8;
1191 // ----------------------------------------------------------------------------
1193 // ----------------------------------------------------------------------------
1195 typedef wxObject
*(*wxObjectConstructorFn
)(void);
1196 typedef wxObject
* (*wxVariantToObjectConverter
)( wxxVariant
&data
) ;
1197 typedef wxxVariant (*wxObjectToVariantConverter
)( wxObject
* ) ;
1200 typedef bool (*wxObjectStreamingCallback
) ( const wxObject
*, wxWriter
* , wxPersister
* , wxxVariantArray
& ) ;
1202 class WXDLLIMPEXP_BASE wxClassInfo
1205 wxClassInfo(const wxClassInfo
**_Parents
,
1206 const wxChar
*_UnitName
,
1207 const wxChar
*_ClassName
,
1209 wxObjectConstructorFn ctor
,
1210 wxPropertyInfo
*_Props
,
1211 wxHandlerInfo
*_Handlers
,
1212 wxConstructorBridge
* _Constructor
,
1213 const wxChar
** _ConstructorProperties
,
1214 const int _ConstructorPropertiesCount
,
1215 wxVariantToObjectConverter _PtrConverter1
,
1216 wxVariantToObjectConverter _Converter2
,
1217 wxObjectToVariantConverter _Converter3
,
1218 wxObjectStreamingCallback _streamingCallback
= NULL
1219 ) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1220 m_objectSize(size
), m_objectConstructor(ctor
) , m_firstProperty(_Props
) , m_firstHandler(_Handlers
) , m_constructor( _Constructor
) ,
1221 m_constructorProperties(_ConstructorProperties
) , m_constructorPropertiesCount(_ConstructorPropertiesCount
),
1222 m_variantOfPtrToObjectConverter( _PtrConverter1
) , m_variantToObjectConverter( _Converter2
) , m_objectToVariantConverter( _Converter3
) ,
1223 m_next(sm_first
) , m_streamingCallback( _streamingCallback
)
1229 wxClassInfo(const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
**_Parents
) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1230 m_objectSize(0), m_objectConstructor(NULL
) , m_firstProperty(NULL
) , m_firstHandler(NULL
) , m_constructor( NULL
) ,
1231 m_constructorProperties(NULL
) , m_constructorPropertiesCount(NULL
),
1232 m_variantOfPtrToObjectConverter( NULL
) , m_variantToObjectConverter( NULL
) , m_objectToVariantConverter( NULL
) , m_next(sm_first
) ,
1233 m_streamingCallback( NULL
)
1239 virtual ~wxClassInfo() ;
1241 // allocates an instance of this class, this object does not have to be initialized or fully constructed
1242 // as this call will be followed by a call to Create
1243 virtual wxObject
*AllocateObject() const { return m_objectConstructor ?
(*m_objectConstructor
)() : 0; }
1245 // 'old naming' for AllocateObject staying here for backward compatibility
1246 wxObject
*CreateObject() const { return AllocateObject() ; }
1248 const wxChar
*GetClassName() const { return m_className
; }
1249 const wxChar
*GetIncludeName() const { return m_unitName
; }
1250 const wxClassInfo
**GetParents() const { return m_parents
; }
1251 int GetSize() const { return m_objectSize
; }
1253 wxObjectConstructorFn
GetConstructor() const { return m_objectConstructor
; }
1254 static const wxClassInfo
*GetFirst() { return sm_first
; }
1255 const wxClassInfo
*GetNext() const { return m_next
; }
1256 static wxClassInfo
*FindClass(const wxChar
*className
);
1258 // Climb upwards through inheritance hierarchy.
1259 // Dual inheritance is catered for.
1261 bool IsKindOf(const wxClassInfo
*info
) const
1268 for ( int i
= 0 ; m_parents
[i
] ; ++ i
)
1270 if ( m_parents
[i
]->IsKindOf( info
) )
1277 // if there is a callback registered with that class it will be called before this
1278 // object will be written to disk, it can veto streaming out this object by returning
1279 // false, if this class has not registered a callback, the search will go up the inheritance tree
1280 // if no callback has been registered true will be returned by default
1281 bool BeforeWriteObject( const wxObject
*obj
, wxWriter
*streamer
, wxPersister
*persister
, wxxVariantArray
&metadata
) const ;
1283 // gets the streaming callback from this class or any superclass
1284 wxObjectStreamingCallback
GetStreamingCallback() const ;
1286 #ifdef WXWIN_COMPATIBILITY_2_4
1287 // Initializes parent pointers and hash table for fast searching.
1288 wxDEPRECATED( static void InitializeClasses() );
1289 // Cleans up hash table used for fast searching.
1290 wxDEPRECATED( static void CleanUpClasses() );
1292 static void CleanUp();
1294 // returns the first property
1295 const wxPropertyInfo
* GetFirstProperty() const { return m_firstProperty
; }
1297 // returns the first handler
1298 const wxHandlerInfo
* GetFirstHandler() const { return m_firstHandler
; }
1300 // Call the Create upon an instance of the class, in the end the object is fully
1302 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const
1304 wxASSERT_MSG( ParamCount
== m_constructorPropertiesCount
, wxT("Illegal Parameter Count for Create Method")) ;
1305 m_constructor
->Create( object
, Params
) ;
1308 // get number of parameters for constructor
1309 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount
; }
1311 // get n-th constructor parameter
1312 virtual const wxChar
* GetCreateParamName(int n
) const { return m_constructorProperties
[n
] ; }
1314 // Runtime access to objects for simple properties (get/set) by property name, and variant data
1315 virtual void SetProperty (wxObject
*object
, const wxChar
*propertyName
, const wxxVariant
&value
) const ;
1316 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*propertyName
) const;
1318 // Runtime access to objects for collection properties by property name
1319 virtual wxxVariantArray
GetPropertyCollection(wxObject
*object
, const wxChar
*propertyName
) const ;
1320 virtual void AddToPropertyCollection(wxObject
*object
, const wxChar
*propertyName
, const wxxVariant
& value
) const ;
1322 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1323 wxObject
* VariantToInstance( wxxVariant
&data
) const
1324 { if ( data
.GetTypeInfo()->GetKind() == wxT_OBJECT
)
1325 return m_variantToObjectConverter( data
) ;
1327 return m_variantOfPtrToObjectConverter( data
) ;
1330 wxxVariant
InstanceToVariant( wxObject
*object
) const { return m_objectToVariantConverter( object
) ; }
1332 // find property by name
1333 virtual const wxPropertyInfo
*FindPropertyInfo (const wxChar
*PropertyName
) const ;
1335 // find handler by name
1336 virtual const wxHandlerInfo
*FindHandlerInfo (const wxChar
*PropertyName
) const ;
1338 // find property by name
1339 virtual const wxPropertyInfo
*FindPropertyInfoInThisClass (const wxChar
*PropertyName
) const ;
1341 // find handler by name
1342 virtual const wxHandlerInfo
*FindHandlerInfoInThisClass (const wxChar
*PropertyName
) const ;
1344 // puts all the properties of this class and its superclasses in the map, as long as there is not yet
1345 // an entry with the same name (overriding mechanism)
1346 void GetProperties( wxPropertyInfoMap
&map
) const ;
1348 const wxChar
*m_className
;
1350 wxObjectConstructorFn m_objectConstructor
;
1352 // class info object live in a linked list:
1353 // pointers to its head and the next element in it
1355 static wxClassInfo
*sm_first
;
1356 wxClassInfo
*m_next
;
1358 // FIXME: this should be private (currently used directly by way too
1360 static wxHashTable
*sm_classTable
;
1363 wxPropertyInfo
* m_firstProperty
;
1364 wxHandlerInfo
* m_firstHandler
;
1366 const wxClassInfo
** m_parents
;
1367 const wxChar
* m_unitName
;
1369 wxConstructorBridge
* m_constructor
;
1370 const wxChar
** m_constructorProperties
;
1371 const int m_constructorPropertiesCount
;
1372 wxVariantToObjectConverter m_variantOfPtrToObjectConverter
;
1373 wxVariantToObjectConverter m_variantToObjectConverter
;
1374 wxObjectToVariantConverter m_objectToVariantConverter
;
1375 wxObjectStreamingCallback m_streamingCallback
;
1376 const wxPropertyAccessor
*FindAccessor (const wxChar
*propertyName
) const ;
1379 // InitializeClasses() helper
1380 static wxClassInfo
*GetBaseByName(const wxChar
*name
) ;
1383 // registers the class
1387 DECLARE_NO_COPY_CLASS(wxClassInfo
)
1391 WXDLLIMPEXP_BASE wxObject
*wxCreateDynamicObject(const wxChar
*name
);
1393 // ----------------------------------------------------------------------------
1395 // ----------------------------------------------------------------------------
1397 // this object leads to having a pure runtime-instantiation
1399 class wxDynamicClassInfo
: public wxClassInfo
1402 wxDynamicClassInfo( const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
* superClass
) ;
1403 virtual ~wxDynamicClassInfo() ;
1405 // constructs a wxDynamicObject with an instance
1406 virtual wxObject
*AllocateObject() const ;
1408 // Call the Create method for a class
1409 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const ;
1411 // get number of parameters for constructor
1412 virtual int GetCreateParamCount() const ;
1414 // get i-th constructor parameter
1415 virtual const wxChar
* GetCreateParamName(int i
) const ;
1417 // Runtime access to objects by property name, and variant data
1418 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
) const ;
1419 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
) const ;
1421 void AddProperty( const wxChar
*propertyName
, const wxTypeInfo
* typeInfo
) ;
1422 void AddHandler( const wxChar
*handlerName
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) ;
1425 // ----------------------------------------------------------------------------
1426 // Dynamic class macros
1427 // ----------------------------------------------------------------------------
1429 #define _DECLARE_DYNAMIC_CLASS(name) \
1431 static wxClassInfo sm_class##name; \
1432 static const wxClassInfo* sm_classParents##name[] ; \
1433 static wxPropertyInfo* GetPropertiesStatic() ; \
1434 static wxHandlerInfo* GetHandlersStatic() ; \
1435 static wxClassInfo *GetClassInfoStatic() \
1436 { return &name::sm_class##name; } \
1437 virtual wxClassInfo *GetClassInfo() const \
1438 { return &name::sm_class##name; }
1440 #define DECLARE_DYNAMIC_CLASS(name) \
1441 static wxConstructorBridge* sm_constructor##name ; \
1442 static const wxChar * sm_constructorProperties##name[] ; \
1443 static const int sm_constructorPropertiesCount##name ; \
1444 _DECLARE_DYNAMIC_CLASS(name)
1446 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1447 DECLARE_NO_ASSIGN_CLASS(name) \
1448 DECLARE_DYNAMIC_CLASS(name)
1450 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1451 DECLARE_NO_COPY_CLASS(name) \
1452 DECLARE_DYNAMIC_CLASS(name)
1454 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1455 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1457 // -----------------------------------
1458 // for concrete classes
1459 // -----------------------------------
1461 // Single inheritance with one base class
1463 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit , callback) \
1464 wxObject* wxConstructorFor##name() \
1465 { return new name; } \
1466 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1467 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1468 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1469 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1470 (int) sizeof(name), \
1471 (wxObjectConstructorFn) wxConstructorFor##name , \
1472 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1473 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name , callback); \
1474 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1475 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1476 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1477 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1478 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1479 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1480 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1481 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1482 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1484 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \
1485 wxObject* wxConstructorFor##name() \
1486 { return new name; } \
1487 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1488 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1489 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1490 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1491 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1492 (int) sizeof(name), \
1493 (wxObjectConstructorFn) wxConstructorFor##name , \
1494 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1495 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name, callback); \
1496 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1497 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1498 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1499 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1500 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1501 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1502 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1503 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1504 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1506 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1507 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" , NULL ) \
1508 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1509 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1510 WX_CONSTRUCTOR_DUMMY( name )
1512 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1513 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" , NULL ) \
1514 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1515 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1516 WX_CONSTRUCTOR_DUMMY( name )
1518 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1519 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , NULL )
1521 #define IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name , basename , unit , callback ) \
1522 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , &callback )
1524 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1525 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit , NULL )
1527 // this is for classes that do not derive from wxobject, there are no creators for these
1529 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1530 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1531 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1532 (int) sizeof(name), \
1533 (wxObjectConstructorFn) 0 , \
1534 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1536 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1537 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1538 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1539 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1540 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1541 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1542 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1544 // this is for subclasses that still do not derive from wxobject
1546 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1547 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1548 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1549 (int) sizeof(name), \
1550 (wxObjectConstructorFn) 0 , \
1551 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1553 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1554 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1555 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1556 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1557 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1558 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1559 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1562 // Multiple inheritance with two base classes
1564 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1565 wxObject* wxConstructorFor##name() \
1566 { return new name; } \
1567 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1568 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1569 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1570 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1571 (int) sizeof(name), \
1572 (wxObjectConstructorFn) wxConstructorFor##name , \
1573 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1574 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1575 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1576 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1577 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1578 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1579 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1580 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1581 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1583 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1584 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1585 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1586 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1587 WX_CONSTRUCTOR_DUMMY( name )
1589 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1590 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1592 // -----------------------------------
1593 // for abstract classes
1594 // -----------------------------------
1596 // Single inheritance with one base class
1598 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1599 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1600 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1601 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1602 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1603 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1604 (int) sizeof(name), \
1605 (wxObjectConstructorFn) 0 , \
1606 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1607 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1608 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1609 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1610 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1611 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1612 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1613 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1614 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1616 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1617 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1618 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1619 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1621 // Multiple inheritance with two base classes
1623 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1624 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1625 wxT(#basename2), (int) sizeof(name), \
1626 (wxObjectConstructorFn) 0);
1628 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1629 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
1631 // --------------------------------------------------------------------------
1632 // Collection Support
1633 // --------------------------------------------------------------------------
1635 template<typename collection_t
> void wxListCollectionToVariantArray( const collection_t
& coll
, wxxVariantArray
&value
)
1637 collection_t
::compatibility_iterator current
= coll
.GetFirst() ;
1640 value
.Add( new wxxVariant(current
->GetData()) ) ;
1641 current
= current
->GetNext();
1645 template<typename collection_t
> void wxArrayCollectionToVariantArray( const collection_t
& coll
, wxxVariantArray
&value
)
1647 for( size_t i
= 0 ; i
< coll
.GetCount() ; i
++ )
1649 value
.Add( new wxxVariant(coll
[i
]) ) ;