-class WXDLLIMPEXP_BASE wxPropertyAccessor
-{
-public :
-#if WX_XTI_TEMPLATE_FIX
- class SetByRef ;
- class SetByRefRetBool ;
- class SetRetBool ;
- class SetAndGetByRef ;
- class SetAndGetByRefRetBool ;
- class GetByRef ;
-#endif
- wxPropertyAccessor() { m_setterName = NULL ; m_getterName = NULL ; }
- virtual ~wxPropertyAccessor() {}
- virtual void SetProperty(wxObject *object, const wxxVariant &value) const = 0 ;
- virtual wxxVariant GetProperty(const wxObject *object) const = 0 ;
- virtual bool HasSetter() const = 0 ;
- virtual bool HasGetter() const = 0 ;
- const wxChar * GetGetterName() const { return m_setterName ; }
- const wxChar * GetSetterName() const { return m_getterName ; }
- virtual wxxVariant ReadValue( const wxString &value ) const = 0 ;
- virtual void WriteValue( wxString& value , const wxObject *o ) const = 0 ;
-protected :
- const wxChar *m_setterName ;
- const wxChar *m_getterName ;
-};
-
-class WXDLLIMPEXP_BASE wxGenericPropertyAccessor : public wxPropertyAccessor
-{
-public :
- wxGenericPropertyAccessor( const wxChar* propertyName ) ;
- ~wxGenericPropertyAccessor() ;
- virtual void SetProperty(wxObject *object, const wxxVariant &value) const ;
- virtual wxxVariant GetProperty(const wxObject *object) const ;
- virtual bool HasSetter() const { return true ; }
- virtual bool HasGetter() const { return true ; }
- virtual wxxVariant ReadValue( const wxString &value ) const ;
- virtual void WriteValue( wxString& value , const wxObject *o ) const ;
-private :
- struct wxGenericPropertyAccessorInternal ;
- wxGenericPropertyAccessorInternal* m_data ;
-} ;
-
-template<class Klass, typename T>
-class WXDLLIMPEXP_BASE wxPropertyAccessorT : public wxPropertyAccessor
-{
-public:
-
- 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 *g, const wxChar *s)
- : 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(SetRetBool*,) setter_bool_t setter, getter_t getter, const wxChar *g, const wxChar *s)
- : 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 *g, const wxChar *s)
- : 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 *g, const wxChar *s)
- : 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 *g, const wxChar *s)
- : 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 *g, const wxChar *s)
- : 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 *g, const wxChar *s)
- : 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 ; }
-
- // 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 ;
-};
-
-class WXDLLIMPEXP_BASE wxPropertyInfo
-{
-public :
- wxPropertyInfo( wxPropertyInfo* &iter , const wxChar *name , const wxChar *typeName , const wxTypeInfo* typeInfo , wxPropertyAccessor *accessor , wxxVariant dv ) :
- m_name( name ) , m_typeName(typeName) , m_typeInfo( typeInfo ) , m_accessor( accessor ) , m_defaultValue( dv )
- {
- m_next = NULL ;
- if ( iter == NULL )
- iter = this ;
- else
- {
- wxPropertyInfo* i = iter ;
- while( i->m_next )
- i = i->m_next ;
-
- i->m_next = this ;
- }
- }
- // return the name of this property
- const wxChar * GetName() const { return m_name ; }
-
- // return the typename of this property
- const wxChar * GetTypeName() const { return m_typeName ; }
-
- // 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 :
- const wxChar * m_name;
- const wxChar * m_typeName ;
- const wxTypeInfo* m_typeInfo ;
- 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 , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#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 , #type , 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 , #type , 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 , #type , 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 , #type , 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 , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#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 )
-
-#endif
-
-#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
- static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , #type , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
-
-#define WX_DELEGATE( name , eventType , eventClass ) \
- static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
- static wxPropertyInfo _propertyInfo##name( first , #name , NULL , &_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 ;
-};
-
-#define WX_HANDLER(name,eventClassType) \
- static wxHandlerInfo _handlerInfo##name( first , #name , (wxObjectEventFunction) (wxEventFunction) &name , CLASSINFO( eventClassType ) ) ;
-
-#define WX_BEGIN_HANDLERS_TABLE(theClass) \
- wxHandlerInfo *theClass::GetHandlersStatic() \
- { \
- typedef theClass class_t; \
- static wxHandlerInfo* first = NULL ;
-
-#define WX_END_HANDLERS_TABLE() \
- return first ; }
-
-// ----------------------------------------------------------------------------
-// Constructor Bridges
-//
-// allow to set up constructors with params during runtime
-// ----------------------------------------------------------------------------
-
-class WXDLLIMPEXP_BASE wxConstructorBridge
-{
-public :
- virtual void Create(wxObject *o, wxxVariant *args) = 0;
-};
-
-// Creator Bridges for all Numbers of Params
-
-// no params
-
-template<typename Class>
-struct wxConstructorBridge_0 : public wxConstructorBridge
-{
- void Create(wxObject *o, wxxVariant *)
- {
- Class *obj = dynamic_cast<Class*>(o);
- obj->Create();
- }
-};
-
-struct wxConstructorBridge_Dummy : public wxConstructorBridge
-{
- void Create(wxObject *, wxxVariant *)
- {
- }
-} ;
-
-#define WX_CONSTRUCTOR_0(klass) \
- wxConstructorBridge_0<klass> constructor##klass ; \
- wxConstructorBridge* klass::sm_constructor##klass = &constructor##klass ; \
- const wxChar *klass::sm_constructorProperties##klass[] = { NULL } ; \
- const int klass::sm_constructorPropertiesCount##klass = 0 ;