wxArt2D
canprop.cpp
Go to the documentation of this file.
1 /*! \file canvas/src/canprop.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2001-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: canprop.cpp,v 1.96 2008/08/14 18:33:28 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include "wx/canvas/canprop.h"
22 #include "wx/canvas/canglob.h"
23 #include "wx/canvas/drawer.h"
24 #include "wx/canvas/polygon.h"
25 //#include "wx/general/id.inl"
26 #include <wx/tokenzr.h>
27 
28 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
29 #include <wx/msw/msvcrt.h>
30 #endif
31 
32 IMPLEMENT_DYNAMIC_CLASS( a2dStyleProperty, a2dNamedProperty )
33 IMPLEMENT_DYNAMIC_CLASS( a2dShadowStyleProperty, a2dNamedProperty )
34 IMPLEMENT_DYNAMIC_CLASS( a2dClipPathProperty, a2dNamedProperty )
35 IMPLEMENT_DYNAMIC_CLASS( a2dCanvasObjectPtrProperty, a2dNamedProperty )
36 IMPLEMENT_DYNAMIC_CLASS( a2dTagVecProperty, a2dNamedProperty )
37 
38 //----------------------------------------------------------------------------
39 // template instantiations
40 //----------------------------------------------------------------------------
41 #if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
42 
44 
45 #endif // (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
46 
47 
48 //----------------------------------------------------------------------------
49 // a2dStyleProperty
50 //----------------------------------------------------------------------------
51 a2dStyleProperty::a2dStyleProperty( )
53 {
54  //we choose a2dNullFILL etc. because that is the default behaviour if no style is specified
55  m_fill = *a2dNullFILL;
56  m_stroke = *a2dNullSTROKE;
57 }
58 
59 a2dStyleProperty::a2dStyleProperty( const a2dPropertyId* id )
60  : a2dNamedProperty( id )
61 {
62  //we choose a2dNullFILL etc. because that is the default behaviour if no style is specified
63  m_fill = *a2dNullFILL;
64  m_stroke = *a2dNullSTROKE;
65 }
66 
67 a2dStyleProperty::~a2dStyleProperty()
68 {
69 }
70 
71 a2dStyleProperty::a2dStyleProperty( const a2dStyleProperty& other )
72  : a2dNamedProperty( other )
73 {
74  m_fill = other.m_fill;
75  m_stroke = other.m_stroke;
76 }
77 
78 a2dNamedProperty* a2dStyleProperty::Clone( a2dObject::CloneOptions WXUNUSED( options ) ) const
79 {
80  return new a2dStyleProperty( *this );
81 };
82 
84 {
85  a2dStyleProperty* propcast = wxStaticCast( &other, a2dStyleProperty );
86  m_stroke = propcast->m_stroke;
87  m_fill = propcast->m_fill;
88 }
89 
91 {
92  return GetName() + wxT( " = " ) + StringValueRepresentation();
93 }
94 
96 {
97  wxString s;
98  s = s + wxT( "fill " );
99  s = s + wxT( "stroke " );
100  return s;
101 }
102 
104 {
105  if ( m_fill.IsNoFill() && m_stroke.IsNoStroke() )
106  return true;
107  return false;
108 }
109 
111 {
112  m_fill = fill;
113 }
114 
115 void a2dStyleProperty::SetFill( const wxColour& fillcolor, a2dFillStyle style )
116 {
117  m_fill = a2dFill( fillcolor, style );
118 }
119 
120 void a2dStyleProperty::SetFill( const wxColour& fillcolor, const wxColour& fillcolor2, a2dFillStyle style )
121 {
122  m_fill = a2dFill( fillcolor, fillcolor2, style );
123 }
124 
125 
126 void a2dStyleProperty::SetStroke( const wxColour& strokecolor, float width, a2dStrokeStyle style )
127 {
128  m_stroke = a2dStroke( strokecolor, width, style );
129 }
130 
131 void a2dStyleProperty::SetStroke( const wxColour& strokecolor, int width, a2dStrokeStyle style )
132 {
133  m_stroke = a2dStroke( strokecolor, width, style );
134 }
135 
137 {
138  m_stroke = stroke;
139 }
140 
141 #if wxART2D_USE_CVGIO
142 void a2dStyleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
143 {
144  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
145  if ( xmlparts == a2dXmlSer_attrib )
146  {
147  }
148  else
149  {
150  if ( !m_fill.IsNoFill() )
151  m_fill.Save( parent, out, towrite );
152 
153  if ( !m_stroke.IsNoStroke() )
154  m_stroke.Save( parent, out, towrite );
155  }
156 }
157 
158 void a2dStyleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag WXUNUSED( xmlparts ) )
159 {
160  parser.Next();
161 
162  if ( parser.GetTagName() == wxT( "fill" ) )
163  {
164  if ( parser.GetAttributeValue( wxT( "style" ) ) == wxT( "inherit" ) )
165  {
167  parser.Next();
168  parser.Require( END_TAG, wxT( "fill" ) );
169  parser.Next();
170  }
171  else
172  {
173  a2dFill* fill = ( a2dFill* ) parser.CreateObject( parser.GetAttributeValue( wxT( "classname" ) ) );
174  wxASSERT_MSG( fill, wxT( "wrong a2dFill" ) );
175  fill->Load( parent, parser );
176  m_fill = *fill;
177  delete fill;
178  }
179  }
180 
181  if ( parser.GetTagName() == wxT( "stroke" ) )
182  {
183  if ( parser.GetAttributeValue( wxT( "style" ) ) == wxT( "inherit" ) )
184  {
186  parser.Next();
187  parser.Require( END_TAG, wxT( "stroke" ) );
188  parser.Next();
189  }
190  else
191  {
192  a2dStroke* stroke = ( a2dStroke* ) parser.CreateObject( parser.GetAttributeValue( wxT( "classname" ) ) );
193  wxASSERT_MSG( stroke, wxT( "wrong a2dStroke" ) );
194  stroke->Load( parent, parser );
195  m_stroke = *stroke;
196  delete stroke;
197  }
198  }
199 }
200 #endif //wxART2D_USE_CVGIO
201 
202 //----------------------------------------------------------------------------
203 // a2dShadowStyleProperty
204 //----------------------------------------------------------------------------
205 
206 a2dShadowStyleProperty::a2dShadowStyleProperty()
207  : a2dStyleProperty()
208 {
209  m_depth = 0;
210  m_angle3d = 30;
211 }
212 
213 a2dShadowStyleProperty::a2dShadowStyleProperty( const a2dPropertyIdCanvasShadowStyle* id, double depth, double angle )
214  : a2dStyleProperty( id )
215 {
216  m_depth = depth;
217  m_angle3d = angle;
218 }
219 
220 
221 a2dShadowStyleProperty::~a2dShadowStyleProperty()
222 {
223 }
224 
225 a2dShadowStyleProperty::a2dShadowStyleProperty( const a2dShadowStyleProperty& other )
226  : a2dStyleProperty( other )
227 {
228  m_depth = other.m_depth;
229  m_angle3d = other.m_angle3d;
230 }
231 
232 a2dNamedProperty* a2dShadowStyleProperty::Clone( a2dObject::CloneOptions WXUNUSED( options ) ) const
233 {
234  return new a2dShadowStyleProperty( *this );
235 };
236 
237 #if wxART2D_USE_CVGIO
238 void a2dShadowStyleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
239 {
240  a2dStyleProperty::DoSave( parent, out, xmlparts, towrite );
241  if ( xmlparts == a2dXmlSer_attrib )
242  {
243  out.WriteAttribute( wxT( "depth" ), m_depth );
244  out.WriteAttribute( wxT( "angle" ), m_angle3d );
245  }
246  else
247  {
248  }
249 }
250 
251 
252 void a2dShadowStyleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
253 {
254  a2dStyleProperty::DoLoad( parent, parser, xmlparts );
255  if ( xmlparts == a2dXmlSer_attrib )
256  {
257  m_depth = parser.GetAttributeValueDouble( wxT( "depth" ) );
258  m_angle3d = parser.GetAttributeValueDouble( wxT( "angle" ) );
259  }
260  else
261  {
262  }
263 }
264 #endif //wxART2D_USE_CVGIO
265 
266 
267 //----------------------------------------------------------------------------
268 // a2dClipPathProperty
269 //----------------------------------------------------------------------------
270 
271 a2dClipPathProperty::a2dClipPathProperty()
272  : a2dNamedProperty()
273 {
274  m_clip = 0;
275  m_visible = false;
276  m_render = true;
277 }
278 
279 a2dClipPathProperty::a2dClipPathProperty( const a2dPropertyIdCanvasClipPath* id, a2dPolygonL* clip )
280  : a2dNamedProperty( id )
281 {
282  m_clip = clip;
283  m_visible = false;
284  m_render = true;
285 }
286 
287 a2dClipPathProperty::~a2dClipPathProperty()
288 {
289 }
290 
291 a2dClipPathProperty::a2dClipPathProperty( const a2dClipPathProperty& other, a2dObject::CloneOptions options )
292  : a2dNamedProperty( other )
293 {
294  if ( options & a2dObject::clone_members )
295  {
296  if ( other.m_clip )
297  m_clip = ( a2dPolygonL* ) other.m_clip->TClone( options );
298  }
299  else
300  m_clip = other.m_clip;
301 
302 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
303  //klion: it is because the CurrentSmartPointerOwner can change in Clone ( )
304  CurrentSmartPointerOwner = this;
305 #endif
306 }
307 
308 a2dNamedProperty* a2dClipPathProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
309 {
310  return new a2dClipPathProperty( *this, options );
311 };
312 
314 {
315  a2dClipPathProperty* propcast = wxStaticCast( &other, a2dClipPathProperty );
316  m_clip = propcast->m_clip;
317  m_visible = propcast->m_visible;
318  m_render = propcast->m_render;
319 }
320 
322 {
323  return m_clip;
324 }
325 
327 {
328  return m_clip;
329 }
330 
332 {
333  m_clip = ( a2dPolygonL* ) clip;
334 }
335 
336 void a2dClipPathProperty::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
337 {
338  if ( m_clip && GetCanRender() )
339  m_clip->Walker( this, handler );
340 }
341 
342 #if wxART2D_USE_CVGIO
343 void a2dClipPathProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
344 {
345  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
346  if ( xmlparts == a2dXmlSer_attrib )
347  {
348  out.WriteAttribute( wxT( "clippath" ), GetName() );
349  }
350  else
351  {
352  if ( m_clip )
353  m_clip->Save( this, out, towrite );
354  }
355 }
356 
357 void a2dClipPathProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
358 {
359  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
360  if ( xmlparts == a2dXmlSer_attrib )
361  {
362  wxString clipobject = parser.GetAttributeValue( wxT( "clippath" ) );
363  if ( clipobject != wxT( "" ) )
364  {
365  //TODO
366  //m_clip = clipobject;
367  }
368  }
369  else
370  {
371  parser.Require( START_TAG, wxT( "o" ) );
372  wxString classname = parser.GetAttributeValue( wxT( "classname" ) );
373 
374  if ( classname == wxT( "ref" ) )
375  {
376  parser.SkipSubTree();
377  parser.Require( END_TAG, wxT( "o" ) );
378  parser.Next();
379  }
380  else
381  {
382  a2dPolygonL* object = ( a2dPolygonL* ) parser.CreateObject( classname );
383  if ( !object )
384  {
385  wxLogError( wxT( "could not create a2dPolygonL from %s, will be skipped line %d" ),
386  classname.c_str(), parser.GetCurrentLineNumber() );
387  parser.SkipSubTree();
388  parser.Require( END_TAG, wxT( "o" ) );
389  parser.Next();
390  }
391  else
392  {
393  m_clip = object;
394  m_clip->Load( this, parser );
395  }
396  }
397  }
398 
399 }
400 #endif //wxART2D_USE_CVGIO
401 
402 void a2dClipPathProperty::PushClip( a2dDrawingPart* drawer, a2dBooleanClip clipoperation )
403 {
404  if ( m_clip )
405  drawer->GetDrawer2D()->ExtendAndPushClippingRegion( m_clip->GetSegments(), m_clip->GetSpline(), m_clip->GetFillRule(), clipoperation );
406 }
407 
408 void a2dClipPathProperty::PopClip( a2dDrawingPart* drawer )
409 {
410  if ( m_clip )
411  {
412  drawer->GetDrawer2D()->PopClippingRegion();
413  }
414 }
415 
416 //----------------------------------------------------------------------------
417 // a2dVisibleProperty
418 //----------------------------------------------------------------------------
419 BEGIN_EVENT_TABLE( a2dVisibleProperty, a2dText )
421  EVT_CHAR( a2dVisibleProperty::OnChar )
422 END_EVENT_TABLE()
423 
424 IMPLEMENT_DYNAMIC_CLASS( a2dVisibleProperty, a2dText );
425 
426 void a2dVisibleProperty::OnPropertyChanged( a2dComEvent& event )
427 {
428  if ( event.GetPropertyId() == m_propId )
429  {
430  SetPending( true );
431  }
432 }
433 
435  : a2dText()
436 {
437  m_flags.m_visible = true;
438  m_flags.m_prerenderaschild = false;
439  m_flags.m_subEditAsChild = true;
440  m_propId = NULL;
441  m_showname = true;
442  m_parent = NULL;
443 }
444 
445 a2dVisibleProperty::a2dVisibleProperty( a2dCanvasObject* parent, const a2dPropertyId* propertyId, double x, double y, double angle )
446  : a2dText( wxT( "" ), x, y, *a2dDEFAULT_CANVASFONT, angle )
447 {
448  m_flags.m_visible = true;
449  m_flags.m_prerenderaschild = false;
450  m_flags.m_subEditAsChild = true;
451  m_parent = parent;
452  m_propId = propertyId;
453 
454  Connect( wxID_ANY, wxID_ANY, a2dEVT_COM_EVENT, wxObjectEventFunction( &a2dVisibleProperty::OnPropertyChanged ), 0, this );
455  m_showname = true;
456 }
457 
458 a2dVisibleProperty::a2dVisibleProperty( a2dCanvasObject* parent, const a2dPropertyId* propertyId, double x, double y, bool visible, const a2dFont& font, double angle )
459  : a2dText( wxT( "" ), x, y, font, angle )
460 {
461  m_flags.m_visible = visible;
462  m_flags.m_prerenderaschild = false;
463  m_flags.m_subEditAsChild = true;
464  m_parent = parent;
465  m_propId = propertyId;
466  Connect( wxID_ANY, wxID_ANY, a2dEVT_COM_EVENT, wxObjectEventFunction( &a2dVisibleProperty::OnPropertyChanged ), 0, this );
467  m_showname = true;
468 }
469 
470 a2dVisibleProperty::~a2dVisibleProperty()
471 {
472  Disconnect( wxID_ANY, wxID_ANY, a2dEVT_COM_EVENT, wxObjectEventFunction( &a2dVisibleProperty::OnPropertyChanged ), 0, this );
473 }
474 
475 a2dVisibleProperty::a2dVisibleProperty( const a2dVisibleProperty& other, CloneOptions options, a2dRefMap* refs )
476  : a2dText( other, options, refs )
477 {
478  m_propId = other.m_propId;
479  m_parent = other.m_parent;
480  m_showname = other.m_showname;
481 }
482 
484 {
485  m_showname = show;
486  SetPending( true );
487 }
488 
490 {
491  m_parent = parent;
492  SetPending( true );
493 }
494 
496 {
497  return new a2dVisibleProperty( *this, options, refs );
498 };
499 
500 void a2dVisibleProperty::OnMouseEvent( a2dCanvasObjectMouseEvent& event )
501 {
502  event.Skip();
503 }
504 
506 {
509 
511 }
512 
513 void a2dVisibleProperty::OnChar( wxKeyEvent& event )
514 {
515  //klion: warning C4189: 'selection_start_pos' : local variable is initialized but not referenced
516  //size_t selection_start_pos = m_selection_start_pos;
517  //klion: warning C4189: 'selection_end_pos' : local variable is initialized but not referenced
518  //size_t selection_end_pos = m_selection_end_pos;
519  //klion: warning C4189: 'caret' : local variable is initialized but not referenced
520  //size_t caret = m_caret;
521  wxString text = m_text;
522 
523  a2dText::OnChar( event );
524  if ( m_flags.m_editingCopy )
525  {
526  //m_propId->ValidateString( m_text )
527  }
528 }
529 
530 bool a2dVisibleProperty::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
531 {
532  if ( !m_bbox.GetValid() )
533  {
534  if ( m_showname )
535  m_text = m_propId->GetName() + wxT( " = " );
536  else
537  m_text = wxEmptyString;
538  m_firsteditable = m_text.Length();
539  if ( m_caret < m_firsteditable )
542  if ( property )
543  m_text = m_text + property->StringValueRepresentation();
544  m_utbbox_changed = true;
545  }
546 
547  return a2dText::DoUpdate( mode, childbox, clipbox, propbox );
548 }
549 
550 #if wxART2D_USE_CVGIO
551 void a2dVisibleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
552 {
553  a2dText::DoSave( parent, out, xmlparts, towrite );
554 
555  if ( xmlparts == a2dXmlSer_attrib )
556  {
557  out.WriteAttribute( wxT( "showname" ), m_showname, true );
558  out.WriteAttribute( wxT( "propertyId" ), m_propId->GetName() );
559  }
560  else
561  {
562 
563  }
564 }
565 
566 void a2dVisibleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
567 {
568  a2dText::DoLoad( parent, parser, xmlparts );
569 
570  if ( xmlparts == a2dXmlSer_attrib )
571  {
573  wxString resolveKey;
574  if ( parser.HasAttribute( wxT( "propertyId" ) ) )
575  {
576  m_propId = wxStaticCast( parent, a2dObject )->HasPropertyId( parser.GetAttributeValue( wxT( "propertyId" ) ) );
577  }
578  m_showname = parser.GetAttributeValueBool( wxT( "showname" ) );
579  }
580  else
581  {
582  }
583 }
584 #endif //wxART2D_USE_CVGIO
585 
586 //----------------------------------------------------------------------------
587 // a2dCanvasObjectPtrProperty
588 //----------------------------------------------------------------------------
589 
590 a2dCanvasObjectPtrProperty::a2dCanvasObjectPtrProperty()
591  : a2dNamedProperty()
592 {
593  m_object = 0;
594  m_visible = false;
595  m_render = false;
596  m_prerender = false;
597  m_selectedonly = false;
598 }
599 
600 a2dCanvasObjectPtrProperty::a2dCanvasObjectPtrProperty( const a2dPropertyIdCanvasObject* id, a2dCanvasObject* object, bool visible, bool render )
601  : a2dNamedProperty( id )
602 {
603  m_object = wxStaticCastNull( object, a2dCanvasObject );
604  m_visible = visible;
605  m_render = render;
606  m_prerender = false;
607  m_selectedonly = false;
608 }
609 
610 a2dCanvasObjectPtrProperty::~a2dCanvasObjectPtrProperty()
611 {
612 }
613 
614 a2dCanvasObjectPtrProperty::a2dCanvasObjectPtrProperty( const a2dCanvasObjectPtrProperty& other, a2dObject::CloneOptions options )
615  : a2dNamedProperty( other )
616 {
617  if ( options & a2dObject::clone_properties && m_id->IsCloneDeep() )
618  {
619  if ( other.m_object )
620  m_object = other.m_object->TClone( options );
621  }
622  else
623  m_object = other.m_object;
624  m_visible = other.m_visible;
625  m_render = other.m_render;
626  m_prerender = other.m_prerender;
627  m_selectedonly = other.m_selectedonly;
628 
629 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
630  //klion: it is because the CurrentSmartPointerOwner can change in Clone ( )
631  CurrentSmartPointerOwner = this;
632 #endif
633 }
634 
635 a2dNamedProperty* a2dCanvasObjectPtrProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
636 {
637  return new a2dCanvasObjectPtrProperty( *this, options );
638 };
639 
641 {
642  a2dCanvasObjectPtrProperty* propcast = wxStaticCast( &other, a2dCanvasObjectPtrProperty );
643  m_object = propcast->m_object;
644  m_prerender = propcast->m_prerender;
645  m_selectedonly = propcast->m_selectedonly;
646  m_visible = propcast->m_visible;
647  m_render = propcast->m_render;
648 }
649 
650 a2dCanvasObjectPtrProperty* a2dCanvasObjectPtrProperty::CreatePropertyFromString( const a2dPropertyIdCanvasObject* WXUNUSED( id ), const wxString& WXUNUSED( value ) )
651 {
652  return 0;
653 }
654 
656 {
657  m_object = wxStaticCastNull( object, a2dCanvasObject );
658 }
659 
660 void a2dCanvasObjectPtrProperty::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
661 {
662  if ( m_object && GetCanRender() )
663  m_object->Walker( this, handler );
664 }
665 
666 
667 #if wxART2D_USE_CVGIO
668 void a2dCanvasObjectPtrProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
669 {
670  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
671  if ( xmlparts == a2dXmlSer_attrib )
672  {
673  }
674  else
675  {
676  if ( m_object )
677  m_object->Save( parent, out, towrite );
678  }
679 }
680 
681 void a2dCanvasObjectPtrProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
682 {
683  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
684  if ( xmlparts == a2dXmlSer_attrib )
685  {
686  m_object = NULL;
687  }
688  else
689  {
690  if ( parser.GetTagName() == wxT( "o" ) && parser.GetEventType() != END_TAG )
691  {
692  parser.Require( START_TAG, wxT( "o" ) );
693 
694  wxString classname = parser.GetAttributeValue( wxT( "classname" ) );
695  m_object = wxStaticCast( parser.CreateObject( classname ), a2dCanvasObject );
696  if ( !m_object )
697  {
698  a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _( "could not create a2dCanvasObject %s, will be skipped line %d" ),
699  classname.c_str(), parser.GetCurrentLineNumber() );
700  parser.SkipSubTree();
701  parser.Require( END_TAG, wxT( "o" ) );
702  parser.Next();
703  }
704  else
705  {
706  m_object->Load( this, parser );
708  }
709  }
710  }
711 }
712 #endif //wxART2D_USE_CVGIO
713 
714 
715 //----------------------------------------------------------------------------
716 // a2dBoudingBoxProperty
717 //----------------------------------------------------------------------------
718 IMPLEMENT_DYNAMIC_CLASS( a2dBoudingBoxProperty, a2dNamedProperty )
719 
721 {
722  m_value = a2dBoundingBox();
723 }
724 
725 a2dBoudingBoxProperty::a2dBoudingBoxProperty( const a2dPropertyIdBoundingBox* id, const a2dBoundingBox& value )
726  : a2dNamedProperty( id )
727 {
728  m_value = value;
729 }
730 
731 a2dBoudingBoxProperty::a2dBoudingBoxProperty( const a2dPropertyIdBoundingBox* id, const wxString& value )
732  : a2dNamedProperty( id )
733 {
734  wxStringTokenizer args( value, wxT( "," ) );
735  while ( args.HasMoreTokens() )
736  {
737  double x;
738  args.GetNextToken().ToDouble( &x );
739  double y;
740  args.GetNextToken().ToDouble( &y );
741  m_value.Expand( x, y );
742  }
743 }
744 
745 a2dBoudingBoxProperty::~a2dBoudingBoxProperty()
746 {
747 }
748 
749 a2dBoudingBoxProperty::a2dBoudingBoxProperty( const a2dBoudingBoxProperty& other )
750  : a2dNamedProperty( other )
751 {
752  m_value = other.m_value;
753 }
754 
755 a2dNamedProperty* a2dBoudingBoxProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
756 {
757  return new a2dBoudingBoxProperty( *this );
758 };
759 
761 {
763  m_value = propcast->m_value;
764 }
765 
767 {
768  a2dBoundingBox valuenew;
769  wxStringTokenizer args( value );
770  while ( args.HasMoreTokens() )
771  {
772  double x;
773  args.GetNextToken().ToDouble( &x );
774  double y;
775  args.GetNextToken().ToDouble( &y );
776  valuenew.Expand( x, y );
777  }
778  return new a2dBoudingBoxProperty( id, valuenew );
779 }
780 
781 #if wxART2D_USE_CVGIO
782 void a2dBoudingBoxProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
783 {
784  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
785  if ( xmlparts == a2dXmlSer_attrib )
786  {
787  wxString attrib;
788  attrib << m_value.GetMinX() << wxT( " " );
789  attrib << m_value.GetMinY() << wxT( " " );
790  attrib << m_value.GetMaxX() << wxT( " " );
791  attrib << m_value.GetMaxY();
792 
793  out.WriteAttribute( wxT( "value" ), attrib );
794  }
795  else
796  {
797  }
798 }
799 
800 void a2dBoudingBoxProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
801 {
802  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
803  if ( xmlparts == a2dXmlSer_attrib )
804  {
805  }
806  else
807  {
808  }
809 }
810 #endif //wxART2D_USE_CVGIO
811 
812 void a2dBoudingBoxProperty::SetValue( const a2dBoundingBox& value )
813 {
814  m_value = value;
815 }
816 
818 {
819  wxString attrib;
820  attrib << m_value.GetMinX() << wxT( " " );
821  attrib << m_value.GetMinY() << wxT( " " );
822  attrib << m_value.GetMaxX() << wxT( " " );
823  attrib << m_value.GetMaxY();
824 
825  wxString form;
826  form.Printf( wxT( "%s = %s" ), GetName().c_str(), attrib.c_str() );
827  return form;
828 }
829 
831 {
832  wxString attrib;
833  attrib << m_value.GetMinX() << wxT( " " );
834  attrib << m_value.GetMinY() << wxT( " " );
835  attrib << m_value.GetMaxX() << wxT( " " );
836  attrib << m_value.GetMaxY();
837 
838  wxString form;
839  form.Printf( wxT( "%s" ), attrib.c_str() );
840  return form;
841 }
842 
843 //----------------------------------------------------------------------------
844 // a2dTagVecProperty
845 //----------------------------------------------------------------------------
846 
847 static int a2dTagCount = 0;
848 
849 A2DCANVASDLLEXP a2dTag a2dNewTag()
850 {
851  a2dTagCount++;
852  if ( a2dTagCount >= 255 )
853  a2dTagCount = 0;
854  return a2dTagCount;
855 }
856 
857 a2dTagVecProperty::a2dTagVecProperty(): a2dNamedProperty()
858 {
859 }
860 
861 a2dTagVecProperty::a2dTagVecProperty( const a2dPropertyIdTagVec* id, a2dTagVec value )
862  : a2dNamedProperty( id )
863 {
864  m_value = value;
865 }
866 
867 a2dTagVecProperty::~a2dTagVecProperty()
868 {
869 }
870 
871 a2dTagVecProperty::a2dTagVecProperty( const a2dTagVecProperty& other )
872  : a2dNamedProperty( other )
873 {
874  m_value = other.m_value;
875 }
876 
877 a2dNamedProperty* a2dTagVecProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
878 {
879  return new a2dTagVecProperty( *this );
880 };
881 
883 {
884  a2dTagVecProperty* propcast = wxStaticCast( &other, a2dTagVecProperty );
885  m_value = propcast->m_value;
886 }
887 
888 a2dTagVecProperty* a2dTagVecProperty::CreatePropertyFromString( const a2dPropertyIdTagVec* id, const wxString& value )
889 {
890  a2dTagVec result;
891  //value.ParseItToa2dTagVec();
892  return new a2dTagVecProperty( id, result );
893 }
894 
895 #if wxART2D_USE_CVGIO
896 void a2dTagVecProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
897 {
898  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
899  if ( xmlparts == a2dXmlSer_attrib )
900  {
901  }
902  else
903  {
904  for( a2dTagVec::iterator iter = m_value.begin(); iter != m_value.end(); ++iter )
905  {
906  wxUint8 tag = *iter;
907  out.WriteStartElementAttributes( wxT( "tag" ) );
908  out.WriteAttribute( wxT( "v" ), tag );
909  out.WriteEndAttributes();
910  }
911  }
912 }
913 
914 void a2dTagVecProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
915 {
916  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
917  if ( xmlparts == a2dXmlSer_attrib )
918  {
919  }
920  else
921  {
922  while( parser.GetTagName() == wxT( "tag" ) )
923  {
924  a2dTag value = parser.GetAttributeValueUint16( wxT( "v" ) );
925  m_value.push_back( value );
926  parser.Next();
927  parser.Require( END_TAG, wxT( "tag" ) );
928  parser.Next();
929  }
930  }
931 }
932 #endif //wxART2D_USE_CVGIO
933 
934 void a2dTagVecProperty::SetValue( a2dTagVec value )
935 {
936  m_value = value;
937 }
938 
940 {
941  wxString form;
942  //form.Printf( wxT( "%s = %d" ), GetName().c_str(), m_value );
943  return form;
944 }
945 
947 {
948  wxString form;
949  //form.Printf( wxT( "%d" ), m_value );
950  return form;
951 }
952 
953 void a2dTagVecProperty::PushTag( a2dTag tag )
954 {
955  m_value.push_back( tag );
956 }
957 
958 a2dTag a2dTagVecProperty::PopTag()
959 {
960  a2dTag tag = m_value.back();
961  m_value.pop_back();
962  return tag;
963 }
964 
965 a2dTag a2dTagVecProperty::Last() const
966 {
967  return m_value.back();
968 }
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: cantext.cpp:822
bool GetAttributeValueBool(const wxString &attrib, bool defaultv=false)
Returns the boolean value of an attribute.
Definition: genxmlpars.cpp:537
void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: canprop.cpp:313
virtual wxString StringValueRepresentation() const
Definition: canprop.cpp:946
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
a2dCanvasObject * m_parent
object which contains m_propId
Definition: canprop.h:452
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
virtual wxString StringValueRepresentation() const
Definition: canprop.cpp:830
bool IsNoStroke() const
Definition: stylebase.h:510
void SetStroke(const wxColour &strokecolor, float width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
Definition: canprop.cpp:126
bool HasAttribute(const wxString &attrib)
Does the current tag have this attribute?
Definition: genxmlpars.cpp:560
virtual a2dObject * GetRefObjectNA() const
when a2dProperty, return its value else return NULL
Definition: canprop.cpp:326
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
wxString StringValueRepresentation() const
Definition: canprop.cpp:95
XMLeventType Next()
Walks to next element and returns event type.
Definition: genxmlpars.cpp:422
const a2dFill * a2dINHERIT_FILL
global a2dFill stock object for INHERTED from parent object filling
bool ResolveOrAdd(a2dSmrtPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
try to resolve the object that is in storedHere when it is a reference.
Definition: gen.cpp:4760
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
static a2dCanvasObjectPtrProperty * CreatePropertyFromString(const a2dPropertyIdCanvasObject *id, const wxString &value)
Definition: canprop.cpp:650
Creates a shadow behind a a2dCanvasObject when added as property.
Definition: canprop.h:157
a2dDrawing * m_root
root group for rendering and accessing the canvas&#39;s also contains layer settings
Definition: canobj.h:2525
virtual wxString GetName() const
Get the ids print and serialization name.
Definition: id.h:245
void DoEndEdit()
only used for editable objects and under control of a editing tool.
Definition: canprop.cpp:505
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
static a2dTagVecProperty * CreatePropertyFromString(const a2dPropertyIdTagVec *id, const wxString &value)
Definition: canprop.cpp:888
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
Definition: genxmlpars.cpp:757
polygon defined with list of points.
Definition: polygon.h:45
Ref Counted base object.
Definition: gen.h:1045
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
Definition: cantext.cpp:536
a2dVisibleProperty()
constructor
Definition: canprop.cpp:434
virtual wxString StringRepresentation() const
Definition: canprop.cpp:817
This template class is for property ids meant for properties that do not encapsulate another type...
Definition: id.h:397
virtual int GetCurrentLineNumber()
where in the input was line the current tag
Definition: genxmlpars.cpp:349
bool GetCanRender() const
return true if the object can be rendered.
Definition: canprop.h:242
bool AllNo()
if IsNoStroke() and IsNoFill() return true
Definition: canprop.cpp:103
int m_caret
position of caret within text string
Definition: cantext.h:387
a2dStroke m_stroke
Definition: canprop.h:137
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: canprop.cpp:495
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
bool IsNoFill() const
Definition: stylebase.h:273
const a2dPropertyId * m_propId
the property id for which the value needs to be displayed.
Definition: canprop.h:455
static a2dBoudingBoxProperty * CreatePropertyFromString(const a2dPropertyIdBoundingBox *id, const wxString &value)
Definition: canprop.cpp:766
a2dNamedProperty * GetProperty(const a2dPropertyId *propertyId, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const
get property on this object
Definition: gen.cpp:1590
wxString GetName() const
Get the name of the a2dPropertyId object.
Definition: gen.h:1864
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
property to hold a byte integer type vector to be associated with a a2dObject
Definition: canprop.h:526
virtual wxString StringRepresentation() const
Definition: canprop.cpp:939
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: canprop.cpp:760
virtual wxObject * CreateObject(const wxString &symbolicName)
Creates an specific object by name.
Definition: gen.cpp:4937
a2dCanvasObjectPtr m_object
object held by this property.
Definition: canprop.h:303
size_t m_firsteditable
The first editable character, usually 0, but may be different for a2dVisibleProperty.
Definition: cantext.h:407
virtual a2dObject * GetRefObject() const
when a2dProperty, return its value else assert
Definition: canprop.cpp:321
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
a2dFillStyle
Filling styles for a2dFill.
Definition: stylebase.h:91
void SetParent(a2dCanvasObject *parent)
to set the parent where the m_propId is searched for.
Definition: canprop.cpp:489
a2dText is an abstract base class.
Definition: cantext.h:93
used to change a property on objects
Definition: drawing.h:2244
bool m_render
in case of a grahics application, should this property be rendered.
Definition: canprop.h:383
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
Definition: bbox.cpp:299
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
Definition: bbox.cpp:155
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
bool m_visible
is the object visible (overruled by paranet object in some cases during rendering ...
Definition: candefs.h:250
void SkipSubTree()
Skips all child elements / tags of current element / tag.
Definition: genxmlpars.cpp:652
void SetObject(wxObject *object)
to set the a2dCanvasObject*
Definition: canprop.cpp:655
wxString StringRepresentation() const
Definition: canprop.cpp:90
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
Definition: gen.cpp:1473
(In)Visible property that can be added to Canvas Objects.
Definition: canprop.h:396
const a2dError a2dError_XMLparse
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
a2dVertexListPtr GetSegments()
Get the list of points ( this is not a copy! )
Definition: polygon.h:219
a2dTag a2dNewTag()
Generate new tag for grouping.
Definition: canprop.cpp:849
void SetCanvasObject(a2dPolygonL *clip)
set object to use for clipping
Definition: canprop.cpp:331
#define EVT_CANVASOBJECT_MOUSE_EVENT(func)
static event table macro for a2dCanvasObject mouse event
Definition: canglob.h:312
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: canprop.cpp:882
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
Definition: canprop.cpp:551
a2dDrawer2D * GetDrawer2D()
get the internal m_drawer2D that is used for rendering the document
Definition: drawer.h:1125
const a2dStroke * a2dINHERIT_STROKE
global a2dStroke stock object for INHERTED from parent object stroking
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
Invisible Style property that can be added to Canvas Objects.
Definition: canprop.h:55
bool m_showname
Indicates if both name and value of the property are visible, or just the value.
Definition: canprop.h:458
bool m_visible
see SetVisible()
Definition: canprop.h:381
bool m_visible
see SetVisible()
Definition: canprop.h:295
bool m_subEditAsChild
allow subedit on this object when child of other object
Definition: candefs.h:247
const a2dFill * a2dNullFILL
global a2dFill stock object for defining NO filling
bool GetSpline()
Get the polygon spline setting.
Definition: polygon.h:235
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canprop.cpp:530
void WriteEndAttributes(bool close=false)
&quot;Closes&quot; the start tag after writing all attributes (writes the &quot;&gt;&quot; or &quot;/&gt;&quot; bracket).
Definition: genxmlpars.cpp:837
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
Definition: comevt.cpp:842
properties specific for a2dCanvasOject
a2dFill m_fill
Definition: canprop.h:142
double GetAttributeValueDouble(const wxString &attrib, double defaultv=0)
Returns the double value of an attribute.
Definition: genxmlpars.cpp:474
const a2dStroke * a2dNullSTROKE
global a2dStroke stock object for NO stroking
virtual void ExtendAndPushClippingRegion(a2dVertexList *points, bool spline=false, wxPolygonFillMode fillStyle=wxODDEVEN_RULE, a2dBooleanClip clipoperation=a2dCLIP_AND)=0
push on stack the current clipping region and extend clipping region
double GetMaxX() const
get maximum X of the boundingbox
Definition: bbox.cpp:316
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canprop.cpp:110
wxUint16 GetAttributeValueUint16(const wxString &attrib, wxUint16 defaultv=0)
cast to wxUint16 of GetAttributeValueInt()
Definition: genxmlpars.h:462
bool m_render
in case of a grahics application, should this property be rendered.
Definition: canprop.h:297
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
Definition: drawing.h:549
a2dBooleanClip
Used for defining how a ClippingRegion defined as a polygon is combined with.
Definition: drawer2d.h:54
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
Definition: cantext.cpp:568
Clipping Path property that can be added to a2dCanvasObject&#39;s.
Definition: canprop.h:322
virtual void Load(wxObject *parent, a2dIOHandlerXmlSerIn &parser)
load object from CVG file
Definition: gen.cpp:1396
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
Definition: genxmlpars.cpp:450
This is the base class for all kinds of property id&#39;s for a2dObject.
Definition: id.h:154
double GetMaxY() const
get maximum Y of the boundingbox
Definition: bbox.cpp:322
void ShowName(bool show=false)
Show both name and value of the property or just the value.
Definition: canprop.cpp:483
wxPolygonFillMode GetFillRule()
Get Polygon filling mode wxODDEVEN_RULE or wxWINDING_RULE.
Definition: polygon.h:246
XMLeventType GetEventType()
Returns the type of current event.
Definition: genxmlpars.cpp:606
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
Definition: genxmlpars.cpp:390
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: canprop.cpp:640
wxString GetTagName()
Returns name of the current XML tag.
Definition: genxmlpars.cpp:565
if set, clone properties (e.g. fill style), otherwise ref-copy them
Definition: gen.h:1205
property to hold a a2dCanvasObject pointer type variable to be associated with a canvasobject ...
Definition: canprop.h:202
bool m_editingCopy
true if the object needs to be rendered in edit mode.
Definition: candefs.h:304
bool m_utbbox_changed
Untransformed bounding box changed.
Definition: cantext.h:399
if set, clone members (e.g. line end styles), otherwise ref-copy them
Definition: gen.h:1203
see a2dComEvent
Definition: gen.h:371
virtual void PopClippingRegion()=0
pop a previously pushed clipping region
virtual wxString StringValueRepresentation() const
Definition: gen.h:1905
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
all polygon and polyline a2dCanvasObject are here.
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canprop.cpp:566
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
Definition: gen.cpp:1343
bool m_prerenderaschild
as child this object will be rendered before the parent object itself when true (default) ...
Definition: candefs.h:289
This template class is for property ids with a known data type.
Definition: id.h:477
property to hold a a2dBoundingBox type variable to be associated with a canvasobject ...
Definition: canprop.h:470
a2dBoundingBox m_bbox
boundingbox in world coordinates
Definition: canobj.h:2539
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: canprop.cpp:83
wxString m_text
the text to display
Definition: cantext.h:381
a2dStrokeStyle
stroke styles for a2dStroke
Definition: stylebase.h:298
list of a2dObject&#39;s
Definition: gen.h:3157
CloneOptions
options for cloning
Definition: gen.h:1200
bool GetCanRender() const
return true if the object can be rendered.
Definition: canprop.h:360
virtual void DoEndEdit()
only used for editable objects and under control of a editing tool.
Definition: cantext.cpp:1026
virtual a2dNamedProperty * CreatePropertyFromString(const wxString &value) const
Create a new property object from a value string.
Definition: id.h:255
general canvas module declarations and classes
canprop.cpp Source File -- Sun Oct 12 2014 17:04:14 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation