1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Basic OGL classes and definitions
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "basic.h"
19 #define OGL_VERSION 2.0
21 #ifndef DEFAULT_MOUSE_TOLERANCE
22 #define DEFAULT_MOUSE_TOLERANCE 3
25 // Edit these lines if you positively don't want PROLOGIO support
39 #define ARROW_MIDDLE 3
42 // Control point types
43 // Rectangle and most other shapes
44 #define CONTROL_POINT_VERTICAL 1
45 #define CONTROL_POINT_HORIZONTAL 2
46 #define CONTROL_POINT_DIAGONAL 3
49 #define CONTROL_POINT_ENDPOINT_TO 4
50 #define CONTROL_POINT_ENDPOINT_FROM 5
51 #define CONTROL_POINT_LINE 6
53 // Types of formatting: can be combined in a bit list
56 #define FORMAT_CENTRE_HORIZ 1
57 // Centre horizontally
58 #define FORMAT_CENTRE_VERT 2
60 #define FORMAT_SIZE_TO_CONTENTS 4
61 // Resize shape to contents
66 #define SHADOW_RIGHT 2
73 #define SHAPE_BASIC wxTYPE_USER + 1
74 #define SHAPE_RECTANGLE wxTYPE_USER + 2
75 #define SHAPE_ELLIPSE wxTYPE_USER + 3
76 #define SHAPE_POLYGON wxTYPE_USER + 4
77 #define SHAPE_CIRCLE wxTYPE_USER + 5
78 #define SHAPE_LINE wxTYPE_USER + 6
79 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
80 #define SHAPE_COMPOSITE wxTYPE_USER + 9
81 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
82 #define SHAPE_DRAWN wxTYPE_USER + 11
83 #define SHAPE_DIVISION wxTYPE_USER + 12
84 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
85 #define SHAPE_BITMAP wxTYPE_USER + 14
86 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
88 #define OBJECT_REGION wxTYPE_USER + 20
90 #define OP_CLICK_LEFT 1
91 #define OP_CLICK_RIGHT 2
92 #define OP_DRAG_LEFT 4
93 #define OP_DRAG_RIGHT 8
95 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
98 #define ATTACHMENT_MODE_NONE 0
99 #define ATTACHMENT_MODE_EDGE 1
100 #define ATTACHMENT_MODE_BRANCHING 2
102 // Sub-modes for branching attachment mode
103 #define BRANCHING_ATTACHMENT_NORMAL 1
104 #define BRANCHING_ATTACHMENT_BLOB 2
106 class wxShapeTextLine
;
109 class wxControlPoint
;
114 class WXDLLEXPORT wxExpr
;
115 class WXDLLEXPORT wxExprDatabase
;
119 #define WXROUND(x) ( (long) (x + 0.5) )
121 class wxShapeEvtHandler
: public wxObject
123 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
126 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
127 virtual ~wxShapeEvtHandler();
129 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
130 inline wxShape
*GetShape() const { return m_handlerShape
; }
132 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
133 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
135 // This is called when the _shape_ is deleted.
136 virtual void OnDelete();
137 virtual void OnDraw(wxDC
& dc
);
138 virtual void OnDrawContents(wxDC
& dc
);
139 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
140 virtual void OnMoveLinks(wxDC
& dc
);
141 virtual void OnErase(wxDC
& dc
);
142 virtual void OnEraseContents(wxDC
& dc
);
143 virtual void OnHighlight(wxDC
& dc
);
144 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
145 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
146 virtual void OnSize(double x
, double y
);
147 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
148 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
150 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
151 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
152 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
153 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
154 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
155 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
156 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
157 virtual void OnDrawControlPoints(wxDC
& dc
);
158 virtual void OnEraseControlPoints(wxDC
& dc
);
159 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= TRUE
);
161 // Control points ('handles') redirect control to the actual shape, to make it easier
162 // to override sizing behaviour.
163 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
164 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
165 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
167 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
168 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
170 // Can override this to prevent or intercept line reordering.
171 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
173 // Creates a copy of this event handler.
174 wxShapeEvtHandler
*CreateNewCopy();
176 // Does the copy - override for new event handlers which might store
177 // app-specific data.
178 virtual void CopyData(wxShapeEvtHandler
& copy
) {};
181 wxShapeEvtHandler
* m_previousHandler
;
182 wxShape
* m_handlerShape
;
185 class wxShape
: public wxShapeEvtHandler
187 DECLARE_ABSTRACT_CLASS(wxShape
)
191 wxShape(wxShapeCanvas
*can
= NULL
);
193 virtual void GetBoundingBoxMax(double *width
, double *height
);
194 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
195 virtual bool GetPerimeterPoint(double x1
, double y1
,
196 double x2
, double y2
,
197 double *x3
, double *y3
);
198 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
199 void SetCanvas(wxShapeCanvas
*the_canvas
);
200 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
201 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
203 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
204 inline double GetX() const { return m_xpos
; }
205 inline double GetY() const { return m_ypos
; }
206 inline void SetX(double x
) { m_xpos
= x
; }
207 inline void SetY(double y
) { m_ypos
= y
; }
209 inline wxShape
*GetParent() const { return m_parent
; }
210 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
211 wxShape
*GetTopAncestor();
212 inline wxList
& GetChildren() { return m_children
; }
214 virtual void OnDraw(wxDC
& dc
);
215 virtual void OnDrawContents(wxDC
& dc
);
216 virtual void OnMoveLinks(wxDC
& dc
);
217 virtual void Unlink() { };
218 void SetDrawHandles(bool drawH
);
219 inline bool GetDrawHandles() { return m_drawHandles
; }
220 virtual void OnErase(wxDC
& dc
);
221 virtual void OnEraseContents(wxDC
& dc
);
222 virtual void OnHighlight(wxDC
& dc
);
223 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
224 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
225 virtual void OnSize(double x
, double y
);
226 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
227 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
229 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
230 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
231 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
232 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
233 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
234 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
235 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
236 virtual void OnDrawControlPoints(wxDC
& dc
);
237 virtual void OnEraseControlPoints(wxDC
& dc
);
239 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
240 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
242 // Control points ('handles') redirect control to the actual shape, to make it easier
243 // to override sizing behaviour.
244 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
245 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
246 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
248 virtual void MakeControlPoints();
249 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
250 virtual void ResetControlPoints();
252 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
253 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
255 // Mandatory control points, e.g. the divided line moving handles
256 // should appear even if a child of the 'selected' image
257 virtual void MakeMandatoryControlPoints();
258 virtual void ResetMandatoryControlPoints();
260 inline virtual bool Recompute() { return TRUE
; };
261 // Calculate size recursively, if size changes. Size might depend on children.
262 inline virtual void CalculateSize() { };
263 virtual void Select(bool select
= TRUE
, wxDC
* dc
= NULL
);
264 virtual void SetHighlight(bool hi
= TRUE
, bool recurse
= FALSE
);
265 inline virtual bool IsHighlighted() const { return m_highlighted
; };
266 virtual bool Selected() const;
267 virtual bool AncestorSelected() const;
268 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= FALSE
);
269 int GetSensitivityFilter() const { return m_sensitivity
; }
270 void SetDraggable(bool drag
, bool recursive
= FALSE
);
271 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
272 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
273 inline bool GetFixedWidth() const { return m_fixedWidth
; }
274 inline bool GetFixedHeight() const { return m_fixedHeight
; }
275 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
276 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
277 void SetShadowMode(int mode
, bool redraw
= FALSE
);
278 inline int GetShadowMode() const { return m_shadowMode
; }
279 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
280 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
281 inline bool GetCentreResize() const { return m_centreResize
; }
282 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
283 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
284 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
285 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
286 inline bool GetDisableLabel() const { return m_disableLabel
; }
287 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
288 inline int GetAttachmentMode() const { return m_attachmentMode
; }
289 inline void SetId(long i
) { m_id
= i
; }
290 inline long GetId() const { return m_id
; }
292 void SetPen(wxPen
*pen
);
293 void SetBrush(wxBrush
*brush
);
294 inline void SetClientData(wxObject
*client_data
) { m_clientData
= client_data
; };
295 inline wxObject
*GetClientData() const { return m_clientData
; };
297 virtual void Show(bool show
);
298 virtual bool IsShown() const { return m_visible
; }
299 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= TRUE
);
300 virtual void Erase(wxDC
& dc
);
301 virtual void EraseContents(wxDC
& dc
);
302 virtual void Draw(wxDC
& dc
);
303 virtual void Flash();
304 virtual void MoveLinks(wxDC
& dc
);
305 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
306 virtual void SetSize(double x
, double y
, bool recursive
= TRUE
);
307 virtual void SetAttachmentSize(double x
, double y
);
308 void Attach(wxShapeCanvas
*can
);
311 inline virtual bool Constrain() { return FALSE
; } ;
313 void AddLine(wxLineShape
*line
, wxShape
*other
,
314 int attachFrom
= 0, int attachTo
= 0,
316 int positionFrom
= -1, int positionTo
= -1);
318 // Return the zero-based position in m_lines of line.
319 int GetLinePosition(wxLineShape
* line
);
321 void AddText(const wxString
& string
);
323 inline wxPen
*GetPen() const { return m_pen
; }
324 inline wxBrush
*GetBrush() const { return m_brush
; }
327 * Region-specific functions (defaults to the default region
331 // Set the default, single region size to be consistent
332 // with the object size
333 void SetDefaultRegionSize();
334 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
335 virtual void SetFormatMode(int mode
, int regionId
= 0);
336 virtual int GetFormatMode(int regionId
= 0) const;
337 virtual void SetFont(wxFont
*font
, int regionId
= 0);
338 virtual wxFont
*GetFont(int regionId
= 0) const;
339 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
340 virtual wxString
GetTextColour(int regionId
= 0) const;
341 virtual inline int GetNumberOfTextRegions() const { return m_regions
.Number(); }
342 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
344 // Get the name representing the region for this image alone.
345 // I.e. this image's region ids go from 0 to N-1.
346 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
347 // So the last digit represents the region Id, the others represent positions
349 virtual wxString
GetRegionName(int regionId
);
351 // Gets the region corresponding to the name, or -1 if not found.
352 virtual int GetRegionId(const wxString
& name
);
354 // Construct names for regions, unique even for children of a composite.
355 virtual void NameRegions(const wxString
& parentName
= "");
357 // Get list of regions
358 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
360 virtual void AddRegion(wxShapeRegion
*region
);
362 virtual void ClearRegions();
364 // Assign new ids to this image and children (if composite)
367 // Returns actual image (same as 'this' if non-composite) and region id
368 // for given region name.
369 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
371 // Finds all region names for this image (composite or simple).
372 // Supply empty string list.
373 virtual void FindRegionNames(wxStringList
& list
);
375 virtual void ClearText(int regionId
= 0);
376 void RemoveLine(wxLineShape
*line
);
380 virtual void WriteAttributes(wxExpr
*clause
);
381 virtual void ReadAttributes(wxExpr
*clause
);
383 // In case the object has constraints it needs to read in in a different pass
384 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
385 virtual void WriteRegions(wxExpr
*clause
);
386 virtual void ReadRegions(wxExpr
*clause
);
390 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
391 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
392 virtual int GetNumberOfAttachments() const;
393 virtual bool AttachmentIsValid(int attachment
) const;
395 // Only get the attachment position at the _edge_ of the shape, ignoring
396 // branching mode. This is used e.g. to indicate the edge of interest, not the point
397 // on the attachment branch.
398 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
399 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
401 // Assuming the attachment lies along a vertical or horizontal line,
402 // calculate the position on that point.
403 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
404 int nth
, int noArcs
, wxLineShape
* line
);
406 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
407 // edge of the shape.
408 // attachmentPoint is the attachment point (= side) in question.
409 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
411 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
412 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
414 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
417 // Reorders the lines coming into the node image at this attachment
418 // position, in the order in which they appear in linesToSort.
419 virtual void SortLines(int attachment
, wxList
& linesToSort
);
421 // Apply an attachment ordering change
422 void ApplyAttachmentOrdering(wxList
& ordering
);
424 // Can override this to prevent or intercept line reordering.
425 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
427 //// New banching attachment code, 24/9/98
433 // shoulder1 ->---------<- shoulder2
435 // <- branching attachment point N-1
437 // This function gets the root point at the given attachment.
438 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
440 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
441 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
442 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
444 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
445 // at this attachment point.
446 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
448 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
449 wxRealPoint
& stemPoint
);
451 // Get the number of lines at this attachment position.
452 virtual int GetAttachmentLineCount(int attachment
) const;
454 // Draw the branches (not the actual arcs though)
455 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
456 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
458 // Branching attachment settings
459 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
460 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
462 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
463 inline int GetBranchStemLength() const { return m_branchStemLength
; }
465 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
466 inline int GetBranchSpacing() const { return m_branchSpacing
; }
468 // Further detail on branching style, e.g. blobs on interconnections
469 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
470 inline long GetBranchStyle() const { return m_branchStyle
; }
472 // Rotate the standard attachment point from physical (0 is always North)
473 // to logical (0 -> 1 if rotated by 90 degrees)
474 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
476 // Rotate the standard attachment point from logical
477 // to physical (0 is always North)
478 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
480 // This is really to distinguish between lines and other images.
481 // For lines, want to pass drag to canvas, since lines tend to prevent
482 // dragging on a canvas (they get in the way.)
483 virtual bool Draggable() const { return TRUE
; }
485 // Returns TRUE if image is a descendant of this image
486 bool HasDescendant(wxShape
*image
);
488 // Creates a copy of this shape.
489 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
491 // Does the copying for this object
492 virtual void Copy(wxShape
& copy
);
494 // Does the copying for this object, including copying event
495 // handler data if any. Calls the virtual Copy function.
496 void CopyWithHandler(wxShape
& copy
);
498 // Rotate about the given axis by the given amount in radians.
499 virtual void Rotate(double x
, double y
, double theta
);
500 virtual inline double GetRotation() const { return m_rotation
; }
502 void ClearAttachments();
504 // Recentres all the text regions for this object
505 void Recentre(wxDC
& dc
);
507 // Clears points from a list of wxRealPoints
508 void ClearPointList(wxList
& list
);
511 wxObject
* m_clientData
;
514 wxShapeEvtHandler
* m_eventHandler
;
516 double m_xpos
, m_ypos
;
520 wxColour
* m_textColour
;
521 wxString m_textColourName
;
522 wxShapeCanvas
* m_canvas
;
525 wxList m_controlPoints
;
527 wxList m_attachmentPoints
;
532 bool m_highlighted
; // Different from selected: user-defined highlighting,
533 // e.g. thick border.
537 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
538 // 2 for branching attachments
539 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
542 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
543 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
544 wxList m_children
; // In case it's composite
545 wxShape
* m_parent
; // In case it's a child
548 wxBrush
* m_shadowBrush
;
551 int m_textMarginX
; // Gap between text and border
553 wxString m_regionName
;
554 bool m_maintainAspectRatio
;
555 int m_branchNeckLength
;
556 int m_branchStemLength
;
561 class wxPolygonShape
: public wxShape
563 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
568 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
569 // Deletes user's points in destructor.
570 virtual void Create(wxList
*points
);
571 virtual void ClearPoints();
573 void GetBoundingBoxMin(double *w
, double *h
);
574 void CalculateBoundingBox();
575 bool GetPerimeterPoint(double x1
, double y1
,
576 double x2
, double y2
,
577 double *x3
, double *y3
);
578 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
579 void SetSize(double x
, double y
, bool recursive
= TRUE
);
580 void OnDraw(wxDC
& dc
);
581 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
583 // Control points ('handles') redirect control to the actual shape, to make it easier
584 // to override sizing behaviour.
585 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
586 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
587 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
589 // A polygon should have a control point at each vertex,
590 // with the option of moving the control points individually
591 // to change the shape.
592 void MakeControlPoints();
593 void ResetControlPoints();
595 // If we've changed the shape, must make the original
596 // points match the working points
597 void UpdateOriginalPoints();
599 // Add a control point after the given point
600 virtual void AddPolygonPoint(int pos
= 0);
602 // Delete a control point
603 virtual void DeletePolygonPoint(int pos
= 0);
605 // Recalculates the centre of the polygon
606 virtual void CalculatePolygonCentre();
609 void WriteAttributes(wxExpr
*clause
);
610 void ReadAttributes(wxExpr
*clause
);
613 int GetNumberOfAttachments() const;
614 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
615 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
616 bool AttachmentIsValid(int attachment
);
617 // Does the copying for this object
618 void Copy(wxShape
& copy
);
620 inline wxList
*GetPoints() { return m_points
; }
622 // Rotate about the given axis by the given amount in radians
623 virtual void Rotate(double x
, double y
, double theta
);
627 wxList
* m_originalPoints
;
629 double m_boundHeight
;
630 double m_originalWidth
;
631 double m_originalHeight
;
634 class wxRectangleShape
: public wxShape
636 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
638 wxRectangleShape(double w
= 0.0, double h
= 0.0);
639 void GetBoundingBoxMin(double *w
, double *h
);
640 bool GetPerimeterPoint(double x1
, double y1
,
641 double x2
, double y2
,
642 double *x3
, double *y3
);
643 void OnDraw(wxDC
& dc
);
644 void SetSize(double x
, double y
, bool recursive
= TRUE
);
645 void SetCornerRadius(double rad
); // If > 0, rounded corners
648 void WriteAttributes(wxExpr
*clause
);
649 void ReadAttributes(wxExpr
*clause
);
652 int GetNumberOfAttachments() const;
653 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
654 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
655 // Does the copying for this object
656 void Copy(wxShape
& copy
);
658 inline double GetWidth() const { return m_width
; }
659 inline double GetHeight() const { return m_height
; }
660 inline void SetWidth(double w
) { m_width
= w
; }
661 inline void SetHeight(double h
) { m_height
= h
; }
666 double m_cornerRadius
;
669 class wxTextShape
: public wxRectangleShape
671 DECLARE_DYNAMIC_CLASS(wxTextShape
)
673 wxTextShape(double width
= 0.0, double height
= 0.0);
675 void OnDraw(wxDC
& dc
);
678 void WriteAttributes(wxExpr
*clause
);
681 // Does the copying for this object
682 void Copy(wxShape
& copy
);
685 class wxEllipseShape
: public wxShape
687 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
689 wxEllipseShape(double w
= 0.0, double h
= 0.0);
691 void GetBoundingBoxMin(double *w
, double *h
);
692 bool GetPerimeterPoint(double x1
, double y1
,
693 double x2
, double y2
,
694 double *x3
, double *y3
);
696 void OnDraw(wxDC
& dc
);
697 void SetSize(double x
, double y
, bool recursive
= TRUE
);
700 void WriteAttributes(wxExpr
*clause
);
701 void ReadAttributes(wxExpr
*clause
);
704 int GetNumberOfAttachments() const;
705 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
706 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
708 // Does the copying for this object
709 void Copy(wxShape
& copy
);
711 inline double GetWidth() const { return m_width
; }
712 inline double GetHeight() const { return m_height
; }
714 inline void SetWidth(double w
) { m_width
= w
; }
715 inline void SetHeight(double h
) { m_height
= h
; }
722 class wxCircleShape
: public wxEllipseShape
724 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
726 wxCircleShape(double w
= 0.0);
728 bool GetPerimeterPoint(double x1
, double y1
,
729 double x2
, double y2
,
730 double *x3
, double *y3
);
731 // Does the copying for this object
732 void Copy(wxShape
& copy
);