00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "docviewprec.h"
00012
00013 #ifdef __BORLANDC__
00014 #pragma hdrstop
00015 #endif
00016
00017 #ifndef WX_PRECOMP
00018 #include <wx/tokenzr.h>
00019 #include <wx/utils.h>
00020
00021
00022 #include "wx/general/gen.h"
00023 #include "wx/general/comevt.h"
00024
00025 #if wxART2D_USE_CVGIO
00026 #include "wx/xmlparse/genxmlpars.h"
00027 #endif //wxART2D_USE_CVGIO
00028 #endif
00029
00030 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
00031 #include <wx/msw/msvcrt.h>
00032 #endif
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #include "wx/general/smrtptr.inl"
00053
00054 static int wxGenIdCount = 0;
00055
00056 A2DGENERALDLLEXP long wxGenNewId()
00057 {
00058 return ++ wxGenIdCount;
00059 }
00060
00061 A2DGENERALDLLEXP void wxGenRegisterId( long id )
00062 {
00063 wxGenIdCount = id;
00064 }
00065
00066
00067 const a2dError a2dError_NoError( wxT("a2dError_NoError"), wxT("All Oke") );
00068 const a2dError a2dError_CommandError( wxT("a2dError_CommandError"), wxT("") );
00069 const a2dError a2dError_NotSpecified( wxT("a2dError_NotSpecified"), wxT("") );
00070 const a2dError a2dError_CanceledFileDialog( wxT("a2dError_CanceledFileDialog"), wxT("") );
00071 const a2dError a2dError_FileCouldNotOpen( wxT("a2dError_FileCouldNotOpen"), _("Sorry, could not open file for saving") );
00072 const a2dError a2dError_CouldNotCreateDocument( wxT("a2dError_CouldNotCreateDocument"), wxT("") );
00073 const a2dError a2dError_NoDocTemplateRef( wxT("a2dError_NoDocTemplateRef"), wxT("") );
00074 const a2dError a2dError_DocumentsOpened( wxT("a2dError_DocumentsOpened"), _("No template defined in a2dDocument::OnSaveAsDocument") );
00075 const a2dError a2dError_SetEnv( wxT("a2dError_SetEnv"), wxT("") );
00076 const a2dError a2dError_GetEnv( wxT("a2dError_GetEnv"), wxT("") );
00077 const a2dError a2dError_GetVar( wxT("a2dError_GetVar"), wxT("") );
00078 const a2dError a2dError_SaveFile( wxT("a2dError_SaveFile"), _("Sorry, could not save document to file") );
00079 const a2dError a2dError_LoadFile( wxT("a2dError_LoadFile"), _("Sorry, could not load file into document") );
00080 const a2dError a2dError_ExportFile( wxT("a2dError_ExportFile"), _("Sorry, could not export document to file") );
00081 const a2dError a2dError_ImportFile( wxT("a2dError_ImportFile"), _("bad stream") );
00082 const a2dError a2dError_IOHandler( wxT("a2dError_IOHandler"), _("suitable template I/O handler for loading not available in document templates") );
00083 const a2dError a2dError_SaveObject( wxT("a2dError_SaveObject"), _("I/O handler cannot save document" ) );
00084 const a2dError a2dError_LoadObject( wxT("a2dError_LoadObject"), _("I/O handler cannot load document" ) );
00085 const a2dError a2dError_FileHistory( wxT("a2dError_FileHistory"), wxT("") );
00086 const a2dError a2dError_ImportObject( wxT("a2dError_ImportObject"), wxT("") );
00087 const a2dError a2dError_XMLparse( wxT("a2dError_XMLparse"), wxT("") );
00088 const a2dError a2dError_LoadLayers( wxT("a2dError_LoadLayers"), _("Could not load layers") );
00089 const a2dError a2dError_property( wxT("a2dError_property"), _("problems on property") );
00090 const a2dError a2dError_NoView( wxT("a2dError_NoView"), _("Not a a2dCanvasView View") );
00091 const a2dError a2dError_NoDocument( wxT("a2dError_NoDocument"), _("No document set for a2dCanvasView in a2dCentralCanvasCommandProcessor::SetShowObject()") );
00092 const a2dError a2dError_NoController( wxT("a2dError_NoController"), _("No controller set for current view") );
00093 const a2dError a2dError_NoTool( wxT("a2dError_NoTool"), _("No tool available") );
00094 const a2dError a2dError_LinkRef( wxT("a2dError_LinkRef"), wxT("") );
00095 const a2dError a2dError_NoWrapper( wxT("a2dError_NoWrapper"), wxT("") );
00096 const a2dError a2dError_LinkPin( wxT("a2dError_LinkPin"), wxT("") );
00097 const a2dError a2dError_NoPinClass( wxT("a2dError_NoPinClass"), wxT("") );
00098 const a2dError a2dError_CouldNotEvaluatePath( wxT("a2dError_CouldNotEvaluatePath"), wxT("") );
00099 const a2dError a2dError_Canceled( wxT("a2dError_Canceled"), wxT("") );
00100 const a2dError a2dError_CouldNotLoad( wxT("a2dError_CouldNotLoad"), _("I/O handler error during loading this format.") );
00101 const a2dError a2dError_NoSelection( wxT("a2dError_NoSelection"), wxT("") );
00102 const a2dError a2dError_ToManyOpen( wxT("a2dError_ToManyOpen"), wxT("") );
00103 const a2dError a2dError_canvasObjectRelease( wxT("a2dError_canvasObjectRelease"), _("could not release a2dCanvasObject in a2dCommand_ReleaseObject::Do") );
00104
00105
00106 a2dErrorHash& a2dError::GetHashMap()
00107 {
00108 static a2dMemoryCriticalSectionHelper helper;
00109 static a2dErrorHash ms_Name2Id;
00110 return ms_Name2Id;
00111 }
00112
00113
00114 #if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
00115
00116 #ifdef _MSC_VER
00117 #pragma warning(disable: 4660)
00118 #endif
00119
00120
00121
00122 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
00123 template class A2DGENERALDLLEXP a2dSmrtPtr<a2dObject>;
00124 template class A2DGENERALDLLEXP a2dPropertyIdTyped<a2dSmrtPtr<a2dObject>, a2dProperty>;
00125 template class A2DGENERALDLLEXP a2dAutoZeroPtr<class a2dObject>;
00126 template class A2DGENERALDLLEXP a2dPropertyIdTyped<a2dAutoZeroPtr<a2dObject>, a2dAutoZeroProperty>;
00127 template class A2DGENERALDLLEXP a2dPropertyIdTyped<a2dPathList, a2dPathListProperty> ;
00128
00129 template class A2DGENERALDLLEXP a2dSmrtPtrList<a2dObject>;
00130 template class A2DGENERALDLLEXP a2dlist<class a2dSmrtPtr<class a2dObject> >;
00131 #endif
00132
00133 #ifdef _MSC_VER
00134 #pragma warning(default: 4660)
00135 #endif
00136
00137 #endif // (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
00138
00139 IMPLEMENT_ABSTRACT_CLASS(a2dObject,wxObject)
00140 IMPLEMENT_ABSTRACT_CLASS(a2dNamedProperty,a2dObject)
00141 IMPLEMENT_DYNAMIC_CLASS(a2dProperty,a2dNamedProperty)
00142 IMPLEMENT_DYNAMIC_CLASS(a2dAutoZeroProperty,a2dNamedProperty)
00143 IMPLEMENT_DYNAMIC_CLASS(a2dBoolProperty,a2dNamedProperty)
00144 IMPLEMENT_DYNAMIC_CLASS(a2dStringProperty,a2dNamedProperty)
00145 IMPLEMENT_DYNAMIC_CLASS(a2dVoidPtrProperty,a2dNamedProperty)
00146 IMPLEMENT_DYNAMIC_CLASS(a2dInt16Property,a2dNamedProperty)
00147 IMPLEMENT_DYNAMIC_CLASS(a2dUint16Property,a2dNamedProperty)
00148 IMPLEMENT_DYNAMIC_CLASS(a2dInt32Property,a2dNamedProperty)
00149 IMPLEMENT_DYNAMIC_CLASS(a2dUint32Property,a2dNamedProperty)
00150 IMPLEMENT_DYNAMIC_CLASS(a2dDoubleProperty,a2dNamedProperty)
00151 IMPLEMENT_DYNAMIC_CLASS(a2dFloatProperty,a2dNamedProperty)
00152 IMPLEMENT_DYNAMIC_CLASS(a2dArrayStringProperty,a2dNamedProperty)
00153 IMPLEMENT_DYNAMIC_CLASS(a2dFileNameProperty,a2dNamedProperty)
00154 IMPLEMENT_DYNAMIC_CLASS(a2dMenuProperty,a2dNamedProperty)
00155 IMPLEMENT_DYNAMIC_CLASS(a2dWindowProperty,a2dNamedProperty)
00156 IMPLEMENT_DYNAMIC_CLASS(a2dTipWindowProperty,a2dWindowProperty)
00157 IMPLEMENT_DYNAMIC_CLASS(a2dDateTimeProperty,a2dNamedProperty)
00158 IMPLEMENT_DYNAMIC_CLASS(a2dPathListProperty,a2dNamedProperty)
00159 IMPLEMENT_DYNAMIC_CLASS(a2dColourProperty,a2dNamedProperty)
00160 IMPLEMENT_DYNAMIC_CLASS(a2dPropObject, a2dObject)
00161 IMPLEMENT_DYNAMIC_CLASS(a2dObjectProperty, a2dNamedProperty )
00162
00163 WX_DEFINE_LIST( a2dResolveIdList );
00164
00165
00166
00167
00168
00169 bool a2dResolveIdInfo::Assign( a2dObject *ptr )
00170 {
00171 switch ( m_mode )
00172 {
00173 case mode_a2dObjectSmrtPtr:
00174 if( !ptr )
00175 return false;
00176 *m_storedHere.m_a2dObjectSmrtPtr = wxStaticCast( ptr, a2dObject );
00177 return true;
00178
00179 case mode_a2dObjectAutoZeroPtr:
00180 if( !ptr )
00181 return false;
00182 *m_storedHere.m_a2dObjectAutoZeroPtr = wxStaticCast( ptr, a2dObject );
00183 return true;
00184
00185 case mode_link:
00186 return m_storedHere.m_link->LinkReference( ptr );
00187
00188 case mode_inform:
00189 m_storedHere.m_inform->ResolveInform();
00190 return true;
00191
00192 default:
00193 wxASSERT(0);
00194 return false;
00195 }
00196 }
00197
00198
00199
00200
00201
00202 #ifdef _DEBUG
00203
00204 a2dObject *_dbro1 = 0;
00205 a2dObject *_dbro2 = 0;
00206 #endif
00207
00208 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00209 A2DGENERALDLLEXP_DATA (wxObject *) CurrentSmartPointerOwner = 0;
00210 #endif
00211
00212 a2dPropertyIdBool* a2dObject::PROPID_Check = NULL;
00213
00214 INITIALIZE_PROPERTIES_BASE( a2dObject )
00215 {
00216 PROPID_Check = new a2dPropertyIdBool( wxT("Check"),
00217 a2dPropertyId::flag_temporary | a2dPropertyId::flag_norender, false,
00218 a2dPropertyIdBool::Get( &a2dObject::GetCheck ),
00219 a2dPropertyIdBool::Set( &a2dObject::SetCheck ) );
00220 AddPropertyId( PROPID_Check );
00221 return true;
00222 }
00223
00224 a2dNamedProperty* a2dObject::GetProperty( const a2dPropertyId* propertyId, a2dPropertyId::Flags flags ) const
00225 {
00226 static a2dNamedPropertyPtr returnproperty = NULL;
00227
00228
00229 a2dNamedPropertyList props;
00230 CollectProperties2( &props, propertyId, flags );
00231
00232 if( props.begin() != props.end() )
00233 returnproperty = *props.begin();
00234 else
00235 returnproperty = NULL;
00236 return returnproperty;
00237 }
00238
00239 void a2dObject::SetProperty( a2dNamedProperty* propertyHolder, a2dPropertyId::SetFlags setflags )
00240 {
00241 wxASSERT( !m_recursion_active );
00242
00243 propertyHolder->GetId()->SetNamedPropertyToObject( this, propertyHolder );
00244 OnPropertyChanged( propertyHolder->GetId() );
00245 }
00246
00247 void a2dObject::SetProperty( const a2dNamedProperty& propertyHolder, a2dPropertyId::SetFlags setflags )
00248 {
00249 wxASSERT( !m_recursion_active );
00250
00251 propertyHolder.GetId()->SetNamedPropertyToObject( this, const_cast<a2dNamedProperty*>(&propertyHolder) );
00252 OnPropertyChanged( propertyHolder.GetId() );
00253 }
00254
00255 bool a2dObject::AddProperty( a2dNamedProperty *property )
00256 {
00257 static a2dNamedPropertyPtr prop = NULL;
00258 prop = property;
00259 return false;
00260 }
00261
00262 bool a2dObject::RemoveProperty( const a2dPropertyId* WXUNUSED(id), bool WXUNUSED(all) )
00263 {
00264 return false;
00265 }
00266
00267 bool a2dObject::HasProperty( const a2dPropertyId* id, const wxString &stringvalue ) const
00268 {
00269 if ( ! HasPropertyId( id ) )
00270 return false;
00271
00272 bool ret = false;
00273 a2dNamedPropertyPtr prop = GetProperty( id );
00274 if ( prop && ! stringvalue.IsEmpty() )
00275 ret = prop->StringValueRepresentation() == stringvalue;
00276 else
00277 ret = prop.Get() != NULL;
00278 return ret;
00279 }
00280
00281 a2dObject::a2dObject()
00282 {
00283 m_refcount = 0;
00284 m_autozeroptrlist = 0;
00285 m_check = false;
00286 m_release = false;
00287 m_recursion_active = false;
00288 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00289 m_ownerlist = 0;
00290 CurrentSmartPointerOwner = this;
00291 #endif
00292 }
00293
00294 a2dObject::a2dObject( const a2dObject& other )
00295 :wxObject( other )
00296 {
00297 m_refcount = 0;
00298 m_autozeroptrlist = 0;
00299 m_check = false;
00300 m_release = false;
00301 m_recursion_active = false;
00302
00303 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00304 m_ownerlist = 0;
00305 CurrentSmartPointerOwner = this;
00306 #endif
00307 }
00308
00309 a2dObject::~a2dObject()
00310 {
00311 wxASSERT_MSG( m_refcount == 0 || m_refcount == refcount_nondynamic, wxT("deleting a2dObject while referenced") );
00312 m_autozeroptrlist->TargetDestructing();
00313 }
00314
00315 void a2dObject:: operator = ( const a2dObject& WXUNUSED(other) )
00316 {
00317
00318
00319
00320
00321
00322 }
00323
00324
00325
00326
00327
00328
00329 #if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
00330 void a2dObject::Dump(wxSTD ostream& str)
00331 {
00332 str << GetUniqueSerializationId();
00333 }
00334 #endif
00335
00336 void a2dObject::CheckReferences()
00337 {
00338 if ( m_refcount <= 0 )
00339 delete this;
00340 }
00341
00342 bool a2dObject::SmrtPtrRelease()
00343 {
00344 m_refcount--;
00345 wxASSERT_MSG( m_refcount >= 0, wxT("a2dObject Own/Release not matched (extra Release calls)") );
00346 if ( m_refcount <= 0 )
00347 {
00348 delete this;
00349 return true;
00350 }
00351 return false;
00352 }
00353
00354 a2dObject* a2dObject::SetNonDynamic()
00355 {
00356 wxASSERT_MSG( m_refcount == 0, wxT("Setting a referenced a2dObject to non-dynamic") );
00357 m_refcount += refcount_nondynamic;
00358 return this;
00359 }
00360
00361 wxString a2dObject::GetName() const
00362 {
00363 return wxString::Format(wxT("%d"), GetUniqueSerializationId() );
00364 }
00365
00366 #if wxART2D_USE_CVGIO
00367 void a2dObject::Save( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dObjectList* towrite )
00368 {
00369
00370 if ( m_check == true )
00371 {
00372
00373 out.WriteStartElementAttributes( wxT("o") );
00374 out.WriteAttribute( wxT("classname"), GetClassInfo()->GetClassName() );
00375 out.WriteAttribute( wxT("refid"), GetUniqueSerializationId() );
00376 out.WriteEndAttributes();
00377 out.WriteEndElement();
00378 return;
00379 }
00380
00381 if( IsTemporary_DontSave())
00382 return;
00383
00384 out.WriteStartElementAttributes( wxT("o") );
00385 out.WriteAttribute( wxT("classname"), GetClassInfo()->GetClassName() );
00386 if( m_refcount > 1 || AlwaysWriteSerializationId() )
00387 out.WriteAttribute( wxT("id"), GetUniqueSerializationId() );
00388
00389 wxString idstr;
00390 idstr << GetUniqueSerializationId();
00391 if ( GetName() != idstr )
00392 out.WriteAttribute( wxT("name"), GetName() );
00393
00394 DoSave( parent, out, a2dXmlSer_attrib, towrite );
00395
00396 out.WriteEndAttributes();
00397
00398 DoSave( parent, out, a2dXmlSer_Content, towrite );
00399
00400 out.WriteEndElement();
00401 m_check = true;
00402 }
00403
00404
00405 void a2dObject::Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser )
00406 {
00407 parser.Require( START_TAG, wxT("o") );
00408 parser.SetLastObjectLoadedId( wxT("") );
00409
00410 if ( parser.HasAttribute( wxT("refid") ) )
00411 {
00412
00413 wxUint32 refId = parser.GetAttributeValueInt( wxT("refid") );
00414
00415 if ( refId )
00416 {
00417 wxString resolveKey;
00418 resolveKey << refId;
00419 parser.SetLastObjectLoadedId( resolveKey );
00420 }
00421 m_check = true;
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432 parser.Next();
00433 parser.Require( END_TAG, wxT("o") );
00434 parser.Next();
00435
00436 return;
00437 }
00438
00439 if ( parser.HasAttribute( wxT("id") ) )
00440 {
00441
00442 int id = parser.GetAttributeValueInt( wxT("id") );
00443 wxASSERT( id!=0 );
00444 wxString resolveKey;
00445 resolveKey << id;
00446 parser.GetObjectHashMap()[resolveKey] = this;
00447 }
00448
00449 DoLoad( parent, parser, a2dXmlSer_attrib );
00450 parser.Next();
00451
00452 DoLoad( parent, parser, a2dXmlSer_Content );
00453
00454 parser.Require( END_TAG, wxT("o") );
00455 parser.Next();
00456 }
00457 #endif //wxART2D_USE_CVGIO
00458
00459 #if wxART2D_USE_CVGIO
00460 void a2dObject::DoSave( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerOut& WXUNUSED(out), a2dXmlSer_flag WXUNUSED(xmlparts) , a2dObjectList* WXUNUSED(towrite) )
00461 {
00462 }
00463
00464 void a2dObject::DoLoad( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerIn& WXUNUSED(parser), a2dXmlSer_flag WXUNUSED(xmlparts) )
00465 {
00466 }
00467 #endif //wxART2D_USE_CVGIO
00468
00469 wxInt64 a2dObject::GetUniqueSerializationId() const
00470 {
00471 return ((wxInt64) this) >> 3;
00472 }
00473
00474 bool a2dObject::AlwaysWriteSerializationId() const
00475 {
00476 return false;
00477 }
00478
00479 bool a2dObject::LinkReference( a2dObject* WXUNUSED(other) )
00480 {
00481
00482 wxASSERT(0);
00483 return false;
00484 }
00485
00486 void a2dObject::ResolveInform( )
00487 {
00488
00489 wxASSERT(0);
00490 }
00491
00492 void a2dObject::Walker( wxObject* parent, a2dWalkerIOHandler& handler )
00493 {
00494 if ( handler.GetUseCheck() && GetCheck() )
00495 return;
00496
00497 handler.IncCurrentDepth();
00498
00499 handler.WalkTask( parent, this, a2dWalker_a2dObjectStart );
00500
00501 DoWalker( parent, handler );
00502
00503 handler.WalkTask( parent, this, a2dWalker_a2dObjectEnd );
00504 handler.DecCurrentDepth();
00505 }
00506
00507 void a2dObject::DoWalker( wxObject *parent, a2dWalkerIOHandler& WXUNUSED(handler) )
00508 {
00509 }
00510
00511 bool a2dObject::DistributeEvent( wxEvent& event )
00512 {
00513 if ( a2dGeneralGlobals && a2dGeneralGlobals->GetEventDistributer() )
00514 return a2dGeneralGlobals->GetEventDistributer()->ProcessEvent( event );
00515 return false;
00516 }
00517
00518
00519
00520
00521 #ifdef _DEBUG
00522 static int _debug_cnt;
00523 #endif
00524
00525 #ifdef CLASS_MEM_MANAGEMENT
00526 a2dMemManager a2dNamedProperty::sm_memManager(wxT("a2dNamedProperty memory manager"));
00527 #endif //CLASS_MEM_MANAGEMENT
00528
00529 a2dNamedProperty::a2dNamedProperty()
00530 {
00531 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00532 m_ownerlist = NULL;
00533 #endif
00534
00535 m_id = 0;
00536
00537 #ifdef _DEBUG
00538 _debug_id = _debug_cnt++;
00539
00540 #endif
00541
00542 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00543 CurrentSmartPointerOwner = this;
00544 #endif
00545 }
00546
00547 a2dNamedProperty::a2dNamedProperty( const a2dPropertyId* id )
00548 {
00549 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00550 m_ownerlist = NULL;
00551 #endif
00552 m_id = id;
00553
00554 #ifdef _DEBUG
00555 _debug_id = _debug_cnt++;
00556
00557 #endif
00558
00559 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00560 CurrentSmartPointerOwner = this;
00561 #endif
00562 }
00563
00564 a2dNamedProperty::a2dNamedProperty( const a2dNamedProperty &other )
00565 : a2dObject( other )
00566 {
00567 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00568 m_ownerlist = NULL;
00569 #endif
00570 m_id = other.m_id;
00571
00572 #ifdef _DEBUG
00573 _debug_id = _debug_cnt++;
00574
00575 #endif
00576
00577 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00578 CurrentSmartPointerOwner = this;
00579 #endif
00580 }
00581
00582 a2dNamedProperty::~a2dNamedProperty()
00583 {
00584 }
00585
00586 #if wxART2D_USE_CVGIO
00587 void a2dNamedProperty::Save( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dObjectList* towrite )
00588 {
00589 if( m_id->IsTemporary() )
00590 return;
00591
00592 out.WriteStartElementAttributes( wxT("o") );
00593 out.WriteAttribute( wxT("classname"), GetClassInfo()->GetClassName() );
00594 out.WriteAttribute( wxT("name"), m_id->GetName() );
00595
00596 DoSave( parent, out, a2dXmlSer_attrib, towrite );
00597
00598 out.WriteEndAttributes();
00599
00600 DoSave( parent, out, a2dXmlSer_Content, towrite );
00601
00602 out.WriteEndElement();
00603 }
00604
00605
00606 void a2dNamedProperty::Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser )
00607 {
00608 parser.Require( START_TAG, wxT("o") );
00609
00610 wxString name;
00611 name = parser.RequireAttributeValue( wxT("name") );
00612
00613 a2dPropertyId *id = wxStaticCast( parent, a2dPropObject )->HasPropertyId( name );
00614 if ( !id )
00615 {
00616
00617
00618
00619
00620 wxString error;
00621 error.Printf( wxT("Property with name: %s has no internal a2dPropertyId binding name to internal property"), name.c_str() );
00622 a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, error );
00623 parser.SetLastError( a2dGeneralGlobals->GetLastError() );
00624 }
00625
00626 DoLoad( parent, parser, a2dXmlSer_attrib );
00627
00628 parser.Next();
00629
00630 DoLoad( parent, parser, a2dXmlSer_Content );
00631
00632 parser.Require( END_TAG, wxT("o") );
00633 parser.Next();
00634 }
00635 #endif //wxART2D_USE_CVGIO
00636
00637 #if wxART2D_USE_CVGIO
00638 void a2dNamedProperty::DoSave( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerOut& WXUNUSED(out), a2dXmlSer_flag WXUNUSED(xmlparts), a2dObjectList* WXUNUSED(towrite) )
00639 {
00640 }
00641
00642 void a2dNamedProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00643 {
00644 if ( xmlparts == a2dXmlSer_attrib )
00645 {
00646 wxString name = parser.RequireAttributeValue( wxT("name") );
00647 m_id = wxStaticCast( parent, a2dPropObject )->HasPropertyId( name );
00648 }
00649 else
00650 {
00651 }
00652 }
00653 #endif //wxART2D_USE_CVGIO
00654
00655
00656 void a2dNamedProperty::Walker( wxObject* parent, a2dWalkerIOHandler& handler )
00657 {
00658 handler.WalkTask( parent, this, a2dWalker_a2dNamedPropertyStart );
00659 handler.IncCurrentDepth();
00660
00661 DoWalker( parent, handler );
00662
00663 handler.WalkTask( parent, this, a2dWalker_a2dNamedPropertyEnd );
00664 handler.DecCurrentDepth();
00665 }
00666
00667 void a2dNamedProperty::DoWalker( wxObject *parent, a2dWalkerIOHandler& WXUNUSED(handler) )
00668 {
00669 }
00670
00671 wxString a2dNamedProperty::GetString() const
00672 {
00673 wxASSERT_MSG( 0, wxT("Not derived from a2dStringProperty") );
00674 return wxT("");
00675 }
00676
00677 double a2dNamedProperty::GetDouble() const
00678 {
00679 wxASSERT_MSG( 0, wxT("Not derived from a2dDoubleProperty") );
00680 return 0.0;
00681 }
00682
00683 float a2dNamedProperty::GetFloat() const
00684 {
00685 wxASSERT_MSG( 0, wxT("Not derived from a2dFloatProperty") );
00686 return 0.0;
00687 }
00688
00689 bool a2dNamedProperty::GetBool() const
00690 {
00691 wxASSERT_MSG( 0, wxT("Not derived from a2dBoolProperty") );
00692 return false;
00693 }
00694
00695 wxInt16 a2dNamedProperty::GetInt16() const
00696 {
00697 wxASSERT_MSG( 0, wxT("Not derived from a2dInt16Property") );
00698 return 0;
00699 }
00700
00701 wxUint16 a2dNamedProperty::GetUint16() const
00702 {
00703 wxASSERT_MSG( 0, wxT("Not derived from a2dUint16Property") );
00704 return 0;
00705 }
00706
00707 wxInt32 a2dNamedProperty::GetInt32() const
00708 {
00709 wxASSERT_MSG( 0, wxT("Not derived from a2dInt32Property") );
00710 return 0;
00711 }
00712
00713 wxUint32 a2dNamedProperty::GetUint32() const
00714 {
00715 wxASSERT_MSG( 0, wxT("Not derived from a2dUint32Property") );
00716 return 0;
00717 }
00718
00719 void* a2dNamedProperty::GetVoidPtr() const
00720 {
00721 wxASSERT_MSG( 0, wxT("Not derived from a2dVoidPtrProperty") );
00722 return 0;
00723 }
00724
00725 a2dObject* a2dNamedProperty::GetRefObject() const
00726 {
00727 wxASSERT_MSG( 0, wxT("Not derived from a2dProperty") );
00728 return 0;
00729 }
00730
00731 a2dObject* a2dNamedProperty::GetRefObjectNA() const
00732 {
00733 return 0;
00734 }
00735
00736 double a2dNamedProperty::ParseDouble( unsigned int& position )
00737 {
00738 const wxChar* buffer = StringValueRepresentation().c_str();
00739
00740 const wxChar *start = buffer + position;
00741 wxChar *end;
00742 double val = wxStrtod(start, &end);
00743 position = end - buffer;
00744
00745 if ( start == end )
00746 a2dGeneralGlobals->ReportErrorF( a2dError_NotSpecified, _("Not a number while parsing string %s"), start );
00747
00748 return val;
00749 }
00750
00751 void a2dNamedProperty::SkipCommaSpaces( unsigned int& position )
00752 {
00753 char current;
00754 for(;;)
00755 {
00756 current = StringValueRepresentation()[position];
00757 switch (current)
00758 {
00759 default:
00760 return;
00761 case wxT(','): case 0x20: case 0x09: case 0x0D: case 0x0A:
00762 position++;
00763 break;
00764 }
00765 }
00766 }
00767
00768 void a2dNamedProperty::SkipSpaces( unsigned int& position )
00769 {
00770 char current;
00771 for(;;)
00772 {
00773 current = StringValueRepresentation()[position];
00774 switch (current)
00775 {
00776 default:
00777 return;
00778 case 0x20: case 0x09: case 0x0D: case 0x0A:
00779 position++;
00780 break;
00781 }
00782 }
00783 }
00784
00785
00786
00787
00788
00789 a2dNamedPropertyList::a2dNamedPropertyList( const a2dNamedPropertyList &other )
00790 {
00791
00792
00793 a2dNamedPropertyList::const_iterator iter;
00794 for( iter = other.begin(); iter != other.end(); ++iter )
00795 {
00796 a2dNamedProperty *obj = *iter;
00797 push_back( obj->Clone( a2dObject::clone_flat ) );
00798
00799 }
00800 }
00801
00802 a2dNamedPropertyList::~a2dNamedPropertyList()
00803 {
00804 }
00805
00806 bool a2dNamedPropertyList::Remove( const a2dPropertyId* id, bool all )
00807 {
00808 bool did=false;
00809
00810 a2dNamedPropertyList::iterator iter = begin();
00811 while( iter != end() )
00812 {
00813 a2dNamedProperty *prop = *iter;
00814 if ( prop->GetId() == id )
00815 {
00816 iter = erase( iter );
00817 if (!all)
00818 {
00819 return true;
00820 }
00821 else
00822 did = true;
00823 }
00824 else
00825 iter++;
00826 }
00827 return did;
00828 }
00829
00830 void a2dNamedPropertyList::RemoveTemporary()
00831 {
00832 a2dNamedPropertyList::iterator iter = begin();
00833 while( iter != end() )
00834 {
00835 a2dNamedProperty *prop = *iter;
00836 if ( prop->GetId()->IsTemporary() )
00837 {
00838 iter = erase( iter );
00839 }
00840 else
00841 iter++;
00842 }
00843 }
00844
00845 void a2dNamedPropertyList::Walker( wxObject* parent, a2dWalkerIOHandler& handler )
00846 {
00847 handler.WalkTask( parent, parent, a2dWalker_a2dNamedPropertyListStart );
00848
00849 a2dNamedPropertyList::iterator iter = begin();
00850 iter = begin();
00851 while( iter != end() )
00852 {
00853 a2dNamedProperty *prop = *iter;
00854 prop->Walker( parent, handler );
00855 iter++;
00856 }
00857
00858 handler.WalkTask( parent, parent, a2dWalker_a2dNamedPropertyListEnd );
00859 }
00860
00861
00862
00863
00864
00865 a2dBoolProperty::a2dBoolProperty(): a2dNamedProperty()
00866 {
00867 m_value = true;
00868 }
00869
00870 a2dBoolProperty::a2dBoolProperty( const a2dPropertyIdBool* id, bool value )
00871 :a2dNamedProperty( id )
00872 {
00873 m_value = value;
00874 }
00875
00876 a2dBoolProperty::~a2dBoolProperty()
00877 {
00878 }
00879
00880 a2dBoolProperty::a2dBoolProperty( const a2dBoolProperty &other, a2dObject::CloneOptions WXUNUSED(options) )
00881 :a2dNamedProperty( other )
00882 {
00883 m_value = other.m_value;
00884 }
00885
00886 a2dNamedProperty* a2dBoolProperty::Clone( a2dObject::CloneOptions options ) const
00887 {
00888 return new a2dBoolProperty( *this, options );
00889 };
00890
00891 void a2dBoolProperty::Assign( const a2dNamedProperty &other )
00892 {
00893 a2dBoolProperty *propcast = wxStaticCast( &other, a2dBoolProperty);
00894 m_value = propcast->m_value;
00895 }
00896
00897 a2dBoolProperty *a2dBoolProperty::CreatePropertyFromString( const a2dPropertyIdBool* id, const wxString &value )
00898 {
00899
00900 wxString lower = value.Lower().Trim( true ).Trim( false );
00901
00902 bool val = ( lower == wxT("true") ) || ( lower == wxT("yes") ) || ( lower == wxT("y") ) || ( lower == wxT("1") ) || ( lower == _("yes") );
00903
00904 return new a2dBoolProperty( id, val );
00905 }
00906
00907 #if wxART2D_USE_CVGIO
00908 void a2dBoolProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00909 {
00910 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
00911 if ( xmlparts == a2dXmlSer_attrib )
00912 {
00913 out.WriteAttribute( wxT("value"), m_value );
00914 }
00915 else
00916 {
00917 }
00918 }
00919
00920 void a2dBoolProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00921 {
00922 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
00923 if ( xmlparts == a2dXmlSer_attrib )
00924 {
00925 m_value = parser.GetAttributeValueBool( wxT("value"), true );
00926 }
00927 else
00928 {
00929 }
00930 }
00931 #endif //wxART2D_USE_CVGIO
00932
00933 void a2dBoolProperty::SetValue( bool value )
00934 {
00935 m_value = value;
00936 }
00937
00938 wxString a2dBoolProperty::StringRepresentation() const
00939 {
00940 return m_value == true? GetName() + wxT("true"): GetName() + wxT("false");
00941 }
00942
00943 wxString a2dBoolProperty::StringValueRepresentation() const
00944 {
00945 return m_value == true? wxT("true"): wxT("false");
00946 }
00947
00948
00949
00950
00951
00952 a2dStringProperty::a2dStringProperty(): a2dNamedProperty()
00953 {
00954 m_value = wxT("");
00955 }
00956
00957 a2dStringProperty::a2dStringProperty( const a2dPropertyIdString* id, const wxString& value )
00958 :a2dNamedProperty( id )
00959 {
00960 m_value = value;
00961 }
00962
00963 a2dStringProperty::~a2dStringProperty()
00964 {
00965 }
00966
00967 a2dStringProperty::a2dStringProperty( const a2dStringProperty &other, a2dObject::CloneOptions WXUNUSED(options) )
00968 :a2dNamedProperty( other )
00969 {
00970 m_value = other.m_value;
00971 }
00972
00973 a2dNamedProperty *a2dStringProperty::Clone( a2dObject::CloneOptions options ) const
00974 {
00975 return new a2dStringProperty( *this, options );
00976 };
00977
00978 void a2dStringProperty::Assign( const a2dNamedProperty &other )
00979 {
00980 a2dStringProperty *propcast = wxStaticCast( &other, a2dStringProperty);
00981 m_value = propcast->m_value;
00982 }
00983
00984 a2dStringProperty *a2dStringProperty::CreatePropertyFromString( const a2dPropertyIdString* id, const wxString &value )
00985 {
00986 return new a2dStringProperty( id, value );
00987 }
00988
00989 #if wxART2D_USE_CVGIO
00990 void a2dStringProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00991 {
00992 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
00993 if ( xmlparts == a2dXmlSer_attrib )
00994 {
00995 out.WriteAttribute( wxT("value"), m_value );
00996 }
00997 else
00998 {
00999 }
01000 }
01001
01002 void a2dStringProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01003 {
01004 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01005 if ( xmlparts == a2dXmlSer_attrib )
01006 {
01007 m_value = parser.GetAttributeValue( wxT("value"), wxT("") );
01008 }
01009 else
01010 {
01011 }
01012 }
01013 #endif //wxART2D_USE_CVGIO
01014
01015 void a2dStringProperty::SetValue( const wxString& value )
01016 {
01017 m_value = value;
01018 }
01019
01020
01021
01022
01023
01024 a2dObjectProperty::a2dObjectProperty(): a2dNamedProperty()
01025 {
01026 }
01027
01028 a2dObjectProperty::a2dObjectProperty( const a2dPropertyIdObject* id, const wxObject& value )
01029 :a2dNamedProperty( id )
01030 {
01031 m_value = value;
01032 }
01033
01034 a2dObjectProperty::~a2dObjectProperty()
01035 {
01036 }
01037
01038 a2dObjectProperty::a2dObjectProperty( const a2dObjectProperty &other )
01039 : a2dNamedProperty( other )
01040 {
01041 m_value = other.m_value;
01042 }
01043
01044 a2dNamedProperty *a2dObjectProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01045 {
01046 return new a2dObjectProperty(*this );
01047 };
01048
01049 void a2dObjectProperty::Assign( const a2dNamedProperty &other )
01050 {
01051 a2dObjectProperty *propcast = wxStaticCast( &other, a2dObjectProperty);
01052 m_value = propcast->m_value;
01053 }
01054
01055 void a2dObjectProperty::SetValue( const wxObject& value )
01056 {
01057 m_value = value;
01058 }
01059
01060
01061
01062
01063
01064 a2dVoidPtrProperty::a2dVoidPtrProperty(): a2dNamedProperty()
01065 {
01066 m_value = NULL;
01067 }
01068
01069 a2dVoidPtrProperty::a2dVoidPtrProperty( const a2dPropertyIdVoidPtr* id, void* value )
01070 :a2dNamedProperty( id )
01071 {
01072 m_value = value;
01073 }
01074
01075 a2dVoidPtrProperty::~a2dVoidPtrProperty()
01076 {
01077 }
01078
01079 a2dVoidPtrProperty::a2dVoidPtrProperty( const a2dVoidPtrProperty &other )
01080 : a2dNamedProperty( other )
01081 {
01082 m_value = other.m_value;
01083 }
01084
01085 a2dNamedProperty *a2dVoidPtrProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01086 {
01087 return new a2dVoidPtrProperty(*this );
01088 };
01089
01090 void a2dVoidPtrProperty::Assign( const a2dNamedProperty &other )
01091 {
01092 a2dVoidPtrProperty *propcast = wxStaticCast( &other, a2dVoidPtrProperty);
01093 m_value = propcast->m_value;
01094 }
01095
01096 a2dVoidPtrProperty *a2dVoidPtrProperty::CreatePropertyFromString( const a2dPropertyIdVoidPtr* WXUNUSED(id), const wxString& WXUNUSED(value) )
01097 {
01098 return 0;
01099 }
01100
01101 #if wxART2D_USE_CVGIO
01102 void a2dVoidPtrProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01103 {
01104 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01105 if ( xmlparts == a2dXmlSer_attrib )
01106 {
01107 out.WriteAttribute( wxT("value"), wxT("VOID") );
01108 }
01109 else
01110 {
01111 }
01112 }
01113
01114 void a2dVoidPtrProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01115 {
01116 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01117 if ( xmlparts == a2dXmlSer_attrib )
01118 {
01119 m_value = NULL;
01120 }
01121 else
01122 {
01123 }
01124 }
01125 #endif //wxART2D_USE_CVGIO
01126
01127 void a2dVoidPtrProperty::SetValue( void* value )
01128 {
01129 m_value = value;
01130 }
01131
01132 wxString a2dVoidPtrProperty::StringRepresentation() const
01133 {
01134 return m_value == 0 ? GetName() + wxT("NULL"): GetName() + wxT("VOID");
01135 }
01136
01137 wxString a2dVoidPtrProperty::StringValueRepresentation() const
01138 {
01139 return m_value == 0 ? wxT("NULL") : wxT("VOID");
01140 }
01141
01142
01143
01144
01145
01146 a2dProperty::a2dProperty(): a2dNamedProperty()
01147 {
01148 m_value = NULL;
01149 }
01150
01151 a2dProperty::a2dProperty( const a2dPropertyIdRefObject* id, a2dObject* value )
01152 :a2dNamedProperty( id )
01153 {
01154 m_value = value;
01155 }
01156
01157 a2dProperty::~a2dProperty()
01158 {
01159 }
01160
01161 a2dProperty::a2dProperty( const a2dProperty &other, a2dObject::CloneOptions options )
01162 : a2dNamedProperty( other )
01163 {
01164 if ( options & a2dObject::clone_properties && m_id->IsCloneDeep() )
01165 {
01166 if ( other.m_value )
01167 m_value = other.m_value->Clone( options );
01168 }
01169 else
01170 m_value = other.m_value;
01171
01172 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
01173
01174 CurrentSmartPointerOwner = this;
01175 #endif
01176 }
01177
01178 a2dNamedProperty *a2dProperty::Clone( a2dObject::CloneOptions options ) const
01179 {
01180 return new a2dProperty( *this, options );
01181 };
01182
01183 void a2dProperty::Assign( const a2dNamedProperty &other )
01184 {
01185 a2dProperty *propcast = wxStaticCast( &other, a2dProperty);
01186 m_value = propcast->m_value;
01187 }
01188
01189 a2dProperty *a2dProperty::CreatePropertyFromString( const a2dPropertyIdRefObject* WXUNUSED(id), const wxString& WXUNUSED(value) )
01190 {
01191 return 0;
01192 }
01193
01194 #if wxART2D_USE_CVGIO
01195 void a2dProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01196 {
01197 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01198 if ( xmlparts == a2dXmlSer_attrib )
01199 {
01200 }
01201 else
01202 {
01203 if ( m_value )
01204 m_value->Save( parent, out, towrite );
01205 }
01206 }
01207
01208 void a2dProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01209 {
01210 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01211 if ( xmlparts == a2dXmlSer_attrib )
01212 {
01213 m_value = NULL;
01214 }
01215 else
01216 {
01217 if ( parser.GetTagName() == wxT("o") && parser.GetEventType() != END_TAG )
01218 {
01219 parser.Require( START_TAG, wxT("o") );
01220
01221 wxString classname = parser.GetAttributeValue( wxT("classname") );
01222 m_value = wxDynamicCast( parser.CreateObject( classname ), a2dObject );
01223 if ( !m_value )
01224 {
01225 a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dObject %s, will be skipped line %d"),
01226 classname.c_str(), parser.GetCurrentLineNumber() );
01227 parser.SetLastError( a2dGeneralGlobals->GetLastError() );
01228
01229 parser.SkipSubTree();
01230 parser.Require( END_TAG, wxT("o") );
01231 parser.Next();
01232 }
01233 else
01234 {
01235 m_value->Load( this, parser );
01236 parser.ResolveOrAdd( &m_value );
01237 }
01238
01239 }
01240 }
01241 }
01242 #endif //wxART2D_USE_CVGIO
01243
01244 void a2dProperty::SetValue( a2dObject* value )
01245 {
01246 m_value = value;
01247 }
01248
01249 wxString a2dProperty::StringRepresentation() const
01250 {
01251 return m_value ? GetName() + wxT("NULL"): GetName() + wxT("RefObject");
01252 }
01253
01254 wxString a2dProperty::StringValueRepresentation() const
01255 {
01256 return m_value ? wxT("NULL") : wxT("RefObject");
01257 }
01258
01259
01260
01261
01262
01263 a2dAutoZeroProperty::a2dAutoZeroProperty(): a2dNamedProperty()
01264 {
01265 m_value = NULL;
01266 }
01267
01268 a2dAutoZeroProperty::a2dAutoZeroProperty( const a2dPropertyIdRefObjectAutoZero* id, a2dObject* value )
01269 :a2dNamedProperty( id )
01270 {
01271 m_value = value;
01272 }
01273
01274 a2dAutoZeroProperty::~a2dAutoZeroProperty()
01275 {
01276 }
01277
01278 a2dAutoZeroProperty::a2dAutoZeroProperty( const a2dAutoZeroProperty &other, a2dObject::CloneOptions options )
01279 : a2dNamedProperty( other )
01280 {
01281 if ( options & a2dObject::clone_properties && m_id->IsCloneDeep() )
01282 {
01283 if ( other.m_value )
01284 m_value = other.m_value->Clone( options );
01285 }
01286 else
01287 m_value = other.m_value;
01288
01289 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
01290
01291 CurrentSmartPointerOwner = this;
01292 #endif
01293 }
01294
01295 a2dNamedProperty *a2dAutoZeroProperty::Clone( a2dObject::CloneOptions options ) const
01296 {
01297 return new a2dAutoZeroProperty( *this, options );
01298 };
01299
01300 void a2dAutoZeroProperty::Assign( const a2dNamedProperty &other )
01301 {
01302 a2dAutoZeroProperty *propcast = wxStaticCast( &other, a2dAutoZeroProperty);
01303 m_value = propcast->m_value;
01304 }
01305
01306 a2dAutoZeroProperty *a2dAutoZeroProperty::CreatePropertyFromString( const a2dPropertyIdRefObjectAutoZero* WXUNUSED(id), const wxString& WXUNUSED(value) )
01307 {
01308 return 0;
01309 }
01310
01311 #if wxART2D_USE_CVGIO
01312 void a2dAutoZeroProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01313 {
01314 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01315 if ( xmlparts == a2dXmlSer_attrib )
01316 {
01317 }
01318 else
01319 {
01320 if ( m_value )
01321 m_value->Save( parent, out, towrite );
01322 }
01323 }
01324
01325 void a2dAutoZeroProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01326 {
01327 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01328 if ( xmlparts == a2dXmlSer_attrib )
01329 {
01330 m_value = NULL;
01331 }
01332 else
01333 {
01334 if ( parser.GetTagName() == wxT("o") && parser.GetEventType() != END_TAG )
01335 {
01336 parser.Require( START_TAG, wxT("o") );
01337
01338 wxString classname = parser.GetAttributeValue( wxT("classname") );
01339 m_value = wxStaticCast( parser.CreateObject( classname ), a2dObject );
01340 if ( !m_value )
01341 {
01342 a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dObject %s, will be skipped line %d"),
01343 classname.c_str(), parser.GetCurrentLineNumber() );
01344 parser.SkipSubTree();
01345 parser.Require( END_TAG, wxT("o") );
01346 parser.Next();
01347 }
01348 else
01349 {
01350 m_value->Load( this, parser );
01351 parser.ResolveOrAdd( &m_value );
01352 }
01353
01354 }
01355 }
01356 }
01357 #endif //wxART2D_USE_CVGIO
01358
01359 void a2dAutoZeroProperty::SetValue( a2dObject* value )
01360 {
01361 m_value = value;
01362 }
01363
01364 wxString a2dAutoZeroProperty::StringRepresentation() const
01365 {
01366 return m_value ? GetName() + wxT("NULL"): GetName() + wxT("RefObject");
01367 }
01368
01369 wxString a2dAutoZeroProperty::StringValueRepresentation() const
01370 {
01371 return m_value ? wxT("NULL") : wxT("RefObject");
01372 }
01373
01374
01375
01376
01377
01378 a2dInt16Property::a2dInt16Property(): a2dNamedProperty()
01379 {
01380 m_value = 0;
01381 }
01382
01383 a2dInt16Property::a2dInt16Property( const a2dPropertyIdInt16* id, wxInt16 value )
01384 :a2dNamedProperty( id )
01385 {
01386 m_value = value;
01387 }
01388
01389 a2dInt16Property::~a2dInt16Property()
01390 {
01391 }
01392
01393 a2dInt16Property::a2dInt16Property( const a2dInt16Property &other )
01394 :a2dNamedProperty( other )
01395 {
01396 m_value = other.m_value;
01397 }
01398
01399 a2dNamedProperty *a2dInt16Property::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01400 {
01401 return new a2dInt16Property( *this );
01402 };
01403
01404 void a2dInt16Property::Assign( const a2dNamedProperty &other )
01405 {
01406 a2dInt16Property *propcast = wxStaticCast( &other, a2dInt16Property);
01407 m_value = propcast->m_value;
01408 }
01409
01410 a2dInt16Property *a2dInt16Property::CreatePropertyFromString( const a2dPropertyIdInt16* id, const wxString &value )
01411 {
01412 long intval;
01413 value.ToLong( &intval , 10 );
01414 return new a2dInt16Property( id, intval );
01415 }
01416
01417 #if wxART2D_USE_CVGIO
01418 void a2dInt16Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01419 {
01420 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01421 if ( xmlparts == a2dXmlSer_attrib )
01422 {
01423 out.WriteAttribute( wxT("value"), m_value );
01424 }
01425 else
01426 {
01427 }
01428 }
01429
01430 void a2dInt16Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01431 {
01432 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01433 if ( xmlparts == a2dXmlSer_attrib )
01434 {
01435 m_value = parser. GetAttributeValueInt( wxT("value"), 0 );
01436 }
01437 else
01438 {
01439 }
01440 }
01441 #endif //wxART2D_USE_CVGIO
01442
01443 void a2dInt16Property::SetValue( wxInt16 value )
01444 {
01445 m_value = value;
01446 }
01447
01448 wxString a2dInt16Property::StringRepresentation() const
01449 {
01450 wxString form;
01451 form.Printf( wxT("%s = %d"), GetName().c_str(), m_value );
01452 return form;
01453 }
01454
01455 wxString a2dInt16Property::StringValueRepresentation() const
01456 {
01457 wxString form;
01458 form.Printf( wxT("%d"), m_value );
01459 return form;
01460 }
01461
01462
01463
01464
01465
01466 a2dUint16Property::a2dUint16Property(): a2dNamedProperty()
01467 {
01468 m_value = 0;
01469 }
01470
01471 a2dUint16Property::a2dUint16Property( const a2dPropertyIdUint16* id, wxUint16 value )
01472 :a2dNamedProperty( id )
01473 {
01474 m_value = value;
01475 }
01476
01477 a2dUint16Property::~a2dUint16Property()
01478 {
01479 }
01480
01481 a2dUint16Property::a2dUint16Property( const a2dUint16Property &other )
01482 :a2dNamedProperty( other )
01483 {
01484 m_value = other.m_value;
01485 }
01486
01487 a2dNamedProperty *a2dUint16Property::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01488 {
01489 return new a2dUint16Property( *this );
01490 };
01491
01492 void a2dUint16Property::Assign( const a2dNamedProperty &other )
01493 {
01494 a2dUint16Property *propcast = wxStaticCast( &other, a2dUint16Property);
01495 m_value = propcast->m_value;
01496 }
01497
01498 a2dUint16Property *a2dUint16Property::CreatePropertyFromString( const a2dPropertyIdUint16* id, const wxString &value )
01499 {
01500 unsigned long intval;
01501 value.ToULong( &intval , 10 );
01502 return new a2dUint16Property( id, intval );
01503 }
01504
01505 #if wxART2D_USE_CVGIO
01506 void a2dUint16Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01507 {
01508 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01509 if ( xmlparts == a2dXmlSer_attrib )
01510 {
01511 out.WriteAttribute( wxT("value"), m_value );
01512 }
01513 else
01514 {
01515 }
01516 }
01517
01518 void a2dUint16Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01519 {
01520 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01521 if ( xmlparts == a2dXmlSer_attrib )
01522 {
01523 m_value = parser. GetAttributeValueInt( wxT("value"), 0 );
01524 }
01525 else
01526 {
01527 }
01528 }
01529 #endif //wxART2D_USE_CVGIO
01530
01531 void a2dUint16Property::SetValue( wxUint16 value )
01532 {
01533 m_value = value;
01534 }
01535
01536 wxString a2dUint16Property::StringRepresentation() const
01537 {
01538 wxString form;
01539 form.Printf( wxT("%s = %d"), GetName().c_str(), m_value );
01540 return form;
01541 }
01542
01543 wxString a2dUint16Property::StringValueRepresentation() const
01544 {
01545 wxString form;
01546 form.Printf( wxT("%d"), m_value );
01547 return form;
01548 }
01549
01550
01551
01552
01553
01554 a2dInt32Property::a2dInt32Property(): a2dNamedProperty()
01555 {
01556 m_value = 0;
01557 }
01558
01559 a2dInt32Property::a2dInt32Property( const a2dPropertyIdInt32* id, wxInt32 value )
01560 :a2dNamedProperty( id )
01561 {
01562 m_value = value;
01563 }
01564
01565 a2dInt32Property::~a2dInt32Property()
01566 {
01567 }
01568
01569 a2dInt32Property::a2dInt32Property( const a2dInt32Property &other )
01570 :a2dNamedProperty( other )
01571 {
01572 m_value = other.m_value;
01573 }
01574
01575 a2dNamedProperty *a2dInt32Property::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01576 {
01577 return new a2dInt32Property( *this );
01578 };
01579
01580 void a2dInt32Property::Assign( const a2dNamedProperty &other )
01581 {
01582 a2dInt32Property *propcast = wxStaticCast( &other, a2dInt32Property);
01583 m_value = propcast->m_value;
01584 }
01585
01586 a2dInt32Property *a2dInt32Property::CreatePropertyFromString( const a2dPropertyIdInt32* id, const wxString &value )
01587 {
01588 long intval;
01589 value.ToLong( &intval , 10 );
01590 return new a2dInt32Property( id, intval );
01591 }
01592
01593 #if wxART2D_USE_CVGIO
01594 void a2dInt32Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01595 {
01596 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01597 if ( xmlparts == a2dXmlSer_attrib )
01598 {
01599 out.WriteAttribute( wxT("value"), m_value );
01600 }
01601 else
01602 {
01603 }
01604 }
01605
01606 void a2dInt32Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01607 {
01608 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01609 if ( xmlparts == a2dXmlSer_attrib )
01610 {
01611 m_value = parser. GetAttributeValueInt( wxT("value"), 0 );
01612 }
01613 else
01614 {
01615 }
01616 }
01617 #endif //wxART2D_USE_CVGIO
01618
01619 void a2dInt32Property::SetValue( wxInt32 value )
01620 {
01621 m_value = value;
01622 }
01623
01624 wxString a2dInt32Property::StringRepresentation() const
01625 {
01626 wxString form;
01627 form.Printf( wxT("%s = %d"), GetName().c_str(), m_value );
01628 return form;
01629 }
01630
01631 wxString a2dInt32Property::StringValueRepresentation() const
01632 {
01633 wxString form;
01634 form.Printf( wxT("%d"), m_value );
01635 return form;
01636 }
01637
01638
01639
01640
01641
01642 a2dUint32Property::a2dUint32Property(): a2dNamedProperty()
01643 {
01644 m_value = 0;
01645 }
01646
01647 a2dUint32Property::a2dUint32Property( const a2dPropertyIdUint32* id, wxUint32 value )
01648 :a2dNamedProperty( id )
01649 {
01650 m_value = value;
01651 }
01652
01653 a2dUint32Property::~a2dUint32Property()
01654 {
01655 }
01656
01657 a2dUint32Property::a2dUint32Property( const a2dUint32Property &other)
01658 :a2dNamedProperty( other )
01659 {
01660 m_value = other.m_value;
01661 }
01662
01663 a2dNamedProperty *a2dUint32Property::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01664 {
01665 return new a2dUint32Property( *this );
01666 };
01667
01668 void a2dUint32Property::Assign( const a2dNamedProperty &other )
01669 {
01670 a2dUint32Property *propcast = wxStaticCast( &other, a2dUint32Property);
01671 m_value = propcast->m_value;
01672 }
01673
01674 a2dUint32Property *a2dUint32Property::CreatePropertyFromString( const a2dPropertyIdUint32* id, const wxString &value )
01675 {
01676 unsigned long intval;
01677 value.ToULong( &intval , 10 );
01678 return new a2dUint32Property( id, intval );
01679 }
01680
01681 #if wxART2D_USE_CVGIO
01682 void a2dUint32Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01683 {
01684 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01685 if ( xmlparts == a2dXmlSer_attrib )
01686 {
01687 out.WriteAttribute( wxT("value"), m_value );
01688 }
01689 else
01690 {
01691 }
01692 }
01693
01694 void a2dUint32Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01695 {
01696 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01697 if ( xmlparts == a2dXmlSer_attrib )
01698 {
01699 m_value = parser. GetAttributeValueInt( wxT("value"), 0 );
01700 }
01701 else
01702 {
01703 }
01704 }
01705 #endif //wxART2D_USE_CVGIO
01706
01707 void a2dUint32Property::SetValue( wxUint32 value )
01708 {
01709 m_value = value;
01710 }
01711
01712 wxString a2dUint32Property::StringRepresentation() const
01713 {
01714 wxString form;
01715 form.Printf( wxT("%s = %d"), GetName().c_str(), m_value );
01716 return form;
01717 }
01718
01719 wxString a2dUint32Property::StringValueRepresentation() const
01720 {
01721 wxString form;
01722 form.Printf( wxT("%d"), m_value );
01723 return form;
01724 }
01725
01726
01727
01728
01729
01730 a2dDoubleProperty::a2dDoubleProperty(): a2dNamedProperty()
01731 {
01732 m_value = 0.0;
01733 }
01734
01735 a2dDoubleProperty::a2dDoubleProperty( const a2dPropertyIdDouble* id, double value )
01736 : a2dNamedProperty( id )
01737 {
01738 m_value = value;
01739 }
01740
01741 a2dDoubleProperty::~a2dDoubleProperty()
01742 {
01743 }
01744
01745 a2dDoubleProperty::a2dDoubleProperty( const a2dDoubleProperty &other)
01746 :a2dNamedProperty( other )
01747 {
01748 m_value = other.m_value;
01749 }
01750
01751 a2dNamedProperty *a2dDoubleProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01752 {
01753 return new a2dDoubleProperty(*this);
01754 };
01755
01756 void a2dDoubleProperty::Assign( const a2dNamedProperty &other )
01757 {
01758 a2dDoubleProperty *propcast = wxStaticCast( &other, a2dDoubleProperty);
01759 m_value = propcast->m_value;
01760 }
01761
01762 a2dDoubleProperty *a2dDoubleProperty::CreatePropertyFromString( const a2dPropertyIdDouble* id, const wxString &value )
01763 {
01764 double doubleval;
01765 value.ToDouble( &doubleval );
01766 return new a2dDoubleProperty( id, doubleval );
01767 }
01768
01769 #if wxART2D_USE_CVGIO
01770 void a2dDoubleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01771 {
01772 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01773 if ( xmlparts == a2dXmlSer_attrib )
01774 {
01775 out.WriteAttribute( wxT("value"), m_value );
01776 }
01777 else
01778 {
01779 }
01780 }
01781
01782 void a2dDoubleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01783 {
01784 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01785 if ( xmlparts == a2dXmlSer_attrib )
01786 {
01787 m_value = parser. GetAttributeValueDouble( wxT("value"), 0 );
01788 }
01789 else
01790 {
01791 }
01792 }
01793 #endif //wxART2D_USE_CVGIO
01794
01795 void a2dDoubleProperty::SetValue( double value )
01796 {
01797 m_value = value;
01798 }
01799
01800 wxString a2dDoubleProperty::StringRepresentation() const
01801 {
01802 wxString form;
01803 form.Printf( wxT("%s = %6.3f"), GetName().c_str(), m_value );
01804 return form;
01805 }
01806
01807 wxString a2dDoubleProperty::StringValueRepresentation() const
01808 {
01809 wxString form;
01810
01811 form.Printf( wxT("%g"), m_value );
01812 return form;
01813 }
01814
01815
01816
01817
01818
01819 a2dFloatProperty::a2dFloatProperty(): a2dNamedProperty()
01820 {
01821 m_value = 0.0;
01822 }
01823
01824 a2dFloatProperty::a2dFloatProperty( const a2dPropertyIdFloat* id, float value )
01825 : a2dNamedProperty( id )
01826 {
01827 m_value = value;
01828 }
01829
01830 a2dFloatProperty::~a2dFloatProperty()
01831 {
01832 }
01833
01834 a2dFloatProperty::a2dFloatProperty( const a2dFloatProperty &other)
01835 :a2dNamedProperty( other )
01836 {
01837 m_value = other.m_value;
01838 }
01839
01840 a2dNamedProperty *a2dFloatProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01841 {
01842 return new a2dFloatProperty(*this);
01843 };
01844
01845 void a2dFloatProperty::Assign( const a2dNamedProperty &other )
01846 {
01847 a2dFloatProperty *propcast = wxStaticCast( &other, a2dFloatProperty);
01848 m_value = propcast->m_value;
01849 }
01850
01851 a2dFloatProperty *a2dFloatProperty::CreatePropertyFromString( const a2dPropertyIdFloat* id, const wxString &value )
01852 {
01853 double doubleval;
01854 value.ToDouble( &doubleval );
01855 return new a2dFloatProperty( id, (float) doubleval );
01856 }
01857
01858 #if wxART2D_USE_CVGIO
01859 void a2dFloatProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01860 {
01861 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01862 if ( xmlparts == a2dXmlSer_attrib )
01863 {
01864 out.WriteAttribute( wxT("value"), m_value );
01865 }
01866 else
01867 {
01868 }
01869 }
01870
01871 void a2dFloatProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01872 {
01873 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01874 if ( xmlparts == a2dXmlSer_attrib )
01875 {
01876 m_value = parser. GetAttributeValueDouble( wxT("value"), 0 );
01877 }
01878 else
01879 {
01880 }
01881 }
01882 #endif //wxART2D_USE_CVGIO
01883
01884 void a2dFloatProperty::SetValue( float value )
01885 {
01886 m_value = value;
01887 }
01888
01889 wxString a2dFloatProperty::StringRepresentation() const
01890 {
01891 wxString form;
01892 form.Printf( wxT("%s = %6.3f"), GetName().c_str(), m_value );
01893 return form;
01894 }
01895
01896 wxString a2dFloatProperty::StringValueRepresentation() const
01897 {
01898 wxString form;
01899
01900 form.Printf( wxT("%g"), m_value );
01901 return form;
01902 }
01903
01904
01905
01906
01907
01908 a2dArrayStringProperty::a2dArrayStringProperty(): a2dNamedProperty()
01909 {
01910 m_value = wxArrayString();
01911 }
01912
01913 a2dArrayStringProperty::a2dArrayStringProperty( const a2dPropertyIdArrayString* id, const wxArrayString& value )
01914 : a2dNamedProperty( id )
01915 {
01916 m_value = value;
01917 }
01918
01919 a2dArrayStringProperty::a2dArrayStringProperty( const a2dPropertyIdArrayString* id, const wxString& value )
01920 : a2dNamedProperty( id )
01921 {
01922 wxStringTokenizer args( value, wxT(","));
01923 while ( args.HasMoreTokens() )
01924 {
01925 m_value.Add( args.GetNextToken() );
01926 }
01927 }
01928
01929 a2dArrayStringProperty::~a2dArrayStringProperty()
01930 {
01931 }
01932
01933 a2dArrayStringProperty::a2dArrayStringProperty( const a2dArrayStringProperty &other)
01934 :a2dNamedProperty( other )
01935 {
01936 m_value = other.m_value;
01937 }
01938
01939 a2dNamedProperty *a2dArrayStringProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
01940 {
01941 return new a2dArrayStringProperty(*this);
01942 };
01943
01944 void a2dArrayStringProperty::Assign( const a2dNamedProperty &other )
01945 {
01946 a2dArrayStringProperty *propcast = wxStaticCast( &other, a2dArrayStringProperty);
01947 m_value = propcast->m_value;
01948 }
01949
01950 a2dArrayStringProperty *a2dArrayStringProperty::CreatePropertyFromString( const a2dPropertyIdArrayString* id, const wxString &value )
01951 {
01952 wxArrayString valuenew;
01953 wxStringTokenizer args( value );
01954 while ( args.HasMoreTokens() )
01955 {
01956 valuenew.Add( args.GetNextToken() );
01957 }
01958 return new a2dArrayStringProperty( id, valuenew);
01959 }
01960
01961 #if wxART2D_USE_CVGIO
01962 void a2dArrayStringProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01963 {
01964 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
01965 if ( xmlparts == a2dXmlSer_attrib )
01966 {
01967 wxString attrib;
01968 size_t j;
01969 for ( j=0; j < m_value.GetCount(); j++)
01970 {
01971 attrib += m_value.Item(j);
01972 }
01973
01974 out.WriteAttribute( wxT("value"), attrib );
01975 }
01976 else
01977 {
01978 }
01979 }
01980
01981 void a2dArrayStringProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01982 {
01983 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
01984 if ( xmlparts == a2dXmlSer_attrib )
01985 {
01986 wxStringTokenizer args( parser.GetAttributeValue( wxT("value") ), wxT(",") );
01987 while ( args.HasMoreTokens() )
01988 {
01989 m_value.Add( args.GetNextToken() );
01990 }
01991 }
01992 else
01993 {
01994 }
01995 }
01996 #endif //wxART2D_USE_CVGIO
01997
01998 void a2dArrayStringProperty::SetValue( const wxArrayString& value )
01999 {
02000 m_value = value;
02001 }
02002
02003 void a2dArrayStringProperty::Add( const wxString& value )
02004 {
02005 m_value.Add( value );
02006 }
02007
02008 wxString a2dArrayStringProperty::StringRepresentation() const
02009 {
02010 wxString attrib;
02011 size_t j;
02012 for ( j=0; j < m_value.GetCount(); j++)
02013 {
02014 attrib += m_value.Item(j);
02015 }
02016
02017 wxString form;
02018 form.Printf( wxT("%s = %s"), GetName().c_str(), attrib.c_str() );
02019 return form;
02020 }
02021
02022 wxString a2dArrayStringProperty::StringValueRepresentation() const
02023 {
02024 wxString attrib;
02025 size_t j;
02026 for ( j=0; j < m_value.GetCount(); j++)
02027 {
02028 attrib += m_value.Item(j);
02029 }
02030
02031 wxString form;
02032 form.Printf( wxT("%s"), attrib.c_str() );
02033 return form;
02034 }
02035
02036
02037
02038
02039
02040 a2dFileNameProperty::a2dFileNameProperty(): a2dNamedProperty()
02041 {
02042 m_filenameObject = wxT("");
02043 }
02044
02045 a2dFileNameProperty::a2dFileNameProperty( const a2dPropertyIdFileName* id, const wxFileName& filename )
02046 : a2dNamedProperty( id )
02047 {
02048 m_filenameObject = filename;
02049 }
02050
02051 a2dFileNameProperty::~a2dFileNameProperty()
02052 {
02053 }
02054
02055 a2dFileNameProperty::a2dFileNameProperty( const a2dFileNameProperty &other)
02056 :a2dNamedProperty( other )
02057 {
02058 m_filenameObject = other.m_filenameObject;
02059 }
02060
02061 a2dNamedProperty *a2dFileNameProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02062 {
02063 return new a2dFileNameProperty(*this);
02064 };
02065
02066 void a2dFileNameProperty::Assign( const a2dNamedProperty &other )
02067 {
02068 a2dFileNameProperty *propcast = wxStaticCast( &other, a2dFileNameProperty);
02069 m_filenameObject = propcast->m_filenameObject;
02070 }
02071
02072 a2dFileNameProperty *a2dFileNameProperty::CreatePropertyFromString( const a2dPropertyIdFileName* id, const wxString &value )
02073 {
02074 wxFileName filenameval( value );
02075 return new a2dFileNameProperty( id, filenameval );
02076 }
02077
02078 #if wxART2D_USE_CVGIO
02079 void a2dFileNameProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02080 {
02081 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02082 if ( xmlparts == a2dXmlSer_attrib )
02083 {
02084
02085 out.WriteAttribute( wxT("fullfilename"), m_filenameObject.GetFullPath() );
02086 }
02087 else
02088 {
02089 }
02090 }
02091
02092 void a2dFileNameProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02093 {
02094 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02095 if ( xmlparts == a2dXmlSer_attrib )
02096 {
02097 m_filenameObject = parser.GetAttributeValue( wxT("fullfilename"), wxT("") );
02098 }
02099 else
02100 {
02101 }
02102
02103
02104 }
02105 #endif //wxART2D_USE_CVGIO
02106
02107 void a2dFileNameProperty::SetValue( const wxFileName& filenameObject )
02108 {
02109 m_filenameObject = filenameObject;
02110 }
02111
02112 void a2dFileNameProperty::SetFileName( const wxFileName& filenameObject )
02113 {
02114 m_filenameObject = filenameObject;
02115 }
02116
02117 wxString a2dFileNameProperty::StringRepresentation() const
02118 {
02119 wxString form;
02120 form.Printf( wxT("%s = %s"), GetName().c_str(), m_filenameObject.GetFullPath().c_str() );
02121 return form;
02122 }
02123
02124 wxString a2dFileNameProperty::StringValueRepresentation() const
02125 {
02126 wxString form;
02127 form.Printf( wxT("%s"), m_filenameObject.GetFullPath().c_str() );
02128 return form;
02129 }
02130
02131
02132
02133
02134
02135 a2dDateTimeProperty::a2dDateTimeProperty(): a2dNamedProperty()
02136 {
02137 m_datetimeObject = wxDefaultDateTime;
02138 }
02139
02140 a2dDateTimeProperty::a2dDateTimeProperty( const a2dPropertyIdDateTime* id, const wxDateTime& datetime )
02141 : a2dNamedProperty( id )
02142 {
02143 m_datetimeObject = datetime;
02144 }
02145
02146 a2dDateTimeProperty::~a2dDateTimeProperty()
02147 {
02148 }
02149
02150 a2dDateTimeProperty::a2dDateTimeProperty( const a2dDateTimeProperty &other)
02151 :a2dNamedProperty( other )
02152 {
02153 m_datetimeObject = other.m_datetimeObject;
02154 }
02155
02156 a2dNamedProperty *a2dDateTimeProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02157 {
02158 return new a2dDateTimeProperty(*this);
02159 };
02160
02161 void a2dDateTimeProperty::Assign( const a2dNamedProperty &other )
02162 {
02163 a2dDateTimeProperty *propcast = wxStaticCast( &other, a2dDateTimeProperty);
02164 m_datetimeObject = propcast->m_datetimeObject;
02165 }
02166
02167 a2dDateTimeProperty *a2dDateTimeProperty::CreatePropertyFromString( const a2dPropertyIdDateTime* id, const wxString &value )
02168 {
02169 wxDateTime datetimeval;
02170
02171 datetimeval.ParseFormat( value, wxDefaultDateTimeFormat );
02172 return new a2dDateTimeProperty( id, datetimeval );
02173 }
02174
02175 #if wxART2D_USE_CVGIO
02176 void a2dDateTimeProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02177 {
02178 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02179 if ( xmlparts == a2dXmlSer_attrib )
02180 {
02181
02182 out.WriteAttribute( wxT("datetime"), m_datetimeObject.Format() );
02183 }
02184 else
02185 {
02186 }
02187 }
02188
02189 void a2dDateTimeProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02190 {
02191 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02192 if ( xmlparts == a2dXmlSer_attrib )
02193 {
02194 wxString dateTime = parser.GetAttributeValue( wxT("datetime"), wxT("") );
02195
02196 m_datetimeObject.ParseFormat( dateTime, wxDefaultDateTimeFormat );
02197 }
02198 else
02199 {
02200 }
02201
02202
02203 }
02204 #endif //wxART2D_USE_CVGIO
02205
02206 void a2dDateTimeProperty::SetValue( const wxDateTime& datetimeObject )
02207 {
02208 m_datetimeObject = datetimeObject;
02209 }
02210
02211 void a2dDateTimeProperty::SetDateTime( const wxDateTime& datetimeObject )
02212 {
02213 m_datetimeObject = datetimeObject;
02214 }
02215
02216 wxString a2dDateTimeProperty::StringRepresentation() const
02217 {
02218 wxString form;
02219 form.Printf( wxT("%s = %s"), GetName().c_str(), m_datetimeObject.Format().c_str() );
02220 return form;
02221 }
02222
02223 wxString a2dDateTimeProperty::StringValueRepresentation() const
02224 {
02225 wxString form;
02226 form.Printf( wxT("%s"), m_datetimeObject.Format().c_str() );
02227 return form;
02228 }
02229
02230
02231
02232
02233
02234 a2dMenuProperty::a2dMenuProperty(): a2dNamedProperty()
02235 {
02236 m_menu = NULL;
02237 }
02238
02239 a2dMenuProperty::a2dMenuProperty( const a2dPropertyIdMenu* id, wxMenu* menu )
02240 : a2dNamedProperty( id )
02241 {
02242 m_menu = menu;
02243 }
02244
02245 a2dMenuProperty::~a2dMenuProperty()
02246 {
02247 }
02248
02249 a2dMenuProperty::a2dMenuProperty( const a2dMenuProperty &other)
02250 :a2dNamedProperty( other )
02251 {
02252 m_menu = other.m_menu;
02253 }
02254
02255 a2dNamedProperty *a2dMenuProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02256 {
02257 return new a2dMenuProperty(*this);
02258 };
02259
02260 void a2dMenuProperty::Assign( const a2dNamedProperty &other )
02261 {
02262 a2dMenuProperty *propcast = wxStaticCast( &other, a2dMenuProperty);
02263 m_menu = propcast->m_menu;
02264 }
02265
02266 #if wxART2D_USE_CVGIO
02267 void a2dMenuProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02268 {
02269 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02270 if ( xmlparts == a2dXmlSer_attrib )
02271 {
02272 }
02273 else
02274 {
02275 }
02276 }
02277
02278 void a2dMenuProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02279 {
02280 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02281 if ( xmlparts == a2dXmlSer_attrib )
02282 {
02283 }
02284 else
02285 {
02286 }
02287
02288
02289 }
02290 #endif //wxART2D_USE_CVGIO
02291
02292 void a2dMenuProperty::SetValue( wxMenu* menu )
02293 {
02294 m_menu = menu;
02295 }
02296
02297 a2dMenuProperty *a2dMenuProperty::CreatePropertyFromString( const a2dPropertyIdMenu* id, const wxString &value )
02298 {
02299 return NULL;
02300 }
02301
02302
02303
02304
02305
02306 a2dWindowProperty::a2dWindowProperty(): a2dNamedProperty()
02307 {
02308 m_window = NULL;
02309 }
02310
02311 a2dWindowProperty::a2dWindowProperty( const a2dPropertyIdWindow* id, wxWindow* window )
02312 : a2dNamedProperty( id )
02313 {
02314 m_window = window;
02315 }
02316
02317 a2dWindowProperty::~a2dWindowProperty()
02318 {
02319 if(m_window)
02320 m_window->Close();
02321 }
02322
02323 a2dWindowProperty::a2dWindowProperty( const a2dWindowProperty &other)
02324 :a2dNamedProperty( other )
02325 {
02326 m_window = other.m_window;
02327 }
02328
02329 a2dNamedProperty *a2dWindowProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02330 {
02331 return new a2dWindowProperty(*this);
02332 };
02333
02334 void a2dWindowProperty::Assign( const a2dNamedProperty &other )
02335 {
02336 a2dWindowProperty *propcast = wxStaticCast( &other, a2dWindowProperty);
02337 m_window = propcast->m_window;
02338 }
02339
02340 #if wxART2D_USE_CVGIO
02341 void a2dWindowProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02342 {
02343 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02344 if ( xmlparts == a2dXmlSer_attrib )
02345 {
02346 }
02347 else
02348 {
02349 }
02350 }
02351
02352 void a2dWindowProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02353 {
02354 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02355 if ( xmlparts == a2dXmlSer_attrib )
02356 {
02357 }
02358 else
02359 {
02360 }
02361
02362
02363 }
02364 #endif //wxART2D_USE_CVGIO
02365
02366 void a2dWindowProperty::SetValue( wxWindow* window )
02367 {
02368 m_window = window;
02369 }
02370
02371 a2dWindowProperty *a2dWindowProperty::CreatePropertyFromString( const a2dPropertyIdWindow* id, const wxString &value )
02372 {
02373 return NULL;
02374 }
02375
02376
02377
02378
02379
02380 a2dTipWindowProperty::a2dTipWindowProperty(): a2dWindowProperty()
02381 {
02382 m_rectStay = wxRect( -20, -20, 40 , 40 );
02383 }
02384
02385 a2dTipWindowProperty::a2dTipWindowProperty( const a2dPropertyIdWindow* id, wxTipWindow* window, const wxString& tipstring, bool useObjRect )
02386 : a2dWindowProperty( id, window )
02387 {
02388 m_useObjRect = useObjRect;
02389 m_tipstring = tipstring;
02390 }
02391
02392 a2dTipWindowProperty::a2dTipWindowProperty( const a2dPropertyIdWindow* id, wxTipWindow* window, const wxString& tipstring, const wxRect& rect )
02393 : a2dWindowProperty( id, window )
02394 {
02395 m_rectStay = rect;
02396 m_useObjRect = false;
02397 m_tipstring = tipstring;
02398 }
02399
02400 a2dTipWindowProperty::~a2dTipWindowProperty()
02401 {
02402 if(m_window)
02403 {
02404 wxTipWindow* tipwindow = wxDynamicCast(m_window,wxTipWindow);
02405 if(tipwindow)
02406 tipwindow->SetTipWindowPtr(NULL);
02407 }
02408 }
02409
02410 a2dTipWindowProperty::a2dTipWindowProperty( const a2dTipWindowProperty &other)
02411 :a2dWindowProperty( other )
02412 {
02413 m_tipstring = other.m_tipstring;
02414 }
02415
02416 a2dNamedProperty *a2dTipWindowProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02417 {
02418 return new a2dTipWindowProperty(*this);
02419 };
02420
02421 void a2dTipWindowProperty::Assign( const a2dNamedProperty &other )
02422 {
02423 a2dTipWindowProperty *propcast = wxStaticCast( &other, a2dTipWindowProperty);
02424 m_window = propcast->m_window;
02425 m_tipstring = propcast->m_tipstring;
02426 }
02427
02428 #if wxART2D_USE_CVGIO
02429 void a2dTipWindowProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02430 {
02431 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02432 if ( xmlparts == a2dXmlSer_attrib )
02433 {
02434 }
02435 else
02436 {
02437 }
02438 }
02439
02440 void a2dTipWindowProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02441 {
02442 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02443 if ( xmlparts == a2dXmlSer_attrib )
02444 {
02445 }
02446 else
02447 {
02448 }
02449
02450
02451 }
02452 #endif //wxART2D_USE_CVGIO
02453
02454 void a2dTipWindowProperty::SetString( const wxString& tipstring )
02455 {
02456 m_tipstring = tipstring;
02457 }
02458
02459 a2dTipWindowProperty *a2dTipWindowProperty::CreatePropertyFromString( const a2dPropertyIdWindow* id, const wxString &value )
02460 {
02461 return NULL;
02462 }
02463
02464
02465
02466
02467
02468 a2dPathListProperty::a2dPathListProperty(): a2dNamedProperty()
02469 {
02470 m_pathlistObject = a2dPathList();
02471 }
02472
02473 a2dPathListProperty::a2dPathListProperty( const a2dPropertyIdPathList* id, const a2dPathList& pathlist )
02474 : a2dNamedProperty( id )
02475 {
02476 m_pathlistObject = pathlist;
02477 }
02478
02479 a2dPathListProperty::~a2dPathListProperty()
02480 {
02481 }
02482
02483 a2dPathListProperty::a2dPathListProperty( const a2dPathListProperty &other)
02484 :a2dNamedProperty( other )
02485 {
02486 m_pathlistObject = other.m_pathlistObject;
02487 }
02488
02489 a2dNamedProperty *a2dPathListProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02490 {
02491 return new a2dPathListProperty(*this);
02492 };
02493
02494 void a2dPathListProperty::Assign( const a2dNamedProperty &other )
02495 {
02496 a2dPathListProperty *propcast = wxStaticCast( &other, a2dPathListProperty);
02497 m_pathlistObject = propcast->m_pathlistObject;
02498 }
02499
02500 a2dPathListProperty *a2dPathListProperty::CreatePropertyFromString( const a2dPropertyIdPathList* id, const wxString &value )
02501 {
02502 a2dPathList a = a2dPathList();
02503 a.Add( value );
02504 return new a2dPathListProperty( id, a );
02505 }
02506
02507 #if wxART2D_USE_CVGIO
02508 void a2dPathListProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02509 {
02510 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02511 if ( xmlparts == a2dXmlSer_attrib )
02512 {
02513
02514
02515 }
02516 else
02517 {
02518 }
02519 }
02520
02521 void a2dPathListProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02522 {
02523 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02524 if ( xmlparts == a2dXmlSer_attrib )
02525 {
02526
02527 }
02528 else
02529 {
02530 }
02531
02532
02533 }
02534 #endif //wxART2D_USE_CVGIO
02535
02536 void a2dPathListProperty::SetValue( const a2dPathList& pathlistObject )
02537 {
02538 m_pathlistObject = pathlistObject;
02539 }
02540
02541 void a2dPathListProperty::SetFileName( const a2dPathList& pathlistObject )
02542 {
02543 m_pathlistObject = pathlistObject;
02544 }
02545
02546 wxString a2dPathListProperty::StringRepresentation() const
02547 {
02548 wxString form;
02549
02550 return form;
02551 }
02552
02553 wxString a2dPathListProperty::StringValueRepresentation() const
02554 {
02555 wxString form;
02556
02557 return form;
02558 }
02559
02560
02561
02562
02563
02564 A2DGENERALDLLEXP wxColour ParseSvgColour( wxString value )
02565 {
02566 wxColour colour;
02567 value.Trim(false).Trim();
02568 if (value.GetChar(0) == _T('#'))
02569 {
02570 colour = HexToColour( value.After(_T('#')));
02571 }
02572 else if (value.Mid(0, 4).Lower() == _T("rgb("))
02573 {
02574 long red, green, blue;
02575 value = value.Mid(4);
02576 value = value.BeforeLast(_T(')'));
02577
02578 wxStringTokenizer rgb( value, _T(",") );
02579 if ( rgb.CountTokens() != 3 )
02580 wxLogWarning(_("Invalid RGB value"));
02581 if ( !rgb.GetNextToken().ToLong( &red ) )
02582 wxLogWarning(_("Invalid RGB value"));
02583 if ( !rgb.GetNextToken().ToLong( &green ) )
02584 wxLogWarning(_("Invalid RGB value"));
02585 if ( !rgb.GetNextToken().ToLong( &blue ) )
02586 wxLogWarning(_("Invalid RGB value"));
02587
02588 colour.Set(red, green, blue);
02589 }
02590 else
02591 {
02592
02593 bool ishex = (value.Length() == 6);
02594 for ( int i = 0; ishex && i < 6; i++ )
02595 ishex = ( wxIsxdigit( value.GetChar( i ) ) != 0 );
02596 if ( ishex )
02597 colour = HexToColour( value );
02598 else {
02599
02600 unsigned long red, green, blue;
02601 bool commavalue = true;
02602 wxStringTokenizer rgbcomma( value, _T(","), wxTOKEN_RET_EMPTY );
02603 if ( rgbcomma.CountTokens() != 3 )
02604 commavalue = false;
02605 if ( !rgbcomma.GetNextToken().ToULong( &red ) )
02606 commavalue = false;
02607 if ( !rgbcomma.GetNextToken().ToULong( &green ) )
02608 commavalue = false;
02609 if ( !rgbcomma.GetNextToken().ToULong( &blue ) )
02610 commavalue = false;
02611
02612 if ( !commavalue )
02613 {
02614 commavalue = true;
02615 wxStringTokenizer rgbspace( value, _T(" ") );
02616 if ( rgbspace.CountTokens() != 3 )
02617 commavalue = false;
02618 if ( !rgbspace.GetNextToken().ToULong( &red ) )
02619 commavalue = false;
02620 if ( !rgbspace.GetNextToken().ToULong( &green ) )
02621 commavalue = false;
02622 if ( !rgbspace.GetNextToken().ToULong( &blue ) )
02623 commavalue = false;
02624 }
02625 if ( commavalue )
02626 colour.Set(red, green, blue);
02627 else
02628 {
02629
02630 colour = wxTheColourDatabase->FindName( value );
02631 }
02632 }
02633 }
02634 return colour;
02635 }
02636
02637 a2dColourProperty::a2dColourProperty(): a2dNamedProperty()
02638 {
02639 m_colour = wxT("");
02640 }
02641
02642 a2dColourProperty::a2dColourProperty( const a2dPropertyIdColour* id, const wxColour& colour )
02643 : a2dNamedProperty( id )
02644 {
02645 m_colour = colour;
02646 }
02647
02648 a2dColourProperty::~a2dColourProperty()
02649 {
02650 }
02651
02652 a2dColourProperty::a2dColourProperty( const a2dColourProperty &other)
02653 :a2dNamedProperty( other )
02654 {
02655 m_colour = other.m_colour;
02656 }
02657
02658 a2dNamedProperty *a2dColourProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02659 {
02660 return new a2dColourProperty(*this);
02661 };
02662
02663 void a2dColourProperty::Assign( const a2dNamedProperty &other )
02664 {
02665 a2dColourProperty *propcast = wxStaticCast( &other, a2dColourProperty);
02666 m_colour = propcast->m_colour;
02667 }
02668
02669 a2dColourProperty *a2dColourProperty::CreatePropertyFromString( const a2dPropertyIdColour* id, const wxString &value )
02670 {
02671 return new a2dColourProperty( id, ParseSvgColour(value) );
02672 }
02673
02674 #if wxART2D_USE_CVGIO
02675 void a2dColourProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
02676 {
02677 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
02678 if ( xmlparts == a2dXmlSer_attrib )
02679 {
02680
02681 wxString form;
02682 form.Printf( wxT("%d %d %d"), m_colour.Red(), m_colour.Green(), m_colour.Blue() );
02683 out.WriteAttribute( wxT("colour"), form );
02684 }
02685 else
02686 {
02687 }
02688 }
02689
02690 void a2dColourProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
02691 {
02692 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
02693 if ( xmlparts == a2dXmlSer_attrib )
02694 {
02695 wxString colstr = parser.GetAttributeValue( wxT("colour"), wxT("") );
02696 m_colour = ParseSvgColour(colstr);
02697 }
02698 else
02699 {
02700 }
02701
02702
02703 }
02704 #endif //wxART2D_USE_CVGIO
02705
02706 void a2dColourProperty::SetValue( const wxColour& colour )
02707 {
02708 m_colour = colour;
02709 }
02710
02711 void a2dColourProperty::SetColour( const wxColour& colour )
02712 {
02713 m_colour = colour;
02714 }
02715
02716 wxString a2dColourProperty::StringRepresentation() const
02717 {
02718 wxString form;
02719 form.Printf( wxT("%s = {%d %d %d}"), GetName().c_str(), m_colour.Red(), m_colour.Green(), m_colour.Blue() );
02720
02721 return form;
02722 }
02723
02724 wxString a2dColourProperty::StringValueRepresentation() const
02725 {
02726 wxString form;
02727 form.Printf( wxT("{%d %d %d}"), m_colour.Red(), m_colour.Green(), m_colour.Blue() );
02728 return form;
02729 }
02730
02731
02732
02733
02734 A2DGENERALDLLEXP_DATA(a2dObjectList*) wxNullRefObjectList = 0;
02735
02736
02737
02738 a2dObjectList::a2dObjectList()
02739 {
02740 }
02741
02742 a2dObjectList::~a2dObjectList()
02743 {
02744 }
02745
02746 void a2dObjectList::MakeUnique()
02747 {
02748 for( a2dObjectList::iterator iter = begin(); iter != end(); ++iter )
02749 {
02750 a2dObject *obj = *iter;
02751 if ( obj && obj->GetOwnedBy() > 1)
02752 {
02753 *iter = obj->Clone( a2dObject::clone_flat );
02754 }
02755 }
02756 }
02757
02758 a2dObjectList* a2dObjectList::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
02759 {
02760
02761 if ( this == wxNullRefObjectList )
02762 return wxNullRefObjectList;
02763 else
02764 return new a2dObjectList( *this );
02765 }
02766
02767 bool a2dObjectList::Release( const wxString& classname, bool all )
02768 {
02769 bool did=false;
02770
02771 a2dObjectList::iterator iter = begin();
02772 while ( iter != end() )
02773 {
02774 a2dObject *obj = (*iter);
02775 if ( classname.IsEmpty() || obj->GetClassInfo()->GetClassName()==classname )
02776 {
02777 did = true;
02778 iter = erase( iter );
02779 if (!all)
02780 return did;
02781 }
02782 else
02783 iter++;
02784 }
02785
02786 return did;
02787 }
02788
02789 a2dObject* a2dObjectList::Find( const wxString& classname, const wxString& name )
02790 {
02791 for( a2dObjectList::iterator iter = begin(); iter != end(); ++iter )
02792 {
02793 a2dObject *cobj = *iter;
02794
02795 if (
02796 ( classname.IsEmpty() || cobj->GetClassInfo()->GetClassName()==classname ) &&
02797 ( name.IsEmpty() || cobj->GetName() == name )
02798 )
02799 {
02800 return cobj;
02801 }
02802 }
02803
02804 return (a2dObject*) NULL;
02805 }
02806
02807 int a2dObjectList::CollectObjects( a2dObjectList* total, const wxString& propertyNameFilter, const wxString& classname )
02808 {
02809 int count = 0;
02810 for( a2dObjectList::iterator iter = begin(); iter != end(); ++iter )
02811 {
02812 a2dObject *cobj = *iter;
02813
02814 if ( (classname.IsEmpty() || cobj->GetClassInfo()->GetClassName() == classname ) &&
02815 ( propertyNameFilter.IsEmpty() || ( cobj->GetName().Matches( propertyNameFilter) ) )
02816 )
02817 {
02818 if ( total && total != wxNullRefObjectList )
02819 total->push_back(cobj);
02820 count++;
02821 }
02822 }
02823
02824 return count;
02825 }
02826
02827
02828
02829
02830
02831 a2dVariablesHash::a2dVariablesHash()
02832 {
02833 }
02834
02835 a2dVariablesHash::a2dVariablesHash( const a2dVariablesHash &other )
02836 :
02837 a2dVariablesHashBase( other )
02838 {
02839
02840 iterator i;
02841 for( i = begin(); i != end(); ++i )
02842 {
02843 i->second = i->second->Clone( a2dObject::clone_flat );
02844 }
02845 }
02846
02847 void a2dVariablesHash::operator = ( const a2dVariablesHash &other )
02848 {
02849 a2dVariablesHashBase::operator = ( other );
02850
02851 iterator i;
02852 for( i = begin(); i != end(); ++i )
02853 {
02854 i->second = i->second->Clone( a2dObject::clone_flat );
02855 }
02856 }
02857
02858 a2dVariablesHash::~a2dVariablesHash()
02859 {
02860 iterator i;
02861 for( i = begin(); i != end(); ++i )
02862 {
02863 delete i->second;
02864 }
02865 }
02866
02867 bool a2dVariablesHash::SetVariable( const wxString& variableName, a2dNamedProperty *property )
02868 {
02869 iterator iter = find( variableName );
02870 if( iter != end() )
02871 {
02872 delete iter->second;
02873 }
02874
02875 (*this)[ variableName ] = property;
02876
02877 return iter != end();
02878 }
02879
02880 bool a2dVariablesHash::SetVariableRefObject( const wxString& variableName, a2dObject *value )
02881 {
02882 iterator iter = find( variableName );
02883 if( iter != end() )
02884 {
02885 delete iter->second;
02886 }
02887
02888 (*this)[ variableName ] = new a2dProperty( a2dPropertyIdRefObject::GetDummy(), value );
02889
02890 return iter != end();
02891 }
02892
02893 bool a2dVariablesHash::SetVariableString( const wxString& variableName, const wxString &value )
02894 {
02895 iterator iter = find( variableName );
02896 if( iter != end() )
02897 {
02898 delete iter->second;
02899 }
02900
02901 (*this)[ variableName ] = new a2dStringProperty( a2dPropertyIdString::GetDummy(), value );
02902
02903 return iter != end();
02904 }
02905
02906 bool a2dVariablesHash::SetVariableDouble( const wxString& variableName, double value )
02907 {
02908 iterator iter = find( variableName );
02909 if( iter != end() )
02910 {
02911 delete iter->second;
02912 }
02913
02914 (*this)[ variableName ] = new a2dDoubleProperty( a2dPropertyIdDouble::GetDummy(), value );
02915
02916 return iter != end();
02917 }
02918
02919 bool a2dVariablesHash::SetVariableInt( const wxString& variableName, int value )
02920 {
02921 iterator iter = find( variableName );
02922 if( iter != end() )
02923 {
02924 delete iter->second;
02925 }
02926
02927 (*this)[ variableName ] = new a2dInt32Property( a2dPropertyIdInt32::GetDummy(), value );
02928
02929 return iter != end();
02930 }
02931
02932 const a2dNamedProperty *a2dVariablesHash::GetVariable( const wxString& variableName )
02933 {
02934 iterator iter = find( variableName );
02935 if( iter == end() )
02936 return NULL;
02937
02938 return iter->second;
02939 }
02940
02941 a2dNamedProperty *a2dVariablesHash::GetVariableClone( const wxString& variableName )
02942 {
02943 iterator iter = find( variableName );
02944 if( iter == end() )
02945 return NULL;
02946
02947 return iter->second->Clone( a2dObject::clone_flat );
02948 }
02949
02950 a2dObject* a2dVariablesHash::GetVariableRefObject( const wxString& variableName )
02951 {
02952 iterator iter = find( variableName );
02953 if( iter == end() )
02954 return NULL;
02955
02956 return iter->second->GetRefObjectNA();
02957 }
02958
02959 wxString* a2dVariablesHash::GetVariableString( const wxString& variableName )
02960 {
02961 iterator iter = find( variableName );
02962 if( iter == end() )
02963 return NULL;
02964
02965 a2dStringProperty *prop = wxDynamicCast( iter->second, a2dStringProperty );
02966 if( prop )
02967 return prop->GetValuePtr();
02968 else
02969 return 0;
02970 }
02971
02972
02973
02974
02975
02976 a2dVariablesArray::a2dVariablesArray()
02977 {
02978 m_nelements = 0;
02979 m_melements = 100;
02980 m_properties = new a2dNamedProperty*[m_melements];
02981
02982 for( int i=0; i<100; i++ )
02983 {
02984 m_properties[i] = 0;
02985 }
02986 }
02987
02988 a2dVariablesArray::~a2dVariablesArray()
02989 {
02990 for( int i=0; i<m_nelements; i++ )
02991 {
02992 delete m_properties[i];
02993 }
02994 delete [] m_properties;
02995 }
02996
02997 void a2dVariablesArray::DeleteAll()
02998 {
02999 for( int i=0; i<m_nelements; i++ )
03000 {
03001 delete m_properties[i];
03002 m_properties[i] = 0;
03003 }
03004 m_nelements = 0;
03005 }
03006
03007 void a2dVariablesArray::AppendVariable( a2dNamedProperty *value )
03008 {
03009 SetMinSize( m_nelements + 1 );
03010 m_properties[ m_nelements++ ] = value;
03011 }
03012
03013 void a2dVariablesArray::AppendVariableRefObject( a2dObject *value )
03014 {
03015 SetMinSize( m_nelements + 1 );
03016 m_properties[ m_nelements++ ] = new a2dProperty( a2dPropertyIdRefObject::GetDummy(), value );
03017 }
03018
03019 void a2dVariablesArray::AppendVariableString( const wxString &value )
03020 {
03021 SetMinSize( m_nelements + 1 );
03022 m_properties[ m_nelements++ ] = new a2dStringProperty( a2dPropertyIdString::GetDummy(), value );
03023 }
03024
03025 void a2dVariablesArray::AppendVariableDouble( double value )
03026 {
03027 SetMinSize( m_nelements + 1 );
03028 m_properties[ m_nelements++ ] = new a2dDoubleProperty( a2dPropertyIdDouble::GetDummy(), value );
03029 }
03030
03031 void a2dVariablesArray::AppendVariableInt( int value )
03032 {
03033 SetMinSize( m_nelements + 1 );
03034 m_properties[ m_nelements++ ] = new a2dInt32Property( a2dPropertyIdInt32::GetDummy(), value );
03035 }
03036
03037 const a2dNamedProperty &a2dVariablesArray::GetVariable( int index )
03038 {
03039 wxASSERT( index < m_nelements && index >= 0 );
03040 return *m_properties[index];
03041 }
03042
03043 a2dNamedProperty *a2dVariablesArray::GetVariableClone( int index )
03044 {
03045 wxASSERT( index < m_nelements && index >= 0 );
03046 return m_properties[index]->Clone( a2dObject::clone_flat );
03047 }
03048
03049 a2dObject* a2dVariablesArray::GetVariableRefObject( int index )
03050 {
03051 wxASSERT( index < m_nelements && index >= 0 );
03052 return m_properties[index]->GetRefObject();
03053 }
03054
03055 wxString a2dVariablesArray::GetVariableString( int index )
03056 {
03057 wxASSERT( index < m_nelements && index >= 0 );
03058 return m_properties[index]->GetString();
03059 }
03060
03061 wxString a2dVariablesArray::GetVariableAsString( int index )
03062 {
03063 wxASSERT( index < m_nelements && index >= 0 );
03064 return m_properties[index]->StringValueRepresentation();
03065 }
03066
03067 void a2dVariablesArray::SetMinSize( int size )
03068 {
03069 if( size > m_melements )
03070 {
03071 int i;
03072 if( size < m_melements * 2 )
03073 m_melements *= 2;
03074 else
03075 m_melements = size;
03076 a2dNamedProperty **newdata = new a2dNamedProperty*[m_melements];
03077
03078 for( i=0; i<m_nelements; i++ )
03079 {
03080 newdata[i] = m_properties[i];
03081 }
03082 for( ; i<m_melements; i++ )
03083 {
03084 newdata[i] = 0;
03085 }
03086 delete [] m_properties;
03087 m_properties = newdata;
03088 }
03089 }
03090
03091
03092
03093
03094 #define PATHLENGTH 255 * 4
03095
03096
03097 static wxChar wxFileFunctionsBuffer[PATHLENGTH];
03098
03099 a2dPathList::a2dPathList()
03100 {
03101 }
03102
03103 a2dPathList::~a2dPathList()
03104 {
03105 Clear();
03106 }
03107
03108 wxString a2dPathList::GetAsString()
03109 {
03110 wxString ret;
03111
03112 #if wxCHECK_VERSION(2,7,0)
03113 for (wxPathList::iterator node = begin(); node != end(); node++ )
03114 #else
03115 for (wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext())
03116 #endif
03117 {
03118 wxString path = node->GetData();
03119 ret += wxPATH_SEP + path;
03120 }
03121 return ret;
03122 }
03123
03124 wxString a2dPathList::FindValidPath (const wxString& file)
03125 {
03126 wxFileName ffile( file );
03127 wxString fileUnix = ffile.GetFullPath(wxPATH_UNIX);
03128
03129 if ( ExpandPath( fileUnix ) && wxFileExists( fileUnix ) )
03130 return wxString(m_b);
03131
03132 wxFileName fileobj = wxFileName( fileUnix );
03133
03134
03135 wxString filename = fileobj.IsAbsolute() ? fileobj.GetFullName() : fileobj.GetFullPath();
03136
03137 #if wxCHECK_VERSION(2,7,0)
03138 for (wxPathList::iterator node = begin(); node != end(); node++ )
03139 #else
03140 for (wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext())
03141 #endif
03142 {
03143 wxFileName filep( node->GetData() );
03144 filep.GetFullPath(wxPATH_UNIX);
03145 wxString path = filep.GetFullPath(wxPATH_UNIX);
03146 if ( !path.IsEmpty() )
03147 {
03148 wxChar ch = path[wxStrlen(path)-1];
03149 if (ch != wxT('\\') && ch != wxT('/'))
03150 path += wxT("/");
03151 }
03152 path += filename;
03153
03154 if ( ExpandPath( path ) && wxFileExists( path ) )
03155 return wxString(m_b);
03156 }
03157
03158 return wxEmptyString;
03159 }
03160
03161 wxString a2dPathList::FindAbsoluteValidPath (const wxString& file)
03162 {
03163 wxString f = FindValidPath(file);
03164 if ( f.empty() || wxIsAbsolutePath(f) )
03165 return f;
03166
03167 wxString buf = wxGetCwd();
03168
03169 if ( !wxEndsWithPathSeparator(buf) )
03170 {
03171 buf += wxFILE_SEP_PATH;
03172 }
03173 buf += f;
03174
03175 return buf;
03176 }
03177
03178 void a2dPathList::IncC()
03179 {
03180 if (m_c == 0)
03181 {
03182
03183 m_c = m_path.c_str();
03184 }
03185 else
03186 {
03187 if (*m_c != wxT('\0') )
03188 m_c++;
03189 }
03190 a = *m_c;
03191 }
03192
03193
03194
03195 bool a2dPathList::Name()
03196 {
03197 m_varref.Empty();
03198 if ( !( wxIsalnum(a) || a == wxT('_') || a == wxT('-') ) )
03199 {
03200 m_error_mes = wxT("wrong name");
03201 return false;
03202 }
03203 m_varref += a;
03204 IncC();
03205 while( wxIsalnum(a) || a == wxT('_') )
03206 {
03207 m_varref+=a;
03208 IncC();
03209 }
03210 return true;
03211 }
03212
03213
03214 bool a2dPathList::ExpandPath( wxString& pathToExpand )
03215 {
03216 wxString result;
03217 m_path = pathToExpand;
03218 m_b.Clear();
03219 m_b.Alloc(PATHLENGTH);
03220
03221 bool change = true;
03222 while ( change )
03223 {
03224 change = false;
03225 m_b.Clear();
03226 m_varref.Clear();
03227 m_error_mes.Clear();
03228 m_c=0;
03229
03230 IncC();
03231
03232 while( a != wxT('\t') && a != wxT('\0') && a != wxT('\n') && a != wxT(';') )
03233 {
03234
03235
03236
03237
03238
03239
03240
03241
03242
03243
03244
03245
03246
03247
03248
03249 if ( (a == wxT('$') ) || ( a == wxT('%') ) || ( a == wxT('@') ) )
03250 {
03251 if (!VarRef(a))
03252 return false;
03253 change = true;
03254 continue;
03255 }
03256
03257
03258 m_b += a;
03259 IncC();
03260 }
03261
03262 m_path = m_b;
03263 }
03264
03265 wxFileName ffile( m_b );
03266 pathToExpand = ffile.GetFullPath(wxPATH_UNIX);
03267
03268 return true;
03269 }
03270
03271
03272
03273
03274
03275 bool a2dPathList::VarRef( wxChar type)
03276 {
03277 if( a != type )
03278 {
03279 m_error_mes = wxT("wrong environment $ or % or @ missing");
03280 return false;
03281 }
03282
03283 IncC();
03284 if( a == wxT('{') )
03285 {
03286 IncC();
03287 if( !Name() )
03288 return false;
03289 if( a != '}' )
03290 {
03291 m_error_mes = wxT("wrong environment name, end brace missing");
03292 return false;
03293 }
03294 IncC();
03295 }
03296 else
03297 {
03298 if( !Name() )
03299 return false;
03300 }
03301
03302 wxString evaluated;
03303 if (type == wxT('$') )
03304 {
03305 if (m_varref.Len()==0)
03306 return false;
03307
03308 if( !wxGetEnv(m_varref, &evaluated) )
03309 {
03310 m_error_mes = wxT("wrong environment Variable, environment does not exist");
03311 return false;
03312 }
03313 }
03314 else
03315 {
03316 a2dVariablesHash aliaslist = a2dGeneralGlobals->GetVariablesHash();
03317 const a2dNamedProperty *prop = a2dGeneralGlobals->GetVariablesHash().GetVariable( m_varref );
03318 if( !prop )
03319 {
03320 m_error_mes = wxT("wrong Variable name, Variable does not exist");
03321 return false;
03322 }
03323 evaluated = prop->StringValueRepresentation();
03324 }
03325
03326 m_b += evaluated;
03327 return true;
03328 }
03329
03330
03331
03332
03333 a2dIOHandler::a2dIOHandler()
03334 {
03335 m_refcount = 0;
03336 m_toResolve.DeleteContents( true );
03337 m_lastObjectId.Empty();
03338 }
03339
03340 a2dIOHandler::~a2dIOHandler()
03341 {
03342 wxASSERT_MSG( m_refcount == 0, wxT("deleting a2dDocument while referenced") );
03343 m_objecthashmap.clear();
03344 m_objectCreate.clear();
03345 m_toResolve.Clear();
03346 m_lastObjectId.Empty();
03347 }
03348
03349 a2dObject* a2dIOHandler::Clone( CloneOptions WXUNUSED(options) ) const
03350 {
03351 wxFAIL_MSG( wxT("cannot clone a2dIOHandler") );
03352 return NULL;
03353 }
03354
03355 #if wxART2D_USE_CVGIO
03356 void a2dIOHandler::DoSave( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerOut& WXUNUSED(out), a2dXmlSer_flag WXUNUSED(xmlparts), a2dObjectList* WXUNUSED(towrite) )
03357 {
03358 wxFAIL_MSG( wxT("cannot Save a2dIOHandler") );
03359 }
03360
03361 void a2dIOHandler::DoLoad( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerIn& WXUNUSED(parser), a2dXmlSer_flag WXUNUSED(xmlparts) )
03362 {
03363 wxFAIL_MSG( wxT("cannot Load a2dIOHandler") );
03364 }
03365 #endif //wxART2D_USE_CVGIO
03366
03367 wxObject* a2dIOHandler::CreateObject( const wxString& symbolicName )
03368 {
03369 a2dHashMapCreateObject::iterator obj = m_objectCreate.find( symbolicName );
03370
03371 if( obj == m_objectCreate.end() )
03372 {
03373 return wxCreateDynamicObject( symbolicName );
03374 }
03375 return wxCreateDynamicObject( obj->second );
03376 }
03377
03378 void a2dIOHandler::Initialize()
03379 {
03380 m_objecthashmap.clear();
03381 m_toResolve.Clear();
03382 m_lastObjectId.Empty();
03383 }
03384
03385 void a2dIOHandler::Reset()
03386 {
03387 m_objecthashmap.clear();
03388 m_toResolve.Clear();
03389 m_lastObjectId.Empty();
03390 }
03391
03392 bool a2dIOHandler::ResolveOrAdd( a2dSmrtPtr<a2dObject>* storedHere, const wxString &id )
03393 {
03394 if ( storedHere && ( !id.IsEmpty() || !m_lastObjectId.IsEmpty() ) )
03395 {
03396 a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( id.IsEmpty() ? m_lastObjectId : id );
03397
03398 if( obj == m_objecthashmap.end() )
03399 {
03400 a2dResolveIdInfo* a = new a2dResolveIdInfo( id.IsEmpty() ? m_lastObjectId : id, storedHere );
03401 m_toResolve.Append( a );
03402 if( id.IsEmpty() )
03403 m_lastObjectId.Empty();
03404 return false;
03405 }
03406
03407
03408 *storedHere = wxDynamicCast( obj->second, a2dObject );
03409 if( id.IsEmpty() )
03410 m_lastObjectId.Empty();
03411 return true;
03412 }
03413 return false;
03414 }
03415
03416 bool a2dIOHandler::ResolveOrAdd( a2dAutoZeroPtr<a2dObject>* storedHere, const wxString &id )
03417 {
03418 if ( storedHere && ( !id.IsEmpty() || !m_lastObjectId.IsEmpty() ) )
03419 {
03420 a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( id.IsEmpty() ? m_lastObjectId : id );
03421
03422 if( obj == m_objecthashmap.end() )
03423 {
03424 a2dResolveIdInfo* a = new a2dResolveIdInfo( id.IsEmpty() ? m_lastObjectId : id, storedHere );
03425 m_toResolve.Append( a );
03426 if( id.IsEmpty() )
03427 m_lastObjectId.Empty();
03428 return false;
03429 }
03430
03431
03432 *storedHere = wxDynamicCast( obj->second, a2dObject );
03433 if( id.IsEmpty() )
03434 m_lastObjectId.Empty();
03435 return true;
03436 }
03437 return false;
03438 }
03439
03440 bool a2dIOHandler::ResolveOrAddLink( a2dObject *owner, const wxString &id )
03441 {
03442 if ( owner && ( !id.IsEmpty() || !m_lastObjectId.IsEmpty() ) )
03443 {
03444 a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( id.IsEmpty() ? m_lastObjectId : id );
03445
03446 if( obj == m_objecthashmap.end() )
03447 {
03448 a2dResolveIdInfo* a = new a2dResolveIdInfo( id.IsEmpty() ? m_lastObjectId : id, owner );
03449 m_toResolve.Append( a );
03450 if( id.IsEmpty() )
03451 m_lastObjectId.Empty();
03452 return false;
03453 }
03454
03455
03456 owner->LinkReference( obj->second );
03457 if( id.IsEmpty() )
03458 m_lastObjectId.Empty();
03459 return true;
03460 }
03461 return false;
03462 }
03463
03464 void a2dIOHandler::ResolveInform( a2dObject *obj )
03465 {
03466 a2dResolveIdInfo* a = new a2dResolveIdInfo( obj );
03467 m_toResolve.Append( a );
03468 }
03469
03470 void a2dIOHandler::SetLastObjectLoadedId( const wxString& lastid )
03471 {
03472 wxASSERT_MSG( m_lastObjectId.IsEmpty(), wxT("last refid not resolved") );
03473 m_lastObjectId = lastid;
03474 }
03475
03476 bool a2dIOHandler::LinkReferences()
03477 {
03478 a2dResolveIdList::compatibility_iterator node = m_toResolve.GetFirst();
03479 while (node)
03480 {
03481 a2dResolveIdList::compatibility_iterator delnode = node;
03482 node = node->GetNext();
03483 wxString toLinkName = delnode->GetData()->m_idStr;
03484 a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( toLinkName );
03485 if( obj != m_objecthashmap.end() )
03486 {
03487 delnode->GetData()->Assign( obj->second );
03488 m_toResolve.DeleteNode( delnode );
03489 }
03490 else
03491 #if wxCHECK_VERSION(2,9,0)
03492 wxLogWarning( wxT("%s%s"), _("Reference not resolved: "), toLinkName );
03493 #else
03494 wxLogWarning( wxT("%s%s"), _("Reference not resolved: "), toLinkName.c_str() );
03495 #endif //wxCHECK_VERSION(2,9,0)
03496
03497 }
03498 return true;
03499 }
03500
03501
03502
03503
03504 a2dIOHandlerStrIn::a2dIOHandlerStrIn( wxMBConv& conv ): m_conv(conv)
03505 {
03506 m_mode = wxEOL_NATIVE;
03507 if (m_mode == wxEOL_NATIVE)
03508 {
03509 #if defined(__WXMSW__) || defined(__WXPM__)
03510 m_mode = wxEOL_DOS;
03511 #elif defined(__WXMAC__) && !defined(__DARWIN__)
03512 m_mode = wxEOL_MAC;
03513 #else
03514 m_mode = wxEOL_UNIX;
03515 #endif
03516 }
03517 }
03518
03519 a2dIOHandlerStrIn::~a2dIOHandlerStrIn()
03520 {
03521 wxASSERT_MSG( m_refcount == 0, wxT("deleting a2dDocument while referenced") );
03522 }
03523
03524 void a2dIOHandlerStrIn::InitializeLoad()
03525 {
03526 m_objecthashmap.clear();
03527 m_toResolve.Clear();
03528 }
03529
03530 void a2dIOHandlerStrIn::ResetLoad()
03531 {
03532 m_objecthashmap.clear();
03533 m_toResolve.Clear();
03534 }
03535
03536 char a2dIOHandlerStrIn::Peek()
03537 {
03538 #if wxUSE_STD_IOSTREAM
03539 return m_streami->peek();
03540 #else
03541 return m_streami->Peek();
03542 #endif
03543 }
03544
03545 char a2dIOHandlerStrIn::GetC()
03546 {
03547 #if wxUSE_STD_IOSTREAM
03548 return m_streami->get();
03549 #else
03550 return m_streami->GetC();
03551 #endif
03552 }
03553
03554 bool a2dIOHandlerStrIn::Eof() const
03555 {
03556 #if wxUSE_STD_IOSTREAM
03557 if (m_streami->eof())
03558 #else
03559 if (m_streami->Eof())
03560 #endif
03561 return true;
03562 return false;
03563 }
03564
03565 bool a2dIOHandlerStrIn::IsOk() const
03566 {
03567 #if wxUSE_STD_IOSTREAM
03568 return ( m_streami->fail() || m_streami->bad());
03569 #else
03570 return ( m_streami->IsOk() );
03571 #endif
03572 }
03573
03574 a2dIOHandlerStrIn& a2dIOHandlerStrIn::SeekI( wxFileOffset pos )
03575 {
03576 #if wxUSE_STD_IOSTREAM
03577 m_streami->clear();
03578 m_streami->seekg( pos, wxSTD ios::beg );
03579 #else
03580 m_streami->SeekI( pos );
03581 #endif
03582 return *this;
03583 }
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598 size_t a2dIOHandlerStrIn::Read( char* buffer, size_t size)
03599 {
03600 #if wxUSE_STD_IOSTREAM
03601 m_streami->read( buffer, size);
03602 size_t len = m_streami->gcount();
03603 #else
03604 size_t len = m_streami->Read( buffer, size).LastRead();
03605 #endif
03606 return len;
03607 }
03608
03609
03610 void a2dIOHandlerStrIn::SetMode(wxEOL mode)
03611 {
03612 m_mode = mode;
03613 if (m_mode == wxEOL_NATIVE)
03614 {
03615 #if defined(__WXMSW__) || defined(__WXPM__)
03616 m_mode = wxEOL_DOS;
03617 #elif defined(__WXMAC__) && !defined(__DARWIN__)
03618 m_mode = wxEOL_MAC;
03619 #else
03620 m_mode = wxEOL_UNIX;
03621 #endif
03622 }
03623 }
03624
03625
03626
03627
03628 a2dIOHandlerStrOut::a2dIOHandlerStrOut( wxMBConv& conv ): m_conv(conv)
03629 {
03630 m_mode = wxEOL_NATIVE;
03631 if (m_mode == wxEOL_NATIVE)
03632 {
03633 #if defined(__WXMSW__) || defined(__WXPM__)
03634 m_mode = wxEOL_DOS;
03635 #elif defined(__WXMAC__) && !defined(__DARWIN__)
03636 m_mode = wxEOL_MAC;
03637 #else
03638 m_mode = wxEOL_UNIX;
03639 #endif
03640 }
03641 }
03642
03643 a2dIOHandlerStrOut::~a2dIOHandlerStrOut()
03644 {
03645 }
03646
03647 void a2dIOHandlerStrOut::InitializeSave()
03648 {
03649 m_objecthashmap.clear();
03650 m_toResolve.Clear();
03651 }
03652
03653 void a2dIOHandlerStrOut::ResetSave()
03654 {
03655 m_objecthashmap.clear();
03656 m_toResolve.Clear();
03657 }
03658
03659 void a2dIOHandlerStrOut::WriteString(const wxString& string )
03660 {
03661 size_t len = string.length();
03662
03663 wxString out;
03664 out.reserve(len);
03665
03666 if ( m_mode != wxEOL_UNIX )
03667 {
03668 for ( size_t i = 0; i < len; i++ )
03669 {
03670 const wxChar c = string[i];
03671 if ( c == wxT('\n') )
03672 {
03673 switch ( m_mode )
03674 {
03675 case wxEOL_DOS:
03676 out << _T("\r\n");
03677 continue;
03678
03679 case wxEOL_MAC:
03680 out << _T('\r');
03681 continue;
03682
03683 default:
03684 wxFAIL_MSG( _T("unknown EOL mode in a2dIOHandlerStrOut") );
03685
03686
03687 case wxEOL_UNIX:
03688
03689 ;
03690 }
03691 }
03692
03693 out << c;
03694 }
03695 }
03696 else
03697 out = string;
03698
03699 #if wxUSE_STD_IOSTREAM
03700
03701
03702 #if wxUSE_UNICODE
03703 #if !wxUSE_WSTREAM
03704
03705 wxString str2(out.wc_str(wxConvLocal ), m_conv);
03706 m_streamo->write(str2.mb_str(), str2.Len());
03707 #else
03708 m_streamo->write( out, len );
03709 #endif
03710 #else
03711 m_streamo->write(out.c_str(), out.length() );
03712 #endif
03713
03714 #else
03715
03716 #if wxUSE_UNICODE
03717 wxCharBuffer buffer = m_conv.cWC2MB( out );
03718 m_streamo->Write( (const char*) buffer, strlen( (const char*) buffer ) );
03719 #else
03720
03721 wxString str2(out.wc_str(wxConvLocal ), m_conv);
03722 m_streamo->Write(str2.mb_str(), str2.Len());
03723 #endif
03724
03725 #endif
03726 }
03727
03728 void a2dIOHandlerStrOut::Write32(wxUint32 i)
03729 {
03730 wxString str;
03731 str.Printf(wxT("%u"), i);
03732
03733 WriteString(str);
03734 }
03735
03736 void a2dIOHandlerStrOut::Write16(wxUint16 i)
03737 {
03738 wxString str;
03739 str.Printf(wxT("%u"), i);
03740
03741 WriteString(str);
03742 }
03743
03744 void a2dIOHandlerStrOut::Write8(wxUint8 i)
03745 {
03746 wxString str;
03747 str.Printf(wxT("%u"), i);
03748
03749 WriteString(str);
03750 }
03751
03752 void a2dIOHandlerStrOut::WriteDouble(double d)
03753 {
03754 wxString str;
03755
03756 str.Printf(wxT("%f"), d);
03757 WriteString(str);
03758 }
03759
03760 bool a2dIOHandlerStrOut::IsOk() const
03761 {
03762 #if wxUSE_STD_IOSTREAM
03763 return ( m_streamo->fail() || m_streamo->bad()) == 0;
03764 #else
03765 return ( m_streamo->IsOk() );
03766 #endif
03767 }
03768
03769 a2dIOHandlerStrOut& a2dIOHandlerStrOut::PutChar(wxChar c)
03770 {
03771 WriteString( wxString(&c, m_conv, 1) );
03772 return *this;
03773 }
03774
03775
03776
03777
03778
03779 extern a2dWalkEvent a2dWalker_a2dObjectStart = wxNewId();
03780 extern a2dWalkEvent a2dWalker_a2dObjectEnd = wxNewId();
03781 extern a2dWalkEvent a2dWalker_a2dPropObjectStart = wxNewId();
03782 extern a2dWalkEvent a2dWalker_a2dPropObjectEnd = wxNewId();
03783 extern a2dWalkEvent a2dWalker_a2dNamedPropertyListStart = wxNewId();
03784 extern a2dWalkEvent a2dWalker_a2dNamedPropertyListEnd = wxNewId();
03785 extern a2dWalkEvent a2dWalker_a2dNamedPropertyStart = wxNewId();
03786 extern a2dWalkEvent a2dWalker_a2dNamedPropertyEnd = wxNewId();
03787
03788 extern a2dWalkEvent a2dWalker_a2dCanvasObjectStart = wxNewId();
03789 extern a2dWalkEvent a2dWalker_a2dCanvasObjectProperties = wxNewId();
03790 extern a2dWalkEvent a2dWalker_a2dCanvasObjectPreChild = wxNewId();
03791 extern a2dWalkEvent a2dWalker_a2dCanvasObjectPostChild = wxNewId();
03792 extern a2dWalkEvent a2dWalker_a2dCanvasObjectEnd = wxNewId();
03793 extern a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectStart = wxNewId();
03794 extern a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectEnd = wxNewId();
03795
03796 a2dWalkerIOHandler::a2dWalkerIOHandler()
03797 {
03798 m_useCheck = false;
03799 m_depthFirst = false;
03800 Initialize();
03801 }
03802
03803 a2dWalkerIOHandler::~a2dWalkerIOHandler()
03804 {
03805 }
03806
03807 void a2dWalkerIOHandler::Initialize()
03808 {
03809 m_currentDepth = 0;
03810 m_currentParent = NULL;
03811 m_stopWalking = false;
03812 m_result = false;
03813 }
03814
03815 bool a2dWalkerIOHandler::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
03816 {
03817 a2dObjectIOFn* function = m_register.find( object->GetClassInfo()->GetClassName() )->second;
03818
03819 if ( function )
03820 {
03821 (*function)( parent, object, event );
03822 return true;
03823 }
03824 return false;
03825 }
03826
03827
03828
03829
03830
03831 a2dPropertyIdString* a2dPropObject::PROPID_Name = NULL;
03832 a2dPropertyIdString* a2dPropObject::PROPID_URL = NULL;
03833 a2dPropertyIdVoidPtr* a2dPropObject::PROPID_autozeroptrlist = NULL;
03834
03835 INITIALIZE_PROPERTIES( a2dPropObject, a2dObject )
03836 {
03837 A2D_PROPID_D_F( a2dPropertyIdString, URL, wxT(""), a2dPropertyId::flag_isEditable );
03838 A2D_PROPID_D_F( a2dPropertyIdString, Name, wxT(""), a2dPropertyId::flag_isEditable );
03839 A2D_PROPID_D( a2dPropertyIdVoidPtr, autozeroptrlist, 0 );
03840 return true;
03841 }
03842
03843 DEFINE_EVENT_TYPE( a2dPropObject::sm_Edit_properties )
03844
03845 a2dPropObject::a2dPropObject()
03846 {
03847 }
03848
03849 a2dPropObject::~a2dPropObject()
03850 {
03851 }
03852
03853 a2dObject* a2dPropObject::Clone( CloneOptions options ) const
03854 {
03855 return new a2dPropObject( *this, options );
03856 }
03857
03858 a2dPropObject::a2dPropObject( const a2dPropObject &other, CloneOptions options )
03859 : a2dObject( other )
03860 {
03861 a2dNamedPropertyList::const_iterator iter;
03862 for( iter = other.m_propertylist.begin(); iter != other.m_propertylist.end(); ++iter )
03863 {
03864 const a2dNamedProperty *prop = *iter;
03865
03866 m_propertylist.push_back( prop->Clone( options ) );
03867 }
03868
03869 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
03870
03871 CurrentSmartPointerOwner = this;
03872 #endif
03873 }
03874
03875 bool a2dPropObject::EditProperties( const a2dPropertyId* id, bool withUndo )
03876 {
03877 a2dNamedPropertyList allprops;
03878
03879 CollectProperties2( &allprops, id, a2dPropertyId::flag_none );
03880
03881 bool res = false;
03882
03883 a2dPropertyEditEvent event( this, &allprops );
03884 event.SetEventObject( this );
03885
03886
03887 if ( ! ProcessEvent( event ) )
03888
03889 a2dGeneralGlobals->GetEventDistributer()->ProcessEvent( event );
03890
03891 if ( event.GetEdited() && !allprops.empty() )
03892 {
03893 res = true;
03894 a2dNamedPropertyList::iterator iter;
03895 for( iter = allprops.begin(); iter != allprops.end(); ++iter )
03896 {
03897 a2dNamedProperty *prop = *iter;
03898 prop->SetToObject( this );
03899 }
03900 }
03901
03902 return res;
03903 }
03904
03905 void a2dPropObject::TakeOverProperties( a2dPropObject* from, a2dPropertyIdList* listOfIds )
03906 {
03907 if ( !listOfIds )
03908 return;
03909
03910 forEachIn( a2dPropertyIdList, listOfIds )
03911 {
03912 a2dPropertyId *id = *iter;
03913 a2dNamedProperty *property = from->GetProperty( id );
03914 if ( property )
03915 property->SetToObject( this );
03916 }
03917 }
03918
03919 bool a2dPropObject::AddProperty( a2dNamedProperty *property )
03920 {
03921 m_propertylist.push_back( property );
03922 return true;
03923 }
03924
03925 a2dNamedProperty* a2dPropObject::FindProperty( const a2dPropertyId* id, a2dPropertyId::Flags flags )
03926 {
03927 a2dNamedPropertyList::iterator iter;
03928 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
03929 {
03930 a2dNamedProperty *prop = *iter;
03931 if ( id->CheckCollect( prop->GetId(), flags ) )
03932 return prop;
03933 }
03934
03935 return NULL;
03936 }
03937
03938 const a2dNamedProperty* a2dPropObject::FindProperty( const a2dPropertyId* id, a2dPropertyId::Flags flags ) const
03939 {
03940 a2dNamedPropertyList::const_iterator iter;
03941 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
03942 {
03943 const a2dNamedProperty *prop = *iter;
03944 if ( id->CheckCollect( prop->GetId(), flags ) )
03945 return prop;
03946 }
03947
03948 return NULL;
03949 }
03950
03951 bool a2dPropObject::RemoveProperty( const a2dPropertyId* id, bool all )
03952 {
03953 if( m_propertylist.Remove( id, all ) )
03954 {
03955 OnPropertyChanged( id );
03956 return true;
03957 }
03958 else
03959 return false;
03960 }
03961
03962 void a2dPropObject::RemoveTemporaryProperties( )
03963 {
03964 m_propertylist.RemoveTemporary();
03965 }
03966
03967 void a2dPropObject::SetURL( const wxString& url )
03968 {
03969 PROPID_URL->SetPropertyToObject( this, url );
03970 }
03971
03972 wxString a2dPropObject::GetURL() const
03973 {
03974 return PROPID_URL->GetPropertyValue( this );
03975 }
03976
03977 void a2dPropObject::SetName(const wxString& name)
03978 {
03979 PROPID_Name->SetPropertyToObject( this, name );
03980 }
03981
03982 wxString a2dPropObject::GetName() const
03983 {
03984
03985 const a2dNamedProperty *p = FindProperty( PROPID_Name );
03986 if (p)
03987 return p->StringValueRepresentation();
03988 return a2dObject::GetName();
03989 }
03990
03991 #if wxART2D_USE_CVGIO
03992
03993 void a2dPropObject::DoSave( wxObject* WXUNUSED(parent), a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList* towrite )
03994 {
03995 if ( xmlparts == a2dXmlSer_attrib )
03996 {
03997 a2dObject::DoSave( this, out, xmlparts, towrite);
03998 }
03999 else
04000 {
04001 a2dObject::DoSave( this, out, xmlparts, towrite);
04002
04003 if ( !m_propertylist.empty() )
04004 {
04005 out.WriteNewLine();
04006 out.WriteStartElement( wxT("properties") );
04007
04008 a2dNamedPropertyList::iterator iter;
04009 for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
04010 {
04011 a2dNamedProperty *prop = *iter;
04012
04013 if( !prop->GetId()->IsTemporary() )
04014 {
04015 prop->Save( this, out, towrite );
04016 }
04017 }
04018
04019 out.WriteEndElement();
04020 out.WriteNewLine();
04021 }
04022 }
04023 }
04024
04025 void a2dPropObject::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
04026 {
04027 a2dObject::DoLoad( parent, parser, xmlparts );
04028
04029 if ( xmlparts == a2dXmlSer_attrib )
04030 {
04031 }
04032 else
04033 {
04034 if ( parser.GetTagName() == wxT("properties") )
04035 {
04036 parser.Next();
04037 while( parser.GetTagName() == wxT("o") )
04038 {
04039 wxString classname = parser.GetAttributeValue( wxT("classname") );
04040 wxObject *obj = parser.CreateObject( classname );
04041 a2dNamedProperty *property = wxDynamicCast( obj, a2dNamedProperty );
04042 if ( !property )
04043 {
04044 a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dNamedProperty %s, will be skipped line %d"),
04045 classname.c_str(), parser.GetCurrentLineNumber() );
04046 parser.SkipSubTree();
04047 parser.Require( END_TAG, wxT("o") );
04048 parser.Next();
04049 }
04050 else
04051 {
04052 property->Load( this, parser );
04053 property->SetToObject( this );
04054 }
04055 }
04056
04057 parser.Require( END_TAG, wxT("properties") );
04058 parser.Next();
04059 }
04060 }
04061 }
04062
04063 #endif //wxART2D_USE_CVGIO
04064
04065 void a2dPropObject::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
04066 {
04067 handler.WalkTask( parent, this, a2dWalker_a2dPropObjectStart );
04068
04069 if ( !handler.GetStopWalking() )
04070 {
04071 m_propertylist.Walker( this, handler );
04072 }
04073 handler.WalkTask( parent, this, a2dWalker_a2dPropObjectEnd );
04074 }
04075
04076
04077
04078 wxColour HexToColour(const wxString& hex)
04079 {
04080 if (hex.Length() == 6)
04081 {
04082 long r, g, b;
04083 r = g = b = 0;
04084 hex.Mid(0,2).ToLong(&r, 16);
04085 hex.Mid(2,2).ToLong(&g, 16);
04086 hex.Mid(4,2).ToLong(&b, 16);
04087 return wxColour(r, g, b);
04088 }
04089 else
04090 return wxColour(0,0,0);
04091 }
04092
04093
04094 wxString ColourToHex(const wxColour& colour)
04095 {
04096 wxChar buf[7];
04097 unsigned int red = colour.Red();
04098 unsigned int green = colour.Green();
04099 unsigned int blue = colour.Blue();
04100
04101 wxDecToHex(red, buf);
04102 wxDecToHex(green, buf+2);
04103 wxDecToHex(blue, buf+4);
04104
04105 return wxString(buf);
04106 }
04107
04108
04109
04110