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
.Contains( 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(data)) ;} \
219 void ToLong##SetName( const wxxVariant& data , long &result ) { result = (long) data.Get<SetName>() ;} \
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 ,
754 class WXDLLIMPEXP_BASE wxPropertyInfo
757 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
) :
758 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
)
763 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
) :
764 m_name( name
) , m_itsClass( itsClass
) , m_typeInfo( collTypeInfo
) , m_accessor( accessor
) , m_collectionElementTypeInfo(elemTypeInfo
) , m_helpString (helpString
) , m_groupString( groupString
) , m_flags(flags
)
769 // return the class this property is declared in
770 const wxClassInfo
* GetDeclaringClass() const { return m_itsClass
; }
772 // return the name of this property
773 const wxString
& GetName() const { return m_name
; }
775 // returns the flags of this property
776 wxPropertyInfoFlags
GetFlags() const { return m_flags
;}
778 // returns the short help string of this property
779 const wxString
& GetHelpString() const { return m_helpString
; }
781 // returns the group string of this property
782 const wxString
& GetGroupString() const { return m_groupString
; }
784 // return the element type info of this property (for collections, otherwise NULL)
785 const wxTypeInfo
* GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo
; }
787 // return the type info of this property
788 const wxTypeInfo
* GetTypeInfo() const { return m_typeInfo
; }
790 // return the accessor for this property
791 wxPropertyAccessor
* GetAccessor() const { return m_accessor
; }
793 // returns NULL if this is the last property of this class
794 wxPropertyInfo
* GetNext() const { return m_next
; }
796 // returns the default value of this property, its kind may be wxT_VOID if it is not valid
797 wxxVariant
GetDefaultValue() const { return m_defaultValue
; }
799 void Insert(wxPropertyInfo
* &iter
)
806 wxPropertyInfo
* i
= iter
;
815 wxString m_typeName
;
816 wxString m_groupString
;
817 wxString m_helpString
;
818 const wxClassInfo
* m_itsClass
;
819 wxPropertyInfoFlags m_flags
;
820 const wxTypeInfo
* m_typeInfo
;
821 const wxTypeInfo
* m_collectionElementTypeInfo
;
822 wxPropertyAccessor
* m_accessor
;
823 wxxVariant m_defaultValue
;
824 // string representation of the default value
825 // to be assigned by the designer to the property
826 // when the component is dropped on the container.
827 wxPropertyInfo
* m_next
;
830 WX_DECLARE_EXPORTED_STRING_HASH_MAP( wxPropertyInfo
* , wxPropertyInfoMap
) ;
832 #define WX_BEGIN_PROPERTIES_TABLE(theClass) \
833 wxPropertyInfo *theClass::GetPropertiesStatic() \
835 typedef theClass class_t; \
836 static wxPropertyInfo* first = NULL ;
838 #define WX_END_PROPERTIES_TABLE() \
843 #define WX_PROPERTY( name , type , setter , getter ,defaultValue , flags , help , group) \
844 WX_SETTER( name , class_t , type , setter ) \
845 static wxSetter##name _setter##name ; \
846 WX_GETTER( name , class_t , type , getter ) \
847 static wxGetter##name _getter##name ; \
848 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
849 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) , flags , group , help ) ;
851 #define WX_PROPERTY_FLAGS( name , flags , type , setter , getter ,defaultValue , pflags , help , group) \
852 WX_SETTER( name , class_t , type , setter ) \
853 static wxSetter##name _setter##name ; \
854 WX_GETTER( name , class_t , type , getter ) \
855 static wxGetter##name _getter##name ; \
856 static wxPropertyAccessor _accessor##name( &_setter##name , &_getter##name , NULL , NULL ) ; \
857 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (flags*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), wxPROP_ENUM_STORE_LONG | pflags , help , group ) ;
859 #define WX_READONLY_PROPERTY( name , type , getter ,defaultValue , flags , help , group) \
860 WX_GETTER( name , class_t , type , getter ) \
861 static wxGetter##name _getter##name ; \
862 static wxPropertyAccessor _accessor##name( NULL , &_getter##name , NULL , NULL ) ; \
863 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue), flags , help , group ) ;
865 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter , flags , help , group ) \
866 WX_ADDER( name , class_t , addelemtype , adder ) \
867 static wxAdder##name _adder##name ; \
868 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
869 static wxCollectionGetter##name _collectionGetter##name ; \
870 static wxPropertyAccessor _accessor##name( NULL , NULL ,&_adder##name , &_collectionGetter##name ) ; \
871 static wxPropertyInfo _propertyInfo##name( first , class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
873 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter , flags , help , group) \
874 WX_COLLECTION_GETTER( name , class_t , colltype , getter ) \
875 static wxCollectionGetter##name _collectionGetter##name ; \
876 static wxPropertyAccessor _accessor##name( NULL , NULL , NULL , &_collectionGetter##name ) ; \
877 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name , flags , help , group ) ;
879 #define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
880 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
881 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
883 #define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
884 static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &getter , #getter ) ; \
885 static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
890 #define WX_DELEGATE( name , eventType , eventClass ) \
891 static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
892 static wxPropertyInfo _propertyInfo##name( first ,class_t::GetClassInfoStatic() , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
894 // ----------------------------------------------------------------------------
897 // this is describing an event sink
898 // ----------------------------------------------------------------------------
903 wxHandlerInfo( wxHandlerInfo
* &iter
, const wxString
& name
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) :
904 m_name( name
) , m_eventClassInfo( eventClassInfo
) , m_eventFunction( address
)
911 wxHandlerInfo
* i
= iter
;
919 // return the name of this handler
920 const wxString
& GetName() const { return m_name
; }
922 // return the class info of the event
923 const wxClassInfo
* GetEventClassInfo() const { return m_eventClassInfo
; }
925 // get the handler function pointer
926 wxObjectEventFunction
GetEventFunction() const { return m_eventFunction
; }
928 // returns NULL if this is the last handler of this class
929 wxHandlerInfo
* GetNext() const { return m_next
; }
931 wxObjectEventFunction m_eventFunction
;
933 const wxClassInfo
* m_eventClassInfo
;
934 wxHandlerInfo
* m_next
;
937 #define WX_HANDLER(name,eventClassType) \
938 static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
940 #define WX_BEGIN_HANDLERS_TABLE(theClass) \
941 wxHandlerInfo *theClass::GetHandlersStatic() \
943 typedef theClass class_t; \
944 static wxHandlerInfo* first = NULL ;
946 #define WX_END_HANDLERS_TABLE() \
949 // ----------------------------------------------------------------------------
950 // Constructor Bridges
952 // allow to set up constructors with params during runtime
953 // ----------------------------------------------------------------------------
955 class WXDLLIMPEXP_BASE wxConstructorBridge
958 virtual void Create(wxObject
*o
, wxxVariant
*args
) = 0;
961 // Creator Bridges for all Numbers of Params
965 template<typename Class
>
966 struct wxConstructorBridge_0
: public wxConstructorBridge
968 void Create(wxObject
*o
, wxxVariant
*)
970 Class
*obj
= dynamic_cast<Class
*>(o
);
975 struct wxConstructorBridge_Dummy
: public wxConstructorBridge
977 void Create(wxObject
*, wxxVariant
*)
982 #define WX_CONSTRUCTOR_0(klass) \
983 wxConstructorBridge_0<klass> constructor##klass ; \
984 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
985 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
986 const int klass::sm_constructorPropertiesCount##klass = 0 ;
988 #define WX_CONSTRUCTOR_DUMMY(klass) \
989 wxConstructorBridge_Dummy constructor##klass ; \
990 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
991 const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
992 const int klass::sm_constructorPropertiesCount##klass = 0 ;
996 template<typename Class
, typename T0
>
997 struct wxConstructorBridge_1
: public wxConstructorBridge
999 void Create(wxObject
*o
, wxxVariant
*args
)
1001 Class
*obj
= dynamic_cast<Class
*>(o
);
1008 #define WX_CONSTRUCTOR_1(klass,t0,v0) \
1009 wxConstructorBridge_1<klass,t0> constructor##klass ; \
1010 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1011 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 } ; \
1012 const int klass::sm_constructorPropertiesCount##klass = 1 ;
1016 template<typename Class
,
1017 typename T0
, typename T1
>
1018 struct wxConstructorBridge_2
: public wxConstructorBridge
1020 void Create(wxObject
*o
, wxxVariant
*args
)
1022 Class
*obj
= dynamic_cast<Class
*>(o
);
1030 #define WX_CONSTRUCTOR_2(klass,t0,v0,t1,v1) \
1031 wxConstructorBridge_2<klass,t0,t1> constructor##klass ; \
1032 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1033 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 } ; \
1034 const int klass::sm_constructorPropertiesCount##klass = 2;
1038 template<typename Class
,
1039 typename T0
, typename T1
, typename T2
>
1040 struct wxConstructorBridge_3
: public wxConstructorBridge
1042 void Create(wxObject
*o
, wxxVariant
*args
)
1044 Class
*obj
= dynamic_cast<Class
*>(o
);
1053 #define WX_CONSTRUCTOR_3(klass,t0,v0,t1,v1,t2,v2) \
1054 wxConstructorBridge_3<klass,t0,t1,t2> constructor##klass ; \
1055 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1056 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 } ; \
1057 const int klass::sm_constructorPropertiesCount##klass = 3 ;
1061 template<typename Class
,
1062 typename T0
, typename T1
, typename T2
, typename T3
>
1063 struct wxConstructorBridge_4
: public wxConstructorBridge
1065 void Create(wxObject
*o
, wxxVariant
*args
)
1067 Class
*obj
= dynamic_cast<Class
*>(o
);
1077 #define WX_CONSTRUCTOR_4(klass,t0,v0,t1,v1,t2,v2,t3,v3) \
1078 wxConstructorBridge_4<klass,t0,t1,t2,t3> constructor##klass ; \
1079 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1080 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 } ; \
1081 const int klass::sm_constructorPropertiesCount##klass = 4 ;
1085 template<typename Class
,
1086 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
>
1087 struct wxConstructorBridge_5
: public wxConstructorBridge
1089 void Create(wxObject
*o
, wxxVariant
*args
)
1091 Class
*obj
= dynamic_cast<Class
*>(o
);
1102 #define WX_CONSTRUCTOR_5(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4) \
1103 wxConstructorBridge_5<klass,t0,t1,t2,t3,t4> constructor##klass ; \
1104 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1105 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 } ; \
1106 const int klass::sm_constructorPropertiesCount##klass = 5;
1110 template<typename Class
,
1111 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
>
1112 struct wxConstructorBridge_6
: public wxConstructorBridge
1114 void Create(wxObject
*o
, wxxVariant
*args
)
1116 Class
*obj
= dynamic_cast<Class
*>(o
);
1128 #define WX_CONSTRUCTOR_6(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5) \
1129 wxConstructorBridge_6<klass,t0,t1,t2,t3,t4,t5> constructor##klass ; \
1130 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1131 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 } ; \
1132 const int klass::sm_constructorPropertiesCount##klass = 6;
1136 template<typename Class
,
1137 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
, typename T6
>
1138 struct wxConstructorBridge_7
: public wxConstructorBridge
1140 void Create(wxObject
*o
, wxxVariant
*args
)
1142 Class
*obj
= dynamic_cast<Class
*>(o
);
1155 #define WX_CONSTRUCTOR_7(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6) \
1156 wxConstructorBridge_7<klass,t0,t1,t2,t3,t4,t5,t6> constructor##klass ; \
1157 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1158 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6} ; \
1159 const int klass::sm_constructorPropertiesCount##klass = 7;
1163 template<typename Class
,
1164 typename T0
, typename T1
, typename T2
, typename T3
, typename T4
, typename T5
, typename T6
, typename T7
>
1165 struct wxConstructorBridge_8
: public wxConstructorBridge
1167 void Create(wxObject
*o
, wxxVariant
*args
)
1169 Class
*obj
= dynamic_cast<Class
*>(o
);
1183 #define WX_CONSTRUCTOR_8(klass,t0,v0,t1,v1,t2,v2,t3,v3,t4,v4,t5,v5,t6,v6,t7,v7) \
1184 wxConstructorBridge_8<klass,t0,t1,t2,t3,t4,t5,t6,t7> constructor##klass ; \
1185 wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
1186 const wxChar *klass::sm_constructorProperties##klass[] = { #v0 , #v1 , #v2 , #v3 , #v4 , #v5 , #v6 , #v7} ; \
1187 const int klass::sm_constructorPropertiesCount##klass = 8;
1188 // ----------------------------------------------------------------------------
1190 // ----------------------------------------------------------------------------
1192 typedef wxObject
*(*wxObjectConstructorFn
)(void);
1193 typedef wxObject
* (*wxVariantToObjectConverter
)( wxxVariant
&data
) ;
1194 typedef wxxVariant (*wxObjectToVariantConverter
)( wxObject
* ) ;
1196 class WXDLLIMPEXP_BASE wxClassInfo
1199 wxClassInfo(const wxClassInfo
**_Parents
,
1200 const wxChar
*_UnitName
,
1201 const wxChar
*_ClassName
,
1203 wxObjectConstructorFn ctor
,
1204 wxPropertyInfo
*_Props
,
1205 wxHandlerInfo
*_Handlers
,
1206 wxConstructorBridge
* _Constructor
,
1207 const wxChar
** _ConstructorProperties
,
1208 const int _ConstructorPropertiesCount
,
1209 wxVariantToObjectConverter _PtrConverter1
,
1210 wxVariantToObjectConverter _Converter2
,
1211 wxObjectToVariantConverter _Converter3
1212 ) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1213 m_objectSize(size
), m_objectConstructor(ctor
) , m_firstProperty(_Props
) , m_firstHandler(_Handlers
) , m_constructor( _Constructor
) ,
1214 m_constructorProperties(_ConstructorProperties
) , m_constructorPropertiesCount(_ConstructorPropertiesCount
),
1215 m_variantOfPtrToObjectConverter( _PtrConverter1
) , m_variantToObjectConverter( _Converter2
) , m_objectToVariantConverter( _Converter3
) , m_next(sm_first
)
1221 wxClassInfo(const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
**_Parents
) : m_parents(_Parents
) , m_unitName(_UnitName
) ,m_className(_ClassName
),
1222 m_objectSize(0), m_objectConstructor(NULL
) , m_firstProperty(NULL
) , m_firstHandler(NULL
) , m_constructor( NULL
) ,
1223 m_constructorProperties(NULL
) , m_constructorPropertiesCount(NULL
),
1224 m_variantOfPtrToObjectConverter( NULL
) , m_variantToObjectConverter( NULL
) , m_objectToVariantConverter( NULL
) , m_next(sm_first
)
1230 virtual ~wxClassInfo() ;
1232 // allocates an instance of this class, this object does not have to be initialized or fully constructed
1233 // as this call will be followed by a call to Create
1234 virtual wxObject
*AllocateObject() const { return m_objectConstructor ?
(*m_objectConstructor
)() : 0; }
1236 // 'old naming' for AllocateObject staying here for backward compatibility
1237 wxObject
*CreateObject() const { return AllocateObject() ; }
1239 const wxChar
*GetClassName() const { return m_className
; }
1240 const wxClassInfo
**GetParents() const { return m_parents
; }
1241 int GetSize() const { return m_objectSize
; }
1243 wxObjectConstructorFn
GetConstructor() const { return m_objectConstructor
; }
1244 static const wxClassInfo
*GetFirst() { return sm_first
; }
1245 const wxClassInfo
*GetNext() const { return m_next
; }
1246 static wxClassInfo
*FindClass(const wxChar
*className
);
1248 // Climb upwards through inheritance hierarchy.
1249 // Dual inheritance is catered for.
1251 bool IsKindOf(const wxClassInfo
*info
) const
1258 for ( int i
= 0 ; m_parents
[i
] ; ++ i
)
1260 if ( m_parents
[i
]->IsKindOf( info
) )
1267 #ifdef WXWIN_COMPATIBILITY_2_4
1268 // Initializes parent pointers and hash table for fast searching.
1269 wxDEPRECATED( static void InitializeClasses() );
1270 // Cleans up hash table used for fast searching.
1271 wxDEPRECATED( static void CleanUpClasses() );
1273 static void CleanUp();
1275 // returns the first property
1276 const wxPropertyInfo
* GetFirstProperty() const { return m_firstProperty
; }
1278 // returns the first handler
1279 const wxHandlerInfo
* GetFirstHandler() const { return m_firstHandler
; }
1281 // Call the Create upon an instance of the class, in the end the object is fully
1283 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const
1285 wxASSERT_MSG( ParamCount
== m_constructorPropertiesCount
, wxT("Illegal Parameter Count for Create Method")) ;
1286 m_constructor
->Create( object
, Params
) ;
1289 // get number of parameters for constructor
1290 virtual int GetCreateParamCount() const { return m_constructorPropertiesCount
; }
1292 // get n-th constructor parameter
1293 virtual const wxChar
* GetCreateParamName(int n
) const { return m_constructorProperties
[n
] ; }
1295 // Runtime access to objects for simple properties (get/set) by property name, and variant data
1296 virtual void SetProperty (wxObject
*object
, const wxChar
*propertyName
, const wxxVariant
&value
) const ;
1297 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*propertyName
) const;
1299 // Runtime access to objects for collection properties by property name
1300 virtual wxxVariantArray
GetPropertyCollection(wxObject
*object
, const wxChar
*propertyName
) const ;
1301 virtual void AddToPropertyCollection(wxObject
*object
, const wxChar
*propertyName
, const wxxVariant
& value
) const ;
1303 // we must be able to cast variants to wxObject pointers, templates seem not to be suitable
1304 wxObject
* VariantToInstance( wxxVariant
&data
) const
1305 { if ( data
.GetTypeInfo()->GetKind() == wxT_OBJECT
)
1306 return m_variantToObjectConverter( data
) ;
1308 return m_variantOfPtrToObjectConverter( data
) ;
1311 wxxVariant
InstanceToVariant( wxObject
*object
) const { return m_objectToVariantConverter( object
) ; }
1313 // find property by name
1314 virtual const wxPropertyInfo
*FindPropertyInfo (const wxChar
*PropertyName
) const ;
1316 // find handler by name
1317 virtual const wxHandlerInfo
*FindHandlerInfo (const wxChar
*PropertyName
) const ;
1319 // find property by name
1320 virtual const wxPropertyInfo
*FindPropertyInfoInThisClass (const wxChar
*PropertyName
) const ;
1322 // find handler by name
1323 virtual const wxHandlerInfo
*FindHandlerInfoInThisClass (const wxChar
*PropertyName
) const ;
1325 // puts all the properties of this class and its superclasses in the map, as long as there is not yet
1326 // an entry with the same name (overriding mechanism)
1327 void GetProperties( wxPropertyInfoMap
&map
) const ;
1329 const wxChar
*m_className
;
1331 wxObjectConstructorFn m_objectConstructor
;
1333 // class info object live in a linked list:
1334 // pointers to its head and the next element in it
1336 static wxClassInfo
*sm_first
;
1337 wxClassInfo
*m_next
;
1339 // FIXME: this should be private (currently used directly by way too
1341 static wxHashTable
*sm_classTable
;
1344 wxPropertyInfo
* m_firstProperty
;
1345 wxHandlerInfo
* m_firstHandler
;
1347 const wxClassInfo
** m_parents
;
1348 const wxChar
* m_unitName
;
1350 wxConstructorBridge
* m_constructor
;
1351 const wxChar
** m_constructorProperties
;
1352 const int m_constructorPropertiesCount
;
1353 wxVariantToObjectConverter m_variantOfPtrToObjectConverter
;
1354 wxVariantToObjectConverter m_variantToObjectConverter
;
1355 wxObjectToVariantConverter m_objectToVariantConverter
;
1357 const wxPropertyAccessor
*FindAccessor (const wxChar
*propertyName
) const ;
1360 // InitializeClasses() helper
1361 static wxClassInfo
*GetBaseByName(const wxChar
*name
) ;
1364 // registers the class
1368 DECLARE_NO_COPY_CLASS(wxClassInfo
)
1372 WXDLLIMPEXP_BASE wxObject
*wxCreateDynamicObject(const wxChar
*name
);
1374 // ----------------------------------------------------------------------------
1376 // ----------------------------------------------------------------------------
1378 // this object leads to having a pure runtime-instantiation
1380 class wxDynamicClassInfo
: public wxClassInfo
1383 wxDynamicClassInfo( const wxChar
*_UnitName
, const wxChar
*_ClassName
, const wxClassInfo
* superClass
) ;
1384 virtual ~wxDynamicClassInfo() ;
1386 // constructs a wxDynamicObject with an instance
1387 virtual wxObject
*AllocateObject() const ;
1389 // Call the Create method for a class
1390 virtual void Create (wxObject
*object
, int ParamCount
, wxxVariant
*Params
) const ;
1392 // get number of parameters for constructor
1393 virtual int GetCreateParamCount() const ;
1395 // get i-th constructor parameter
1396 virtual const wxChar
* GetCreateParamName(int i
) const ;
1398 // Runtime access to objects by property name, and variant data
1399 virtual void SetProperty (wxObject
*object
, const wxChar
*PropertyName
, const wxxVariant
&Value
) const ;
1400 virtual wxxVariant
GetProperty (wxObject
*object
, const wxChar
*PropertyName
) const ;
1402 void AddProperty( const wxChar
*propertyName
, const wxTypeInfo
* typeInfo
) ;
1403 void AddHandler( const wxChar
*handlerName
, wxObjectEventFunction address
, const wxClassInfo
* eventClassInfo
) ;
1406 // ----------------------------------------------------------------------------
1407 // Dynamic class macros
1408 // ----------------------------------------------------------------------------
1410 #define _DECLARE_DYNAMIC_CLASS(name) \
1412 static wxClassInfo sm_class##name; \
1413 static const wxClassInfo* sm_classParents##name[] ; \
1414 static wxPropertyInfo* GetPropertiesStatic() ; \
1415 static wxHandlerInfo* GetHandlersStatic() ; \
1416 static wxClassInfo *GetClassInfoStatic() \
1417 { return &name::sm_class##name; } \
1418 virtual wxClassInfo *GetClassInfo() const \
1419 { return &name::sm_class##name; }
1421 #define DECLARE_DYNAMIC_CLASS(name) \
1422 static wxConstructorBridge* sm_constructor##name ; \
1423 static const wxChar * sm_constructorProperties##name[] ; \
1424 static const int sm_constructorPropertiesCount##name ; \
1425 _DECLARE_DYNAMIC_CLASS(name)
1427 #define DECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
1428 DECLARE_NO_ASSIGN_CLASS(name) \
1429 DECLARE_DYNAMIC_CLASS(name)
1431 #define DECLARE_DYNAMIC_CLASS_NO_COPY(name) \
1432 DECLARE_NO_COPY_CLASS(name) \
1433 DECLARE_DYNAMIC_CLASS(name)
1435 #define DECLARE_ABSTRACT_CLASS(name) _DECLARE_DYNAMIC_CLASS(name)
1436 #define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
1438 // -----------------------------------
1439 // for concrete classes
1440 // -----------------------------------
1442 // Single inheritance with one base class
1444 #define _IMPLEMENT_DYNAMIC_CLASS(name, basename, unit) \
1445 wxObject* wxConstructorFor##name() \
1446 { return new name; } \
1447 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1448 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1449 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1450 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1451 (int) sizeof(name), \
1452 (wxObjectConstructorFn) wxConstructorFor##name , \
1453 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1454 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , NULL , wxObjectToVariantConverter##name); \
1455 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1456 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1457 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1458 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1459 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1460 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1461 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1462 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1463 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1465 #define _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY(name, basename, unit) \
1466 wxObject* wxConstructorFor##name() \
1467 { return new name; } \
1468 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1469 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return &data.Get<name>() ; } \
1470 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1471 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1472 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1473 (int) sizeof(name), \
1474 (wxObjectConstructorFn) wxConstructorFor##name , \
1475 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1476 name::sm_constructorPropertiesCount##name , wxVariantOfPtrToObjectConverter##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1477 template<> void wxStringReadValue(const wxString & , name & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1478 template<> void wxStringWriteValue(wxString & , name const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1479 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") ) ;}\
1480 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1481 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1482 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1483 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1484 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1485 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1487 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename ) \
1488 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , "" ) \
1489 const wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1490 const wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1491 WX_CONSTRUCTOR_DUMMY( name )
1493 #define IMPLEMENT_DYNAMIC_CLASS( name , basename ) \
1494 _IMPLEMENT_DYNAMIC_CLASS( name , basename , "" ) \
1495 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1496 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1497 WX_CONSTRUCTOR_DUMMY( name )
1499 #define IMPLEMENT_DYNAMIC_CLASS_XTI( name , basename , unit ) \
1500 _IMPLEMENT_DYNAMIC_CLASS( name , basename , unit )
1502 #define IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI( name , basename , unit ) \
1503 _IMPLEMENT_DYNAMIC_CLASS_WITH_COPY( name , basename , unit )
1505 // this is for classes that do not derive from wxobject, there are no creators for these
1507 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_NO_BASE_XTI( name , unit ) \
1508 const wxClassInfo* name::sm_classParents##name[] = { NULL } ; \
1509 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1510 (int) sizeof(name), \
1511 (wxObjectConstructorFn) 0 , \
1512 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1514 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1515 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1516 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1517 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1518 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1519 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1520 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1522 // this is for subclasses that still do not derive from wxobject
1524 #define IMPLEMENT_DYNAMIC_CLASS_NO_WXOBJECT_XTI( name , basename, unit ) \
1525 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1526 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1527 (int) sizeof(name), \
1528 (wxObjectConstructorFn) 0 , \
1529 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1531 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1532 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1533 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1534 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1535 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID ) ; wxASSERT_MSG(0 , wxT("illegal specialization called") ) ; return &s_typeInfo ; } \
1536 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1537 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; }
1540 // Multiple inheritance with two base classes
1542 #define _IMPLEMENT_DYNAMIC_CLASS2(name, basename, basename2, unit) \
1543 wxObject* wxConstructorFor##name() \
1544 { return new name; } \
1545 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,&basename2::sm_class##basename2 , NULL } ; \
1546 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1547 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1548 wxClassInfo name::sm_class##name(sm_classParents##name , wxT(unit) , wxT(#name), \
1549 (int) sizeof(name), \
1550 (wxObjectConstructorFn) wxConstructorFor##name , \
1551 name::GetPropertiesStatic(),name::GetHandlersStatic(),name::sm_constructor##name , name::sm_constructorProperties##name , \
1552 name::sm_constructorPropertiesCount##name , wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
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 ; }
1561 #define IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2) \
1562 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , "") \
1563 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; } \
1564 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1565 WX_CONSTRUCTOR_DUMMY( name )
1567 #define IMPLEMENT_DYNAMIC_CLASS2_XTI( name , basename , basename2, unit) \
1568 _IMPLEMENT_DYNAMIC_CLASS2( name , basename , basename2 , unit)
1570 // -----------------------------------
1571 // for abstract classes
1572 // -----------------------------------
1574 // Single inheritance with one base class
1576 #define _IMPLEMENT_ABSTRACT_CLASS(name, basename) \
1577 const wxClassInfo* name::sm_classParents##name[] = { &basename::sm_class##basename ,NULL } ; \
1578 wxObject* wxVariantToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1579 wxObject* wxVariantOfPtrToObjectConverter##name ( wxxVariant &data ) { return data.Get<name*>() ; } \
1580 wxxVariant wxObjectToVariantConverter##name ( wxObject *data ) { return wxxVariant( dynamic_cast<name*> (data) ) ; } \
1581 wxClassInfo name::sm_class##name(sm_classParents##name , wxT("") , wxT(#name), \
1582 (int) sizeof(name), \
1583 (wxObjectConstructorFn) 0 , \
1584 name::GetPropertiesStatic(),name::GetHandlersStatic(),0 , 0 , \
1585 0 , wxVariantOfPtrToObjectConverter##name ,wxVariantToObjectConverter##name , wxObjectToVariantConverter##name); \
1586 template<> void wxStringReadValue(const wxString & , name * & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1587 template<> void wxStringWriteValue(wxString & , name* const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1588 template<> void wxStringReadValue(const wxString & , name ** & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1589 template<> void wxStringWriteValue(wxString & , name** const & ){wxASSERT_MSG( 0 , wxT("Illegal Spezialication Called") );}\
1590 template<> const wxTypeInfo* wxGetTypeInfo( name * ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT , &name::sm_class##name) ; return &s_typeInfo ; } \
1591 template<> const wxTypeInfo* wxGetTypeInfo( name ** ){ static wxClassTypeInfo s_typeInfo(wxT_OBJECT_PTR , &name::sm_class##name) ; return &s_typeInfo ; } \
1592 template<> const wxTypeInfo* wxGetTypeInfo( name *** ){ static wxBuiltInTypeInfo s_typeInfo(wxT_VOID) ; assert(0) ; return &s_typeInfo ; }
1594 #define IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1595 _IMPLEMENT_ABSTRACT_CLASS( name , basename ) \
1596 wxHandlerInfo *name::GetHandlersStatic() { return (wxHandlerInfo*) NULL ; } \
1597 wxPropertyInfo *name::GetPropertiesStatic() { return (wxPropertyInfo*) NULL ; }
1599 // Multiple inheritance with two base classes
1601 #define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
1602 wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
1603 wxT(#basename2), (int) sizeof(name), \
1604 (wxObjectConstructorFn) 0);
1606 #define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
1607 #define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
1609 // --------------------------------------------------------------------------
1610 // Collection Support
1611 // --------------------------------------------------------------------------
1613 template<typename collection_t
> void wxListCollectionToVariantArray( const collection_t
& coll
, wxxVariantArray
&value
)
1615 collection_t
::compatibility_iterator current
= coll
.GetFirst() ;
1618 value
.Add( new wxxVariant(current
->GetData()) ) ;
1619 current
= current
->GetNext();
1623 template<typename collection_t
> void wxArrayCollectionToVariantArray( const collection_t
& coll
, wxxVariantArray
&value
)
1625 for( size_t i
= 0 ; i
< coll
.GetCount() ; i
++ )
1627 value
.Add( new wxxVariant(coll
[i
]) ) ;