- typedef void (Klass::*setter_t)(T value);
- typedef bool (Klass::*setter_bool_t)(T value);
- typedef void (Klass::*setter_ref_t)(const T& value);
- typedef bool (Klass::*setter_ref_bool_t)(const T& value);
- typedef T (Klass::*getter_t)() const;
- typedef const T& (Klass::*getter_ref_t)() const;
-
- wxPropertyAccessorT(setter_t setter, getter_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(setter), m_setter_ref(NULL), m_getter(getter) ,m_getter_ref(NULL) {m_setterName = s;m_getterName=g ;}
-
- wxPropertyAccessorT( getter_t getter, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(NULL), m_getter(getter) ,m_getter_ref(NULL) {m_setterName = "";m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(GetByRef*,) getter_ref_t getter, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(NULL), m_getter(NULL) ,m_getter_ref(getter) {m_setterName = "";m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetRetBool*,) setter_bool_t setter, getter_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( setter ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(NULL), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRef*,) setter_ref_t setter, getter_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(setter), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetByRefRetBool*,) setter_ref_bool_t setter, getter_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( setter ) , m_setter(NULL), m_setter_ref(NULL), m_getter(getter) , m_getter_ref(NULL){m_setterName = s;m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRef*,) setter_ref_t setter, getter_ref_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter_ref(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(SetAndGetByRefRetBool*,) setter_ref_bool_t setter, getter_ref_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( setter ) , m_setter(NULL), m_setter_ref(NULL), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
-
- wxPropertyAccessorT(WX_XTI_PARAM_FIX(GetByRef*,) setter_t setter, getter_ref_t getter, const wxChar *s, const wxChar *g)
- : m_setter_bool( NULL ) , m_setter_ref_bool( NULL ) , m_setter(NULL), m_setter(setter), m_getter(NULL) , m_getter_ref(getter){m_setterName = s;m_getterName=g ;}
-
- // returns true if this accessor has a setter
- bool HasSetter() const { return m_setter != NULL || m_setter_ref != NULL || m_setter_ref_bool != NULL || m_setter_bool ; }
-
- // return true if this accessor has a getter
- bool HasGetter() const { return m_getter != NULL || m_getter_ref != NULL ; }
-
- bool HasAdder() const { return true ; }
- // set the property this accessor is responsible for in an object
- void SetProperty(wxObject *o, const wxxVariant &v) const
- {
- Klass *obj = dynamic_cast<Klass*>(o);
- T value ;
-
- if ( wxGetTypeInfo((T*)NULL)->GetKind() == wxT_OBJECT && v.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR )
- value = *v.Get<T*>();
- else
- value = v.Get<T>();
- if (m_setter)
- (obj->*(m_setter))(value);
- else if ( m_setter_ref )
- (obj->*(m_setter_ref))(value);
- else if ( m_setter_ref_bool )
- (obj->*(m_setter_ref_bool))(value);
- else if ( m_setter_bool )
- (obj->*(m_setter_bool))(value);
- else
- {
- wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ;
- }
- }
-
- // gets the property this accessor is responsible for from an object
- wxxVariant GetProperty(const wxObject *o) const
- {
- return wxxVariant( (wxxVariantData* ) DoGetProperty( o ) ) ;
- }
-
- // write the property this accessor is responsible for from an object into
- // a string
- void WriteValue( wxString& s , const wxObject *o ) const
- {
- DoGetProperty( o )->Write( s ) ;
- }
-
- // read a wxxVariant having the correct type for the property this accessor
- // is responsible for from a string
- wxxVariant ReadValue( const wxString &value ) const
- {
- T data ;
- wxStringReadValue( value , data ) ;
- return wxxVariant( data ) ;
- }
-
-private :
- wxxVariantDataT<T>* DoGetProperty(const wxObject *o) const
- {
- const Klass *obj = dynamic_cast<const Klass*>(o);
- if ( m_getter )
- return new wxxVariantDataT<T>( (obj->*(m_getter))() ) ;
- else
- return new wxxVariantDataT<T>( (obj->*(m_getter_ref))() ) ;
- }
-
- setter_t m_setter;
- setter_ref_t m_setter_ref;
- setter_ref_bool_t m_setter_ref_bool ;
- setter_bool_t m_setter_bool ;
- getter_t m_getter;
- getter_ref_t m_getter_ref ;
-};
-
-template<class Klass, typename CollectionType , typename AddedElementType>
-class WXDLLIMPEXP_BASE wxPropertyCollectionAccessorT : public wxPropertyAccessor
-{
-public:
-
- typedef void (Klass::*adder_t)(AddedElementType value);
- typedef CollectionType (Klass::*getter_t)() const;
- typedef const CollectionType& (Klass::*getter_ref_t)() const;
-
- wxPropertyCollectionAccessorT(adder_t adder, getter_t getter, const wxChar *a, const wxChar *g)
- : m_getter(getter), m_adder(adder) , m_getter_ref( NULL ) { m_adderName = a;m_getterName=g ;}
-
- wxPropertyCollectionAccessorT(adder_t adder, getter_ref_t getter, const wxChar *a, const wxChar *g)
- : m_getter(NULL), m_adder(adder) , m_getter_ref( getter ) { m_adderName = a;m_getterName=g ;}
-
- ~wxPropertyCollectionAccessorT() {}
-
- // returns true if this accessor has a setter
- bool HasSetter() const { return false ;}
-
- // return true if this accessor has a getter
- bool HasGetter() const { return m_getter != NULL ;}
-
- // return true if this accessor has a getter
- bool HasAdder() const { return m_adder != NULL ;}
-
- // set the property this accessor is responsible for in an object
- void AddToPropertyCollection(wxObject *o, const wxxVariant &v) const
- {
- Klass *obj = dynamic_cast<Klass*>(o);
- AddedElementType value ;
-
- if ( wxGetTypeInfo((AddedElementType*)NULL)->GetKind() == wxT_OBJECT && v.GetTypeInfo()->GetKind() == wxT_OBJECT_PTR )
- value = *v.Get<AddedElementType*>();
- else
- value = v.Get<AddedElementType>();
-
- if (m_adder)
- (obj->*(m_adder))(value);
- else
- {
- wxASSERT_MSG(0 , wxT("SetPropertyCalled without a valid Setter") ) ;
- }
- }
-
- // gets the property this accessor is responsible for from an object
- wxxVariantArray GetPropertyCollection(const wxObject *o) const
- {
- const Klass *obj = dynamic_cast<const Klass*>(o);
-
- wxxVariantArray result ;
- CollectionType::compatibility_iterator current = (obj->*(m_getter_ref))().GetFirst() ;
-
- while (current)
- {
- result.Add( new wxxVariant(current->GetData()) ) ;
- current = current->GetNext();
- }
- return result ;
- }
-
-
- // set the property this accessor is responsible for in an object
- void SetProperty(wxObject *WXUNUSED(o), const wxxVariant &WXUNUSED(v)) const
- {
- wxASSERT_MSG(0,wxT("SetProperty called on Collection Property")) ;
- }
-
- // gets the property this accessor is responsible for from an object
- wxxVariant GetProperty(const wxObject *WXUNUSED(o)) const
- {
- wxASSERT_MSG(0,wxT("GetProperty called on Collection Property")) ;
- return wxxVariant() ;
- }
-
- // write the property this accessor is responsible for from an object into
- // a string
- void WriteValue( wxString& s , const wxObject *o ) const
- {
- wxASSERT_MSG(0,wxT("WriteValue called on Collection Property")) ;
- }
-
- // read a wxxVariant having the correct type for the property this accessor
- // is responsible for from a string
- wxxVariant ReadValue( const wxString &value ) const
- {
- wxASSERT_MSG(0,wxT("ReadValue called on Collection Property")) ;
- return wxxVariant() ;
- }
-
-private :
- getter_t m_getter;
- getter_ref_t m_getter_ref ;
- adder_t m_adder;
-};
-
-class WXDLLIMPEXP_BASE wxPropertyInfo
-{
-public :
- wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv ) :
- m_name( name ) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv ) , m_collectionElementTypeInfo(NULL)
- {
- Insert(iter) ;
- }
-
- wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxTypeInfo* collTypeInfo , const wxTypeInfo* elemTypeInfo , wxPropertyAccessor *accessor ) :
- m_name( name ) , m_typeInfo( collTypeInfo ) , m_accessor( accessor ) , m_collectionElementTypeInfo(elemTypeInfo)
- {
- Insert(iter) ;
- }
-
- // return the name of this property
- const wxChar * GetName() const { return m_name ; }
-
- // return the element type info of this property (for collections, otherwise NULL)
- const wxTypeInfo * GetCollectionElementTypeInfo() const { return m_collectionElementTypeInfo ; }
-
- // return the type info of this property
- const wxTypeInfo * GetTypeInfo() const { return m_typeInfo ; }
-
- // return the accessor for this property
- wxPropertyAccessor* GetAccessor() const { return m_accessor ; }
-
- // returns NULL if this is the last property of this class
- wxPropertyInfo* GetNext() const { return m_next ; }
-
- // returns the default value of this property, its kind may be wxT_VOID if it is not valid
- wxxVariant GetDefaultValue() const { return m_defaultValue ; }
-private :
- void Insert(wxPropertyInfo* &iter)
- {
- m_next = NULL ;
- if ( iter == NULL )
- iter = this ;
- else
- {
- wxPropertyInfo* i = iter ;
- while( i->m_next )
- i = i->m_next ;
-
- i->m_next = this ;
- }
- }
-
- const wxChar * m_name;
- const wxChar * m_typeName ;
- const wxTypeInfo* m_typeInfo ;
- const wxTypeInfo* m_collectionElementTypeInfo ;
- wxPropertyAccessor* m_accessor ;
- wxxVariant m_defaultValue;
- // string representation of the default value
- // to be assigned by the designer to the property
- // when the component is dropped on the container.
- wxPropertyInfo* m_next ;
-};
-
-#define WX_BEGIN_PROPERTIES_TABLE(theClass) \
- wxPropertyInfo *theClass::GetPropertiesStatic() \
- { \
- typedef theClass class_t; \
- static wxPropertyInfo* first = NULL ;
-
-#define WX_END_PROPERTIES_TABLE() \
- return first ; }
-
-
-#if WX_XTI_TEMPLATE_FIX
-
-#define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
- static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
-
-#define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
- static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( NULL , &getter , #adder , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
-
-#define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetRetBool*)NULL , &setter , &getter , #setter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRef*)NULL, &setter , &getter , #setter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetAndGetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_READONLY_PROPERTY_GET_BY_REF( name , type , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::GetByRef*)NULL , &getter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#else
-
-#define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( &setter , &getter , #setter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_PROPERTY_COLLECTION( name , colltype , addelemtype , adder , getter ) \
- static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #adder , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
-
-#define WX_READONLY_PROPERTY_COLLECTION( name , colltype , addelemtype , getter ) \
- static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( NULL , &getter , "" , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (colltype*) NULL ) ,wxGetTypeInfo( (addelemtype*) NULL ) ,&_accessor##name ) ;
-
-#define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
- WX_PROPERTY( name , type , setter , getter , defaultValue )
-
-#define WX_PROPERTY_SET_BY_REF( name , type , setter , getter ,defaultValue ) \
- WX_PROPERTY( name , type , setter , getter , defaultValue )
-
-#define WX_PROPERTY_SET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
- WX_PROPERTY( name , type , setter , getter , defaultValue )
-
-#define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( name , type , setter , getter ,defaultValue ) \
- WX_PROPERTY( name , type , setter , getter , defaultValue )
-
-#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_READONLY_PROPERTY_GET_BY_REF( name , type , getter ,defaultValue ) \
- WX_READONLY_PROPERTY( name , type , getter , defaultValue )
-
-#endif
-
-
-#define WX_DELEGATE( name , eventType , eventClass ) \
- static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
-
-// ----------------------------------------------------------------------------
-// Handler Info
-//
-// this is describing an event sink
-// ----------------------------------------------------------------------------
-
-class wxHandlerInfo
-{
-public :
- wxHandlerInfo( wxHandlerInfo* &iter , const wxChar *name , wxObjectEventFunction address , const wxClassInfo* eventClassInfo ) :
- m_name( name ) , m_eventClassInfo( eventClassInfo ) , m_eventFunction( address )
- {
- m_next = NULL ;
- if ( iter == NULL )
- iter = this ;
- else
- {
- wxHandlerInfo* i = iter ;
- while( i->m_next )
- i = i->m_next ;
-
- i->m_next = this ;
- }
- }
-
- // get the name of the handler method
- const wxChar * GetName() const { return m_name ; }
-
- // return the class info of the event
- const wxClassInfo * GetEventClassInfo() const { return m_eventClassInfo ; }
-
- // get the handler function pointer
- wxObjectEventFunction GetEventFunction() const { return m_eventFunction ; }
-
- // returns NULL if this is the last handler of this class
- wxHandlerInfo* GetNext() const { return m_next ; }
-private :
- wxObjectEventFunction m_eventFunction ;
- const wxChar * m_name;
- const wxClassInfo* m_eventClassInfo ;
- wxHandlerInfo* m_next ;