+void wxObjectWriter::WriteOneProperty( const wxObject *obj, const wxClassInfo* ci,
+ const wxPropertyInfo* pi, wxObjectWriterCallback *writercallback,
+ wxObjectWriterInternalPropertiesData *WXUNUSED(data) )
+{
+ if ( pi->GetFlags() & wxPROP_DONT_STREAM )
+ return;
+
+ // make sure that we are picking the correct object for accessing the property
+ const wxDynamicObject* dynobj = wx_dynamic_cast(const wxDynamicObject*, obj );
+ if ( dynobj && (wx_dynamic_cast(const wxDynamicClassInfo*, ci) == NULL) )
+ obj = dynobj->GetSuperClassInstance();
+
+ if ( pi->GetTypeInfo()->GetKind() == wxT_COLLECTION )
+ {
+ wxAnyList data;
+ pi->GetAccessor()->GetPropertyCollection(obj, data);
+ const wxTypeInfo * elementType =
+ wx_dynamic_cast( const wxCollectionTypeInfo*, pi->GetTypeInfo() )->GetElementType();
+ if ( !data.empty() )
+ {
+ DoBeginWriteProperty( pi );
+ for ( wxAnyList::const_iterator iter = data.begin(); iter != data.end(); ++iter )
+ {
+ DoBeginWriteElement();
+ const wxAny* valptr = *iter;
+ if ( writercallback->BeforeWriteProperty( this, obj, pi, *valptr ) )
+ {
+ const wxClassTypeInfo* cti =
+ wx_dynamic_cast( const wxClassTypeInfo*, elementType );
+ if ( cti )
+ {
+ wxStringToAnyHashMap md;
+ wxObjectPropertyWriter pw(cti,writercallback,this, md);
+
+ const wxClassInfo* pci = cti->GetClassInfo();
+ pci->CallOnAny( *valptr, &pw);
+ }
+ else
+ {
+ DoWriteSimpleType( *valptr );
+ }
+ }
+ DoEndWriteElement();
+ }
+ DoEndWriteProperty( pi );
+ }
+ }
+ else
+ {
+ const wxEventSourceTypeInfo* dti =
+ wx_dynamic_cast( const wxEventSourceTypeInfo* , pi->GetTypeInfo() );
+ if ( dti )
+ {
+ const wxObject* sink = NULL;
+ const wxHandlerInfo *handler = NULL;
+
+ const wxEvtHandler * evSource = wx_dynamic_cast(const wxEvtHandler *, obj);
+ if ( evSource )
+ {
+ FindConnectEntry( evSource, dti, sink, handler );
+ if ( writercallback->BeforeWriteDelegate( this, obj, ci, pi, sink, handler ) )
+ {
+ if ( sink != NULL && handler != NULL )
+ {
+ DoBeginWriteProperty( pi );
+ if ( IsObjectKnown( sink ) )
+ {
+ DoWriteDelegate( obj, ci, pi, sink, GetObjectID( sink ),
+ sink->GetClassInfo(), handler );
+ DoEndWriteProperty( pi );
+ }
+ else
+ {
+ wxLogError( _T("Streaming delegates for not already ")
+ _T("streamed objects not yet supported") );
+ }
+ }
+ }
+ }
+ else
+ {
+ wxLogError(_("Illegal Object Class (Non-wxEvtHandler) as Event Source") );
+ }
+ }
+ else
+ {
+ wxAny value;
+ pi->GetAccessor()->GetProperty(obj, value);
+
+ // avoid streaming out void objects
+ // TODO Verify
+ if( value.IsNull() )
+ return;
+
+ if ( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
+ {
+ const wxEnumTypeInfo *eti =
+ wx_dynamic_cast(const wxEnumTypeInfo*, pi->GetTypeInfo() );
+ if ( eti )
+ {
+ eti->ConvertFromLong( wxANY_AS(value, long ), value );
+ }
+ else
+ {
+ wxLogError( _("Type must have enum - long conversion") );
+ }
+ }
+
+ // avoid streaming out default values
+ if ( pi->GetTypeInfo()->HasStringConverters() &&
+ !pi->GetDefaultValue().IsNull() ) // TODO Verify
+ {
+ if ( wxAnyGetAsString(value) == wxAnyGetAsString(pi->GetDefaultValue()) )
+ return;
+ }
+
+ // avoid streaming out null objects
+ const wxClassTypeInfo* cti =
+ wx_dynamic_cast( const wxClassTypeInfo* , pi->GetTypeInfo() );
+
+ if ( cti && cti->GetKind() == wxT_OBJECT_PTR && wxAnyGetAsObjectPtr(value) == NULL )
+ return;
+
+ if ( writercallback->BeforeWriteProperty( this, obj, pi, value ) )
+ {
+ DoBeginWriteProperty( pi );
+ if ( cti )
+ {
+ if ( cti->HasStringConverters() )
+ {
+ wxString stringValue;
+ cti->ConvertToString( value, stringValue );
+ wxAny convertedValue(stringValue);
+ DoWriteSimpleType( convertedValue );
+ }
+ else
+ {
+ wxStringToAnyHashMap md;
+ wxObjectPropertyWriter pw(cti,writercallback,this, md);
+
+ const wxClassInfo* pci = cti->GetClassInfo();
+ pci->CallOnAny(value, &pw);
+ }
+ }
+ else
+ {
+ DoWriteSimpleType( value );
+ }
+ DoEndWriteProperty( pi );
+ }
+ }
+ }
+}
+
+int wxObjectWriter::GetObjectID(const wxObject *obj)