00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "a2dprec.h"
00012
00013 #ifdef __BORLANDC__
00014 #pragma hdrstop
00015 #endif
00016
00017 #ifndef WX_PRECOMP
00018 #include "wx/wx.h"
00019 #endif
00020
00021 #include "wx/canvas/canprop.h"
00022 #include "wx/canvas/canglob.h"
00023 #include "wx/canvas/candoc.h"
00024 #include "wx/canvas/cancom.h"
00025 #include "wx/canvas/drawer.h"
00026 #include "wx/canvas/polygon.h"
00027
00028 #include <wx/tokenzr.h>
00029
00030 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
00031 #include <wx/msw/msvcrt.h>
00032 #endif
00033
00034 IMPLEMENT_DYNAMIC_CLASS(a2dStyleProperty,a2dNamedProperty)
00035 IMPLEMENT_DYNAMIC_CLASS(a2dShadowStyleProperty,a2dNamedProperty)
00036 IMPLEMENT_DYNAMIC_CLASS(a2dClipPathProperty,a2dNamedProperty)
00037 IMPLEMENT_DYNAMIC_CLASS(a2dCanvasObjectPtrProperty,a2dNamedProperty)
00038
00039
00040
00041
00042 #if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
00043
00044 template class a2dPropertyIdProp<class a2dClipPathProperty>;
00045
00046 #endif // (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
00047
00048
00049
00050
00051 a2dStyleProperty::a2dStyleProperty( )
00052 :a2dNamedProperty()
00053 {
00054
00055 m_fill = *a2dNullFILL;
00056 m_stroke = *a2dNullSTROKE;
00057 }
00058
00059 a2dStyleProperty::a2dStyleProperty( const a2dPropertyId* id )
00060 :a2dNamedProperty( id )
00061 {
00062
00063 m_fill = *a2dNullFILL;
00064 m_stroke = *a2dNullSTROKE;
00065 }
00066
00067 a2dStyleProperty::~a2dStyleProperty()
00068 {
00069 }
00070
00071 a2dStyleProperty::a2dStyleProperty( const a2dStyleProperty &other)
00072 :a2dNamedProperty( other )
00073 {
00074 m_fill = other.m_fill;
00075 m_stroke = other.m_stroke;
00076 }
00077
00078 a2dNamedProperty* a2dStyleProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
00079 {
00080 return new a2dStyleProperty( *this );
00081 };
00082
00083 void a2dStyleProperty::Assign( const a2dNamedProperty &other )
00084 {
00085 a2dStyleProperty *propcast = wxStaticCast( &other, a2dStyleProperty);
00086 m_stroke = propcast->m_stroke;
00087 m_fill = propcast->m_fill;
00088 }
00089
00090 wxString a2dStyleProperty::StringRepresentation() const
00091 {
00092 return GetName() + wxT(" = ") + StringValueRepresentation();
00093 }
00094
00095 wxString a2dStyleProperty::StringValueRepresentation() const
00096 {
00097 wxString s;
00098 s = s + wxT("fill ");
00099 s = s + wxT("stroke ");
00100 return s;
00101 }
00102
00103 bool a2dStyleProperty::AllNo()
00104 {
00105 if ( m_fill.IsNoFill() && m_stroke.IsNoStroke() )
00106 return true;
00107 return false;
00108 }
00109
00110 void a2dStyleProperty::SetFill( const a2dFill& fill )
00111 {
00112 m_fill = fill;
00113 }
00114
00115 void a2dStyleProperty::SetFill( const wxColour& fillcolor, a2dFillStyle style )
00116 {
00117 m_fill = a2dFill( fillcolor, style );
00118 }
00119
00120 void a2dStyleProperty::SetFill( const wxColour& fillcolor, const wxColour& fillcolor2, a2dFillStyle style )
00121 {
00122 m_fill = a2dFill( fillcolor, fillcolor2, style );
00123 }
00124
00125
00126 void a2dStyleProperty::SetStroke( const wxColour& strokecolor, float width, a2dStrokeStyle style )
00127 {
00128 m_stroke = a2dStroke( strokecolor, width, style );
00129 }
00130
00131 void a2dStyleProperty::SetStroke( const wxColour& strokecolor, int width, a2dStrokeStyle style )
00132 {
00133 m_stroke = a2dStroke( strokecolor, width, style );
00134 }
00135
00136 void a2dStyleProperty::SetStroke( const a2dStroke& stroke )
00137 {
00138 m_stroke = stroke;
00139 }
00140
00141 #if wxART2D_USE_CVGIO
00142 void a2dStyleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00143 {
00144 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
00145 if ( xmlparts == a2dXmlSer_attrib )
00146 {
00147 }
00148 else
00149 {
00150 if ( !m_fill.IsNoFill() )
00151 m_fill.Save( parent, out, towrite );
00152
00153 if ( !m_stroke.IsNoStroke() )
00154 m_stroke.Save( parent, out, towrite );
00155 }
00156 }
00157
00158 void a2dStyleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag WXUNUSED(xmlparts) )
00159 {
00160 parser.Next();
00161
00162 if ( parser.GetTagName() == wxT("fill") )
00163 {
00164 if ( parser.GetAttributeValue( wxT("style") ) == wxT("inherit") )
00165 {
00166 m_fill = *a2dINHERIT_FILL;
00167 parser.Next();
00168 parser.Require( END_TAG, wxT("fill") );
00169 parser.Next();
00170 }
00171 else
00172 {
00173 a2dFill* fill = (a2dFill*) parser.CreateObject( parser.GetAttributeValue( wxT("classname") ) );
00174 wxASSERT_MSG( fill, wxT("wrong a2dFill") );
00175 fill->Load( parent, parser );
00176 m_fill = *fill;
00177 delete fill;
00178 }
00179 }
00180
00181 if ( parser.GetTagName() == wxT("stroke") )
00182 {
00183 if ( parser.GetAttributeValue( wxT("style") ) == wxT("inherit") )
00184 {
00185 m_stroke = *a2dINHERIT_STROKE;
00186 parser.Next();
00187 parser.Require( END_TAG, wxT("stroke") );
00188 parser.Next();
00189 }
00190 else
00191 {
00192 a2dStroke* stroke = (a2dStroke*) parser.CreateObject( parser.GetAttributeValue( wxT("classname") ) );
00193 wxASSERT_MSG( stroke, wxT("wrong a2dStroke") );
00194 stroke->Load( parent, parser );
00195 m_stroke = *stroke;
00196 delete stroke;
00197 }
00198 }
00199 }
00200 #endif //wxART2D_USE_CVGIO
00201
00202
00203
00204
00205
00206 a2dShadowStyleProperty::a2dShadowStyleProperty()
00207 :a2dStyleProperty()
00208 {
00209 m_depth = 0;
00210 m_angle3d = 30;
00211 }
00212
00213 a2dShadowStyleProperty::a2dShadowStyleProperty( const a2dPropertyIdCanvasShadowStyle* id, double depth, double angle )
00214 :a2dStyleProperty( id )
00215 {
00216 m_depth = depth;
00217 m_angle3d = angle;
00218 }
00219
00220
00221 a2dShadowStyleProperty::~a2dShadowStyleProperty()
00222 {
00223 }
00224
00225 a2dShadowStyleProperty::a2dShadowStyleProperty( const a2dShadowStyleProperty &other)
00226 :a2dStyleProperty( other )
00227 {
00228 m_depth = other.m_depth;
00229 m_angle3d = other.m_angle3d;
00230 }
00231
00232 a2dNamedProperty* a2dShadowStyleProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
00233 {
00234 return new a2dShadowStyleProperty(*this);
00235 };
00236
00237 #if wxART2D_USE_CVGIO
00238 void a2dShadowStyleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00239 {
00240 a2dStyleProperty::DoSave( parent, out, xmlparts, towrite );
00241 if ( xmlparts == a2dXmlSer_attrib )
00242 {
00243 out.WriteAttribute( wxT("depth"), m_depth );
00244 out.WriteAttribute( wxT("angle"), m_angle3d );
00245 }
00246 else
00247 {
00248 }
00249 }
00250
00251
00252 void a2dShadowStyleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00253 {
00254 a2dStyleProperty::DoLoad( parent, parser, xmlparts );
00255 if ( xmlparts == a2dXmlSer_attrib )
00256 {
00257 m_depth = parser.GetAttributeValueDouble( wxT("depth") );
00258 m_angle3d = parser.GetAttributeValueDouble( wxT("angle") );
00259 }
00260 else
00261 {
00262 }
00263 }
00264 #endif //wxART2D_USE_CVGIO
00265
00266
00267
00268
00269
00270
00271 a2dClipPathProperty::a2dClipPathProperty()
00272 :a2dNamedProperty()
00273 {
00274 m_clip = 0;
00275 m_visible = false;
00276 m_render = true;
00277 }
00278
00279 a2dClipPathProperty::a2dClipPathProperty( const a2dPropertyIdCanvasClipPath* id, a2dPolygonL* clip )
00280 :a2dNamedProperty( id )
00281 {
00282 m_clip = clip;
00283 m_visible = false;
00284 m_render = true;
00285 }
00286
00287 a2dClipPathProperty::~a2dClipPathProperty()
00288 {
00289 }
00290
00291 a2dClipPathProperty::a2dClipPathProperty( const a2dClipPathProperty &other, a2dObject::CloneOptions options )
00292 :a2dNamedProperty( other )
00293 {
00294 if ( options & a2dObject::clone_members )
00295 {
00296 if ( other.m_clip )
00297 m_clip = (a2dPolygonL*) other.m_clip->TClone( options );
00298 }
00299 else
00300 m_clip = other.m_clip;
00301
00302 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00303
00304 CurrentSmartPointerOwner = this;
00305 #endif
00306 }
00307
00308 a2dNamedProperty* a2dClipPathProperty::Clone( a2dObject::CloneOptions options ) const
00309 {
00310 return new a2dClipPathProperty( *this, options );
00311 };
00312
00313 void a2dClipPathProperty::Assign( const a2dNamedProperty &other )
00314 {
00315 a2dClipPathProperty *propcast = wxStaticCast( &other, a2dClipPathProperty);
00316 m_clip = propcast->m_clip;
00317 m_visible = propcast->m_visible;
00318 m_render = propcast->m_render;
00319 }
00320
00321 a2dObject* a2dClipPathProperty::GetRefObject() const {
00322 return m_clip;
00323 }
00324
00325 a2dObject* a2dClipPathProperty::GetRefObjectNA() const {
00326 return m_clip;
00327 }
00328
00329 void a2dClipPathProperty::SetCanvasObject( a2dPolygonL* clip )
00330 {
00331 m_clip = (a2dPolygonL*) clip;
00332 }
00333
00334 void a2dClipPathProperty::DoWalker( wxObject *parent, a2dWalkerIOHandler& handler )
00335 {
00336 if ( m_clip && GetCanRender() )
00337 m_clip->Walker( this, handler );
00338 }
00339
00340 #if wxART2D_USE_CVGIO
00341 void a2dClipPathProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00342 {
00343 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
00344 if ( xmlparts == a2dXmlSer_attrib )
00345 {
00346 out.WriteAttribute( wxT("clippath"), GetName() );
00347 }
00348 else
00349 {
00350 if ( m_clip )
00351 m_clip->Save( this, out, towrite );
00352 }
00353 }
00354
00355 void a2dClipPathProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00356 {
00357 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
00358 if ( xmlparts == a2dXmlSer_attrib )
00359 {
00360 wxString clipobject = parser.GetAttributeValue( wxT("clippath") );
00361 if ( clipobject != wxT("") )
00362 {
00363
00364
00365 }
00366 }
00367 else
00368 {
00369 parser.Require( START_TAG, wxT("o") );
00370 wxString classname = parser.GetAttributeValue( wxT("classname") );
00371
00372 if ( classname == wxT("ref") )
00373 {
00374 parser.SkipSubTree();
00375 parser.Require( END_TAG, wxT("o") );
00376 parser.Next();
00377 }
00378 else
00379 {
00380 a2dPolygonL* object = (a2dPolygonL*) parser.CreateObject( classname );
00381 if ( !object )
00382 {
00383 wxLogError(wxT("could not create a2dPolygonL from %s, will be skipped line %d"),
00384 classname.c_str(), parser.GetCurrentLineNumber() );
00385 parser.SkipSubTree();
00386 parser.Require( END_TAG, wxT("o") );
00387 parser.Next();
00388 }
00389 else
00390 {
00391 m_clip = object;
00392 m_clip->Load( this, parser );
00393 }
00394 }
00395 }
00396
00397 }
00398 #endif //wxART2D_USE_CVGIO
00399
00400 void a2dClipPathProperty::PushClip( a2dCanvasView* drawer, a2dBooleanClip clipoperation )
00401 {
00402 if ( m_clip )
00403 drawer->GetDrawer2D()->ExtendAndPushClippingRegion( m_clip->GetSegments(), m_clip->GetSpline(), m_clip->GetFillRule(), clipoperation );
00404 }
00405
00406 void a2dClipPathProperty::PopClip( a2dCanvasView* drawer )
00407 {
00408 if ( m_clip )
00409 {
00410 drawer->GetDrawer2D()->PopClippingRegion();
00411 }
00412 }
00413
00414
00415
00416
00417 A2D_BEGIN_EVENT_TABLE( a2dVisibleProperty, a2dText )
00418 A2D_EVT_CANVASOBJECT_MOUSE_EVENT( a2dVisibleProperty::OnMouseEvent )
00419 A2D_EVT_CHAR( a2dVisibleProperty::OnChar )
00420 A2D_END_EVENT_TABLE()
00421
00422 IMPLEMENT_DYNAMIC_CLASS(a2dVisibleProperty, a2dText);
00423
00424 a2dVisibleProperty::a2dVisibleProperty()
00425 :a2dText()
00426 {
00427 m_flags.m_visible = false;
00428 m_flags.m_prerenderaschild = false;
00429 m_flags.m_subEditAsChild = true;
00430 m_propId = NULL;
00431 m_showname = true;
00432 m_parent = NULL;
00433 }
00434
00435 a2dVisibleProperty::a2dVisibleProperty( a2dCanvasObject* parent, const a2dPropertyId* propertyId, double x, double y, double angle )
00436 :a2dText( wxT(""), x, y, *a2dDEFAULT_CANVASFONT, angle )
00437 {
00438 m_flags.m_visible = true;
00439 m_flags.m_prerenderaschild = false;
00440 m_flags.m_subEditAsChild = true;
00441 m_parent = parent;
00442 m_propId = propertyId;
00443 m_showname = true;
00444 }
00445
00446 a2dVisibleProperty::a2dVisibleProperty( a2dCanvasObject* parent, const a2dPropertyId* propertyId, double x, double y, bool visible, const a2dFont& font, double angle )
00447 :a2dText( wxT(""), x, y, font, angle )
00448 {
00449 m_flags.m_visible = visible;
00450 m_flags.m_prerenderaschild = false;
00451 m_flags.m_subEditAsChild = true;
00452 m_parent = parent;
00453 m_propId = propertyId;
00454 m_showname = true;
00455 }
00456
00457 a2dVisibleProperty::~a2dVisibleProperty()
00458 {
00459 }
00460
00461 a2dVisibleProperty::a2dVisibleProperty( const a2dVisibleProperty& other, CloneOptions options)
00462 :a2dText( other, options )
00463 {
00464 m_propId = other.m_propId;
00465 m_parent = other.m_parent;
00466 m_showname = other.m_showname;
00467 }
00468
00469 void a2dVisibleProperty::ShowName( bool show )
00470 {
00471 m_showname = show;
00472 SetPending( true );
00473 }
00474
00475 void a2dVisibleProperty::SetParent( a2dCanvasObject* parent )
00476 {
00477 m_parent = parent;
00478 SetPending( true );
00479 }
00480
00481 a2dObject* a2dVisibleProperty::Clone( CloneOptions options ) const
00482 {
00483 return new a2dVisibleProperty( *this, options );
00484 };
00485
00486 void a2dVisibleProperty::OnMouseEvent(a2dCanvasObjectMouseEvent &event)
00487 {
00488 event.Skip();
00489 }
00490
00491 void a2dVisibleProperty::DoEndEdit()
00492 {
00493 a2dNamedProperty* property = m_propId->CreatePropertyFromString( m_text.Mid( m_firsteditable ) );
00494 m_root->GetCommandProcessor()->Submit( new a2dCommand_SetCanvasProperty( m_parent, property ) );
00495
00496 a2dText::DoEndEdit();
00497 }
00498
00499 void a2dVisibleProperty::OnChar(wxKeyEvent& event)
00500 {
00501
00502
00503
00504
00505
00506
00507 wxString text = m_text;
00508
00509 a2dText::OnChar( event );
00510 if ( m_flags.m_editingCopy )
00511 {
00512
00513 }
00514 }
00515
00516 bool a2dVisibleProperty::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
00517 {
00518 if ( !m_bbox.GetValid() )
00519 {
00520 if ( m_showname )
00521 m_text = m_propId->GetName() + wxT(" = ");
00522 else
00523 m_text = wxEmptyString;
00524 m_firsteditable = m_text.Length();
00525 if ( m_caret < m_firsteditable )
00526 m_caret = m_firsteditable;
00527 a2dNamedPropertyPtr property = m_parent->GetProperty( m_propId );
00528 if ( property )
00529 m_text = m_text + property->StringValueRepresentation();
00530 m_utbbox_changed = true;
00531 }
00532
00533 return a2dText::DoUpdate( mode, childbox, clipbox, propbox );
00534 }
00535
00536 #if wxART2D_USE_CVGIO
00537 void a2dVisibleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00538 {
00539 a2dText::DoSave( parent, out, xmlparts, towrite );
00540
00541 if ( xmlparts == a2dXmlSer_attrib )
00542 {
00543 out.WriteAttribute( wxT("showname"), m_showname, true );
00544 out.WriteAttribute( wxT("propertyId"), m_propId->GetName() );
00545 }
00546 else
00547 {
00548
00549 }
00550 }
00551
00552 void a2dVisibleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00553 {
00554 a2dText::DoLoad( parent, parser, xmlparts );
00555
00556 if ( xmlparts == a2dXmlSer_attrib )
00557 {
00558 m_parent = wxStaticCast( parent, a2dCanvasObject );
00559 wxString resolveKey;
00560 if ( parser.HasAttribute( wxT("propertyId") ) )
00561 {
00562 m_propId = wxStaticCast( parent, a2dPropObject )->HasPropertyId( parser.GetAttributeValue( wxT("propertyId") ) );
00563 }
00564 m_showname = parser.GetAttributeValueBool( wxT("showname") );
00565 }
00566 else
00567 {
00568 }
00569 }
00570 #endif //wxART2D_USE_CVGIO
00571
00572
00573
00574
00575
00576 a2dCanvasObjectPtrProperty::a2dCanvasObjectPtrProperty()
00577 :a2dNamedProperty()
00578 {
00579 m_object = 0;
00580 m_visible = false;
00581 m_render = false;
00582 m_prerender = false;
00583 m_selectedonly = false;
00584 }
00585
00586 a2dCanvasObjectPtrProperty::a2dCanvasObjectPtrProperty( const a2dPropertyIdCanvasObject* id, a2dCanvasObject* object, bool visible, bool render )
00587 :a2dNamedProperty( id )
00588 {
00589 m_object = wxStaticCastNull( object, a2dCanvasObject );
00590 m_visible = visible;
00591 m_render = render;
00592 m_prerender = false;
00593 m_selectedonly = false;
00594 }
00595
00596 a2dCanvasObjectPtrProperty::~a2dCanvasObjectPtrProperty()
00597 {
00598 }
00599
00600 a2dCanvasObjectPtrProperty::a2dCanvasObjectPtrProperty( const a2dCanvasObjectPtrProperty &other, a2dObject::CloneOptions options )
00601 :a2dNamedProperty( other )
00602 {
00603 if ( options & a2dObject::clone_properties )
00604 {
00605 if ( other.m_object )
00606 m_object = other.m_object->TClone( options );
00607 }
00608 else
00609 m_object = other.m_object;
00610 m_visible = other.m_visible;
00611 m_render = other.m_render;
00612 m_prerender = other.m_prerender;
00613 m_selectedonly = other.m_selectedonly;
00614
00615 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
00616
00617 CurrentSmartPointerOwner = this;
00618 #endif
00619 }
00620
00621 a2dNamedProperty* a2dCanvasObjectPtrProperty::Clone( a2dObject::CloneOptions options ) const
00622 {
00623 return new a2dCanvasObjectPtrProperty( *this, options );
00624 };
00625
00626 void a2dCanvasObjectPtrProperty::Assign( const a2dNamedProperty &other )
00627 {
00628 a2dCanvasObjectPtrProperty *propcast = wxStaticCast( &other, a2dCanvasObjectPtrProperty);
00629 m_object = propcast->m_object;
00630 m_prerender = propcast->m_prerender;
00631 m_selectedonly = propcast->m_selectedonly;
00632 m_visible = propcast->m_visible;
00633 m_render = propcast->m_render;
00634 }
00635
00636 a2dCanvasObjectPtrProperty *a2dCanvasObjectPtrProperty::CreatePropertyFromString( const a2dPropertyIdCanvasObject* WXUNUSED(id), const wxString& WXUNUSED(value) )
00637 {
00638 return 0;
00639 }
00640
00641 void a2dCanvasObjectPtrProperty::SetObject( wxObject* object )
00642 {
00643 m_object = wxStaticCastNull( object, a2dCanvasObject );
00644 }
00645
00646 void a2dCanvasObjectPtrProperty::DoWalker( wxObject *parent, a2dWalkerIOHandler& handler )
00647 {
00648 if ( m_object && GetCanRender() )
00649 m_object->Walker( this, handler );
00650 }
00651
00652
00653 #if wxART2D_USE_CVGIO
00654 void a2dCanvasObjectPtrProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00655 {
00656 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
00657 if ( xmlparts == a2dXmlSer_attrib )
00658 {
00659 }
00660 else
00661 {
00662 if ( m_object )
00663 m_object->Save( parent, out, towrite );
00664 }
00665 }
00666
00667 void a2dCanvasObjectPtrProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00668 {
00669 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
00670 if ( xmlparts == a2dXmlSer_attrib )
00671 {
00672 m_object = NULL;
00673 }
00674 else
00675 {
00676 if ( parser.GetTagName() == wxT("o") && parser.GetEventType() != END_TAG )
00677 {
00678 parser.Require( START_TAG, wxT("o") );
00679
00680 wxString classname = parser.GetAttributeValue( wxT("classname") );
00681 m_object = wxStaticCast( parser.CreateObject( classname ), a2dCanvasObject );
00682 if ( !m_object )
00683 {
00684 a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _("could not create a2dCanvasObject %s, will be skipped line %d"),
00685 classname.c_str(), parser.GetCurrentLineNumber() );
00686 parser.SkipSubTree();
00687 parser.Require( END_TAG, wxT("o") );
00688 parser.Next();
00689 }
00690 else
00691 {
00692 m_object->Load( this, parser );
00693 parser.ResolveOrAdd( (a2dSmrtPtr<class a2dObject>*) &m_object );
00694 }
00695 }
00696 }
00697 }
00698 #endif //wxART2D_USE_CVGIO
00699
00700
00701
00702
00703
00704 IMPLEMENT_DYNAMIC_CLASS(a2dBoudingBoxProperty,a2dNamedProperty)
00705
00706 a2dBoudingBoxProperty::a2dBoudingBoxProperty(): a2dNamedProperty()
00707 {
00708 m_value = a2dBoundingBox();
00709 }
00710
00711 a2dBoudingBoxProperty::a2dBoudingBoxProperty( const a2dPropertyIdBoundingBox* id, const a2dBoundingBox& value )
00712 : a2dNamedProperty( id )
00713 {
00714 m_value = value;
00715 }
00716
00717 a2dBoudingBoxProperty::a2dBoudingBoxProperty( const a2dPropertyIdBoundingBox* id, const wxString& value )
00718 : a2dNamedProperty( id )
00719 {
00720 wxStringTokenizer args( value, wxT(","));
00721 while ( args.HasMoreTokens() )
00722 {
00723 double x;
00724 args.GetNextToken().ToDouble(&x);
00725 double y;
00726 args.GetNextToken().ToDouble(&y);
00727 m_value.Expand( x, y );
00728 }
00729 }
00730
00731 a2dBoudingBoxProperty::~a2dBoudingBoxProperty()
00732 {
00733 }
00734
00735 a2dBoudingBoxProperty::a2dBoudingBoxProperty( const a2dBoudingBoxProperty &other)
00736 :a2dNamedProperty( other )
00737 {
00738 m_value = other.m_value;
00739 }
00740
00741 a2dNamedProperty *a2dBoudingBoxProperty::Clone( a2dObject::CloneOptions WXUNUSED(options) ) const
00742 {
00743 return new a2dBoudingBoxProperty(*this);
00744 };
00745
00746 void a2dBoudingBoxProperty::Assign( const a2dNamedProperty &other )
00747 {
00748 a2dBoudingBoxProperty *propcast = wxStaticCast( &other, a2dBoudingBoxProperty);
00749 m_value = propcast->m_value;
00750 }
00751
00752 a2dBoudingBoxProperty *a2dBoudingBoxProperty::CreatePropertyFromString( const a2dPropertyIdBoundingBox* id, const wxString &value )
00753 {
00754 a2dBoundingBox valuenew;
00755 wxStringTokenizer args( value );
00756 while ( args.HasMoreTokens() )
00757 {
00758 double x;
00759 args.GetNextToken().ToDouble(&x);
00760 double y;
00761 args.GetNextToken().ToDouble(&y);
00762 valuenew.Expand( x, y );
00763 }
00764 return new a2dBoudingBoxProperty( id, valuenew);
00765 }
00766
00767 #if wxART2D_USE_CVGIO
00768 void a2dBoudingBoxProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00769 {
00770 a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
00771 if ( xmlparts == a2dXmlSer_attrib )
00772 {
00773 wxString attrib;
00774 attrib << m_value.GetMinX() << wxT(" ");
00775 attrib << m_value.GetMinY() << wxT(" ");
00776 attrib << m_value.GetMaxX() << wxT(" ");
00777 attrib << m_value.GetMaxY();
00778
00779 out.WriteAttribute( wxT("value"), attrib );
00780 }
00781 else
00782 {
00783 }
00784 }
00785
00786 void a2dBoudingBoxProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00787 {
00788 a2dNamedProperty::DoLoad( parent, parser, xmlparts );
00789 if ( xmlparts == a2dXmlSer_attrib )
00790 {
00791 }
00792 else
00793 {
00794 }
00795 }
00796 #endif //wxART2D_USE_CVGIO
00797
00798 void a2dBoudingBoxProperty::SetValue( const a2dBoundingBox& value )
00799 {
00800 m_value = value;
00801 }
00802
00803 wxString a2dBoudingBoxProperty::StringRepresentation() const
00804 {
00805 wxString attrib;
00806 attrib << m_value.GetMinX() << wxT(" ");
00807 attrib << m_value.GetMinY() << wxT(" ");
00808 attrib << m_value.GetMaxX() << wxT(" ");
00809 attrib << m_value.GetMaxY();
00810
00811 wxString form;
00812 form.Printf( wxT("%s = %s"), GetName().c_str(), attrib.c_str() );
00813 return form;
00814 }
00815
00816 wxString a2dBoudingBoxProperty::StringValueRepresentation() const
00817 {
00818 wxString attrib;
00819 attrib << m_value.GetMinX() << wxT(" ");
00820 attrib << m_value.GetMinY() << wxT(" ");
00821 attrib << m_value.GetMaxX() << wxT(" ");
00822 attrib << m_value.GetMaxY();
00823
00824 wxString form;
00825 form.Printf( wxT("%s"), attrib.c_str() );
00826 return form;
00827 }