From 16a45a23d9f72eee32690f7c56e8febbc1e76965 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 14 Aug 2003 18:03:06 +0000 Subject: [PATCH] properties as collection git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22877 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/xti.h | 41 +++++++++++-- include/wx/xtistrm.h | 73 ++++++++++++++++------- src/common/xti.cpp | 2 +- src/common/xtistrm.cpp | 131 ++++++++++++++++++++++++++++------------- 4 files changed, 178 insertions(+), 69 deletions(-) diff --git a/include/wx/xti.h b/include/wx/xti.h index 75b4c82151..e67c4e577d 100644 --- a/include/wx/xti.h +++ b/include/wx/xti.h @@ -585,6 +585,9 @@ public: 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 ;} @@ -680,10 +683,14 @@ class WXDLLIMPEXP_BASE wxPropertyCollectionAccessorT : public wxPropertyAccessor public: 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) - : 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() {} @@ -721,7 +728,8 @@ public: const Klass *obj = dynamic_cast(o); wxxVariantArray result ; - CollectionType::compatibility_iterator current = (obj->*(m_getter))().GetFirst(); + CollectionType::compatibility_iterator current = (obj->*(m_getter_ref))().GetFirst() ; + while (current) { result.Add( new wxxVariant(current->GetData()) ) ; @@ -761,6 +769,7 @@ public: private : getter_t m_getter; + getter_ref_t m_getter_ref ; adder_t m_adder; }; @@ -844,6 +853,10 @@ private : static wxPropertyCollectionAccessorT _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 _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 _accessor##name( (wxPropertyAccessor::SetRetBool*)NULL , &setter , &getter , #setter , #getter ) ; \ static wxPropertyInfo _propertyInfo##name( first , #name , wxGetTypeInfo( (type*) NULL ) ,&_accessor##name , wxxVariant(defaultValue) ) ; @@ -860,6 +873,14 @@ private : static wxPropertyAccessorT _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 _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 _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 ) \ @@ -870,6 +891,10 @@ private : static wxPropertyCollectionAccessorT _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 _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 ) @@ -882,12 +907,16 @@ private : #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 _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() ) ; \ @@ -1246,7 +1275,7 @@ public: // Runtime access to objects for collection properties by property name 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 wxObject* VariantToInstance( wxxVariant &data ) const diff --git a/include/wx/xtistrm.h b/include/wx/xtistrm.h index b12e0d2095..c8436f8a7d 100644 --- a/include/wx/xtistrm.h +++ b/include/wx/xtistrm.h @@ -268,37 +268,48 @@ class wxDepersister { public : // 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 // having objectId <> wxInvalidObjectID - virtual void CreateObject(int ObjectID, - const wxClassInfo *ClassInfo, - int ParamCount, + virtual void CreateObject(int objectID, + const wxClassInfo *classInfo, + int paramCount, wxxVariant *VariantValues , int *objectIDValues , const wxClassInfo **objectClassInfos ) = 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 // 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 - virtual void SetProperty(int ObjectID, - const wxClassInfo *ClassInfo, - const wxPropertyInfo* PropertyInfo , + virtual void SetProperty(int objectID, + const wxClassInfo *classInfo, + const wxPropertyInfo* propertyInfo , const wxxVariant &VariantValue) = 0; // sets the corresponding property (value is an object) - virtual void SetPropertyAsObject(int ObjectId, - const wxClassInfo *ClassInfo, - const wxPropertyInfo* PropertyInfo , + virtual void SetPropertyAsObject(int objectID, + const wxClassInfo *classInfo, + const wxPropertyInfo* propertyInfo , 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 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 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 // having objectId <> wxInvalidObjectID - virtual void CreateObject(int ObjectID, - const wxClassInfo *ClassInfo, - int ParamCount, + virtual void CreateObject(int objectID, + const wxClassInfo *classInfo, + int paramCount, wxxVariant *VariantValues , int *objectIDValues, 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 // object can be destroyed after safely virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ; @@ -357,6 +368,17 @@ public : const wxPropertyInfo* propertyInfo , 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 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 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 // having objectId <> wxInvalidObjectID @@ -400,7 +422,7 @@ public: 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 // object can be destroyed after safely virtual void DestroyObject(int objectID, wxClassInfo *classInfo) ; @@ -417,6 +439,17 @@ public: const wxPropertyInfo* propertyInfo , 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 virtual void SetConnect(int eventSourceObjectID, diff --git a/src/common/xti.cpp b/src/common/xti.cpp index 23e5af6cf3..38ed197501 100644 --- a/src/common/xti.cpp +++ b/src/common/xti.cpp @@ -519,7 +519,7 @@ wxxVariantArray wxClassInfo::GetPropertyCollection(wxObject *object, const wxCha 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; diff --git a/src/common/xtistrm.cpp b/src/common/xtistrm.cpp index ccc44b4360..daf4a12647 100644 --- a/src/common/xtistrm.cpp +++ b/src/common/xtistrm.cpp @@ -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 ) { + // 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() ; while( pi ) { // 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 ; DoBeginWriteProperty( pi ) ; @@ -222,17 +237,7 @@ void wxWriter::WriteAllProperties( const wxObject * obj , const wxClassInfo* ci } 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) { @@ -381,7 +386,7 @@ void wxXmlWriter::DoWriteNullObject() } // 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 ) { if ( eventSink != NULL && handlerInfo != NULL ) @@ -439,6 +444,7 @@ and create params are always toplevel class only int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) { + wxASSERT_MSG( callbacks , wxT("Does not support reading without a Depersistor") ) ; wxString className; wxClassInfo *classInfo; @@ -514,6 +520,7 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) const wxChar* paramName = classInfo->GetCreateParamName(i) ; PropertyNodes::iterator propiter = propertyNodes.find( 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 // we use the default value if ( propiter != propertyNodes.end() ) @@ -563,7 +570,8 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) const wxPropertyInfo* pi = classInfo->FindPropertyInfo( propertyNames[j].c_str() ) ; 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 ) { 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() ) { int valueId = ReadComponent( elementContent , callbacks ) ; - if ( callbacks ) + if ( valueId != wxInvalidObjectID ) { - if ( valueId != wxInvalidObjectID ) - { - /* - callbacks->SetPropertyAsObject( objectID , classInfo , pi , valueId ) ; - */ - if ( elementType->GetKind() == wxT_OBJECT && valueId != wxNullObjectID ) - callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ; - } + if ( pi->GetAccessor()->HasAdder() ) + callbacks->AddToPropertyCollectionAsObject( objectID , classInfo , pi , valueId ) ; + // TODO for collections we must have a notation on taking over ownership or not + if ( elementType->GetKind() == wxT_OBJECT && valueId != wxNullObjectID ) + callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ; } } else { wxxVariant elementValue = ReadValue( prop , pi->GetAccessor() ) ; - /* - if ( callbacks ) - callbacks->SetProperty( objectID, classInfo ,pi , ) ; - */ + if ( pi->GetAccessor()->HasAdder() ) + callbacks->AddToPropertyCollection( objectID , classInfo ,pi , elementValue ) ; } prop = prop->GetNext() ; } @@ -598,14 +601,11 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) else if ( pi->GetTypeInfo()->IsObjectType() ) { 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->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ; - } + callbacks->SetPropertyAsObject( objectID , classInfo , pi , valueId ) ; + if ( pi->GetTypeInfo()->GetKind() == wxT_OBJECT && valueId != wxNullObjectID ) + callbacks->DestroyObject( valueId , GetObjectClassInfo( valueId ) ) ; } } else if ( pi->GetTypeInfo()->IsDelegateType() ) @@ -619,16 +619,14 @@ int wxXmlReader::ReadComponent(wxXmlNode *node, wxDepersister *callbacks) wxString handlerName = resstring.Mid(pos+1) ; wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid ) ; - if (callbacks) - callbacks->SetConnect( objectID , classInfo , dynamic_cast(pi->GetTypeInfo()) , sinkClassInfo , - sinkClassInfo->FindHandlerInfo(handlerName) , sinkOid ) ; + callbacks->SetConnect( objectID , classInfo , dynamic_cast(pi->GetTypeInfo()) , sinkClassInfo , + sinkClassInfo->FindHandlerInfo(handlerName) , sinkOid ) ; } } 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; o = m_data->GetObject(objectID); classInfo->SetProperty( o , propertyInfo->GetName() , value ) ; - // propertyInfo->GetAccessor()->SetProperty( o , value ) ; } void wxRuntimeDepersister::SetPropertyAsObject(int objectID, @@ -770,8 +767,6 @@ void wxRuntimeDepersister::SetPropertyAsObject(int objectID, } classInfo->SetProperty( o , propertyInfo->GetName() , valClassInfo->InstanceToVariant(valo) ) ; - // propertyInfo->GetAccessor()->SetProperty( o , - // (dynamic_cast(propertyInfo->GetTypeInfo()))->GetClassInfo()->InstanceToVariant(valo) ) ; } void wxRuntimeDepersister::SetConnect(int eventSourceObjectID, @@ -797,6 +792,38 @@ wxObject *wxRuntimeDepersister::GetObject(int 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(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 @@ -921,6 +948,26 @@ void wxCodeDepersister::SetPropertyAsObject(int objectID, 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, const wxClassInfo *WXUNUSED(eventSourceClassInfo), const wxDelegateTypeInfo *delegateInfo , -- 2.45.2