properties as collection
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22877 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
fae7d15809
commit
16a45a23d9
@ -585,6 +585,9 @@ public:
|
|||||||
wxPropertyAccessorT( getter_t getter, const wxChar *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 ;}
|
: 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)
|
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 ;}
|
: 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 ;}
|
||||||
|
|
||||||
@ -680,10 +683,14 @@ class WXDLLIMPEXP_BASE wxPropertyCollectionAccessorT : public wxPropertyAccessor
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
typedef void (Klass::*adder_t)(AddedElementType value);
|
typedef void (Klass::*adder_t)(AddedElementType value);
|
||||||
typedef const CollectionType& (Klass::*getter_t)() const ;
|
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)
|
wxPropertyCollectionAccessorT(adder_t adder, getter_t getter, const wxChar *a, const wxChar *g)
|
||||||
: m_getter(getter), m_adder(adder) { m_adderName = a;m_getterName=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() {}
|
~wxPropertyCollectionAccessorT() {}
|
||||||
|
|
||||||
@ -721,7 +728,8 @@ public:
|
|||||||
const Klass *obj = dynamic_cast<const Klass*>(o);
|
const Klass *obj = dynamic_cast<const Klass*>(o);
|
||||||
|
|
||||||
wxxVariantArray result ;
|
wxxVariantArray result ;
|
||||||
CollectionType::compatibility_iterator current = (obj->*(m_getter))().GetFirst();
|
CollectionType::compatibility_iterator current = (obj->*(m_getter_ref))().GetFirst() ;
|
||||||
|
|
||||||
while (current)
|
while (current)
|
||||||
{
|
{
|
||||||
result.Add( new wxxVariant(current->GetData()) ) ;
|
result.Add( new wxxVariant(current->GetData()) ) ;
|
||||||
@ -761,6 +769,7 @@ public:
|
|||||||
|
|
||||||
private :
|
private :
|
||||||
getter_t m_getter;
|
getter_t m_getter;
|
||||||
|
getter_ref_t m_getter_ref ;
|
||||||
adder_t m_adder;
|
adder_t m_adder;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -844,6 +853,10 @@ private :
|
|||||||
static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #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 ) ;
|
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 ) \
|
#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 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) ) ;
|
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
|
||||||
@ -860,6 +873,14 @@ private :
|
|||||||
static wxPropertyAccessorT<class_t , type> _accessor##name( (wxPropertyAccessor::SetAndGetByRefRetBool*)NULL, &setter , &getter , #setter , #getter ) ; \
|
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) ) ;
|
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
|
#else
|
||||||
|
|
||||||
#define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
|
#define WX_PROPERTY( name , type , setter , getter ,defaultValue ) \
|
||||||
@ -870,6 +891,10 @@ private :
|
|||||||
static wxPropertyCollectionAccessorT<class_t , colltype , addelemtype > _accessor##name( &adder , &getter , #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 ) ;
|
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 ) \
|
#define WX_PROPERTY_SET_RET_BOOL( name , type , setter , getter ,defaultValue ) \
|
||||||
WX_PROPERTY( name , type , setter , getter , defaultValue )
|
WX_PROPERTY( name , type , setter , getter , defaultValue )
|
||||||
|
|
||||||
@ -882,12 +907,16 @@ private :
|
|||||||
#define WX_PROPERTY_SET_AND_GET_BY_REF_RET_BOOL( 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 )
|
WX_PROPERTY( name , type , setter , getter , defaultValue )
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
|
#define WX_READONLY_PROPERTY( name , type , getter ,defaultValue ) \
|
||||||
static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
|
static wxPropertyAccessorT<class_t , type> _accessor##name( &getter , #getter ) ; \
|
||||||
static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ;
|
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 ) \
|
#define WX_DELEGATE( name , eventType , eventClass ) \
|
||||||
static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
|
static wxDelegateTypeInfo _typeInfo##name( eventType , CLASSINFO( eventClass ) ) ; \
|
||||||
static wxPropertyInfo _propertyInfo##name( first , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
|
static wxPropertyInfo _propertyInfo##name( first , #name , &_typeInfo##name , NULL , wxxVariant() ) ; \
|
||||||
@ -1246,7 +1275,7 @@ public:
|
|||||||
|
|
||||||
// Runtime access to objects for collection properties by property name
|
// Runtime access to objects for collection properties by property name
|
||||||
virtual wxxVariantArray GetPropertyCollection(wxObject *object, const wxChar *propertyName) const ;
|
virtual wxxVariantArray GetPropertyCollection(wxObject *object, const wxChar *propertyName) const ;
|
||||||
virtual void AddPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const ;
|
virtual void AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const ;
|
||||||
|
|
||||||
// we must be able to cast variants to wxObject pointers, templates seem not to be suitable
|
// we must be able to cast variants to wxObject pointers, templates seem not to be suitable
|
||||||
wxObject* VariantToInstance( wxxVariant &data ) const
|
wxObject* VariantToInstance( wxxVariant &data ) const
|
||||||
|
@ -268,37 +268,48 @@ class wxDepersister
|
|||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
// allocate the new object on the heap, that object will have the passed in ID
|
// allocate the new object on the heap, that object will have the passed in ID
|
||||||
virtual void AllocateObject(int ObjectID, wxClassInfo *ClassInfo) = 0;
|
virtual void AllocateObject(int objectID, wxClassInfo *classInfo) = 0;
|
||||||
|
|
||||||
// initialize the already allocated object having the ID ObjectID with the Create method
|
// initialize the already allocated object having the ID objectID with the Create method
|
||||||
// creation parameters which are objects are having their Ids passed in objectIDValues
|
// creation parameters which are objects are having their Ids passed in objectIDValues
|
||||||
// having objectId <> wxInvalidObjectID
|
// having objectId <> wxInvalidObjectID
|
||||||
|
|
||||||
virtual void CreateObject(int ObjectID,
|
virtual void CreateObject(int objectID,
|
||||||
const wxClassInfo *ClassInfo,
|
const wxClassInfo *classInfo,
|
||||||
int ParamCount,
|
int paramCount,
|
||||||
wxxVariant *VariantValues ,
|
wxxVariant *VariantValues ,
|
||||||
int *objectIDValues ,
|
int *objectIDValues ,
|
||||||
const wxClassInfo **objectClassInfos
|
const wxClassInfo **objectClassInfos
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
// destroy the heap-allocated object having the ID ObjectID, this may be used if an object
|
// destroy the heap-allocated object having the ID objectID, this may be used if an object
|
||||||
// is embedded in another object and set via value semantics, so the intermediate
|
// is embedded in another object and set via value semantics, so the intermediate
|
||||||
// object can be destroyed after safely
|
// object can be destroyed after safely
|
||||||
virtual void DestroyObject(int ObjectID, wxClassInfo *ClassInfo) = 0;
|
virtual void DestroyObject(int objectID, wxClassInfo *classInfo) = 0;
|
||||||
|
|
||||||
// set the corresponding property
|
// set the corresponding property
|
||||||
virtual void SetProperty(int ObjectID,
|
virtual void SetProperty(int objectID,
|
||||||
const wxClassInfo *ClassInfo,
|
const wxClassInfo *classInfo,
|
||||||
const wxPropertyInfo* PropertyInfo ,
|
const wxPropertyInfo* propertyInfo ,
|
||||||
const wxxVariant &VariantValue) = 0;
|
const wxxVariant &VariantValue) = 0;
|
||||||
|
|
||||||
// sets the corresponding property (value is an object)
|
// sets the corresponding property (value is an object)
|
||||||
virtual void SetPropertyAsObject(int ObjectId,
|
virtual void SetPropertyAsObject(int objectID,
|
||||||
const wxClassInfo *ClassInfo,
|
const wxClassInfo *classInfo,
|
||||||
const wxPropertyInfo* PropertyInfo ,
|
const wxPropertyInfo* propertyInfo ,
|
||||||
int valueObjectId) = 0;
|
int valueObjectId) = 0;
|
||||||
|
|
||||||
|
// adds an element to a property collection
|
||||||
|
virtual void AddToPropertyCollection( int objectID ,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
const wxxVariant &VariantValue) = 0;
|
||||||
|
|
||||||
|
// sets the corresponding property (value is an object)
|
||||||
|
virtual void AddToPropertyCollectionAsObject(int objectID,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
int valueObjectId) = 0;
|
||||||
|
|
||||||
// sets the corresponding event handler
|
// sets the corresponding event handler
|
||||||
virtual void SetConnect(int EventSourceObjectID,
|
virtual void SetConnect(int EventSourceObjectID,
|
||||||
@ -328,19 +339,19 @@ public :
|
|||||||
// allocate the new object on the heap, that object will have the passed in ID
|
// allocate the new object on the heap, that object will have the passed in ID
|
||||||
virtual void AllocateObject(int objectID, wxClassInfo *classInfo) ;
|
virtual void AllocateObject(int objectID, wxClassInfo *classInfo) ;
|
||||||
|
|
||||||
// initialize the already allocated object having the ID ObjectID with the Create method
|
// initialize the already allocated object having the ID objectID with the Create method
|
||||||
// creation parameters which are objects are having their Ids passed in objectIDValues
|
// creation parameters which are objects are having their Ids passed in objectIDValues
|
||||||
// having objectId <> wxInvalidObjectID
|
// having objectId <> wxInvalidObjectID
|
||||||
|
|
||||||
virtual void CreateObject(int ObjectID,
|
virtual void CreateObject(int objectID,
|
||||||
const wxClassInfo *ClassInfo,
|
const wxClassInfo *classInfo,
|
||||||
int ParamCount,
|
int paramCount,
|
||||||
wxxVariant *VariantValues ,
|
wxxVariant *VariantValues ,
|
||||||
int *objectIDValues,
|
int *objectIDValues,
|
||||||
const wxClassInfo **objectClassInfos
|
const wxClassInfo **objectClassInfos
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
// destroy the heap-allocated object having the ID ObjectID, this may be used if an object
|
// destroy the heap-allocated object having the ID objectID, this may be used if an object
|
||||||
// is embedded in another object and set via value semantics, so the intermediate
|
// is embedded in another object and set via value semantics, so the intermediate
|
||||||
// object can be destroyed after safely
|
// object can be destroyed after safely
|
||||||
virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ;
|
virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ;
|
||||||
@ -357,6 +368,17 @@ public :
|
|||||||
const wxPropertyInfo* propertyInfo ,
|
const wxPropertyInfo* propertyInfo ,
|
||||||
int valueObjectId) ;
|
int valueObjectId) ;
|
||||||
|
|
||||||
|
// adds an element to a property collection
|
||||||
|
virtual void AddToPropertyCollection( int objectID ,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
const wxxVariant &VariantValue) ;
|
||||||
|
|
||||||
|
// sets the corresponding property (value is an object)
|
||||||
|
virtual void AddToPropertyCollectionAsObject(int objectID,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
int valueObjectId) ;
|
||||||
|
|
||||||
// sets the corresponding event handler
|
// sets the corresponding event handler
|
||||||
virtual void SetConnect(int eventSourceObjectID,
|
virtual void SetConnect(int eventSourceObjectID,
|
||||||
@ -388,7 +410,7 @@ public:
|
|||||||
// allocate the new object on the heap, that object will have the passed in ID
|
// allocate the new object on the heap, that object will have the passed in ID
|
||||||
virtual void AllocateObject(int objectID, wxClassInfo *classInfo) ;
|
virtual void AllocateObject(int objectID, wxClassInfo *classInfo) ;
|
||||||
|
|
||||||
// initialize the already allocated object having the ID ObjectID with the Create method
|
// initialize the already allocated object having the ID objectID with the Create method
|
||||||
// creation parameters which are objects are having their Ids passed in objectIDValues
|
// creation parameters which are objects are having their Ids passed in objectIDValues
|
||||||
// having objectId <> wxInvalidObjectID
|
// having objectId <> wxInvalidObjectID
|
||||||
|
|
||||||
@ -400,7 +422,7 @@ public:
|
|||||||
const wxClassInfo **objectClassInfos
|
const wxClassInfo **objectClassInfos
|
||||||
) ;
|
) ;
|
||||||
|
|
||||||
// destroy the heap-allocated object having the ID ObjectID, this may be used if an object
|
// destroy the heap-allocated object having the ID objectID, this may be used if an object
|
||||||
// is embedded in another object and set via value semantics, so the intermediate
|
// is embedded in another object and set via value semantics, so the intermediate
|
||||||
// object can be destroyed after safely
|
// object can be destroyed after safely
|
||||||
virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ;
|
virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ;
|
||||||
@ -417,6 +439,17 @@ public:
|
|||||||
const wxPropertyInfo* propertyInfo ,
|
const wxPropertyInfo* propertyInfo ,
|
||||||
int valueObjectId) ;
|
int valueObjectId) ;
|
||||||
|
|
||||||
|
// adds an element to a property collection
|
||||||
|
virtual void AddToPropertyCollection( int objectID ,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
const wxxVariant &VariantValue) ;
|
||||||
|
|
||||||
|
// sets the corresponding property (value is an object)
|
||||||
|
virtual void AddToPropertyCollectionAsObject(int objectID,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
int valueObjectId) ;
|
||||||
|
|
||||||
// sets the corresponding event handler
|
// sets the corresponding event handler
|
||||||
virtual void SetConnect(int eventSourceObjectID,
|
virtual void SetConnect(int eventSourceObjectID,
|
||||||
|
@ -519,7 +519,7 @@ wxxVariantArray wxClassInfo::GetPropertyCollection(wxObject *object, const wxCha
|
|||||||
return accessor->GetPropertyCollection(object);
|
return accessor->GetPropertyCollection(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxClassInfo::AddPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const
|
void wxClassInfo::AddToPropertyCollection(wxObject *object, const wxChar *propertyName , const wxxVariant& value) const
|
||||||
{
|
{
|
||||||
const wxPropertyAccessor *accessor;
|
const wxPropertyAccessor *accessor;
|
||||||
|
|
||||||
|
@ -145,11 +145,26 @@ void wxWriter::FindConnectEntry(const wxWindow * evSource,const wxDelegateTypeIn
|
|||||||
}
|
}
|
||||||
void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci , wxPersister *persister, wxWriterInternalPropertiesData * data )
|
void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci , wxPersister *persister, wxWriterInternalPropertiesData * data )
|
||||||
{
|
{
|
||||||
|
// in case this object is wxDynamic object we have to hand over the streaming
|
||||||
|
// of the properties of the superclasses to the real super class instance
|
||||||
|
{
|
||||||
|
const wxObject *iterobj = obj ;
|
||||||
|
const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject* > (iterobj ) ;
|
||||||
|
if ( dynobj )
|
||||||
|
iterobj = dynobj->GetSuperClassInstance() ;
|
||||||
|
const wxClassInfo** parents = ci->GetParents() ;
|
||||||
|
for ( int i = 0 ; parents[i] ; ++ i )
|
||||||
|
{
|
||||||
|
WriteAllProperties( iterobj , parents[i] , persister , data ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const wxPropertyInfo *pi = ci->GetFirstProperty() ;
|
const wxPropertyInfo *pi = ci->GetFirstProperty() ;
|
||||||
while( pi )
|
while( pi )
|
||||||
{
|
{
|
||||||
// this property was not written yet in this object and we don't get a veto
|
// this property was not written yet in this object and we don't get a veto
|
||||||
if ( data->m_writtenProperties.find( pi->GetName() ) == data->m_writtenProperties.end() )
|
// if ( data->m_writtenProperties.find( pi->GetName() ) == data->m_writtenProperties.end() )
|
||||||
|
// we will have to handle property overrides differently
|
||||||
{
|
{
|
||||||
data->m_writtenProperties[ pi->GetName() ] = 1 ;
|
data->m_writtenProperties[ pi->GetName() ] = 1 ;
|
||||||
DoBeginWriteProperty( pi ) ;
|
DoBeginWriteProperty( pi ) ;
|
||||||
@ -222,17 +237,7 @@ void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci
|
|||||||
}
|
}
|
||||||
pi = pi->GetNext() ;
|
pi = pi->GetNext() ;
|
||||||
}
|
}
|
||||||
// in case this object is wxDynamic object we have to hand over the streaming
|
}
|
||||||
// of the properties of the superclasses to the real super class instance
|
|
||||||
const wxDynamicObject* dynobj = dynamic_cast< const wxDynamicObject* > (obj ) ;
|
|
||||||
if ( dynobj )
|
|
||||||
obj = dynobj->GetSuperClassInstance() ;
|
|
||||||
const wxClassInfo** parents = ci->GetParents() ;
|
|
||||||
for ( int i = 0 ; parents[i] ; ++ i )
|
|
||||||
{
|
|
||||||
WriteAllProperties( obj , parents[i] , persister , data ) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxWriter::GetObjectID(const wxObject *obj)
|
int wxWriter::GetObjectID(const wxObject *obj)
|
||||||
{
|
{
|
||||||
@ -381,7 +386,7 @@ void wxXmlWriter::DoWriteNullObject()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writes a delegate in the stream format
|
// writes a delegate in the stream format
|
||||||
void wxXmlWriter::DoWriteDelegate( const wxObject *WXUNUSED(object), const wxClassInfo* WXUNUSED(classInfo) , const wxPropertyInfo *pi ,
|
void wxXmlWriter::DoWriteDelegate( const wxObject *WXUNUSED(object), const wxClassInfo* WXUNUSED(classInfo) , const wxPropertyInfo *WXUNUSED(pi) ,
|
||||||
const wxObject *eventSink, int sinkObjectID , const wxClassInfo* WXUNUSED(eventSinkClassInfo) , const wxHandlerInfo* handlerInfo )
|
const wxObject *eventSink, int sinkObjectID , const wxClassInfo* WXUNUSED(eventSinkClassInfo) , const wxHandlerInfo* handlerInfo )
|
||||||
{
|
{
|
||||||
if ( eventSink != NULL && handlerInfo != NULL )
|
if ( eventSink != NULL && handlerInfo != NULL )
|
||||||
@ -439,6 +444,7 @@ and create params are always toplevel class only
|
|||||||
|
|
||||||
int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( callbacks , wxT("Does not support reading without a Depersistor") ) ;
|
||||||
wxString className;
|
wxString className;
|
||||||
wxClassInfo *classInfo;
|
wxClassInfo *classInfo;
|
||||||
|
|
||||||
@ -514,6 +520,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
|||||||
const wxChar* paramName = classInfo->GetCreateParamName(i) ;
|
const wxChar* paramName = classInfo->GetCreateParamName(i) ;
|
||||||
PropertyNodes::iterator propiter = propertyNodes.find( paramName ) ;
|
PropertyNodes::iterator propiter = propertyNodes.find( paramName ) ;
|
||||||
const wxPropertyInfo* pi = classInfo->FindPropertyInfo( paramName ) ;
|
const wxPropertyInfo* pi = classInfo->FindPropertyInfo( paramName ) ;
|
||||||
|
wxASSERT_MSG(pi,wxString::Format("Unkown Property %s",paramName) ) ;
|
||||||
// if we don't have the value of a create param set in the xml
|
// if we don't have the value of a create param set in the xml
|
||||||
// we use the default value
|
// we use the default value
|
||||||
if ( propiter != propertyNodes.end() )
|
if ( propiter != propertyNodes.end() )
|
||||||
@ -563,7 +570,8 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
|||||||
const wxPropertyInfo* pi = classInfo->FindPropertyInfo( propertyNames[j].c_str() ) ;
|
const wxPropertyInfo* pi = classInfo->FindPropertyInfo( propertyNames[j].c_str() ) ;
|
||||||
if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION )
|
if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION )
|
||||||
{
|
{
|
||||||
const wxTypeInfo * elementType = dynamic_cast< const wxCollectionTypeInfo* >( pi->GetTypeInfo() )->GetElementType() ;
|
const wxCollectionTypeInfo* collType = dynamic_cast< const wxCollectionTypeInfo* >( pi->GetTypeInfo() ) ;
|
||||||
|
const wxTypeInfo * elementType = collType->GetElementType() ;
|
||||||
while( prop )
|
while( prop )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG(prop->GetName() == wxT("element") , wxT("A non empty collection must consist of 'element' nodes")) ;
|
wxASSERT_MSG(prop->GetName() == wxT("element") , wxT("A non empty collection must consist of 'element' nodes")) ;
|
||||||
@ -572,25 +580,20 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
|||||||
if ( elementType->IsObjectType() )
|
if ( elementType->IsObjectType() )
|
||||||
{
|
{
|
||||||
int valueId = ReadComponent( elementContent , callbacks ) ;
|
int valueId = ReadComponent( elementContent , callbacks ) ;
|
||||||
if ( callbacks )
|
if ( valueId != wxInvalidObjectID )
|
||||||
{
|
{
|
||||||
if ( valueId != wxInvalidObjectID )
|
if ( pi->GetAccessor()->HasAdder() )
|
||||||
{
|
callbacks->AddToPropertyCollectionAsObject( objectID , classInfo , pi , valueId ) ;
|
||||||
/*
|
// TODO for collections we must have a notation on taking over ownership or not
|
||||||
callbacks->SetPropertyAsObject( objectID , classInfo , pi , valueId ) ;
|
if ( elementType->GetKind() == wxT_OBJECT && valueId != wxNullObjectID )
|
||||||
*/
|
callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ;
|
||||||
if ( elementType->GetKind() == wxT_OBJECT && valueId != wxNullObjectID )
|
|
||||||
callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxxVariant elementValue = ReadValue( prop , pi->GetAccessor() ) ;
|
wxxVariant elementValue = ReadValue( prop , pi->GetAccessor() ) ;
|
||||||
/*
|
if ( pi->GetAccessor()->HasAdder() )
|
||||||
if ( callbacks )
|
callbacks->AddToPropertyCollection( objectID , classInfo ,pi , elementValue ) ;
|
||||||
callbacks->SetProperty( objectID, classInfo ,pi , ) ;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
prop = prop->GetNext() ;
|
prop = prop->GetNext() ;
|
||||||
}
|
}
|
||||||
@ -598,14 +601,11 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
|||||||
else if ( pi->GetTypeInfo()->IsObjectType() )
|
else if ( pi->GetTypeInfo()->IsObjectType() )
|
||||||
{
|
{
|
||||||
int valueId = ReadComponent( prop , callbacks ) ;
|
int valueId = ReadComponent( prop , callbacks ) ;
|
||||||
if ( callbacks )
|
if ( valueId != wxInvalidObjectID )
|
||||||
{
|
{
|
||||||
if ( valueId != wxInvalidObjectID )
|
callbacks->SetPropertyAsObject( objectID , classInfo , pi , valueId ) ;
|
||||||
{
|
if ( pi->GetTypeInfo()->GetKind() == wxT_OBJECT && valueId != wxNullObjectID )
|
||||||
callbacks->SetPropertyAsObject( objectID , classInfo , pi , valueId ) ;
|
callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ;
|
||||||
if ( pi->GetTypeInfo()->GetKind() == wxT_OBJECT && valueId != wxNullObjectID )
|
|
||||||
callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( pi->GetTypeInfo()->IsDelegateType() )
|
else if ( pi->GetTypeInfo()->IsDelegateType() )
|
||||||
@ -619,16 +619,14 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks)
|
|||||||
wxString handlerName = resstring.Mid(pos+1) ;
|
wxString handlerName = resstring.Mid(pos+1) ;
|
||||||
wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ;
|
wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ;
|
||||||
|
|
||||||
if (callbacks)
|
callbacks->SetConnect( objectID , classInfo , dynamic_cast<const wxDelegateTypeInfo*>(pi->GetTypeInfo()) , sinkClassInfo ,
|
||||||
callbacks->SetConnect( objectID , classInfo , dynamic_cast<const wxDelegateTypeInfo*>(pi->GetTypeInfo()) , sinkClassInfo ,
|
sinkClassInfo->FindHandlerInfo(handlerName) , sinkOid ) ;
|
||||||
sinkClassInfo->FindHandlerInfo(handlerName) , sinkOid ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( callbacks )
|
callbacks->SetProperty( objectID, classInfo ,pi , ReadValue( prop , pi->GetAccessor() ) ) ;
|
||||||
callbacks->SetProperty( objectID, classInfo ,pi , ReadValue( prop , pi->GetAccessor() ) ) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -749,7 +747,6 @@ void wxRuntimeDepersister::SetProperty(int objectID,
|
|||||||
wxObject *o;
|
wxObject *o;
|
||||||
o = m_data->GetObject(objectID);
|
o = m_data->GetObject(objectID);
|
||||||
classInfo->SetProperty( o , propertyInfo->GetName() , value ) ;
|
classInfo->SetProperty( o , propertyInfo->GetName() , value ) ;
|
||||||
// propertyInfo->GetAccessor()->SetProperty( o , value ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRuntimeDepersister::SetPropertyAsObject(int objectID,
|
void wxRuntimeDepersister::SetPropertyAsObject(int objectID,
|
||||||
@ -770,8 +767,6 @@ void wxRuntimeDepersister::SetPropertyAsObject(int objectID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
classInfo->SetProperty( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ;
|
classInfo->SetProperty( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ;
|
||||||
// propertyInfo->GetAccessor()->SetProperty( o ,
|
|
||||||
// (dynamic_cast<const wxClassTypeInfo*>(propertyInfo->GetTypeInfo()))->GetClassInfo()->InstanceToVariant(valo) ) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRuntimeDepersister::SetConnect(int eventSourceObjectID,
|
void wxRuntimeDepersister::SetConnect(int eventSourceObjectID,
|
||||||
@ -797,6 +792,38 @@ wxObject *wxRuntimeDepersister::GetObject(int objectID)
|
|||||||
return m_data->GetObject( objectID ) ;
|
return m_data->GetObject( objectID ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adds an element to a property collection
|
||||||
|
void wxRuntimeDepersister::AddToPropertyCollection( int objectID ,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
const wxxVariant &value)
|
||||||
|
{
|
||||||
|
wxObject *o;
|
||||||
|
o = m_data->GetObject(objectID);
|
||||||
|
classInfo->AddToPropertyCollection( o , propertyInfo->GetName() , value ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sets the corresponding property (value is an object)
|
||||||
|
void wxRuntimeDepersister::AddToPropertyCollectionAsObject(int objectID,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
int valueObjectId)
|
||||||
|
{
|
||||||
|
wxObject *o, *valo;
|
||||||
|
o = m_data->GetObject(objectID);
|
||||||
|
valo = m_data->GetObject(valueObjectId);
|
||||||
|
const wxCollectionTypeInfo * collectionTypeInfo = dynamic_cast< const wxCollectionTypeInfo * >(propertyInfo->GetTypeInfo() ) ;
|
||||||
|
const wxClassInfo* valClassInfo = (dynamic_cast<const wxClassTypeInfo*>(collectionTypeInfo->GetElementType()))->GetClassInfo() ;
|
||||||
|
// if this is a dynamic object and we are asked for another class
|
||||||
|
// than wxDynamicObject we cast it down manually.
|
||||||
|
wxDynamicObject *dynvalo = dynamic_cast< wxDynamicObject * > (valo) ;
|
||||||
|
if ( dynvalo!=NULL && (valClassInfo != dynvalo->GetClassInfo()) )
|
||||||
|
{
|
||||||
|
valo = dynvalo->GetSuperClassInstance() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
classInfo->AddToPropertyCollection( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// depersisting to code
|
// depersisting to code
|
||||||
@ -921,6 +948,26 @@ void wxCodeDepersister::SetPropertyAsObject(int objectID,
|
|||||||
m_data->GetObjectName( valueObjectId) ) );
|
m_data->GetObjectName( valueObjectId) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxCodeDepersister::AddToPropertyCollection( int objectID ,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
const wxxVariant &value)
|
||||||
|
{
|
||||||
|
m_fp->WriteString( wxString::Format( "\t%s->%s(%s);\n",
|
||||||
|
m_data->GetObjectName(objectID),
|
||||||
|
propertyInfo->GetAccessor()->GetAdderName(),
|
||||||
|
ValueAsCode(value)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// sets the corresponding property (value is an object)
|
||||||
|
void wxCodeDepersister::AddToPropertyCollectionAsObject(int objectID,
|
||||||
|
const wxClassInfo *classInfo,
|
||||||
|
const wxPropertyInfo* propertyInfo ,
|
||||||
|
int valueObjectId)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
void wxCodeDepersister::SetConnect(int eventSourceObjectID,
|
void wxCodeDepersister::SetConnect(int eventSourceObjectID,
|
||||||
const wxClassInfo *WXUNUSED(eventSourceClassInfo),
|
const wxClassInfo *WXUNUSED(eventSourceClassInfo),
|
||||||
const wxDelegateTypeInfo *delegateInfo ,
|
const wxDelegateTypeInfo *delegateInfo ,
|
||||||
|
Loading…
Reference in New Issue
Block a user