wxArt2D
rectangle.cpp
Go to the documentation of this file.
1 /*! \file canvas/src/rectangle.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: rectangle.cpp,v 1.15 2009/07/24 16:35:01 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/wfstream.h>
22 #include <wx/module.h>
23 #include <wx/clipbrd.h>
24 
25 #include "wx/canvas/canobj.h"
26 #include "wx/canvas/rectangle.h"
27 #include "wx/canvas/canglob.h"
28 #include "wx/canvas/vpath.h"
29 #include "wx/canvas/drawer.h"
30 #include "wx/canvas/canvas.h"
31 #include "wx/canvas/wire.h"
32 #include "wx/canvas/canwidget.h"
33 
34 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
35 #include <wx/msw/msvcrt.h>
36 #endif
37 
38 IMPLEMENT_CLASS( a2dRectMM, a2dCanvasObject )
39 IMPLEMENT_CLASS( a2dWindowMM, a2dRectMM )
40 IMPLEMENT_CLASS( a2dRectWindowT2, a2dRectMM )
41 IMPLEMENT_CLASS( a2dRectWindow, a2dRectMM )
42 
43 //----------------------------------------------------------------------------
44 // a2dRectMM
45 //----------------------------------------------------------------------------
46 
47 BEGIN_EVENT_TABLE( a2dRectMM, a2dCanvasObject )
48  EVT_CANVASHANDLE_MOUSE_EVENT( a2dRectMM::OnHandleEvent )
49 END_EVENT_TABLE()
50 
51 a2dRectMM::a2dRectMM()
52  : a2dCanvasObject()
53 {
54  m_minx = 0;
55  m_miny = 0;
56  m_maxx = 0;
57  m_maxy = 0;
58  m_radius = 0;
59  m_contourwidth = 0;
60  m_border = 0;
61 }
62 
63 a2dRectMM::a2dRectMM( double x, double y, double w, double h , double radius, double contourwidth )
64  : a2dCanvasObject( x, y )
65 {
66  m_minx = 0;
67  m_miny = 0;
68  m_maxx = w;
69  m_maxy = h;
70  m_radius = radius;
71  m_contourwidth = contourwidth;
72  m_border = 0;
73 }
74 
75 a2dRectMM::a2dRectMM( const a2dPoint2D& p1, const a2dPoint2D& p2, double radius, double contourwidth )
76  : a2dCanvasObject( p1.m_x, p1.m_y )
77 {
78  m_minx = 0;
79  m_miny = 0;
80  m_maxx = p2.m_x - p1.m_x;
81  m_maxy = p2.m_y - p1.m_y;
82  m_radius = radius;
83  m_contourwidth = contourwidth;
84  m_border = 0;
85 }
86 
87 a2dRectMM::a2dRectMM( const a2dBoundingBox& bbox, double radius, double contourwidth )
88  : a2dCanvasObject( bbox.GetMinX(), bbox.GetMinY() )
89 {
90  m_minx = bbox.GetMinX();
91  m_miny = bbox.GetMinY();
92  m_maxx = bbox.GetMaxX();
93  m_maxy = bbox.GetMaxY();
94  m_radius = radius;
95  m_contourwidth = contourwidth;
96  m_border = 0;
97 }
98 
99 a2dRectMM::~a2dRectMM()
100 {
101 }
102 
103 a2dRectMM::a2dRectMM( const a2dRectMM& other, CloneOptions options, a2dRefMap* refs )
104  : a2dCanvasObject( other, options, refs )
105 {
106  m_minx = other.m_minx;
107  m_miny = other.m_miny;
108  m_maxx = other.m_maxx;
109  m_maxy = other.m_maxy;
110  m_radius = other.m_radius;
112  m_border = other.m_border;
113 }
114 
116 {
117  return new a2dRectMM( *this, options, refs );
118 };
119 
120 a2dVertexList* a2dRectMM::GetAsVertexList( bool& returnIsPolygon ) const
121 {
122  returnIsPolygon = true;
123 
124  a2dVertexList* pointlist = new a2dVertexList();
125 
126  a2dCanvasObjectList* vectorpaths = GetAsCanvasVpaths();
127  a2dVpath* segments = wxStaticCast( vectorpaths->front().Get(), a2dVectorPath ) ->GetSegments();
128  segments->ConvertToLines();
129  a2dLineSegment* point;
130  unsigned int i;
131  for ( i = 0; i < segments->size(); i++ )
132  {
133  a2dVpathSegmentPtr seg = segments->Item( i );
134  point = new a2dLineSegment( seg->m_x1, seg->m_y1 );
135  pointlist->push_back( point );
136  }
137 
138  delete vectorpaths;
139 
140  return pointlist;
141 }
142 
144 {
145  a2dAffineMatrix pworld;
146  if ( transform )
147  pworld = m_lworld;
148 
149  a2dVpath* segments = new a2dVpath();
150  a2dVectorPath* canpath = new a2dVectorPath( segments );
151  canpath->SetStroke( this->GetStroke() );
152  canpath->SetFill( this->GetFill() );
153  canpath->SetLayer( m_layer );
154  /*
155  if (m_radius)
156  {
157 
158  if ( m_radius < 0 )
159  {
160  double rx = -m_radius;
161  if ( m_maxx-m_minxx < 0 )
162  rx = -rx;
163 
164  double ry = -m_radius;
165  if ( m_maxy-m_minxy < 0 )
166  ry = -ry;
167 
168  a2dVpathSegment* seg = new a2dVpathSegment( rx, 0 , a2dPATHSEG_MOVETO );
169  segments->Add(seg);
170 
171  seg = new a2dVpathArcSegment( *seg, rx, ry, 0.0, ry, 0.0, 0.0, a2dPATHSEG_ARCTO );
172  segments->Add(seg);
173  seg = new a2dVpathSegment( 0, m_height - ry, a2dPATHSEG_LINETO );
174  segments->Add(seg);
175 
176  seg = new a2dVpathArcSegment( *seg, rx, m_height - ry, rx, m_height, 0.0, m_height, a2dPATHSEG_ARCTO );
177  segments->Add(seg);
178  seg = new a2dVpathSegment( m_width - rx, m_height, a2dPATHSEG_LINETO );
179  segments->Add(seg);
180 
181  seg = new a2dVpathArcSegment( *seg, m_width - rx, m_height - ry, m_width, m_height - ry, m_width, m_height, a2dPATHSEG_ARCTO );
182  segments->Add(seg);
183  seg = new a2dVpathSegment( m_width, ry, a2dPATHSEG_LINETO );
184  segments->Add(seg);
185 
186  seg = new a2dVpathArcSegment( *seg, m_width - rx, ry, m_width - rx, 0.0, m_width, 0.0, a2dPATHSEG_ARCTO, a2dPATHSEG_END_CLOSED );
187  segments->Add(seg);
188 
189  segments->Transform( pworld );
190  }
191  else
192  {
193  double rx = m_radius;
194  if ( m_width < 0 )
195  rx = -rx;
196 
197  double ry = m_radius;
198  if ( m_height < 0 )
199  ry = -ry;
200 
201  a2dVpathSegment* seg = new a2dVpathSegment( 0.0, -ry , a2dPATHSEG_MOVETO );
202  segments->Add(seg);
203 
204  seg = new a2dVpathArcSegment( *seg, 0.0, 0.0, -rx, 0.0, -rx, -ry, a2dPATHSEG_ARCTO );
205  segments->Add(seg);
206  seg = new a2dVpathSegment( -rx, m_height, a2dPATHSEG_LINETO );
207  segments->Add(seg);
208 
209  seg = new a2dVpathArcSegment( *seg, 0.0, m_height, 0.0, m_height + ry, -rx, m_height + ry, a2dPATHSEG_ARCTO );
210  segments->Add(seg);
211  seg = new a2dVpathSegment( m_width, m_height + ry, a2dPATHSEG_LINETO );
212  segments->Add(seg);
213 
214  seg = new a2dVpathArcSegment( *seg, m_width, m_height, m_width + rx, m_height, m_width + rx, m_height + ry, a2dPATHSEG_ARCTO );
215  segments->Add(seg);
216  seg = new a2dVpathSegment( m_width + rx, 0.0, a2dPATHSEG_LINETO );
217  segments->Add(seg);
218 
219  seg = new a2dVpathArcSegment( *seg, m_width, 0.0, m_width, -ry, m_width + rx, -ry, a2dPATHSEG_ARCTO, a2dPATHSEG_END_CLOSED );
220  segments->Add(seg);
221 
222  segments->Transform( pworld );
223  }
224  canpath->SetContourWidth( GetContourWidth() );
225  canpath->SetPathType( a2dPATH_END_SQAURE_EXT );
226  }
227  else
228  {
229  if ( GetContourWidth() )
230  {
231  double x,y;
232  double w = GetContourWidth()/2.0;
233  pworld.TransformPoint( -w, -w, x, y );
234  a2dVpathSegment* seg = new a2dVpathSegment( x, y , a2dPATHSEG_MOVETO );
235  segments->Add(seg);
236  pworld.TransformPoint( -w , m_height + w, x, y );
237  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO );
238  segments->Add(seg);
239  pworld.TransformPoint( m_width + w , m_height + w, x, y );
240  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO );
241  segments->Add(seg);
242  pworld.TransformPoint( m_width + w, -w, x, y );
243  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO );
244  segments->Add(seg);
245  pworld.TransformPoint( -w , -w, x, y );
246  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO );
247  segments->Add(seg);
248  pworld.TransformPoint( w, w, x, y );
249  seg = new a2dVpathSegment( x, y, a2dPATHSEG_LINETO_NOSTROKE );
250  segments->Add(seg);
251  pworld.TransformPoint( m_width - w, w, x, y );
252  seg = new a2dVpathSegment( x, y, a2dPATHSEG_LINETO );
253  segments->Add(seg);
254  pworld.TransformPoint( m_width - w, m_height - w, x, y );
255  seg = new a2dVpathSegment( x, y, a2dPATHSEG_LINETO );
256  segments->Add(seg);
257  pworld.TransformPoint( w, m_height - w, x, y );
258  seg = new a2dVpathSegment( x, y, a2dPATHSEG_LINETO );
259  segments->Add(seg);
260  pworld.TransformPoint( w, w, x, y );
261  seg = new a2dVpathSegment( x, y, a2dPATHSEG_LINETO );
262  segments->Add(seg);
263  pworld.TransformPoint( -w, -w, x, y );
264  seg = new a2dVpathSegment( x, y, a2dPATHSEG_LINETO_NOSTROKE, a2dPATHSEG_END_CLOSED );
265  segments->Add(seg);
266  }
267  else
268  {
269  double x,y;
270  pworld.TransformPoint( 0, 0, x, y );
271  a2dVpathSegment* seg = new a2dVpathSegment( x, y , a2dPATHSEG_MOVETO );
272  segments->Add(seg);
273  pworld.TransformPoint( 0 , m_height, x, y );
274  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO );
275  segments->Add(seg);
276  pworld.TransformPoint( m_width , m_height, x, y );
277  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO );
278  segments->Add(seg);
279  pworld.TransformPoint( m_width , 0, x, y );
280  seg = new a2dVpathSegment( x, y , a2dPATHSEG_LINETO, a2dPATHSEG_END_CLOSED );
281  segments->Add(seg);
282  }
283  }
284  */
285  a2dCanvasObjectList* canpathlist = new a2dCanvasObjectList();
286  canpathlist->push_back( canpath );
287  return canpathlist;
288 }
289 
290 
291 bool a2dRectMM::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
292 {
293  if ( m_flags.m_editable )
294  {
295  if ( editmode == 1 )
296  {
297  PROPID_Allowrotation->SetPropertyToObject( this, false );
298  PROPID_Allowskew->SetPropertyToObject( this, false );
299 
300  m_flags.m_visiblechilds = true;
302 
303  //add properties and handles as children in order to edit the object.
304  double rx = m_radius;
305  if ( ( m_radius < 0 && m_maxx - m_minx < 0 ) || ( m_radius > 0 && m_maxx - m_minx > 0 ) )
306  rx = -rx;
307 
308  a2dHandle* handle = new a2dHandle( this, m_minx + rx , m_miny, wxT( "__rounding__" ),
309  Round( GetHabitat()->GetHandle()->GetWidth() * 1.5 ),
310  Round( GetHabitat()->GetHandle()->GetHeight() * 1.5 ) );
311  Append( handle );
312  handle->SetSpecificFlags( true, a2dCanvasOFlags::BIN2 );
313  handle->SetLayer( m_layer );
314 
315  double radius = m_radius;
316  m_radius = 0;
317  double x, y, w, h;
318  x = m_minx;
319  y = m_miny;
320  w = m_maxx - m_minx;
321  h = m_maxy - m_miny;
322  m_radius = radius;
323  /*
324  a2dRectMM* around = new a2dRectMM( x, y, w, h );
325  around->SetStroke( *wxRED, 0, a2dSTROKE_DOT_DASH );
326  around->SetFill( *a2dTRANSPARENT_FILL );
327  around->SetPreRenderAsChild( false );
328  around->SetSpecificFlags( true, a2dCanvasOFlags::BIN2 );
329  around->SetHitFlags( a2dCANOBJ_EVENT_NON );
330  around->SetLayer( m_layer );
331  Append( around );
332  */
333  Append( handle = new a2dHandle( this, x, y, wxT( "handle1" ) ) );
334  handle->SetLayer( m_layer );
335  Append( handle = new a2dHandle( this, x, y + h, wxT( "handle2" ) ) );
336  handle->SetLayer( m_layer );
337  Append( handle = new a2dHandle( this, x + w, y + h , wxT( "handle3" ) ) );
338  handle->SetLayer( m_layer );
339  Append( handle = new a2dHandle( this, x + w, y, wxT( "handle4" ) ) );
340  handle->SetLayer( m_layer );
341  Append( handle = new a2dHandle( this, x, y + h / 2 , wxT( "handle12" ) ) );
342  handle->SetLayer( m_layer );
343  Append( handle = new a2dHandle( this, x + w / 2, y + h, wxT( "handle23" ) ) );
344  handle->SetLayer( m_layer );
345  Append( handle = new a2dHandle( this, x + w, y + h / 2 , wxT( "handle34" ) ) );
346  handle->SetLayer( m_layer );
347  Append( handle = new a2dHandle( this, x + w / 2, y, wxT( "handle41" ) ) );
348 
350  m_childobjects->SetSpecificFlags( true, a2dCanvasOFlags::BIN2, wxT( "a2dHandle" ) );
351 
352  //calculate bbox's else mouse events may take place when first idle event is not yet
353  //processed to do this calculation.
355  //still set it pending to do the redraw ( in place )
356  SetPending( true );
357  return true;
358  }
359  else
360  {
361  PROPID_IncludeChildren->SetPropertyToObject( this, false );
362  PROPID_Allowrotation->SetPropertyToObject( this, false );
363  PROPID_Allowskew->SetPropertyToObject( this, false );
364 
365  return a2dCanvasObject::DoStartEdit( editmode, editstyle );
366  }
367  }
368 
369  return false;
370 }
371 
372 void a2dRectMM::OnHandleEvent( a2dHandleMouseEvent& event )
373 {
374  a2dIterC* ic = event.GetIterC();
375 
376  if ( m_flags.m_editingCopy )
377  {
378  a2dRestrictionEngine* restrictEngine = GetHabitat()->GetRestrictionEngine();
379  a2dHandle* draghandle = event.GetCanvasHandle();
380 
381  wxUint16 editmode = PROPID_Editmode->GetPropertyValue( this );
382 
383  if ( editmode == 1 )
384  {
385  double xw, yw;
386  xw = event.GetX();
387  yw = event.GetY();
388 
389  a2dAffineMatrix atWorld = ic->GetTransform();
390  a2dAffineMatrix inverse = ic->GetInverseTransform();
391 
392  double xwi;
393  double ywi;
394  inverse.TransformPoint( xw, yw, xwi, ywi );
395 
396  a2dRectMM* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dRectMM );
397 
398  double w, h;
399  w = m_maxx - m_minx;
400  h = m_maxy - m_miny;
401 
402  a2dAffineMatrix origworld = m_lworld;
403  double radius = m_radius;
404  if ( event.GetMouseEvent().LeftDown() )
405  {
406  }
407  else if ( event.GetMouseEvent().LeftUp() )
408  {
409  if ( draghandle->GetName() == wxT( "__rounding__" ) )
410  {
411  original->SetRadius( m_radius );
412  }
413  else
414  {
415  original->SetMin( m_minx, m_miny );
416  original->SetMax( m_maxx, m_maxy );
417  }
418  }
419  else if ( event.GetMouseEvent().Dragging() )
420  {
421  if ( restrictEngine )
422  restrictEngine->RestrictPoint( xw, yw );
423  ic->GetInverseTransform().TransformPoint( xw, yw, xwi, ywi );
424 
425  if ( draghandle->GetName() == wxT( "__rounding__" ) )
426  {
427  //assume outward
428  if ( ( m_maxx - m_minx < 0 && xwi < 0 ) || ( m_maxx - m_minx > 0 && xwi > 0 ) )
429  {
430  //inward
431  if ( fabs( xwi ) < fabs( ( m_maxx - m_minx ) / 2 ) && fabs( xwi ) < fabs( ( m_maxy - m_miny ) / 2 ) )
432  {
433  m_radius = -fabs( xwi );
434  draghandle->SetPosXY( xwi, m_miny );
435  SetPending( true );
436  }
437  }
438  else
439  {
440  m_radius = fabs( xwi );
441  draghandle->SetPosXY( xwi, m_miny );
442  SetPending( true );
443  }
444  }
445  else if ( draghandle->GetName() == wxT( "handle1" ) )
446  {
447  m_minx = xwi;
448  m_miny = ywi;
449  }
450  else if ( draghandle->GetName() == wxT( "handle2" ) )
451  {
452  m_minx = xwi;
453  m_maxy = ywi;
454  }
455  else if ( draghandle->GetName() == wxT( "handle3" ) )
456  {
457  m_maxx = xwi;
458  m_maxy = ywi;
459  }
460  else if ( draghandle->GetName() == wxT( "handle4" ) )
461  {
462  m_maxx = xwi;
463  m_miny = ywi;
464  }
465  else if ( draghandle->GetName() == wxT( "handle12" ) )
466  {
467  m_minx = xwi;
468  }
469  else if ( draghandle->GetName() == wxT( "handle23" ) )
470  {
471  m_maxy = ywi;
472  }
473  else if ( draghandle->GetName() == wxT( "handle34" ) )
474  {
475  m_maxx = xwi;
476  }
477  else if ( draghandle->GetName() == wxT( "handle41" ) )
478  {
479  m_miny = ywi;
480  }
481  else
482  event.Skip();
483 
484  SetHandlePos( wxT( "__rounding__" ), m_minx + m_radius, m_miny );
485  SetHandlePos( wxT( "handle1" ), m_minx, m_miny );
486  SetHandlePos( wxT( "handle2" ), m_minx, m_maxy );
487  SetHandlePos( wxT( "handle3" ), m_maxx, m_maxy );
488  SetHandlePos( wxT( "handle4" ), m_maxx, m_miny );
489  SetHandlePos( wxT( "handle12" ), m_minx, m_miny + h / 2 );
490  SetHandlePos( wxT( "handle23" ), m_minx + w / 2, m_maxy );
491  SetHandlePos( wxT( "handle34" ), m_maxx, m_miny + h / 2 );
492  SetHandlePos( wxT( "handle41" ), m_minx + w / 2, m_miny );
493  SetPending( true );
494  }
495  }
496  else
497  {
498  event.Skip();
499  }
500  }
501  else
502  {
503  event.Skip();
504  }
505 }
506 
508 {
509  a2dBoundingBox bbox;
510  bbox.Expand( m_minx, m_miny );
511  bbox.Expand( m_maxx, m_maxy );
512 
513  if ( !( flags & a2dCANOBJ_BBOX_EDIT ) )
514  {
515  if ( m_radius > 0 )
516  bbox.Enlarge( m_radius );
517 
518  if ( m_contourwidth > 0 )
519  bbox.Enlarge( m_contourwidth / 2 );
520  }
521  return bbox;
522 }
523 
524 void a2dRectMM::DoRender( a2dIterC& ic, OVERLAP clipparent )
525 {
526  if ( m_contourwidth )
527  {
528  a2dCanvasObjectList* vectorpaths = GetAsCanvasVpaths( false );
529 
530  forEachIn( a2dCanvasObjectList, vectorpaths )
531  {
532  a2dVectorPath* obj = wxStaticCast( ( *iter ).Get(), a2dVectorPath );
533  obj->DoRender( ic, clipparent );
534  }
535  delete vectorpaths;
536  }
537  else
538  {
539  if ( m_radius <= 0 )
540  {
541  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_miny, -m_radius );
542  }
543  else
544  {
545  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx - m_radius, m_miny - m_radius, m_maxx - m_minx + 2 * m_radius, m_maxy - m_miny + 2 * m_radius, m_radius );
546  }
547  }
548 }
549 
550 #if wxART2D_USE_CVGIO
551 
552 void a2dRectMM::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
553 {
554  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
555  if ( xmlparts == a2dXmlSer_attrib )
556  {
557  if ( m_radius != 0.0 )
558  {
559  out.WriteAttribute( wxT( "minx" ), m_minx );
560  out.WriteAttribute( wxT( "miny" ), m_miny );
561  out.WriteAttribute( wxT( "maxx" ), m_maxx );
562  out.WriteAttribute( wxT( "maxy" ), m_maxy );
563  out.WriteAttribute( wxT( "radius" ), m_radius );
564  out.WriteAttribute( wxT( "contourwidth" ), m_contourwidth );
565  }
566  }
567  else
568  {
569  }
570 }
571 
572 void a2dRectMM::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
573 {
574  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
575  if ( xmlparts == a2dXmlSer_attrib )
576  {
577  m_minx = parser.GetAttributeValueDouble( wxT( "minx" ) );
578  m_miny = parser.GetAttributeValueDouble( wxT( "miny" ) );
579  m_maxx = parser.GetAttributeValueDouble( wxT( "maxx" ) );
580  m_maxy = parser.GetAttributeValueDouble( wxT( "maxy" ) );
581  m_radius = parser.GetAttributeValueDouble( wxT( "radius" ) );
582  m_contourwidth = parser.GetAttributeValueDouble( wxT( "contourwidth" ), 0 );
583  }
584  else
585  {
586  }
587 }
588 #endif //wxART2D_USE_CVGIO
589 
591 {
592  double margin = ic.GetTransformedHitMargin();
593 
594  if ( m_radius > 0 )
595  {
596  m_minx -= m_radius;
597  m_miny -= m_radius;
598  m_maxx += m_radius;
599  m_maxy += m_radius;
600  }
601 
602  hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, m_minx, m_miny, m_maxx, m_maxy, ic.GetWorldStrokeExtend() + margin + m_contourwidth );
603 
604  return hitEvent.m_how.IsHit();
605 }
606 
607 bool a2dRectMM::GeneratePins( a2dPinClass* toConnectTo, a2dConnectTask task, double WXUNUSED( x ), double WXUNUSED( y ), double WXUNUSED(margin) )
608 {
609  a2dPinClass* toCreate;
610  if ( GetGeneratePins() && ( toCreate = toConnectTo->GetPinClassForTask( task, this ) ) )
611  {
612  double width = m_maxx - m_minx;
613  double height = m_maxy - m_miny;
614  m_flags.m_visiblechilds = true;
615  a2dPin* newPin = NULL;
616  if ( !HasPinNamed( wxT( "pinc*" ), true ) )
617  {
618  newPin = AddPin( wxT( "pinc" ), width / 2, height / 2, a2dPin::temporaryObjectPin, toCreate );
619  newPin->SetInternal( true );
620  }
621  if ( !HasPinNamed( wxT( "pin1" ), true ) )
622  AddPin( wxT( "pin1" ), m_minx, m_miny, a2dPin::temporaryObjectPin, toCreate );
623  if ( !HasPinNamed( wxT( "pin2" ), true ) )
624  AddPin( wxT( "pin2" ), m_minx, m_miny + height / 2, a2dPin::temporaryObjectPin, toCreate );
625  if ( !HasPinNamed( wxT( "pin3" ), true ) )
626  AddPin( wxT( "pin3" ), m_minx, m_maxy, a2dPin::temporaryObjectPin, toCreate );
627  if ( !HasPinNamed( wxT( "pin4" ), true ) )
628  AddPin( wxT( "pin4" ), m_minx + width / 2, m_maxy, a2dPin::temporaryObjectPin, toCreate );
629  if ( !HasPinNamed( wxT( "pin5" ), true ) )
630  AddPin( wxT( "pin5" ), m_maxx, m_maxy, a2dPin::temporaryObjectPin, toCreate );
631  if ( !HasPinNamed( wxT( "pin6" ), true ) )
632  AddPin( wxT( "pin6" ), m_maxx, m_miny + height / 2 , a2dPin::temporaryObjectPin, toCreate );
633  if ( !HasPinNamed( wxT( "pin7" ), true ) )
634  AddPin( wxT( "pin7" ), m_maxx, m_miny, a2dPin::temporaryObjectPin, toCreate );
635  if ( !HasPinNamed( wxT( "pin8" ), true ) )
636  AddPin( wxT( "pin8" ), m_maxx + width / 2, m_miny, a2dPin::temporaryObjectPin, toCreate );
637 
638  wxASSERT( HasPins() );
640  return true;
641  }
642  return false;
643 }
644 
645 
646 bool a2dRectMM::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
647 {
648  bool calc = false;
649  if ( !m_bbox.GetValid() )
650  {
651  calc = a2dCanvasObject::DoUpdate( mode, childbox, clipbox, propbox );
652 
654  {
655  m_minx = wxMin( childbox.GetMinX(), m_minx );
656  m_miny = wxMin( childbox.GetMinY(), m_miny );
657  m_maxx = wxMax( childbox.GetMaxX(), m_maxx );
658  m_maxy = wxMax( childbox.GetMaxY(), m_maxy );
659 
660 
661  m_minx = childbox.GetMinX() - m_border;
662  m_miny = childbox.GetMinY() - m_border;
663  m_maxx = childbox.GetMaxX() + m_border;
664  m_maxy = childbox.GetMaxY() + m_border;
665 
666  }
667  }
668  return calc;
669 }
670 
671 //----------------------------------------------------------------------------
672 // a2dWindowMM
673 //----------------------------------------------------------------------------
674 
675 BEGIN_EVENT_TABLE( a2dWindowMM, a2dCanvasObject )
676  EVT_CANVASHANDLE_MOUSE_EVENT( a2dWindowMM::OnHandleEvent )
677  EVT_CANVASOBJECT_ENTER_EVENT( a2dWindowMM::OnEnterObject )
678  EVT_CANVASOBJECT_LEAVE_EVENT( a2dWindowMM::OnLeaveObject )
679 END_EVENT_TABLE()
680 
682  : a2dRectMM()
683 {
684  Init();
685 }
686 
687 a2dWindowMM::a2dWindowMM( double x, double y, double w, double h )
688  : a2dRectMM( x, y, w, h )
689 {
690  Init();
691 }
692 
693 a2dWindowMM::a2dWindowMM( const a2dPoint2D& p1, const a2dPoint2D& p2 )
694  : a2dRectMM( p1, p2 )
695 {
696  Init();
697 }
698 
699 a2dWindowMM::a2dWindowMM( const a2dBoundingBox& bbox )
700  : a2dRectMM( bbox )
701 {
702  Init();
703 }
704 
705 a2dWindowMM::~a2dWindowMM()
706 {
707 }
708 
709 a2dWindowMM::a2dWindowMM( const a2dWindowMM& other, CloneOptions options, a2dRefMap* refs )
710  : a2dRectMM( other, options, refs )
711 {
712  m_style = other.m_style;
713  m_state = other.m_state;
714 
715  m_backStroke = other.m_backStroke;
716  m_darkStroke = other.m_darkStroke;
717  m_lightStroke = other.m_lightStroke;
718  m_whiteStroke = other.m_whiteStroke;
719  m_blackStroke = other.m_blackStroke;
720  m_hoverStroke = other.m_hoverStroke;
721 }
722 
724 {
725  return new a2dWindowMM( *this, options, refs );
726 };
727 
729 {
730  m_style = RAISED;
731  m_state = NON;
732 
733  SetFill( a2dFill( wxColour( 212, 208, 200 ), a2dFILL_SOLID ) );
734  m_backStroke = a2dStroke( wxColour( 212, 208, 200 ), a2dSTROKE_SOLID );
735  m_darkStroke = a2dStroke( wxColour( 64, 64, 64 ), 0, a2dSTROKE_SOLID );
736  m_lightStroke = a2dStroke( wxColour( 128, 128, 128 ), 0, a2dSTROKE_SOLID );
737  m_hoverStroke = a2dStroke( wxColour( 255, 0, 0 ), 0, a2dSTROKE_SOLID );
738  m_whiteStroke = *a2dWHITE_STROKE;
739  m_blackStroke = *a2dBLACK_STROKE;
740 }
741 
742 void a2dWindowMM::OnEnterObject( a2dCanvasObjectMouseEvent& event )
743 {
744  m_state |= HOVER;
745  SetPending( true );
746  event.Skip(); //e.g. for base class object tip
747 }
748 
749 void a2dWindowMM::OnLeaveObject( a2dCanvasObjectMouseEvent& event )
750 {
751  m_state &= ( ALL ^ HOVER );
752  SetPending( true );
753  event.Skip(); //e.g. for base class object tip
754 }
755 
756 void a2dWindowMM::DoRender( a2dIterC& ic, OVERLAP clipparent )
757 {
758  double oneP = ic.GetDrawer2D()->DeviceToWorldXRel( 1 );
759 
760  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_miny, 0 );
761 
763  if ( m_style & SUNKEN )
764  {
765 
766  if ( m_state & FOCUS )
767  {
768  ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
769  ic.GetDrawer2D()->DrawLine( m_minx, m_miny + oneP, m_maxx, m_miny + oneP );
770  ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny, m_maxx - oneP, m_maxy );
771  ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
772  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
773  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_minx, m_maxy );
774  ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
775  ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
776  ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_minx, m_miny );
777  }
778  else
779  {
780  ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
781  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
782  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
783 
784  ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
785  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
786  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
787  ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
788  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + 2 * oneP, m_minx + oneP, m_maxy );
789  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_maxy - oneP, m_maxx, m_maxy - oneP );
790 
791  ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
792  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + oneP, m_maxx, m_miny + oneP );
793  ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny + oneP, m_maxx - oneP, m_maxy );
794  ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
795  ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
796  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
797  }
798  }
799  else
800  {
801  if ( m_state & FOCUS )
802  {
803  ic.GetDrawer2D()->SetDrawerStroke( m_blackStroke );
804  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
805  ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
806  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
807  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
808  ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
809  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + 2 * oneP, m_minx + oneP, m_maxy );
810  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_maxy - oneP, m_maxx, m_maxy - oneP );
811 
812  ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
813  ic.GetDrawer2D()->DrawLine( m_minx + 2 * oneP, m_miny + 2 * oneP, m_maxx - oneP, m_miny + 2 * oneP );
814  ic.GetDrawer2D()->DrawLine( m_maxx - 2 * oneP, m_miny + 2 * oneP, m_maxx - 2 * oneP, m_maxy - oneP );
815 
816  ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
817  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + oneP, m_maxx, m_miny + oneP );
818  ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny + oneP, m_maxx - oneP, m_maxy );
819  }
820  else
821  {
822  ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
823  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
824  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
825 
826  ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
827  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
828  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
829  ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
830  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + 2 * oneP, m_minx + oneP, m_maxy );
831  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_maxy - oneP, m_maxx, m_maxy - oneP );
832 
833  ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
834  ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + oneP, m_maxx, m_miny + oneP );
835  ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny + oneP, m_maxx - oneP, m_maxy );
836  ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
837  ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
838  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
839  }
840  }
842 
843  if ( m_state &= HOVER )
844  {
845  ic.GetDrawer2D()->SetDrawerStroke( m_hoverStroke );
846  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
847  ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
848  ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
849  ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
850  }
851  else
852  {
853 
854  }
855 }
856 
857 #if wxART2D_USE_CVGIO
858 
859 void a2dWindowMM::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
860 {
861  a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
862  if ( xmlparts == a2dXmlSer_attrib )
863  {
864  if ( m_radius != 0.0 )
865  {
866  }
867  }
868  else
869  {
870  }
871 }
872 
873 void a2dWindowMM::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
874 {
875  a2dCanvasObject::DoLoad( parent, parser, xmlparts );
876  if ( xmlparts == a2dXmlSer_attrib )
877  {
878  }
879  else
880  {
881  }
882 }
883 #endif //wxART2D_USE_CVGIO
884 
885 bool a2dWindowMM::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
886 {
887  return a2dRectMM::DoUpdate( mode, childbox, clipbox, propbox );
888 }
889 
890 //----------------------------------------------------------------------------
891 // a2dRectWindowT2
892 //----------------------------------------------------------------------------
893 
895 
896 
897 const long a2dCLOSE_BUTTON = wxNewId();
898 
899 BEGIN_EVENT_TABLE( a2dRectWindowT2, a2dRectMM )
901  EVT_BUTTON( a2dCLOSE_BUTTON, a2dRectWindowT2::OnCloseWindow )
902 END_EVENT_TABLE()
903 
904 void a2dRectWindowT2::Init( a2dCanvasObject* parent )
905 {
906  m_flipIn = false;//true;
907  m_titleObj = new a2dCanvasObject( 0, 0 );
908 
909  m_parent = parent;
910  m_close = new a2dWidgetButton( this, a2dCLOSE_BUTTON, 0, 0, m_initialTitleHeight, m_initialTitleHeight, a2dWidgetButton::ScaledContentKeepAspect );
911  m_close->SetHighLightStroke( a2dStroke( wxColour( 10, 222, 215 ), a2dSTROKE_SOLID ) );
912  m_close->SetHighLightFill( a2dFill( wxColour( 255, 102, 102 ), a2dFILL_SOLID ) );
913  m_close->SetFill( wxColour( 195, 195, 195 ) );
914  m_close->SetStroke( wxColour( 195, 0, 0 ) );
915  m_close->SetName( wxT( "__CLOSE_BUTTON__" ) );
916  m_close->SetDraggable( false );
917 
918  a2dSLine* ll = new a2dSLine( 0, 0, m_initialTitleHeight, m_initialTitleHeight );
919  ll->SetStroke( wxColour( 252, 0, 252 ), 1.0 );
920  a2dSLine* ll2 = new a2dSLine( 0, m_initialTitleHeight, m_initialTitleHeight, 0 );
921  ll2->SetStroke( wxColour( 252, 0, 252 ), 1.0 );
922  a2dCanvasObject* cont = new a2dCanvasObject( 0, 0 );
923  cont->Append( ll );
924  cont->Append( ll2 );
925  m_close->SetContentObject( cont );
926 
927  //a2dText* tip = m_close->SetObjectTip( _T("close this window object") , 0, 0, 10 );
928  //tip->SetFill( wxColour( 195,5,195) );
929 
930  m_titleFill = *a2dWHITE_FILL;
931  m_titleStroke = *a2dBLACK_STROKE;
932 
933  m_title = new a2dText( wxT( "" ), 0, 0, a2dFont( m_initialTitleHeight, wxSWISS ) );
934  m_title->SetName( wxT( "__TITLE__" ) );
935  m_title->SetDraggable( false );
936  m_title->SetSubEditAsChild( true );
937 
938  m_titleObj->Append( m_close );
939  m_titleObj->Append( m_title );
940 
941 }
942 
943 
944 a2dRectWindowT2::a2dRectWindowT2()
945  : a2dRectMM()
946 {
947  Init( NULL );
948 }
949 
950 a2dRectWindowT2::a2dRectWindowT2( a2dCanvasObject* parent, double x, double y, double w, double h , double radius )
951  : a2dRectMM( x, y, w, h, radius, 0 )
952 {
953  Init( parent );
954 }
955 
956 a2dRectWindowT2::a2dRectWindowT2( a2dCanvasObject* parent, const a2dPoint2D& p1, const a2dPoint2D& p2, double radius )
957  : a2dRectMM( p1, p2, radius, 0 )
958 {
959  Init( parent );
960 }
961 
962 a2dRectWindowT2::a2dRectWindowT2( a2dCanvasObject* parent, const a2dBoundingBox& bbox, double radius )
963  : a2dRectMM( bbox, radius, 0 )
964 {
965  Init( parent );
966 }
967 
969 {
970 }
971 
972 a2dRectWindowT2::a2dRectWindowT2( const a2dRectWindowT2& other, CloneOptions options, a2dRefMap* refs )
973  : a2dRectMM( other, options, refs )
974 {
975  m_titleFill = other.m_titleFill;
977  m_parent = other.m_parent;
978  m_flipIn = other.m_flipIn;
979  m_titleObj = other.m_titleObj->TClone( clone_flat );
980 
981  m_title = ( a2dText* ) m_titleObj->Find( wxT( "__TITLE__" ) );
982  m_close = ( a2dWidgetButton* ) m_titleObj->Find( wxT( "__CLOSE_BUTTON__" ) );
983  m_close->SetParent( this );
984 }
985 
987 {
988  return new a2dRectWindowT2( *this, options, refs );
989 };
990 
991 void a2dRectWindowT2::SetTitle( const wxString& title )
992 {
993  a2dText* textobj = ( a2dText* ) m_titleObj->Find( _T( "__TITLE__" ) );
994  if ( title.IsEmpty() )
995  ReleaseChild( textobj );
996  else
997  {
998  if ( !textobj )
999  {
1000  textobj = new a2dText( title, 0, 0, a2dFont( 10, wxSWISS ), 0 );
1001  textobj->SetDraggable( false );
1002  Append( textobj );
1003  textobj->SetName( _T( "__TITLE__" ) );
1004  }
1005  else
1006  textobj->SetText( title );
1007  }
1008 }
1009 
1011 {
1012  m_titleObj->ReleaseChild( m_title );
1013  m_title = textObj;
1014  m_titleObj->Append( m_title );
1015  m_title->SetName( _T( "__TITLE__" ) );
1016 };
1017 
1018 void a2dRectWindowT2::OnCloseWindow( wxCommandEvent& event )
1019 {
1020  if ( m_flags.m_editingCopy )
1021  {
1022  a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
1023  //delete object from document (actually move to command for redo)
1025  new a2dCommand_ReleaseObject( m_parent, original, false )
1026  );
1027  EndEdit();
1028  }
1029  else
1030  {
1032  new a2dCommand_ReleaseObject( m_parent, this, false )
1033  );
1034  }
1035 }
1036 
1037 bool a2dRectWindowT2::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
1038 {
1039  if ( m_flags.m_editable )
1040  {
1041  PROPID_IncludeChildren->SetPropertyToObject( this, false );
1042  PROPID_Allowrotation->SetPropertyToObject( this, false );
1043  PROPID_Allowskew->SetPropertyToObject( this, false );
1044 
1045  return a2dRectMM::DoStartEdit( editmode, editstyle );
1046  }
1047 
1048  return false;
1049 }
1050 
1051 void a2dRectWindowT2::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
1052 {
1053  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
1054  a2dRectMM::DoWalker( parent, handler );
1055 
1056  m_titleObj->Walker( this, handler );
1057 
1058  handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
1059 }
1060 
1062 {
1063  a2dRectMM::ProcessCanvasObjectEvent( ic, hitEvent );
1064  a2dIterCU cu( ic, m_lworld );
1065  m_titleObj->ProcessCanvasObjectEvent( ic, hitEvent );
1066  return hitEvent.m_processed;
1067 }
1068 
1070 {
1072  m_titleObj->AddPending( ic );
1073 }
1074 
1076 {
1077  m_titleObj->Update( mode );
1078  return a2dRectMM::Update( mode );
1079 }
1080 
1082 {
1083  if ( !m_flipIn )
1084  a2dRectMM::Render( ic, clipparent );
1085 
1086  a2dIterCU cu( ic, m_lworld );
1087  m_titleObj->Render( ic, clipparent );
1088 }
1089 
1091 {
1092  a2dStroke current = ic.GetDrawer2D()->GetDrawerStroke();
1093  a2dFill fillcurrent = ic.GetDrawer2D()->GetDrawerFill();
1094 
1097 
1098  if ( m_radius <= 0 )
1099  {
1100  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight, 0 );
1101  ic.GetDrawer2D()->SetDrawerStroke( current );
1102  if ( !m_flipIn )
1103  {
1104  ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
1105  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_titleheight - m_miny, -m_radius );
1106  }
1107  }
1108  else
1109  {
1110  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight, 0 );
1111  ic.GetDrawer2D()->SetDrawerStroke( current );
1112  if ( !m_flipIn )
1113  {
1114  ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
1115  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx - m_radius, m_miny - m_radius, m_maxx - m_minx + 2 * m_radius, m_maxy - m_miny + 2 * m_radius, m_radius );
1116  }
1117  }
1118 }
1119 
1120 #if wxART2D_USE_CVGIO
1121 
1122 void a2dRectWindowT2::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1123 {
1124  a2dRectMM::DoSave( parent, out, xmlparts, towrite );
1125  if ( xmlparts == a2dXmlSer_attrib )
1126  {
1127  }
1128  else
1129  {
1130  }
1131 }
1132 
1133 void a2dRectWindowT2::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1134 {
1135  a2dRectMM::DoLoad( parent, parser, xmlparts );
1136  if ( xmlparts == a2dXmlSer_attrib )
1137  {
1138  }
1139  else
1140  {
1141  }
1142 }
1143 #endif //wxART2D_USE_CVGIO
1144 
1145 bool a2dRectWindowT2::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1146 {
1147  bool calc = false;
1148  if ( !m_bbox.GetValid() )
1149  {
1150  calc = a2dRectMM::DoUpdate( mode, childbox, clipbox, propbox );
1151 
1152  m_title->SetPosXY( m_minx, m_maxy );
1154  titlebox.Translate( m_title->GetPosX(), m_title->GetPosY() );
1156  m_titleheight = titlebox.GetHeight();
1159 
1161  {
1162  m_minx = wxMin( childbox.GetMinX(), m_minx );
1163  m_miny = wxMin( childbox.GetMinY(), m_miny );
1164  m_maxx = wxMax( childbox.GetMaxX(), m_maxx );
1165  m_maxy = wxMax( childbox.GetMaxY(), m_maxy );
1166  /*
1167  m_minx = childbox.GetMinX();
1168  m_miny = childbox.GetMinY();
1169  m_maxx = childbox.GetMaxX();
1170  m_maxy = childbox.GetMaxY();
1171  childbox.Dump();
1172  */
1173  }
1174  }
1175  return calc;
1176 }
1177 
1178 
1179 
1180 
1181 
1182 
1183 
1184 
1185 
1186 
1187 //----------------------------------------------------------------------------
1188 // a2dRectWindow
1189 //----------------------------------------------------------------------------
1190 
1192 
1193 BEGIN_EVENT_TABLE( a2dRectWindow, a2dWindowMM )
1195  EVT_BUTTON( a2dCLOSE_BUTTON, a2dRectWindow::OnCloseWindow )
1196 END_EVENT_TABLE()
1197 
1198 void a2dRectWindow::Init( a2dCanvasObject* parent )
1199 {
1200  m_parent = parent;
1201  m_close = new a2dWidgetButton( this, a2dCLOSE_BUTTON, 0, 0, m_initialTitleHeight, m_initialTitleHeight );
1202  Append( m_close );
1203  m_close->SetHighLightStroke( a2dStroke( wxColour( 10, 222, 215 ), a2dSTROKE_SOLID ) );
1204  m_close->SetHighLightFill( a2dFill( wxColour( 255, 102, 102 ), a2dFILL_SOLID ) );
1205  m_close->SetFill( wxColour( 195, 195, 195 ) );
1206  m_close->SetStroke( wxColour( 195, 0, 0 ) );
1207  m_close->SetName( wxT( "__CLOSE_BUTTON__" ) );
1208  m_close->SetDraggable( false );
1209  //a2dText* tip = m_close->SetObjectTip( _T("close this window object") , 0, 0, 10 );
1210  //tip->SetFill( wxColour( 195,5,195) );
1211 
1212  m_titleFill = *a2dWHITE_FILL;
1213  m_titleFill = a2dFill( wxColour( 0, 202, 202 ), a2dFILL_SOLID );
1214  m_titleStroke = *a2dBLACK_STROKE;
1215 
1216  m_title = new a2dText( wxT( "" ), 0, 0, a2dFont( m_initialTitleHeight, wxSWISS ) );
1217  Append( m_title );
1218  m_title->SetName( wxT( "__TITLE__" ) );
1219  m_title->SetDraggable( false );
1220  m_title->SetSubEditAsChild( true );
1221  m_title->SetMultiLine( false );
1222 
1223  m_canvas = new a2dWindowMM( 0, 0, 300, 310 );
1224  m_canvas->SetBorder( 20 );
1225  m_canvas->SetResizeOnChildBox( true );
1226  m_canvas->SetSubEdit( true );
1227  m_canvas->SetName( wxT( "__CANVAS__" ) );
1228  m_canvas->SetSubEdit( true );
1229  m_canvas->SetSubEditAsChild( true );
1230  Append( m_canvas );
1231 }
1232 
1233 
1234 a2dRectWindow::a2dRectWindow()
1235  : a2dWindowMM()
1236 {
1237  Init( NULL );
1238 }
1239 
1240 a2dRectWindow::a2dRectWindow( a2dCanvasObject* parent, double x, double y, double w, double h )
1241  : a2dWindowMM( x, y, w, h )
1242 {
1243  Init( parent );
1244 }
1245 
1246 a2dRectWindow::a2dRectWindow( a2dCanvasObject* parent, const a2dPoint2D& p1, const a2dPoint2D& p2 )
1247  : a2dWindowMM( p1, p2 )
1248 {
1249  Init( parent );
1250 }
1251 
1252 a2dRectWindow::a2dRectWindow( a2dCanvasObject* parent, const a2dBoundingBox& bbox )
1253  : a2dWindowMM( bbox )
1254 {
1255  Init( parent );
1256 }
1257 
1258 a2dRectWindow::~a2dRectWindow()
1259 {
1260 }
1261 
1262 a2dRectWindow::a2dRectWindow( const a2dRectWindow& other, CloneOptions options, a2dRefMap* refs )
1263  : a2dWindowMM( other, options, refs )
1264 {
1265  m_titleFill = other.m_titleFill;
1266  m_titleStroke = other.m_titleStroke;
1267  m_parent = other.m_parent;
1268 
1269  m_title = ( a2dText* ) Find( wxT( "__TITLE__" ) );
1270  m_close = ( a2dWidgetButton* ) Find( wxT( "__CLOSE_BUTTON__" ) );
1271  m_close->SetParent( this );
1272  m_canvas = ( a2dWindowMM* ) Find( wxT( "__CANVAS__" ) );
1273  m_canvas->SetSubEdit( true );
1274  m_canvas->SetSubEditAsChild( true );
1275 }
1276 
1278 {
1279  return new a2dRectWindow( *this, options, refs );
1280 };
1281 
1282 void a2dRectWindow::SetTitle( const wxString& title )
1283 {
1284  a2dText* textobj = ( a2dText* ) Find( _T( "__TITLE__" ) );
1285  if ( title.IsEmpty() )
1286  ReleaseChild( textobj );
1287  else
1288  {
1289  if ( !textobj )
1290  {
1291  textobj = new a2dText( title, 0, 0, a2dFont( 10, wxSWISS ), 0 );
1292  textobj->SetDraggable( false );
1293  Append( textobj );
1294  textobj->SetName( _T( "__TITLE__" ) );
1295  }
1296  else
1297  textobj->SetText( title );
1298  }
1299 }
1300 
1302 {
1303  ReleaseChild( m_title );
1304  m_title = textObj;
1305  Append( m_title );
1306  m_title->SetName( _T( "__TITLE__" ) );
1307 };
1308 
1310 {
1312  m_canvas = canvas;
1313  Append( m_canvas );
1314  m_canvas->SetName( _T( "__CANVAS__" ) );
1315 };
1316 
1317 void a2dRectWindow::OnCloseWindow( wxCommandEvent& event )
1318 {
1319  if ( m_flags.m_editingCopy )
1320  {
1321  a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
1322  //delete object from document (actually move to command for redo)
1324  new a2dCommand_ReleaseObject( m_parent, original, false )
1325  );
1326  EndEdit();
1327  }
1328  else
1329  {
1331  new a2dCommand_ReleaseObject( m_parent, this, false )
1332  );
1333  }
1334 }
1335 
1336 bool a2dRectWindow::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
1337 {
1338  if ( m_flags.m_editable )
1339  {
1340  PROPID_IncludeChildren->SetPropertyToObject( this, false );
1341  PROPID_Allowrotation->SetPropertyToObject( this, false );
1342  PROPID_Allowskew->SetPropertyToObject( this, false );
1343 
1344  return a2dWindowMM::DoStartEdit( editmode, editstyle );
1345  }
1346 
1347  return false;
1348 }
1349 
1351 {
1352  a2dStroke current = ic.GetDrawer2D()->GetDrawerStroke();
1353  a2dFill fillcurrent = ic.GetDrawer2D()->GetDrawerFill();
1354 
1357 
1358  if ( m_radius <= 0 )
1359  {
1360  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight, 0 );
1361  ic.GetDrawer2D()->SetDrawerStroke( current );
1362  ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
1363  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_titleheight - m_miny, -m_radius );
1364  }
1365  else
1366  {
1367  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight, 0 );
1368  ic.GetDrawer2D()->SetDrawerStroke( current );
1369  ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
1370  ic.GetDrawer2D()->DrawRoundedRectangle( m_minx - m_radius, m_miny - m_radius, m_maxx - m_minx + 2 * m_radius, m_maxy - m_miny + 2 * m_radius, m_radius );
1371  }
1372 }
1373 
1374 #if wxART2D_USE_CVGIO
1375 
1376 void a2dRectWindow::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
1377 {
1378  a2dWindowMM::DoSave( parent, out, xmlparts, towrite );
1379  if ( xmlparts == a2dXmlSer_attrib )
1380  {
1381  }
1382  else
1383  {
1384  }
1385 }
1386 
1387 void a2dRectWindow::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1388 {
1389  a2dWindowMM::DoLoad( parent, parser, xmlparts );
1390  if ( xmlparts == a2dXmlSer_attrib )
1391  {
1392  }
1393  else
1394  {
1395  }
1396 }
1397 #endif //wxART2D_USE_CVGIO
1398 
1399 bool a2dRectWindow::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
1400 {
1401  bool calc = false;
1402  if ( !m_bbox.GetValid() )
1403  {
1404  calc = a2dRectMM::DoUpdate( mode, childbox, clipbox, propbox );
1405 
1406  m_title->SetPosXY( m_minx, m_maxy );
1408  //titlebox.Translate( m_title->GetPosX(), m_title->GetPosY() );
1410  m_titleheight = titlebox.GetHeight();
1412 
1413  a2dBoundingBox canvasbox = m_canvas->GetBbox();
1414 
1416  {
1417  m_minx = wxMin( canvasbox.GetMinX(), m_minx );
1418  m_miny = wxMin( canvasbox.GetMinY(), m_miny );
1419  m_maxx = wxMax( canvasbox.GetMaxX(), m_maxx );
1420  m_maxy = wxMax( canvasbox.GetMaxY(), m_maxy );
1421 
1422  m_minx = canvasbox.GetMinX();
1423  m_miny = canvasbox.GetMinY();
1424  m_maxx = canvasbox.GetMaxX();
1425  m_maxy = canvasbox.GetMaxY() + m_titleheight;
1426 
1427  m_title->SetPosXY( m_minx, m_maxy );
1428  m_close->SetPosXY( m_maxx - m_close->GetWidth(), m_maxy - m_titleheight );
1429 
1430  /*
1431  m_minx = wxMin( childbox.GetMinX(), m_minx );
1432  m_miny = wxMin( childbox.GetMinY(), m_miny );
1433  m_maxx = wxMax( childbox.GetMaxX(), m_maxx );
1434  m_maxy = wxMax( childbox.GetMaxY(), m_maxy );
1435  */
1436  /*
1437  m_minx = childbox.GetMinX();
1438  m_miny = childbox.GetMinY();
1439  m_maxx = childbox.GetMaxX();
1440  m_maxy = childbox.GetMaxY();
1441  childbox.Dump();
1442  */
1443  }
1444  }
1445  return calc;
1446 }
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
Definition: canobj.h:301
bool m_processed
set if event was processed sofar
Definition: canobj.h:311
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: rectangle.cpp:524
virtual bool ProcessCanvasObjectEvent(a2dIterC &ic, a2dHitEvent &hitEvent)
Hit objects will receive the event.
Definition: canobj.cpp:3964
~a2dRectWindowT2()
destructor
Definition: rectangle.cpp:968
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: rectangle.cpp:723
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
Definition: canobj.h:289
double GetHeight() const
returns height of the boundingbox
Definition: bbox.cpp:334
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: rectangle.cpp:572
virtual void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
Definition: canobj.cpp:4712
void SetCanvas(a2dWindowMM *canvas)
Set canvas object.
Definition: rectangle.cpp:1309
bool SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask whichobjects=a2dCanvasOFlags::ALL, const a2dBoundingBox &bbox=wxNonValidBbox, const a2dAffineMatrix &tworld=a2dIDENTITY_MATRIX)
set all given bit flags at once recursive for all objects in given boundingbox
Definition: objlist.cpp:519
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
a2dStroke m_titleStroke
stroke for title object
Definition: rectangle.h:481
bool GetGeneratePins() const
get the GeneratePins flag
Definition: canobj.h:2289
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: vpath.cpp:616
void AddPending(a2dIterC &ic)
search objects ( if nested recursive ) that have the pending flag Set
Definition: canobj.cpp:4521
a2dHandle is used inside editing versions of a certain objects.
Definition: canpin.h:30
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
void ConvertToLines()
Convert complex segments to line segments.
Definition: polyver.cpp:4184
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
Definition: connectgen.h:40
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
Definition: rectangle.cpp:507
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
a2dSmrtPtr< a2dWidgetButton > m_close
close object for closing window
Definition: rectangle.h:484
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
a2dDrawing * m_root
root group for rendering and accessing the canvas&#39;s also contains layer settings
Definition: canobj.h:2525
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: rectangle.cpp:1133
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
Definition: rectangle.cpp:590
a2dCanvasOFlags m_flags
holds flags for objects
Definition: canobj.h:2528
double m_maxx
maximum x of rectangle
Definition: rectangle.h:164
const a2dAffineMatrix & GetInverseTransform() const
Inverse of GetTransform()
Definition: canobj.cpp:699
static const a2dCanvasObjectFlagsMask BIN2
Definition: candefs.h:193
#define EVT_CANVASOBJECT_ENTER_EVENT(func)
static event table macro for a2dCanvasObject mouse enter event
Definition: canglob.h:314
a2dPin is used in a2dCanvasObject to add pins to it.
Definition: canpin.h:233
This is a class/type description for a2dPin&#39;s.
Definition: canpin.h:628
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: rectangle.cpp:1336
Ref Counted base object.
Definition: gen.h:1045
void Enlarge(const double Marge)
enlarge with the given amount
Definition: bbox.cpp:162
double m_border
border around children towards the rectangle
Definition: rectangle.h:172
void OnCloseWindow(wxCommandEvent &event)
closing behaviour
Definition: rectangle.cpp:1018
double m_radius
radius in case of rounded rectangle (negatif inwards positif outwards)
Definition: rectangle.h:152
bool IsHit() const
true if this is a hit
Definition: polyver.h:107
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
#define EVT_CANVASHANDLE_MOUSE_EVENT(func)
static event table macro for a2dHandle mouse event
Definition: canglob.h:318
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Definition: drawer2d.cpp:565
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
double m_titleheight
cache to hold the title bar height, claculated from the Title text font and size. ...
Definition: rectangle.h:386
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
bool m_visiblechilds
child objects are visible or not
Definition: candefs.h:292
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: rectangle.cpp:115
const a2dFill * a2dWHITE_FILL
global a2dFill stock object for WHITE filling
a2dSmrtPtr< a2dWindowMM > m_canvas
here object are placed.
Definition: rectangle.h:490
The base class for all drawable objects in a a2dCanvasDocument.
double GetTransformedHitMargin()
transformed to object its coordinate system
Definition: canobj.cpp:616
void Init()
initialize
Definition: rectangle.cpp:728
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: rectangle.cpp:873
wxUint16 m_layer
layer of object, default wxLAYER_DEFAULT
Definition: canobj.h:2556
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: rectangle.cpp:1122
static double m_initialTitleHeight
default Title text height
Definition: rectangle.h:389
void ReStoreFixedStyle()
when fixed drawing style is set, it can be overruled.
Definition: drawer2d.cpp:711
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: rectangle.cpp:291
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: rectangle.cpp:885
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: rectangle.cpp:1090
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dCanvas uses a2dCanvasView for displaying a view on a a2dCanvasDocument.
vertex list of line and arc segments.
Definition: polyver.h:600
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
Definition: afmatrix.cpp:559
virtual a2dVertexList * GetAsVertexList(bool &returnIsPolygon) const
convert to a polygon.
Definition: rectangle.cpp:120
wxString GetName() const
get the name given to the handle.
Definition: canpin.h:56
virtual void EndEdit()
cleanup an editcopy object
Definition: canobj.cpp:1828
return to contain edit bbox, suitable for editing matrix of object
Definition: canobj.h:666
a2dBoundingBox GetTextExtent(const wxString &string, int alignment=wxMINX|wxMINY, double *w=NULL, double *h=NULL, double *descent=NULL, double *externalLeading=NULL) const
Get the dimensions in world coordinates of the string.
Definition: stylebase.cpp:3044
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
Definition: gen.cpp:1305
double m_minx
minimum x of rectangle
Definition: rectangle.h:158
bool GeneratePins(a2dPinClass *toConnectTo, a2dConnectTask task, double x, double y, double margin=0)
create pins in derived objects.
Definition: rectangle.cpp:607
a2dFont GetFont() const
get font for text
Definition: cantext.h:251
int ReleaseChild(a2dCanvasObject *obj, bool backwards=false, bool all=false, bool now=false, bool undoCommands=false)
remove the given object from the childobjects
Definition: canobj.cpp:6260
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: rectangle.cpp:1376
vector path a2dVectorPath derived from a2dCanvasObject
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
Definition: canobj.h:2559
void SetInternal(bool internal)
set when pin is within the border of its parent
Definition: canpin.h:444
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
Definition: drawer2d.cpp:621
void SetTitle(a2dText *textObj)
set title a2dText object
Definition: rectangle.cpp:1301
virtual void SetParent(a2dCanvasObject *parent)
set parent object, this is where events are sent if not handled in this.
Definition: canwidget.h:65
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
void SetTitle(a2dText *textObj)
set title a2dText object
Definition: rectangle.cpp:1010
widget like objects like buttons and sliders go here.
wxMouseEvent & GetMouseEvent()
return the original mouse event that was redirected to the a2dHandle
Definition: canglob.h:290
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: rectangle.cpp:859
a2dText is an abstract base class.
Definition: cantext.h:93
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
const a2dBoundingBox & Translate(a2dPoint2D &)
translate with given vector
Definition: bbox.cpp:370
bool ProcessCanvasObjectEvent(a2dIterC &ic, a2dHitEvent &hitEvent)
Hit objects will receive the event.
Definition: rectangle.cpp:1061
double GetMinX() const
get minimum X of the boundingbox
Definition: bbox.cpp:304
double GetHeight() const
return height
Definition: rectangle.h:102
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
Definition: drawer2d.cpp:2048
a2dCanvasObjectList * m_childobjects
holds child objects
Definition: canobj.h:2562
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
Definition: id.inl:238
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
Definition: gen.cpp:1473
double GetPosX() const
get x position from affine matrix
Definition: canobj.h:527
rectangular shapes derived from a2dCanvasObject
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
Definition: canobj.cpp:636
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
bool m_editable
object can be edited
Definition: candefs.h:295
Normal straight line segment in a2dVertexList and a2dVertexArray.
Definition: polyver.h:163
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
Definition: canobj.cpp:2645
a2dSLine
Definition: canprim.h:987
void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
Definition: rectangle.cpp:1081
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
general event sent from a2dHandle to its parent a2dCanvasObject
Definition: canglob.h:273
void SetRadius(double radius)
set corner radius of rectangle
Definition: rectangle.h:120
Restriction engine for editing restrictions like snapping.
Definition: restrict.h:88
bool m_childrenOnSameLayer
Definition: candefs.h:311
a2dSmrtPtr< a2dText > m_title
title a2dText object
Definition: rectangle.h:372
bool HasPins(bool realcheck=false)
are there a2dPin derived children
Definition: canobj.cpp:6414
static double m_initialTitleHeight
default Title text height
Definition: rectangle.h:496
virtual void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
Definition: drawer2d.cpp:2167
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
a2dPin * AddPin(const wxString name, double x, double y, wxUint32 a2dpinFlags, a2dPinClass *pinClass, bool undo=false)
add a a2dPin as child
Definition: canobj.cpp:6474
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: rectangle.cpp:756
a2dHandle * SetHandlePos(wxString name, double x, double y)
set a2dHandle position with the given name
Definition: canobj.cpp:1881
bool m_resizeToChilds
when true, the wxEVT_CANVASOBJECT_RESIZE_EVENT is sent to this object, if the child box did change...
Definition: candefs.h:357
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: rectangle.cpp:1037
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
Definition: canobj.cpp:1739
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: rectangle.cpp:1350
a2dStroke GetDrawerStroke() const
get the current stroke
Definition: drawer2d.h:548
double GetAttributeValueDouble(const wxString &attrib, double defaultv=0)
Returns the double value of an attribute.
Definition: genxmlpars.cpp:474
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: rectangle.cpp:1387
double GetMaxX() const
get maximum X of the boundingbox
Definition: bbox.cpp:316
double m_titleheight
cache to hold the title bar height, claculated from the Title text font and size. ...
Definition: rectangle.h:493
a2dPin * HasPinNamed(const wxString pinName, bool NotConnected=false)
are there a2dPin derived children which matches the given pin name?
Definition: canobj.cpp:6436
double GetPosY() const
get y position from affine matrix
Definition: canobj.h:530
double GetWorldStrokeExtend()
Definition: canobj.h:3403
void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: rectangle.cpp:1051
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: rectangle.cpp:1145
const a2dStroke * a2dWHITE_STROKE
global a2dStroke stock object for WHITE stroking
double m_maxy
maximum y of rectangle
Definition: rectangle.h:167
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
a2dFill m_titleFill
fill for title object
Definition: rectangle.h:375
#define EVT_CANVASOBJECT_LEAVE_EVENT(func)
static event table macro for a2dCanvasObject mouse leave event
Definition: canglob.h:316
virtual bool Submit(a2dCommand *command, bool storeIt=true)
Definition: drawing.cpp:5966
void DoAddPending(a2dIterC &ic)
called by addPending
Definition: rectangle.cpp:1069
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
Definition: canobj.cpp:2924
void Init(a2dCanvasObject *parent)
initialization used in construction
Definition: rectangle.cpp:904
used to release object from a a2dCanvasDocument in the current parent
Definition: drawing.h:1437
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
Definition: canglob.cpp:934
void SetText(const wxString &text)
set the text for the object &#39; &#39; in string means new line
Definition: cantext.h:165
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: rectangle.cpp:1277
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: rectangle.cpp:552
a2dCanvasCommandProcessor * GetCanvasCommandProcessor()
get a pointer to the command processor
Definition: drawing.cpp:375
wire classes for connecting objects.
double GetMaxY() const
get maximum Y of the boundingbox
Definition: bbox.cpp:322
An object of this class will update a a2dIterC with the required information.
Definition: canobj.h:3123
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
Definition: rectangle.cpp:986
void SetDraggable(bool draggable)
Sets if this object may be dragged.
Definition: canobj.h:1673
void SetPosXY(double x, double y, bool restrict=false)
set position to x,y
Definition: canobj.cpp:1624
a2dRectMM
Definition: rectangle.h:39
double m_miny
minimum of rectangle
Definition: rectangle.h:161
bool m_editingCopy
true if the object needs to be rendered in edit mode.
Definition: candefs.h:304
a2dStroke m_titleStroke
stroke for title object
Definition: rectangle.h:377
a2dCanvasObject * m_parent
This is intentionally not a smart pointer to remove a reference loop.
Definition: rectangle.h:487
a2dSmrtPtr< a2dText > m_title
title a2dText object
Definition: rectangle.h:476
a2dFill GetDrawerFill() const
get the current fill
Definition: drawer2d.h:557
virtual void DoAddPending(a2dIterC &ic)
called by addPending
Definition: canobj.cpp:4601
void SetMax(double maxx, double maxy)
set maximum in x and y
Definition: rectangle.h:84
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
double GetWidth() const
return width
Definition: rectangle.h:99
a2dWidgetButton is a a2dCanvasObject based button in a canvas
Definition: canwidget.h:43
void SetMin(double minx, double miny)
set minimum in x and y
Definition: rectangle.h:81
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dObject&#39;s and derived classes
Definition: gen.cpp:5265
double GetMinY() const
get minimum Y of the boundingbox
Definition: bbox.cpp:310
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.
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
Definition: id.inl:325
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
#define Round(x)
round to integer such that e.g 2.5 &lt; x &lt; 3.5 becomes 3
Definition: artglob.h:60
a2dCanvasObject for a Vector Path
Definition: vpath.h:55
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: rectangle.cpp:143
virtual bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: canobj.cpp:5098
void SetHeight(double h)
set height of rectangle
Definition: rectangle.h:96
int GetAlignment() const
Get the position of the anchor point w.r.t the text.
Definition: cantext.h:304
a2dBoundingBox m_bbox
boundingbox in world coordinates
Definition: canobj.h:2539
Vector Path.
Definition: polyver.h:1211
a2dWindowMM
Definition: rectangle.h:186
a2dCanvasObject * Find(const wxString &objectname, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask mask=a2dCanvasOFlags::ALL, const a2dPropertyId *propid=NULL, const wxString &valueAsString=wxT(""), wxUint32 id=0) const
return the object which fits the filter.
Definition: canobj.cpp:4505
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
Definition: canobj.cpp:663
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
Definition: canobj.cpp:5920
wxString GetText() const
get the text of the object &#39; &#39; in string means new line
Definition: cantext.h:168
double m_contourwidth
if != 0 you get a contour around the rectangle ( donut like ).
Definition: rectangle.h:155
list of a2dObject&#39;s
Definition: gen.h:3157
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
Definition: canobj.h:291
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
double DeviceToWorldXRel(double x) const
convert x relative from device to world coordinates
Definition: drawer2d.h:444
CloneOptions
options for cloning
Definition: gen.h:1200
bool Update(a2dCanvasObject::UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: rectangle.cpp:1075
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
Definition: restrict.cpp:227
a2dSmrtPtr< a2dWidgetButton > m_close
close object
Definition: rectangle.h:380
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
a2dFill m_titleFill
fill for title object
Definition: rectangle.h:479
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: canobj.cpp:5504
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: rectangle.cpp:646
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
Definition: rectangle.cpp:1399
static const a2dCanvasObjectFlagsMask PRERENDERASCHILD
Definition: candefs.h:198
general canvas module declarations and classes
wxEditStyle
Definition: canobj.h:109
void OverRuleFixedStyle()
id style is FIXED, saves current style and sets style to a2dFILLED
Definition: drawer2d.cpp:697
rectangle.cpp Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation