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 wxBitset<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
, wxBitset
<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 wxBitset
<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 wxBitset 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 , wxBitset<e> &data ) \
212 wxSetFromString( s , data ) ; \
214 template<> void wxStringWriteValue( wxString &s , const wxBitset<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 void wxFlagsFromString(const wxString
&s
, e
&data
)
228 wxEnumData
* edata
= wxGetEnumData((e
*) 0) ;
231 wxArrayString array
;
232 wxSetStringToArray( s
, array
) ;
234 for ( int i
= 0 ; i
< array
.Count() ; ++i
)
238 if ( edata
->HasEnumMemberValue( flag
, &ivalue
) )
240 data
.m_data
|= ivalue
;
246 void wxFlagsToString( wxString
&s
, const e
& data
)
248 wxEnumData
* edata
= wxGetEnumData((e
*) 0) ;
249 int count
= edata
->GetEnumCount() ;
252 long dataValue
= data
.m_data
;
253 for ( i
= 0 ; i
< count
; i
++ )
255 int value
= edata
->GetEnumMemberValueByIndex(i
) ;
256 // make this to allow for multi-bit constants to work
257 if ( value
&& ( dataValue
& value
) == value
)
259 // clear the flags we just set
260 dataValue
&= ~value
;
261 // this could also be done by the templated calls
264 s
+= edata
->GetEnumMemberNameByIndex(i
) ;
269 #define WX_BEGIN_FLAGS( e ) \
270 wxEnumMemberData s_enumDataMembers##e[] = {
272 #define WX_FLAGS_MEMBER( v ) { #v, v } ,
274 #define WX_END_FLAGS( e ) { NULL , 0 } } ; \
275 wxEnumData s_enumData##e( s_enumDataMembers##e ) ; \
276 wxEnumData *wxGetEnumData(e*) { return &s_enumData##e ; } \
277 template<> void wxStringReadValue(const wxString &s , e &data ) \
279 wxFlagsFromString<e>( s , data ) ; \
281 template<> void wxStringWriteValue( wxString &s , const e& data ) \
283 wxFlagsToString<e>( s , data ) ; \
285 void FromLong##e( long data , wxxVariant& result ) { result = wxxVariant(e(data)) ;} \
286 void ToLong##e( const wxxVariant& data , long &result ) { result = (long) data.Get<e>().m_data ;} \
287 template<> const wxTypeInfo* wxGetTypeInfo( e * ) \
289 static wxEnumTypeInfo s_typeInfo(wxT_SET , &s_enumData##e , &wxToStringConverter<e> , &wxFromStringConverter<e> , &ToLong##e , &FromLong##e, #e ) ; return &s_typeInfo ; \
292 // ----------------------------------------------------------------------------
294 // ----------------------------------------------------------------------------
297 // All data exposed by the RTTI is characterized using the following classes.
298 // The first characterization is done by wxTypeKind. All enums up to and including
299 // wxT_CUSTOM represent so called simple types. These cannot be divided any further.
300 // They can be converted to and from wxStrings, that's all.
305 wxT_VOID
= 0, // unknown type
315 wxT_STRING
, // must be wxString
316 wxT_SET
, // must be wxBitset<> template
318 wxT_CUSTOM
, // user defined type (e.g. wxPoint)
320 wxT_LAST_SIMPLE_TYPE_KIND
= wxT_CUSTOM
,
322 wxT_OBJECT_PTR
, // object reference
323 wxT_OBJECT
, // embedded object
324 wxT_COLLECTION
, // collection
326 wxT_DELEGATE
, // for connecting against an event source
328 wxT_LAST_TYPE_KIND
= wxT_DELEGATE
// sentinel for bad data, asserts, debugging
334 WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxTypeInfo
* , wxTypeInfoMap
) ;
336 class WXDLLIMPEXP_BASE wxTypeInfo
339 typedef void (*converterToString_t
)( const wxxVariant
& data
, wxString
&result
) ;
340 typedef void (*converterFromString_t
)( const wxString
& data
, wxxVariant
&result
) ;
342 wxTypeInfo(wxTypeKind kind
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
, const wxString
&name
= wxEmptyString
) :
343 m_kind( kind
) , m_toString(to
) , m_fromString(from
) , m_name(name
)
348 virtual ~wxTypeInfo()
353 // return the kind of this type (wxT_... constants)
354 wxTypeKind
GetKind() const { return m_kind
; }
356 // returns the unique name of this type
357 const wxString
& GetTypeName() const { return m_name
; }
359 // is this type a delegate type
360 bool IsDelegateType() const { return m_kind
== wxT_DELEGATE
; }
362 // is this type a custom type
363 bool IsCustomType() const { return m_kind
== wxT_CUSTOM
; }
365 // is this type an object type
366 bool IsObjectType() const { return m_kind
== wxT_OBJECT
|| m_kind
== wxT_OBJECT_PTR
; }
368 // can the content of this type be converted to and from strings ?
369 bool HasStringConverters() const { return m_toString
!= NULL
&& m_fromString
!= NULL
; }
371 // convert a wxxVariant holding data of this type into a string
372 void ConvertToString( const wxxVariant
& data
, wxString
&result
) const
374 { wxASSERT_MSG( m_toString
, wxT("String conversions not supported") ) ; (*m_toString
)( data
, result
) ; }
376 // convert a string into a wxxVariant holding the corresponding data in this type
377 void ConvertFromString( const wxString
& data
, wxxVariant
&result
) const
378 { wxASSERT_MSG( m_fromString
, wxT("String conversions not supported") ) ; (*m_fromString
)( data
, result
) ; }
380 static wxTypeInfo
*FindType(const wxChar
*typeName
);
387 converterToString_t m_toString
;
388 converterFromString_t m_fromString
;
390 static wxTypeInfoMap
* sm_typeTable
;
396 class WXDLLIMPEXP_BASE wxBuiltInTypeInfo
: public wxTypeInfo
399 wxBuiltInTypeInfo( wxTypeKind kind
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
, const wxString
&name
= wxEmptyString
) :
400 wxTypeInfo( kind
, to
, from
, name
)
401 { wxASSERT_MSG( GetKind() < wxT_SET
, wxT("Illegal Kind for Base Type") ) ; }
404 class WXDLLIMPEXP_BASE wxCustomTypeInfo
: public wxTypeInfo
407 wxCustomTypeInfo( const wxString
&name
, converterToString_t to
, converterFromString_t from
) :
408 wxTypeInfo( wxT_CUSTOM
, to
, from
, name
)
412 class WXDLLIMPEXP_BASE wxEnumTypeInfo
: public wxTypeInfo
415 typedef void (*converterToLong_t
)( const wxxVariant
& data
, long &result
) ;
416 typedef void (*converterFromLong_t
)( long data
, wxxVariant
&result
) ;
418 wxEnumTypeInfo( wxTypeKind kind
, wxEnumData
* enumInfo
, converterToString_t to
, converterFromString_t from
,
419 converterToLong_t toLong
, converterFromLong_t fromLong
, const wxString
&name
) :
420 wxTypeInfo( kind
, to
, from
, name
) , m_toLong( toLong
) , m_fromLong( fromLong
)
421 { wxASSERT_MSG( kind
== wxT_ENUM
|| kind
== wxT_SET
, wxT("Illegal Kind for Enum Type")) ; m_enumInfo
= enumInfo
;}
422 const wxEnumData
* GetEnumData() const { return m_enumInfo
; }
424 // convert a wxxVariant holding data of this type into a long
425 void ConvertToLong( const wxxVariant
& data
, long &result
) const
427 { wxASSERT_MSG( m_toLong
, wxT("Long conversions not supported") ) ; (*m_toLong
)( data
, result
) ; }
429 // convert a long into a wxxVariant holding the corresponding data in this type
430 void ConvertFromLong( long data
, wxxVariant
&result
) const
431 { wxASSERT_MSG( m_fromLong
, wxT("Long conversions not supported") ) ; (*m_fromLong
)( data
, result
) ; }
434 converterToLong_t m_toLong
;
435 converterFromLong_t m_fromLong
;
437 wxEnumData
*m_enumInfo
; // Kind == wxT_ENUM or Kind == wxT_SET
440 class WXDLLIMPEXP_BASE wxClassTypeInfo
: public wxTypeInfo
443 wxClassTypeInfo( wxTypeKind kind
, wxClassInfo
* classInfo
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
) ;
444 const wxClassInfo
*GetClassInfo() const { return m_classInfo
; }
446 wxClassInfo
*m_classInfo
; // Kind == wxT_OBJECT - could be NULL
449 class WXDLLIMPEXP_BASE wxCollectionTypeInfo
: public wxTypeInfo
452 wxCollectionTypeInfo( wxTypeInfo
*elementType
, converterToString_t to
, converterFromString_t from
, const wxString
&name
) :
453 wxTypeInfo( wxT_COLLECTION
, to
, from
, name
)
454 { m_elementType
= elementType
;}
456 const wxTypeInfo
* GetElementType() const { return m_elementType
; }
458 wxTypeInfo
* m_elementType
;
461 // a delegate is an exposed event source
463 class WXDLLIMPEXP_BASE wxDelegateTypeInfo
: public wxTypeInfo
466 wxDelegateTypeInfo( int eventType
, wxClassInfo
* eventClass
, converterToString_t to
= NULL
, converterFromString_t from
= NULL
) ;
467 int GetEventType() const { return m_eventType
; }
469 const wxClassInfo
*m_eventClass
; // (extended will merge into classinfo)
473 template<typename T
> const wxTypeInfo
* wxGetTypeInfo( T
* ) ;
475 // this macro is for usage with custom, non-object derived classes and structs, wxPoint is such a custom type
477 #define WX_CUSTOM_TYPE_INFO( e ) \
478 template<> const wxTypeInfo* wxGetTypeInfo( e ** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; } \
479 template<> const wxTypeInfo* wxGetTypeInfo( e * ){ static wxCustomTypeInfo s_typeInfo(#e, &wxToStringConverter<e> , &wxFromStringConverter<e>) ; return &s_typeInfo ; }
481 #define WX_COLLECTION_TYPE_INFO( element , collection ) \
482 template<> const wxTypeInfo* wxGetTypeInfo( collection * ) \
484 static wxCollectionTypeInfo s_typeInfo( (wxTypeInfo*) wxGetTypeInfo( (element *) NULL) , NULL , NULL , #collection ) ; \
485 return &s_typeInfo ; \
489 // templated streaming, every type must have their specialization for these methods
492 void wxStringReadValue( const wxString
&s
, T
&data
);
495 void wxStringWriteValue( wxString
&s
, const T
&data
);
498 void wxToStringConverter( const wxxVariant
&v
, wxString
&s
) { wxStringWriteValue( s
, v
.Get
<T
>() ) ; }
501 void wxFromStringConverter( const wxString
&s
, wxxVariant
&v
) { T d
; wxStringReadValue( s
, d
) ; v
= wxxVariant(d
) ; } \
503 // sometimes a compiler invents specializations that are nowhere called, use this macro to satisfy the refs
505 #define WX_ILLEGAL_TYPE_SPECIALIZATION( a ) \
506 template<> const wxTypeInfo* wxGetTypeInfo( a * ) { assert(0) ; \
507 static wxBuiltInTypeInfo s_typeInfo( wxT_VOID ) ; return &s_typeInfo ; } \
508 template<> void wxStringReadValue(const wxString & , a & ) { assert(0) ; }\
509 template<> void wxStringWriteValue(wxString & , a const & ) { assert(0) ; }
511 // ----------------------------------------------------------------------------
512 // wxxVariant as typesafe data holder
513 // ----------------------------------------------------------------------------
515 class WXDLLIMPEXP_BASE wxxVariantData
518 virtual ~wxxVariantData() {}
520 // return a heap allocated duplicate
521 virtual wxxVariantData
* Clone() const = 0 ;
523 // returns the type info of the contentc
524 virtual const wxTypeInfo
* GetTypeInfo() const = 0 ;
527 template<typename T
> class WXDLLIMPEXP_BASE wxxVariantDataT
: public wxxVariantData
530 wxxVariantDataT(const T
& d
) : m_data(d
) {}
531 virtual ~wxxVariantDataT() {}
533 // get a ref to the stored data
534 T
& Get() { return m_data
; }
536 // get a const ref to the stored data
537 const T
& Get() const { return m_data
; }
540 void Set(const T
& d
) { m_data
= d
; }
542 // return a heap allocated duplicate
543 virtual wxxVariantData
* Clone() const { return new wxxVariantDataT
<T
>( Get() ) ; }
545 // returns the type info of the contentc
546 virtual const wxTypeInfo
* GetTypeInfo() const { return wxGetTypeInfo( (T
*) NULL
) ; }
551 class WXDLLIMPEXP_BASE wxxVariant
554 wxxVariant() { m_data
= NULL
; }
555 wxxVariant( wxxVariantData
* data
, const wxString
& name
= wxT("") ) : m_data(data
) , m_name(name
) {}
556 wxxVariant( const wxxVariant
&d
) { if ( d
.m_data
) m_data
= d
.m_data
->Clone() ; else m_data
= NULL
; m_name
= d
.m_name
; }
558 template<typename T
> wxxVariant( const T
& data
, const wxString
& name
= wxT("") ) :
559 m_data(new wxxVariantDataT
<T
>(data
) ), m_name(name
) {}
561 ~wxxVariant() { delete m_data
; }
563 // get a ref to the stored data
564 template<typename T
> T
& Get()
566 wxxVariantDataT
<T
> *dataptr
= dynamic_cast<wxxVariantDataT
<T
>*> (m_data
) ;
567 wxASSERT_MSG( dataptr
, wxT("Cast not possible") ) ;
568 return dataptr
->Get() ;
571 // get a ref to the stored data
572 template<typename T
> const T
& Get() const
574 const wxxVariantDataT
<T
> *dataptr
= dynamic_cast<const wxxVariantDataT
<T
>*> (m_data
) ;
575 wxASSERT_MSG( dataptr
, wxT("Cast not possible") ) ;
576 return dataptr
->Get() ;
579 template<typename T
> bool HasData() const
581 const wxxVariantDataT
<T
> *dataptr
= dynamic_cast<const wxxVariantDataT
<T
>*> (m_data
) ;
582 return dataptr
!= NULL
;
586 template<typename T
> void Set(const T
& data
) const
589 m_data
= new wxxVariantDataT
<T
>(data
) ;
592 wxxVariant
& operator=(const wxxVariant
&d
)
594 m_data
= d
.m_data
->Clone() ;
599 // gets the stored data casted to a wxObject* , returning NULL if cast is not possible
600 wxObject
* GetAsObject() ;
602 // get the typeinfo of the stored object
603 const wxTypeInfo
* GetTypeInfo() const { return m_data
->GetTypeInfo() ; }
605 // returns this value as string
606 wxString
GetAsString() const
609 GetTypeInfo()->ConvertToString( *this , s
) ;
612 const wxString
& GetName() const { return m_name
; }
614 wxxVariantData
* m_data
;
618 #include <wx/dynarray.h>
620 WX_DECLARE_OBJARRAY_WITH_DECL(wxxVariant
, wxxVariantArray
, class WXDLLIMPEXP_BASE
);
622 // ----------------------------------------------------------------------------
625 // wxPropertyInfo is used to inquire of the property by name. It doesn't
626 // provide access to the property, only information about it. If you
627 // want access, look at wxPropertyAccessor.
628 // ----------------------------------------------------------------------------
633 wxSetter( const wxString name
) { m_name
= name
; }
634 virtual void Set( wxObject
*object
, const wxxVariant
&variantValue
) const = 0;
635 const wxString
& GetName() const { return m_name
; }
643 wxGetter( const wxString name
) { m_name
= name
; }
644 virtual void Get( const wxObject
*object
, wxxVariant
& result
) const = 0;
645 const wxString
& GetName() const { return m_name
; }
650 class wxCollectionGetter
653 wxCollectionGetter( const wxString name
) { m_name
= name
; }
654 virtual void Get( const wxObject
*object
, wxxVariantArray
& result
) const = 0;
655 const wxString
& GetName() const { return m_name
; }
660 template<typename coll_t
> void wxCollectionToVariantArray( const coll_t
& coll
, wxxVariantArray
& result
) ;
665 wxAdder( const wxString name
) { m_name
= name
; }
666 virtual void Add( wxObject
*object
, const wxxVariant
&variantValue
) const= 0;
667 const wxString
& GetName() const { return m_name
; }
674 #define WX_SETTER( property, Klass, valueType, setterMethod ) \
675 class wxSetter##property : public wxSetter \
678 wxSetter##property() : wxSetter( #setterMethod ) {} \
679 void Set( wxObject *object, const wxxVariant &variantValue ) const \
681 Klass *obj = dynamic_cast<Klass*>(object) ; \
682 if ( variantValue.HasData<valueType>() ) \
683 obj->setterMethod(variantValue.Get<valueType>()) ; \
685 obj->setterMethod(*variantValue.Get<valueType*>()) ; \
689 #define WX_GETTER( property, Klass, valueType , gettermethod ) \
690 class wxGetter##property : public wxGetter \
693 wxGetter##property() : wxGetter( #gettermethod ) {} \
694 void Get( const wxObject *object , wxxVariant &result) const \
696 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
697 result = wxxVariant( obj->gettermethod() ) ; \
701 #define WX_ADDER( property, Klass, valueType , addermethod ) \
702 class wxAdder##property : public wxAdder \
705 wxAdder##property() : wxAdder( #addermethod ) {} \
706 void Add( wxObject *object, const wxxVariant &variantValue ) const \
708 Klass *obj = dynamic_cast<Klass*>(object) ; \
709 if ( variantValue.HasData<valueType>() ) \
710 obj->addermethod(variantValue.Get<valueType>()) ; \
712 obj->addermethod(*variantValue.Get<valueType*>()) ; \
716 #define WX_COLLECTION_GETTER( property, Klass, valueType , gettermethod ) \
717 class wxCollectionGetter##property : public wxCollectionGetter \
720 wxCollectionGetter##property() : wxCollectionGetter( #gettermethod ) {} \
721 void Get( const wxObject *object , wxxVariantArray &result) const \
723 const Klass *obj = dynamic_cast<const Klass*>(object) ; \
724 wxCollectionToVariantArray( obj->gettermethod() , result ) ; \
728 class WXDLLIMPEXP_BASE wxPropertyAccessor
731 wxPropertyAccessor( wxSetter
*setter
, wxGetter
*getter
, wxAdder
*adder
, wxCollectionGetter
*collectionGetter
)
732 { m_setter
= setter
; m_getter
= getter
; m_adder
= adder
; m_collectionGetter
= collectionGetter
;}
734 virtual ~wxPropertyAccessor() {}
736 // Setting a simple property (non-collection)
737 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const
738 { wxASSERT_MSG(m_setter
,wxT("SetProperty called w/o valid setter") ) ; m_setter
->Set( object
, value
) ;}
740 // Getting a simple property (non-collection)
741 virtual void GetProperty(const wxObject
*object
, wxxVariant
&result
) const
742 { wxASSERT_MSG(m_getter
,wxT("GetProperty called w/o valid getter") ) ; m_getter
->Get( object
, result
) ;}
744 // Adding an element to a collection property
745 virtual void AddToPropertyCollection(wxObject
*object
, const wxxVariant
&value
) const
746 { wxASSERT_MSG(m_adder
,wxT("AddToPropertyCollection called w/o valid adder") ) ; m_adder
->Add( object
, value
) ;}
748 // Getting a collection property
749 virtual void GetPropertyCollection( const wxObject
*obj
, wxxVariantArray
&result
) const
750 { wxASSERT_MSG(m_collectionGetter
,wxT("GetPropertyCollection called w/o valid collection getter") ) ; m_collectionGetter
->Get( obj
, result
) ;}
752 virtual bool HasSetter() const { return m_setter
!= NULL
; }
753 virtual bool HasCollectionGetter() const { return m_collectionGetter
!= NULL
; }
754 virtual bool HasGetter() const { return m_getter
!= NULL
; }
755 virtual bool HasAdder() const { return m_adder
!= NULL
; }
757 virtual const wxString
& GetCollectionGetterName() const
758 { return m_collectionGetter
->GetName() ; }
759 virtual const wxString
& GetGetterName() const
760 { return m_getter
->GetName() ; }
761 virtual const wxString
& GetSetterName() const
762 { return m_setter
->GetName() ; }
763 virtual const wxString
& GetAdderName() const
764 { return m_adder
->GetName() ; }
766 virtual wxxVariant ReadValue( const wxString &value ) const ;
767 virtual void WriteValue( wxString& value , const wxObject *o ) const ;
773 wxCollectionGetter
* m_collectionGetter
;
776 class WXDLLIMPEXP_BASE wxGenericPropertyAccessor
: public wxPropertyAccessor
779 wxGenericPropertyAccessor( const wxString
&propName
) ;
780 ~wxGenericPropertyAccessor() ;
782 virtual bool HasSetter() const { return true ; }
783 virtual bool HasGetter() const { return true ; }
784 virtual bool HasAdder() const { return false ; }
785 virtual bool HasCollectionGetter() const { return false ; }
787 virtual const wxString
& GetGetterName() const
788 { return m_getterName
; }
789 virtual const wxString
& GetSetterName() const
790 { return m_setterName
; }
792 virtual void SetProperty(wxObject
*object
, const wxxVariant
&value
) const ;
793 virtual void GetProperty(const wxObject
*object
, wxxVariant
&value
) const ;
795 // Adding an element to a collection property
796 virtual void AddToPropertyCollection(wxObject
*WXUNUSED(object
), const wxxVariant
&WXUNUSED(value
)) const
797 { wxASSERT_MSG(0,wxT("AddToPropertyCollection called on a generic accessor") ) ;}
799 // Getting a collection property
800 virtual void GetPropertyCollection( const wxObject
*WXUNUSED(obj
), wxxVariantArray
&WXUNUSED(result
)) const
801 { wxASSERT_MSG(0,wxT("GetPropertyCollection called on a generic accessor") ) ;}
803 struct wxGenericPropertyAccessorInternal
;
804 wxGenericPropertyAccessorInternal
* m_data
;
805 wxString m_propertyName
;
806 wxString m_setterName
;
807 wxString m_getterName
;
810 typedef long wxPropertyInfoFlags
;
812 // will be removed in future releases
813 wxPROP_DEPRECATED
= 0x00000001 ,
814 // object graph property, will be streamed with priority (after constructor properties)
815 wxPROP_OBJECT_GRAPH
= 0x00000002 ,
816 // this will only be streamed out and in as enum/set, the internal representation is still a long
817 wxPROP_ENUM_STORE_LONG
= 0x00000004 ,
818 // don't stream out this property, needed eg to avoid streaming out children that are always created by their parents
819 wxPROP_DONT_STREAM
= 0x00000008 ,
822 class WXDLLIMPEXP_BASE wxPropertyInfo
825 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
) :
826 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
)
831 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
) :
832 m_name( name
) , m_itsClass( itsClass
) , m_typeInfo( collTypeInfo
) , m_accessor( accessor
) , m_collectionElementTypeInfo(elemTypeInfo
) , m_helpString (helpString
) , m_groupString( groupString
) , m_flags(flags
)
837 // return the class this property is declared in
838 const wxClassInfo
* GetDeclaringClass() const { return m_itsClass
; }
840 // return the name of this property
841 const wxString
& GetName() const { return m_name
; }
843 // returns the flags of this property
844 wxPropertyInfoFlags
GetFlags() const { return m_flags
;}
846 // returns the short help string of this property
847 const wxString
& GetHelpString() const { return m_helpString
; }
849 // returns the group string of this property
850 const wxString
& GetGroupString() const { return m_groupString
; }
852 // return the element type info of this property (for collections, otherwise NULL)
853 const wxTypeInfo
* GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo
; }
855 // return the type info of this property
856 const wxTypeInfo
* GetTypeInfo() const { return m_typeInfo
; }
858 // return the accessor for this property
859 wxPropertyAccessor
* GetAccessor() const { return m_accessor
; }
861 // returns NULL if this is the last property of this class
862 wxPropertyInfo
* GetNext() const { return m_next
; }
864 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
865 wxxVariant
GetDefaultValue() const { return m_defaultValue
; }
867 void Insert(wxPropertyInfo
* &iter
)
874 wxPropertyInfo
* i
= iter
;
883 wxString m_typeName
;
884 wxString m_groupString
;
885 wxString m_helpString
;
886 const wxClassInfo
* m_itsClass
;
887 wxPropertyInfoFlags m_flags
;
888 const wxTypeInfo
* m_typeInfo
;
889 const wxTypeInfo
* m_collectionElementTypeInfo
;
890 wxPropertyAccessor
* m_accessor
;
891 wxxVariant m_defaultValue
;
892 // string representation of the default value
893 // to be assigned by the designer to the property
894 // when the component is dropped on the container.
895 wxPropertyInfo
* m_next
;
898 WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxPropertyInfo
* , wxPropertyInfoMap
) ;
900 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
901 wxPropertyInfo *theClass::GetPropertiesStatic() \
903 typedef theClass class_t; \
904 static wxPropertyInfo* first = NULL ;
906 #define WX_END_PROPERTIES_TABLE() \
909 #define WX_HIDE_PROPERTY( name ) \
910 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (void*) NULL ) ,NULL , wxxVariant() , wxPROP_DONT_STREAM , wxEmptyString , wxEmptyString ) ;
912 #define WX_PROPERTY( name , type , setter , getter ,defaultValue , flags , help , group) \
913 WX_SETTER( name , class_t , type , setter ) \
914 static wxSetter##name _setter##name ; \
915 WX_GETTER( name , class_t , type , getter ) \
916 static wxGetter##name _getter##name ; \
917 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
918 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) , flags , group , help ) ;
920 #define WX_PROPERTY_FLAGS( name , flags , type , setter , getter ,defaultValue , pflags , help , group) \
921 WX_SETTER( name , class_t , type , setter ) \
922 static wxSetter##name _setter##name ; \
923 WX_GETTER( name , class_t , type , getter ) \
924 static wxGetter##name _getter##name ; \
925 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
926 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (flags*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ;
928 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue , flags , help , group) \
929 WX_GETTER( name , class_t , type , getter ) \
930 static wxGetter##name _getter##name ; \
931 static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \
932 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), flags , help , group ) ;
934 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter , flags , help , group ) \
935 WX_ADDER( name , class_t , addelemtype , adder ) \
936 static wxAdder##name _adder##name ; \
937 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
938 static wxCollectionGetter##name _collectionGetter##name ; \
939 static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \
940 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
942 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter , flags , help , group) \
943 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
944 static wxCollectionGetter##name _collectionGetter##name ; \
945 static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \
946 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
948 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
949 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
950 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
952 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
953 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &getter , #getter ) ; \
954 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
959 #define WX_DELEGATE( name , eventType , eventClass ) \
960 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
961 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
963 // ----------------------------------------------------------------------------
966 // this is describing an event sink
967 // ----------------------------------------------------------------------------
972 wxHandlerInfo( wxHandlerInfo
* &iter
, const wxString
& name
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) :
973 m_name( name
) , m_eventClassInfo( eventClassInfo
) , m_eventFunction( address
)
980 wxHandlerInfo
* i
= iter
;
988 // return the name of this handler
989 const wxString
& GetName() const { return m_name
; }
991 // return the class info of the event
992 const wxClassInfo
* GetEventClassInfo() const { return m_eventClassInfo
; }
994 // get the handler function pointer
995 wxObjectEventFunction
GetEventFunction() const { return m_eventFunction
; }
997 // returns NULL if this is the last handler of this class
998 wxHandlerInfo
* GetNext() const { return m_next
; }
1000 wxObjectEventFunction m_eventFunction
;
1002 const wxClassInfo
* m_eventClassInfo
;
1003 wxHandlerInfo
* m_next
;
1006 #define WX_HANDLER(name,eventClassType) \
1007 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
1009 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
1010 wxHandlerInfo *theClass::GetHandlersStatic() \
1012 typedef theClass class_t; \
1013 static wxHandlerInfo* first = NULL ;
1015 #define WX_END_HANDLERS_TABLE() \
1018 // ----------------------------------------------------------------------------
1019 // Constructor Bridges
1021 // allow to set up constructors with params during runtime
1022 // ----------------------------------------------------------------------------
1024 class WXDLLIMPEXP_BASE wxConstructorBridge
1027 virtual void Create(wxObject
*o
, wxxVariant
*args
) = 0;
1030 // Creator Bridges for all Numbers of Params
1034 template<typename Class
>
1035 struct wxConstructorBridge_0
: public wxConstructorBridge
1037 void Create(wxObject
*o
, wxxVariant
*)
1039 Class
*obj
= dynamic_cast<Class
*>(o
);
1044 struct wxConstructorBridge_Dummy
: public wxConstructorBridge
1046 void Create(wxObject
*, wxxVariant
*)
1051 #define WX_CONSTRUCTOR_0(klass) \
1052 wxConstructorBridge_0<klass> constructor##klass ; \
1053 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1054 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
1055 const int klass::sm_constructorPropertiesCount##klass = 0 ;
1057 #define WX_CONSTRUCTOR_DUMMY(klass) \
1058 wxConstructorBridge_Dummy constructor##klass ; \
1059 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1060 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
1061 const int klass::sm_constructorPropertiesCount##klass = 0 ;
1065 template<typename Class
, typename T0
>
1066 struct wxConstructorBridge_1
: public wxConstructorBridge
1068 void Create(wxObject
*o
, wxxVariant
*args
)
1070 Class
*obj
= dynamic_cast<Class
*>(o
);
1077 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
1078 wxConstructorBridge_1<klass,t0> constructor##klass ; \
1079 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1080 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
1081 const int klass::sm_constructorPropertiesCount##klass = 1 ;
1085 template<typename Class
,
1086 typename T0
, typename T1
>
1087 struct wxConstructorBridge_2
: public wxConstructorBridge
1089 void Create(wxObject
*o
, wxxVariant
*args
)
1091 Class
*obj
= dynamic_cast<Class
*>(o
);
1099 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
1100 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
1101 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1102 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
1103 const int klass::sm_constructorPropertiesCount##klass = 2;
1107 template<typename Class
,
1108 typename T0
, typename T1
, typename T2
>
1109 struct wxConstructorBridge_3
: public wxConstructorBridge
1111 void Create(wxObject
*o
, wxxVariant
*args
)
1113 Class
*obj
= dynamic_cast<Class
*>(o
);
1122 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
1123 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
1124 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1125 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
1126 const int klass::sm_constructorPropertiesCount##klass = 3 ;
1130 template<typename Class
,
1131 typename T0
, typename T1
, typename T2
, typename T3
>
1132 struct wxConstructorBridge_4
: public wxConstructorBridge
1134 void Create(wxObject
*o
, wxxVariant
*args
)
1136 Class
*obj
= dynamic_cast<Class
*>(o
);
1146 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
1147 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
1148 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1149 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
1150 const int klass::sm_constructorPropertiesCount##klass = 4 ;
1154 template<typename Class
,
1155 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
>
1156 struct wxConstructorBridge_5
: public wxConstructorBridge
1158 void Create(wxObject
*o
, wxxVariant
*args
)
1160 Class
*obj
= dynamic_cast<Class
*>(o
);
1171 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
1172 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
1173 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1174 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
1175 const int klass::sm_constructorPropertiesCount##klass = 5;
1179 template<typename Class
,
1180 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
>
1181 struct wxConstructorBridge_6
: public wxConstructorBridge
1183 void Create(wxObject
*o
, wxxVariant
*args
)
1185 Class
*obj
= dynamic_cast<Class
*>(o
);
1197 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
1198 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
1199 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1200 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
1201 const int klass::sm_constructorPropertiesCount##klass = 6;
1205 template<typename Class
,
1206 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
, typename T6
>
1207 struct wxConstructorBridge_7
: public wxConstructorBridge
1209 void Create(wxObject
*o
, wxxVariant
*args
)
1211 Class
*obj
= dynamic_cast<Class
*>(o
);
1224 #define WX_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
1225 wxConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass ; \
1226 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1227 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6} ; \
1228 const int klass::sm_constructorPropertiesCount##klass = 7;
1232 template<typename Class
,
1233 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
, typename T6
, typename T7
>
1234 struct wxConstructorBridge_8
: public wxConstructorBridge
1236 void Create(wxObject
*o
, wxxVariant
*args
)
1238 Class
*obj
= dynamic_cast<Class
*>(o
);
1252 #define WX_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
1253 wxConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass ; \
1254 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1255 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6 , #v7} ; \
1256 const int klass::sm_constructorPropertiesCount##klass = 8;
1257 // ----------------------------------------------------------------------------
1259 // ----------------------------------------------------------------------------
1261 typedef wxObject
*(*wxObjectConstructorFn
)(void);
1262 typedef wxObject
* (*wxVariantToObjectConverter
)( wxxVariant
&data
) ;
1263 typedef wxxVariant (*wxObjectToVariantConverter
)( wxObject
* ) ;
1266 typedef bool (*wxObjectStreamingCallback
) ( const wxObject
*, wxWriter
* , wxPersister
* , wxxVariantArray
& ) ;
1268 class WXDLLIMPEXP_BASE wxClassInfo
1271 wxClassInfo(const wxClassInfo
**_Parents
,
1272 const wxChar
*_UnitName
,
1273 const wxChar
*_ClassName
,
1275 wxObjectConstructorFn ctor
,
1276 wxPropertyInfo
*_Props
,
1277 wxHandlerInfo
*_Handlers
,
1278 wxConstructorBridge
* _Constructor
,
1279 const wxChar
** _ConstructorProperties
,
1280 const int _ConstructorPropertiesCount
,
1281 wxVariantToObjectConverter _PtrConverter1
,
1282 wxVariantToObjectConverter _Converter2
,
1283 wxObjectToVariantConverter _Converter3
,
1284 wxObjectStreamingCallback _streamingCallback
= NULL
1285 ) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1286 m_objectSize(size
), m_objectConstructor(ctor
) , m_firstProperty(_Props
) , m_firstHandler(_Handlers
) , m_constructor( _Constructor
) ,
1287 m_constructorProperties(_ConstructorProperties
) , m_constructorPropertiesCount(_ConstructorPropertiesCount
),
1288 m_variantOfPtrToObjectConverter( _PtrConverter1
) , m_variantToObjectConverter( _Converter2
) , m_objectToVariantConverter( _Converter3
) ,
1289 m_next(sm_first
) , m_streamingCallback( _streamingCallback
)
1295 wxClassInfo(const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
**_Parents
) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1296 m_objectSize(0), m_objectConstructor(NULL
) , m_firstProperty(NULL
) , m_firstHandler(NULL
) , m_constructor( NULL
) ,
1297 m_constructorProperties(NULL
) , m_constructorPropertiesCount(NULL
),
1298 m_variantOfPtrToObjectConverter( NULL
) , m_variantToObjectConverter( NULL
) , m_objectToVariantConverter( NULL
) , m_next(sm_first
) ,
1299 m_streamingCallback( NULL
)
1305 virtual ~wxClassInfo() ;
1307 // allocates an instance of this class, this object does not have to be initialized or fully constructed
1308 // as this call will be followed by a call to Create
1309 virtual wxObject
*AllocateObject() const { return m_objectConstructor ?
(*m_objectConstructor
)() : 0; }
1311 // 'old naming' for AllocateObject staying here for backward compatibility
1312 wxObject
*CreateObject() const { return AllocateObject() ; }
1314 const wxChar
*GetClassName() const { return m_className
; }
1315 const wxChar
*GetIncludeName() const { return m_unitName
; }
1316 const wxClassInfo
**GetParents() const { return m_parents
; }
1317 int GetSize() const { return m_objectSize
; }
1319 wxObjectConstructorFn
GetConstructor() const { return m_objectConstructor
; }
1320 static const wxClassInfo
*GetFirst() { return sm_first
; }
1321 const wxClassInfo
*GetNext() const { return m_next
; }
1322 static wxClassInfo
*FindClass(const wxChar
*className
);
1324 // Climb upwards through inheritance hierarchy.
1325 // Dual inheritance is catered for.
1327 bool IsKindOf(const wxClassInfo
*info
) const
1334 for ( int i
= 0 ; m_parents
[i
] ; ++ i
)
1336 if ( m_parents
[i
]->IsKindOf( info
) )
1343 // if there is a callback registered with that class it will be called before this
1344 // object will be written to disk, it can veto streaming out this object by returning
1345 // false, if this class has not registered a callback, the search will go up the inheritance tree
1346 // if no callback has been registered true will be returned by default
1347 bool BeforeWriteObject( const wxObject
*obj
, wxWriter
*streamer
, wxPersister
*persister
, wxxVariantArray
&metadata
) const ;
1349 // gets the streaming callback from this class or any superclass
1350 wxObjectStreamingCallback
GetStreamingCallback() const ;
1352 #ifdef WXWIN_COMPATIBILITY_2_4
1353 // Initializes parent pointers and hash table for fast searching.
1354 wxDEPRECATED( static void InitializeClasses() );
1355 // Cleans up hash table used for fast searching.
1356 wxDEPRECATED( static void CleanUpClasses() );
1358 static void CleanUp();
1360 // returns the first property
1361 const wxPropertyInfo
* GetFirstProperty() const { return m_firstProperty
; }
1363 // returns the first handler
1364 const wxHandlerInfo
* GetFirstHandler() const { return m_firstHandler
; }
1366 // Call the Create upon an instance of the class, in the end the object is fully
1368 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const
1370 wxASSERT_MSG( ParamCount
== m_constructorPropertiesCount
, wxT("Illegal Parameter Count for Create Method")) ;
1371 m_constructor
->Create( object
, Params
) ;
1374 // get number of parameters for constructor
1375 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount
; }
1377 // get n-th constructor parameter
1378 virtual const wxChar
* GetCreateParamName(int n
) const { return m_constructorProperties
[n
] ; }
1380 // Runtime access to objects for simple properties (get/set) by property name, and variant data
1381 virtual void SetProperty (wxObject
*object
, const wxChar
*propertyName
, const wxxVariant
&value
) const ;
1382 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*propertyName
) const;
1384 // Runtime access to objects for collection properties by property name
1385 virtual wxxVariantArray
GetPropertyCollection(wxObject
*object
, const wxChar
*propertyName
) const ;
1386 virtual void AddToPropertyCollection(wxObject
*object
, const wxChar
*propertyName
, const wxxVariant
& value
) const ;
1388 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1389 wxObject
* VariantToInstance( wxxVariant
&data
) const
1390 { if ( data
.GetTypeInfo()->GetKind() == wxT_OBJECT
)
1391 return m_variantToObjectConverter( data
) ;
1393 return m_variantOfPtrToObjectConverter( data
) ;
1396 wxxVariant
InstanceToVariant( wxObject
*object
) const { return m_objectToVariantConverter( object
) ; }
1398 // find property by name
1399 virtual const wxPropertyInfo
*FindPropertyInfo (const wxChar
*PropertyName
) const ;
1401 // find handler by name
1402 virtual const wxHandlerInfo
*FindHandlerInfo (const wxChar
*PropertyName
) const ;
1404 // find property by name
1405 virtual const wxPropertyInfo
*FindPropertyInfoInThisClass (const wxChar
*PropertyName
) const ;
1407 // find handler by name
1408 virtual const wxHandlerInfo
*FindHandlerInfoInThisClass (const wxChar
*PropertyName
) const ;
1410 // puts all the properties of this class and its superclasses in the map, as long as there is not yet
1411 // an entry with the same name (overriding mechanism)
1412 void GetProperties( wxPropertyInfoMap
&map
) const ;
1414 const wxChar
*m_className
;
1416 wxObjectConstructorFn m_objectConstructor
;
1418 // class info object live in a linked list:
1419 // pointers to its head and the next element in it
1421 static wxClassInfo
*sm_first
;
1422 wxClassInfo
*m_next
;
1424 // FIXME: this should be private (currently used directly by way too
1426 static wxHashTable
*sm_classTable
;
1429 wxPropertyInfo
* m_firstProperty
;
1430 wxHandlerInfo
* m_firstHandler
;
1432 const wxClassInfo
** m_parents
;
1433 const wxChar
* m_unitName
;
1435 wxConstructorBridge
* m_constructor
;
1436 const wxChar
** m_constructorProperties
;
1437 const int m_constructorPropertiesCount
;
1438 wxVariantToObjectConverter m_variantOfPtrToObjectConverter
;
1439 wxVariantToObjectConverter m_variantToObjectConverter
;
1440 wxObjectToVariantConverter m_objectToVariantConverter
;
1441 wxObjectStreamingCallback m_streamingCallback
;
1442 const wxPropertyAccessor
*FindAccessor (const wxChar
*propertyName
) const ;
1445 // InitializeClasses() helper
1446 static wxClassInfo
*GetBaseByName(const wxChar
*name
) ;
1449 // registers the class
1453 DECLARE_NO_COPY_CLASS(wxClassInfo
)
1457 WXDLLIMPEXP_BASE wxObject
*wxCreateDynamicObject(const wxChar
*name
);
1459 // ----------------------------------------------------------------------------
1461 // ----------------------------------------------------------------------------
1463 // this object leads to having a pure runtime-instantiation
1465 class wxDynamicClassInfo
: public wxClassInfo
1468 wxDynamicClassInfo( const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
* superClass
) ;
1469 virtual ~wxDynamicClassInfo() ;
1471 // constructs a wxDynamicObject with an instance
1472 virtual wxObject
*AllocateObject() const ;
1474 // Call the Create method for a class
1475 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const ;
1477 // get number of parameters for constructor
1478 virtual int GetCreateParamCount() const ;
1480 // get i-th constructor parameter
1481 virtual const wxChar
* GetCreateParamName(int i
) const ;
1483 // Runtime access to objects by property name, and variant data
1484 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
) const ;
1485 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
) const ;
1487 void AddProperty( const wxChar
*propertyName
, const wxTypeInfo
* typeInfo
) ;
1488 void AddHandler( const wxChar
*handlerName
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) ;
1491 // ----------------------------------------------------------------------------
1492 // Dynamic class macros
1493 // ----------------------------------------------------------------------------
1495 #define _DECLARE_DYNAMIC_CLASS(name) \
1497 static wxClassInfo sm_class##name; \
1498 static const wxClassInfo* sm_classParents##name[] ; \
1499 static wxPropertyInfo* GetPropertiesStatic() ; \
1500 static wxHandlerInfo* GetHandlersStatic() ; \
1501 static wxClassInfo *GetClassInfoStatic() \
1502 { return &name::sm_class##name; } \
1503 virtual wxClassInfo *GetClassInfo() const \
1504 { return &name::sm_class##name; }
1506 #define DECLARE_DYNAMIC_CLASS(name) \
1507 static wxConstructorBridge* sm_constructor##name ; \
1508 static const wxChar * sm_constructorProperties##name[] ; \
1509 static const int sm_constructorPropertiesCount##name ; \
1510 _DECLARE_DYNAMIC_CLASS(name)
1512 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1513 DECLARE_NO_ASSIGN_CLASS(name) \
1514 DECLARE_DYNAMIC_CLASS(name)
1516 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1517 DECLARE_NO_COPY_CLASS(name) \
1518 DECLARE_DYNAMIC_CLASS(name)
1520 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1521 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1523 // -----------------------------------
1524 // for concrete classes
1525 // -----------------------------------
1527 // Single inheritance with one base class
1529 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit , callback) \
1530 wxObject* wxConstructorFor##name() \
1531 { return new name; } \
1532 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1533 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1534 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1535 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1536 (int) sizeof(name), \
1537 (wxObjectConstructorFn) wxConstructorFor##name , \
1538 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1539 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name , callback); \
1540 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1541 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1542 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1543 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1544 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1545 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1546 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1547 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1548 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1550 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit, callback ) \
1551 wxObject* wxConstructorFor##name() \
1552 { return new name; } \
1553 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1554 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1555 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1556 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1557 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1558 (int) sizeof(name), \
1559 (wxObjectConstructorFn) wxConstructorFor##name , \
1560 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1561 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name, callback); \
1562 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1563 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1564 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1565 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1566 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1567 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1568 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1569 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1570 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1572 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1573 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" , NULL ) \
1574 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1575 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1576 WX_CONSTRUCTOR_DUMMY( name )
1578 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1579 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" , NULL ) \
1580 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1581 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1582 WX_CONSTRUCTOR_DUMMY( name )
1584 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1585 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , NULL )
1587 #define IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK( name , basename , unit , callback ) \
1588 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit , &callback )
1590 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1591 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit , NULL )
1593 // this is for classes that do not derive from wxobject, there are no creators for these
1595 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1596 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1597 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1598 (int) sizeof(name), \
1599 (wxObjectConstructorFn) 0 , \
1600 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1602 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1603 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1604 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1605 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1606 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1607 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1608 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1610 // this is for subclasses that still do not derive from wxobject
1612 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1613 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1614 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1615 (int) sizeof(name), \
1616 (wxObjectConstructorFn) 0 , \
1617 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1619 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1620 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1621 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1622 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1623 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1624 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1625 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1628 // Multiple inheritance with two base classes
1630 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1631 wxObject* wxConstructorFor##name() \
1632 { return new name; } \
1633 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1634 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1635 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1636 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1637 (int) sizeof(name), \
1638 (wxObjectConstructorFn) wxConstructorFor##name , \
1639 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1640 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1641 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1642 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1643 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1644 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1645 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1646 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1647 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1649 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1650 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1651 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1652 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1653 WX_CONSTRUCTOR_DUMMY( name )
1655 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1656 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1658 // -----------------------------------
1659 // for abstract classes
1660 // -----------------------------------
1662 // Single inheritance with one base class
1664 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1665 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1666 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1667 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1668 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1669 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1670 (int) sizeof(name), \
1671 (wxObjectConstructorFn) 0 , \
1672 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1673 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1674 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1675 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1676 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1677 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1678 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1679 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1680 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1682 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1683 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1684 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1685 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1687 // Multiple inheritance with two base classes
1689 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1690 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1691 wxT(#basename2), (int) sizeof(name), \
1692 (wxObjectConstructorFn) 0);
1694 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1695 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
1697 // --------------------------------------------------------------------------
1698 // Collection Support
1699 // --------------------------------------------------------------------------
1701 template<typename collection_t
> void wxListCollectionToVariantArray( const collection_t
& coll
, wxxVariantArray
&value
)
1703 collection_t
::compatibility_iterator current
= coll
.GetFirst() ;
1706 value
.Add( new wxxVariant(current
->GetData()) ) ;
1707 current
= current
->GetNext();
1711 template<typename collection_t
> void wxArrayCollectionToVariantArray( const collection_t
& coll
, wxxVariantArray
&value
)
1713 for( size_t i
= 0 ; i
< coll
.GetCount() ; i
++ )
1715 value
.Add( new wxxVariant(coll
[i
]) ) ;