wxArt2D
rectangle.h
Go to the documentation of this file.
1 /*! \file wx/canvas/rectangle.h
2  \brief rectangular shapes derived from a2dCanvasObject
3 
4  rectangle shapes
5 
6  \author Klaas Holwerda
7 
8  Copyright: 2000-2004 (c) Klaas Holwerda
9 
10  Licence: wxWidgets Licence
11 
12  RCS-ID: $Id: rectangle.h,v 1.9 2008/07/19 18:29:44 titato Exp $
13 */
14 
15 #ifndef __WXRECTPRIM_H__
16 #define __WXRECTPRIM_H__
17 
18 #ifndef WX_PRECOMP
19 #include "wx/wx.h"
20 #endif
21 
22 #include "wx/image.h"
23 #include "wx/canvas/candefs.h"
24 #include "wx/canvas/canobj.h"
25 
26 class A2DARTBASEDLLEXP a2dVpath;
27 
28 //! a2dRectMM
29 /*!
30  Rectangle with radius and Min and Max coordinates.
31  This rectangle has extra information such that its origin is not always the position of the matrix.
32  It can be placed relative to its matrix in any way.
33  The need for this type of rectangle, becomes clear when one needs to resize a rectangular shape around
34  its children objects.
35 
36 
37  \ingroup canvasobject
38 */
39 class A2DCANVASDLLEXP a2dRectMM: public a2dCanvasObject
40 {
41 
42  DECLARE_EVENT_TABLE()
43 
44 public:
45 
46  a2dRectMM();
47 
48  //!constructor
49  /*!
50  \param x: x minimum
51  \param y: y minimum
52  \param w: Width of rectangle.
53  \param h: Heigth of rectangle
54  \param radius Radius at corners (negatif inwards positif outwards).
55  \param contourwidth contour around rectangle.
56  */
57  a2dRectMM( double x, double y, double w, double h , double radius = 0, double contourwidth = 0 );
58 
59  //!constructor
60  /*!
61  \param p1 one point of rectangle
62  \param p2 second point on diagonal
63  \param radius Radius at corners (negatif inwards positif outwards).
64  \param contourwidth contour around rectangle.
65  */
66  a2dRectMM( const a2dPoint2D& p1, const a2dPoint2D& p2, double radius = 0, double contourwidth = 0 );
67 
68  //!constructor
69  /*!
70  \param bbox used for size of rectangle
71  \param radius Radius at corners (negatif inwards positif outwards).
72  \param contourwidth contour around rectangle.
73  */
74  a2dRectMM( const a2dBoundingBox& bbox, double radius = 0, double contourwidth = 0 );
75 
76  a2dRectMM( const a2dRectMM& rec, CloneOptions options, a2dRefMap* refs );
77 
78  ~a2dRectMM();
79 
80  //! set minimum in x and y
81  void SetMin( double minx, double miny ) { m_minx = minx; m_miny = miny; SetPending( true ); }
82 
83  //! set maximum in x and y
84  void SetMax( double maxx, double maxy ) { m_maxx = maxx; m_maxy = maxy; SetPending( true ); }
85 
86  //!set width of rectangle
87  /*!
88  \param w width of rectangle
89  */
90  void SetWidth( double w ) { m_maxx = m_minx + w; SetPending( true ); }
91 
92  //!set height of rectangle
93  /*!
94  \param h height of rectangle
95  */
96  void SetHeight( double h ) { m_maxy = m_miny + h; SetPending( true ); }
97 
98  //!return width
99  double GetWidth() const { return m_maxx - m_minx; }
100 
101  //!return height
102  double GetHeight() const { return m_maxy - m_miny; }
103 
104  //!set the Contour width of the shape
105  void SetBorder( double width ) { m_border = width; SetPending( true ); }
106 
107  //!get the Contour width of the shape
108  double GetBorder() const { return m_border; }
109 
110  //!set the Contour width of the shape
111  void SetContourWidth( double width ) { m_contourwidth = width; SetPending( true ); }
112 
113  //!get the Contour width of the shape
114  double GetContourWidth() const { return m_contourwidth; }
115 
116  //!set corner radius of rectangle
117  /*!
118  \param radius rounded corner radius of rectangle
119  */
120  void SetRadius( double radius ) { m_radius = radius; SetPending( true ); }
121 
122  //!return radius
123  double GetRadius() const { return m_radius; }
124 
125 #if wxART2D_USE_CVGIO
126  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
127 
128  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
129 #endif //wxART2D_USE_CVGIO
130 
131  virtual a2dVertexList* GetAsVertexList( bool& returnIsPolygon ) const;
132 
133  a2dCanvasObjectList* GetAsCanvasVpaths( bool transform = true ) const;
134 
135  bool GeneratePins( a2dPinClass* toConnectTo, a2dConnectTask task, double x, double y, double margin = 0 );
136  void OnHandleEvent( a2dHandleMouseEvent& event );
137 
138  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
139 
140  DECLARE_DYNAMIC_CLASS( a2dRectMM )
141 
142 protected:
143 
144  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
145  virtual bool DoStartEdit( wxUint16 editmode, wxEditStyle editstyle );
146 
147  void DoRender( a2dIterC& ic, OVERLAP clipparent );
148  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
149  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
150 
151  //!radius in case of rounded rectangle (negatif inwards positif outwards)
152  double m_radius;
153 
154  //! if != 0 you get a contour around the rectangle ( donut like ).
155  double m_contourwidth;
156 
157  //! minimum x of rectangle
158  double m_minx;
159 
160  //! minimum of rectangle
161  double m_miny;
162 
163  //! maximum x of rectangle
164  double m_maxx;
165 
166  //! maximum y of rectangle
167  double m_maxy;
168 
169  bool m_flipIn;
170 
171  //! border around children towards the rectangle
172  double m_border;
173 
174 
175 private:
176  //!this is a not implemented copy constructor that avoids automatic creation of one
177  a2dRectMM( const a2dRectMM& other );
178 };
179 
180 //! a2dWindowMM
181 /*!
182  Rectangular Window with Min and Max coordinates.
183 
184  \ingroup canvasobject
185 */
186 class A2DCANVASDLLEXP a2dWindowMM: public a2dRectMM
187 {
188 
189  DECLARE_EVENT_TABLE()
190 
191 public:
192 
193  enum a2dWindowMMStyle
194  {
195  SUNKEN = 0x0001, //!<
196  RAISED = 0x0002 //!<
197  };
198  enum a2dWindowMMState
199  {
200  NON = 0x0000, //!<
201  DISABLED = 0x0001, //!<
202  SELECTED = 0x0002, //!<
203  FOCUS = 0x0004, //!<
204  HOVER = 0x0008, //!<
205  ALL = 0xFFFF //!<
206  };
207 
208  a2dWindowMM();
209 
210  //!constructor
211  /*!
212  \param x: x minimum
213  \param y: y minimum
214  \param w: Width of rectangle.
215  \param h: Heigth of rectangle
216  */
217  a2dWindowMM( double x, double y, double w, double h );
218 
219  //!constructor
220  /*!
221  \param p1 one point of rectangle
222  \param p2 second point on diagonal
223  */
224  a2dWindowMM( const a2dPoint2D& p1, const a2dPoint2D& p2 );
225 
226  //!constructor
227  /*!
228  \param bbox used for size of rectangle
229  */
230  a2dWindowMM( const a2dBoundingBox& bbox );
231 
232  a2dWindowMM( const a2dWindowMM& rec, CloneOptions options, a2dRefMap* refs );
233 
234  ~a2dWindowMM();
235 
236  //! Set drawing style for window see a2dWindowMMStyle
237  void SetStyle( long style ) { m_style = style; }
238 
239  //! Get drawing style for window see a2dWindowMMStyle
240  long GetStyle() { return m_style;}
241 
242  //! initialize
243  void Init();
244 
245 #if wxART2D_USE_CVGIO
246  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
247 
248  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
249 #endif //wxART2D_USE_CVGIO
250 
251  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
252 
253  DECLARE_DYNAMIC_CLASS( a2dWindowMM )
254 
255 protected:
256 
257  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
258  void OnEnterObject( a2dCanvasObjectMouseEvent& event );
259 
260  void OnLeaveObject( a2dCanvasObjectMouseEvent& event );
261 
262  void DoRender( a2dIterC& ic, OVERLAP clipparent );
263 
264  long m_style;
265  long m_state;
266 
267  a2dStroke m_backStroke;
268  a2dStroke m_darkStroke;
269  a2dStroke m_lightStroke;
270  a2dStroke m_whiteStroke;
271  a2dStroke m_blackStroke;
272  a2dStroke m_hoverStroke;
273 
274 
275 private:
276  //!this is a not implemented copy constructor that avoids automatic creation of one
277  a2dWindowMM( const a2dWindowMM& other );
278 };
279 
280 
281 class A2DCANVASDLLEXP a2dWidgetButton;
282 
283 class A2DCANVASDLLEXP a2dRectWindowT2: public a2dRectMM
284 {
285 
286  DECLARE_EVENT_TABLE()
287 
288 public:
289 
290  a2dRectWindowT2();
291 
292  //!constructor
293  /*!
294  \param parent parent object of this object
295  \param x x minimum
296  \param y y minimum
297  \param w Width of rectangle.
298  \param h Heigth of rectangle
299  \param radius Radius at corners (negatif inwards positif outwards).
300  */
301  a2dRectWindowT2( a2dCanvasObject* parent, double x, double y, double w, double h , double radius = 0 );
302 
303  //!constructor
304  /*!
305  \param parent parent object of this object
306  \param p1 one point of rectangle
307  \param p2 second point on diagonal
308  \param radius Radius at corners (negatif inwards positif outwards).
309  */
310  a2dRectWindowT2( a2dCanvasObject* parent, const a2dPoint2D& p1, const a2dPoint2D& p2, double radius = 0 );
311 
312  //!constructor
313  /*!
314  \param parent parent object of this object
315  \param bbox used for size of rectangle
316  \param radius Radius at corners (negatif inwards positif outwards).
317  */
318  a2dRectWindowT2( a2dCanvasObject* parent, const a2dBoundingBox& bbox, double radius = 0 );
319 
320  //! constructor
321  a2dRectWindowT2( const a2dRectWindowT2& rec, CloneOptions options, a2dRefMap* refs );
322 
323  //! destructor
324  ~a2dRectWindowT2();
325 
326  //! initialization used in construction
327  void Init( a2dCanvasObject* parent );
328 
329  //! closing behaviour
330  void OnCloseWindow( wxCommandEvent& event );
331 
332 #if wxART2D_USE_CVGIO
333  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
334 
335  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
336 #endif //wxART2D_USE_CVGIO
337 
338  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
339 
340  //! get title of window
341  a2dSmrtPtr<a2dText>& GetTitle() { return m_title; }
342 
343  //! set title a2dText object
344  void SetTitle( a2dText* textObj );
345 
346  //! set title string
347  void SetTitle( const wxString& title );
348 
349  //! set parent object of the pin or some other objects that needs a parent
350  virtual void SetParent( a2dCanvasObject* parent ) { m_parent = parent; }
351 
352 
353  void DoWalker( wxObject* parent, a2dWalkerIOHandler& handler );
354  bool ProcessCanvasObjectEvent( a2dIterC& ic, a2dHitEvent& hitEvent );
355  void DoAddPending( a2dIterC& ic );
356  bool Update( a2dCanvasObject::UpdateMode mode );
357  void Render( a2dIterC& ic, OVERLAP clipparent );
358 
359 
360  DECLARE_DYNAMIC_CLASS( a2dRectWindowT2 )
361 
362 protected:
363 
364  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
365  virtual bool DoStartEdit( wxUint16 editmode, wxEditStyle editstyle );
366 
367  void DoRender( a2dIterC& ic, OVERLAP clipparent );
368 
369  a2dCanvasObjectPtr m_titleObj;
370 
371  //! title a2dText object
372  a2dSmrtPtr<a2dText> m_title;
373 
374  //! fill for title object
375  a2dFill m_titleFill;
376  //! stroke for title object
377  a2dStroke m_titleStroke;
378 
379  //! close object
380  a2dSmrtPtr<a2dWidgetButton> m_close;
381 
382  //* This is intentionally not a smart pointer to remove a reference loop */
383  a2dCanvasObject* m_parent;
384 
385  //! cache to hold the title bar height, claculated from the Title text font and size.
386  mutable double m_titleheight;
387 
388  //! default Title text height
389  static double m_initialTitleHeight;
390 
391 private:
392  //!this is a not implemented copy constructor that avoids automatic creation of one
393  a2dRectWindowT2( const a2dRectWindowT2& other );
394 };
395 
396 class A2DCANVASDLLEXP a2dRectWindow: public a2dWindowMM
397 {
398 
399  DECLARE_EVENT_TABLE()
400 
401 public:
402 
403  a2dRectWindow();
404 
405  //!constructor
406  /*!
407  \param parent parent object of this object
408  \param x x minimum
409  \param y y minimum
410  \param w Width of rectangle.
411  \param h Heigth of rectangle
412  \param radius Radius at corners (negatif inwards positif outwards).
413  */
414  a2dRectWindow( a2dCanvasObject* parent, double x, double y, double w, double h );
415 
416  //!constructor
417  /*!
418  \param parent parent object of this object
419  \param p1 one point of rectangle
420  \param p2 second point on diagonal
421  \param radius Radius at corners (negatif inwards positif outwards).
422  */
423  a2dRectWindow( a2dCanvasObject* parent, const a2dPoint2D& p1, const a2dPoint2D& p2 );
424 
425  //!constructor
426  /*!
427  \param parent parent object of this object
428  \param bbox used for size of rectangle
429  \param radius Radius at corners (negatif inwards positif outwards).
430  */
431  a2dRectWindow( a2dCanvasObject* parent, const a2dBoundingBox& bbox );
432 
433  a2dRectWindow( const a2dRectWindow& rec, CloneOptions options, a2dRefMap* refs );
434 
435  ~a2dRectWindow();
436 
437  void Init( a2dCanvasObject* parent );
438 
439  void OnCloseWindow( wxCommandEvent& event );
440 
441 #if wxART2D_USE_CVGIO
442  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
443 
444  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
445 #endif //wxART2D_USE_CVGIO
446 
447  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
448 
449  a2dSmrtPtr<a2dText>& GetTitle() { return m_title; }
450 
451  //! set title a2dText object
452  void SetTitle( a2dText* textObj );
453 
454  //! set title string
455  void SetTitle( const wxString& title );
456 
457  //! Get canvas object pointer
458  a2dSmrtPtr<a2dWindowMM>& GetCanvas() { return m_canvas; }
459 
460  //! Set canvas object
461  void SetCanvas( a2dWindowMM* canvas );
462 
463  //! set parent object of the pin or some other objects that needs a parent
464  virtual void SetParent( a2dCanvasObject* parent ) { m_parent = parent; }
465 
466  DECLARE_DYNAMIC_CLASS( a2dRectWindow )
467 
468 protected:
469 
470  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
471  virtual bool DoStartEdit( wxUint16 editmode, wxEditStyle editstyle );
472 
473  void DoRender( a2dIterC& ic, OVERLAP clipparent );
474 
475  //! title a2dText object
476  a2dSmrtPtr<a2dText> m_title;
477 
478  //! fill for title object
479  a2dFill m_titleFill;
480  //! stroke for title object
481  a2dStroke m_titleStroke;
482 
483  //! close object for closing window
484  a2dSmrtPtr<a2dWidgetButton> m_close;
485 
486  //! This is intentionally not a smart pointer to remove a reference loop
487  a2dCanvasObject* m_parent;
488 
489  //! here object are placed.
490  a2dSmrtPtr<a2dWindowMM> m_canvas;
491 
492  //! cache to hold the title bar height, claculated from the Title text font and size.
493  mutable double m_titleheight;
494 
495  //! default Title text height
496  static double m_initialTitleHeight;
497 
498 private:
499  //!this is a not implemented copy constructor that avoids automatic creation of one
500  a2dRectWindow( const a2dRectWindow& other );
501 };
502 
503 #endif /* __WXRECTPRIM_H__ */
504 
virtual bool GeneratePins(a2dPinClass *toConnectTo, a2dConnectTask task, double x, double y, double margin=0)
create pins in derived objects.
Definition: canobj.h:2054
virtual bool ProcessCanvasObjectEvent(a2dIterC &ic, a2dHitEvent &hitEvent)
Hit objects will receive the event.
Definition: canobj.cpp:3964
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
void OnHandleEvent(a2dHandleMouseEvent &event)
called if a mouse event occured on a child object, that is a handle
Definition: canobj.cpp:2061
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin or some other objects that needs a parent
Definition: rectangle.h:350
virtual void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
Definition: canobj.cpp:4712
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
Definition: connectgen.h:40
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
This is a class/type description for a2dPin&#39;s.
Definition: canpin.h:628
Ref Counted base object.
Definition: gen.h:1045
void SetWidth(double w)
set width of rectangle
Definition: rectangle.h:90
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
long GetStyle()
Get drawing style for window see a2dWindowMMStyle.
Definition: rectangle.h:240
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
void SetStyle(long style)
Set drawing style for window see a2dWindowMMStyle.
Definition: rectangle.h:237
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
The base class for all drawable objects in a a2dCanvasDocument.
a2dSmrtPtr< a2dText > & GetTitle()
get title of window
Definition: rectangle.h:341
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
vertex list of line and arc segments.
Definition: polyver.h:600
defenitions an no more
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
double GetBorder() const
get the Contour width of the shape
Definition: rectangle.h:108
a2dText is an abstract base class.
Definition: cantext.h:93
double GetHeight() const
return height
Definition: rectangle.h:102
a2dSmrtPtr< a2dWindowMM > & GetCanvas()
Get canvas object pointer.
Definition: rectangle.h:458
virtual a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canobj.cpp:1505
void SetBorder(double width)
set the Contour width of the shape
Definition: rectangle.h:105
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
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
virtual a2dVertexList * GetAsVertexList(bool &returnIsPolygon) const
convert to a polygon.
Definition: canobj.h:2491
double GetRadius() const
return radius
Definition: rectangle.h:123
virtual void SetParent(a2dCanvasObject *parent)
set parent object of the pin or some other objects that needs a parent
Definition: rectangle.h:464
a2dRectMM
Definition: rectangle.h:39
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 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
Vector Path.
Definition: polyver.h:1211
a2dWindowMM
Definition: rectangle.h:186
list of a2dObject&#39;s
Definition: gen.h:3157
double GetContourWidth() const
get the Contour width of the shape
Definition: rectangle.h:114
CloneOptions
options for cloning
Definition: gen.h:1200
void SetContourWidth(double width)
set the Contour width of the shape
Definition: rectangle.h:111
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: canobj.cpp:5504
wxEditStyle
Definition: canobj.h:109
rectangle.h Source File -- Sun Oct 12 2014 17:04:23 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation