1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Basic OGL classes and definitions
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #ifndef wxUSE_DEPRECATED
16 #define wxUSE_DEPRECATED 0
20 #include "wx/deprecated/setup.h"
23 #ifndef wxUSE_PROLOGIO
24 #define wxUSE_PROLOGIO 0
27 #define OGL_VERSION 2.0
29 #ifndef DEFAULT_MOUSE_TOLERANCE
30 #define DEFAULT_MOUSE_TOLERANCE 3
42 #define ARROW_MIDDLE 3
45 // Control point types
46 // Rectangle and most other shapes
47 #define CONTROL_POINT_VERTICAL 1
48 #define CONTROL_POINT_HORIZONTAL 2
49 #define CONTROL_POINT_DIAGONAL 3
52 #define CONTROL_POINT_ENDPOINT_TO 4
53 #define CONTROL_POINT_ENDPOINT_FROM 5
54 #define CONTROL_POINT_LINE 6
56 // Types of formatting: can be combined in a bit list
59 #define FORMAT_CENTRE_HORIZ 1
60 // Centre horizontally
61 #define FORMAT_CENTRE_VERT 2
63 #define FORMAT_SIZE_TO_CONTENTS 4
64 // Resize shape to contents
69 #define SHADOW_RIGHT 2
76 #define SHAPE_BASIC wxTYPE_USER + 1
77 #define SHAPE_RECTANGLE wxTYPE_USER + 2
78 #define SHAPE_ELLIPSE wxTYPE_USER + 3
79 #define SHAPE_POLYGON wxTYPE_USER + 4
80 #define SHAPE_CIRCLE wxTYPE_USER + 5
81 #define SHAPE_LINE wxTYPE_USER + 6
82 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
83 #define SHAPE_COMPOSITE wxTYPE_USER + 9
84 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
85 #define SHAPE_DRAWN wxTYPE_USER + 11
86 #define SHAPE_DIVISION wxTYPE_USER + 12
87 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
88 #define SHAPE_BITMAP wxTYPE_USER + 14
89 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
91 #define OBJECT_REGION wxTYPE_USER + 20
93 #define OP_CLICK_LEFT 1
94 #define OP_CLICK_RIGHT 2
95 #define OP_DRAG_LEFT 4
96 #define OP_DRAG_RIGHT 8
98 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
101 #define ATTACHMENT_MODE_NONE 0
102 #define ATTACHMENT_MODE_EDGE 1
103 #define ATTACHMENT_MODE_BRANCHING 2
105 // Sub-modes for branching attachment mode
106 #define BRANCHING_ATTACHMENT_NORMAL 1
107 #define BRANCHING_ATTACHMENT_BLOB 2
109 class wxShapeTextLine
;
112 class wxControlPoint
;
117 class WXDLLEXPORT wxExpr
;
118 class WXDLLEXPORT wxExprDatabase
;
122 #define WXROUND(x) ( (long) (x + 0.5) )
125 // logical function to use when drawing rubberband boxes, etc.
126 #define OGLRBLF wxINVERT
130 class WXDLLIMPEXP_OGL wxShapeEvtHandler
: public wxObject
, public wxClientDataContainer
132 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
135 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
136 virtual ~wxShapeEvtHandler();
138 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
139 inline wxShape
*GetShape() const { return m_handlerShape
; }
141 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
142 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
144 // This is called when the _shape_ is deleted.
145 virtual void OnDelete();
146 virtual void OnDraw(wxDC
& dc
);
147 virtual void OnDrawContents(wxDC
& dc
);
148 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= false);
149 virtual void OnMoveLinks(wxDC
& dc
);
150 virtual void OnErase(wxDC
& dc
);
151 virtual void OnEraseContents(wxDC
& dc
);
152 virtual void OnHighlight(wxDC
& dc
);
153 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
154 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
155 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
156 virtual void OnSize(double x
, double y
);
157 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
158 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
160 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
161 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
162 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
163 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
164 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
165 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
166 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
167 virtual void OnDrawControlPoints(wxDC
& dc
);
168 virtual void OnEraseControlPoints(wxDC
& dc
);
169 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= true);
171 // Control points ('handles') redirect control to the actual shape, to make it easier
172 // to override sizing behaviour.
173 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
174 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
175 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
177 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
178 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
180 // Can override this to prevent or intercept line reordering.
181 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
183 // Creates a copy of this event handler.
184 wxShapeEvtHandler
*CreateNewCopy();
186 // Does the copy - override for new event handlers which might store
187 // app-specific data.
188 virtual void CopyData(wxShapeEvtHandler
& WXUNUSED(copy
)) {};
191 wxShapeEvtHandler
* m_previousHandler
;
192 wxShape
* m_handlerShape
;
195 class WXDLLIMPEXP_OGL wxShape
: public wxShapeEvtHandler
197 DECLARE_ABSTRACT_CLASS(wxShape
)
201 wxShape(wxShapeCanvas
*can
= NULL
);
203 virtual void GetBoundingBoxMax(double *width
, double *height
);
204 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
205 virtual bool GetPerimeterPoint(double x1
, double y1
,
206 double x2
, double y2
,
207 double *x3
, double *y3
);
208 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
209 void SetCanvas(wxShapeCanvas
*the_canvas
);
210 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
211 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
213 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
214 inline double GetX() const { return m_xpos
; }
215 inline double GetY() const { return m_ypos
; }
216 inline void SetX(double x
) { m_xpos
= x
; }
217 inline void SetY(double y
) { m_ypos
= y
; }
219 inline wxShape
*GetParent() const { return m_parent
; }
220 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
221 wxShape
*GetTopAncestor();
222 inline wxList
& GetChildren() { return m_children
; }
224 virtual void OnDraw(wxDC
& dc
);
225 virtual void OnDrawContents(wxDC
& dc
);
226 virtual void OnMoveLinks(wxDC
& dc
);
227 virtual void Unlink() { };
228 void SetDrawHandles(bool drawH
);
229 inline bool GetDrawHandles() { return m_drawHandles
; }
230 virtual void OnErase(wxDC
& dc
);
231 virtual void OnEraseContents(wxDC
& dc
);
232 virtual void OnHighlight(wxDC
& dc
);
233 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
234 virtual void OnLeftDoubleClick(double WXUNUSED(x
), double WXUNUSED(y
), int WXUNUSED(keys
) = 0, int WXUNUSED(attachment
) = 0) {}
235 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
236 virtual void OnSize(double x
, double y
);
237 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
238 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
240 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
241 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
242 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
243 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
244 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
245 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
246 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
247 virtual void OnDrawControlPoints(wxDC
& dc
);
248 virtual void OnEraseControlPoints(wxDC
& dc
);
250 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
251 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
253 // Control points ('handles') redirect control to the actual shape, to make it easier
254 // to override sizing behaviour.
255 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
256 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
257 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
259 virtual void MakeControlPoints();
260 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
261 virtual void ResetControlPoints();
263 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
264 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
266 // Mandatory control points, e.g. the divided line moving handles
267 // should appear even if a child of the 'selected' image
268 virtual void MakeMandatoryControlPoints();
269 virtual void ResetMandatoryControlPoints();
271 inline virtual bool Recompute() { return true; };
272 // Calculate size recursively, if size changes. Size might depend on children.
273 inline virtual void CalculateSize() { };
274 virtual void Select(bool select
= true, wxDC
* dc
= NULL
);
275 virtual void SetHighlight(bool hi
= true, bool recurse
= false);
276 inline virtual bool IsHighlighted() const { return m_highlighted
; };
277 virtual bool Selected() const;
278 virtual bool AncestorSelected() const;
279 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= false);
280 int GetSensitivityFilter() const { return m_sensitivity
; }
281 void SetDraggable(bool drag
, bool recursive
= false);
282 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
283 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
284 inline bool GetFixedWidth() const { return m_fixedWidth
; }
285 inline bool GetFixedHeight() const { return m_fixedHeight
; }
286 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
287 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
288 void SetShadowMode(int mode
, bool redraw
= false);
289 inline int GetShadowMode() const { return m_shadowMode
; }
290 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
291 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
292 inline bool GetCentreResize() const { return m_centreResize
; }
293 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
294 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
295 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
296 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
297 inline bool GetDisableLabel() const { return m_disableLabel
; }
298 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
299 inline int GetAttachmentMode() const { return m_attachmentMode
; }
300 inline void SetId(long i
) { m_id
= i
; }
301 inline long GetId() const { return m_id
; }
303 void SetPen(wxPen
*pen
);
304 void SetBrush(wxBrush
*brush
);
306 virtual void Show(bool show
);
307 virtual bool IsShown() const { return m_visible
; }
308 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= true);
309 virtual void Erase(wxDC
& dc
);
310 virtual void EraseContents(wxDC
& dc
);
311 virtual void Draw(wxDC
& dc
);
312 virtual void Flash();
313 virtual void MoveLinks(wxDC
& dc
);
314 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
315 virtual void SetSize(double x
, double y
, bool recursive
= true);
316 virtual void SetAttachmentSize(double x
, double y
);
317 void Attach(wxShapeCanvas
*can
);
320 inline virtual bool Constrain() { return false; } ;
322 void AddLine(wxLineShape
*line
, wxShape
*other
,
323 int attachFrom
= 0, int attachTo
= 0,
325 int positionFrom
= -1, int positionTo
= -1);
327 // Return the zero-based position in m_lines of line.
328 int GetLinePosition(wxLineShape
* line
);
330 void AddText(const wxString
& string
);
332 inline wxPen
*GetPen() const { return m_pen
; }
333 inline wxBrush
*GetBrush() const { return m_brush
; }
336 * Region-specific functions (defaults to the default region
340 // Set the default, single region size to be consistent
341 // with the object size
342 void SetDefaultRegionSize();
343 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
344 virtual void SetFormatMode(int mode
, int regionId
= 0);
345 virtual int GetFormatMode(int regionId
= 0) const;
346 virtual void SetFont(wxFont
*font
, int regionId
= 0);
347 virtual wxFont
*GetFont(int regionId
= 0) const;
348 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
349 virtual wxString
GetTextColour(int regionId
= 0) const;
350 virtual inline int GetNumberOfTextRegions() const { return m_regions
.GetCount(); }
351 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
353 // Get the name representing the region for this image alone.
354 // I.e. this image's region ids go from 0 to N-1.
355 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
356 // So the last digit represents the region Id, the others represent positions
358 virtual wxString
GetRegionName(int regionId
);
360 // Gets the region corresponding to the name, or -1 if not found.
361 virtual int GetRegionId(const wxString
& name
);
363 // Construct names for regions, unique even for children of a composite.
364 virtual void NameRegions(const wxString
& parentName
= wxEmptyString
);
366 // Get list of regions
367 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
369 virtual void AddRegion(wxShapeRegion
*region
);
371 virtual void ClearRegions();
373 // Assign new ids to this image and children (if composite)
376 // Returns actual image (same as 'this' if non-composite) and region id
377 // for given region name.
378 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
380 // Finds all region names for this image (composite or simple).
381 // Supply empty string list.
382 virtual void FindRegionNames(wxStringList
& list
);
384 virtual void ClearText(int regionId
= 0);
385 void RemoveLine(wxLineShape
*line
);
389 virtual void WriteAttributes(wxExpr
*clause
);
390 virtual void ReadAttributes(wxExpr
*clause
);
392 // In case the object has constraints it needs to read in in a different pass
393 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
394 virtual void WriteRegions(wxExpr
*clause
);
395 virtual void ReadRegions(wxExpr
*clause
);
399 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
400 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
401 virtual int GetNumberOfAttachments() const;
402 virtual bool AttachmentIsValid(int attachment
) const;
403 virtual wxList
& GetAttachments() { return m_attachmentPoints
; }
405 // Only get the attachment position at the _edge_ of the shape, ignoring
406 // branching mode. This is used e.g. to indicate the edge of interest, not the point
407 // on the attachment branch.
408 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
409 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
411 // Assuming the attachment lies along a vertical or horizontal line,
412 // calculate the position on that point.
413 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
414 int nth
, int noArcs
, wxLineShape
* line
);
416 // Returns true if pt1 <= pt2 in the sense that one point comes before another on an
417 // edge of the shape.
418 // attachmentPoint is the attachment point (= side) in question.
419 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
421 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= false);
422 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= false);
424 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
427 // Reorders the lines coming into the node image at this attachment
428 // position, in the order in which they appear in linesToSort.
429 virtual void SortLines(int attachment
, wxList
& linesToSort
);
431 // Apply an attachment ordering change
432 void ApplyAttachmentOrdering(wxList
& ordering
);
434 // Can override this to prevent or intercept line reordering.
435 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
437 //// New banching attachment code, 24/9/98
443 // shoulder1 ->---------<- shoulder2
445 // <- branching attachment point N-1
447 // This function gets the root point at the given attachment.
448 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
450 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
451 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
452 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
454 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
455 // at this attachment point.
456 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
458 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
459 wxRealPoint
& stemPoint
);
461 // Get the number of lines at this attachment position.
462 virtual int GetAttachmentLineCount(int attachment
) const;
464 // Draw the branches (not the actual arcs though)
465 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= false);
466 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= false);
468 // Branching attachment settings
469 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
470 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
472 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
473 inline int GetBranchStemLength() const { return m_branchStemLength
; }
475 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
476 inline int GetBranchSpacing() const { return m_branchSpacing
; }
478 // Further detail on branching style, e.g. blobs on interconnections
479 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
480 inline long GetBranchStyle() const { return m_branchStyle
; }
482 // Rotate the standard attachment point from physical (0 is always North)
483 // to logical (0 -> 1 if rotated by 90 degrees)
484 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
486 // Rotate the standard attachment point from logical
487 // to physical (0 is always North)
488 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
490 // This is really to distinguish between lines and other images.
491 // For lines, want to pass drag to canvas, since lines tend to prevent
492 // dragging on a canvas (they get in the way.)
493 virtual bool Draggable() const { return true; }
495 // Returns true if image is a descendant of this image
496 bool HasDescendant(wxShape
*image
);
498 // Creates a copy of this shape.
499 wxShape
*CreateNewCopy(bool resetMapping
= true, bool recompute
= true);
501 // Does the copying for this object
502 virtual void Copy(wxShape
& copy
);
504 // Does the copying for this object, including copying event
505 // handler data if any. Calls the virtual Copy function.
506 void CopyWithHandler(wxShape
& copy
);
508 // Rotate about the given axis by the given amount in radians.
509 virtual void Rotate(double x
, double y
, double theta
);
510 virtual double GetRotation() const { return m_rotation
; }
511 virtual void SetRotation(double rotation
) { m_rotation
= rotation
; }
513 void ClearAttachments();
515 // Recentres all the text regions for this object
516 void Recentre(wxDC
& dc
);
518 // Clears points from a list of wxRealPoints
519 void ClearPointList(wxList
& list
);
521 // Return pen or brush of the right colour for the background
522 wxPen
GetBackgroundPen();
523 wxBrush
GetBackgroundBrush();
527 wxShapeEvtHandler
* m_eventHandler
;
529 double m_xpos
, m_ypos
;
533 wxColour m_textColour
;
534 wxString m_textColourName
;
535 wxShapeCanvas
* m_canvas
;
538 wxList m_controlPoints
;
540 wxList m_attachmentPoints
;
545 bool m_highlighted
; // Different from selected: user-defined highlighting,
546 // e.g. thick border.
550 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
551 // 2 for branching attachments
552 bool m_spaceAttachments
; // true if lines at one side should be spaced
555 bool m_centreResize
; // Default is to resize keeping the centre constant (true)
556 bool m_drawHandles
; // Don't draw handles if false, usually true
557 wxList m_children
; // In case it's composite
558 wxShape
* m_parent
; // In case it's a child
561 wxBrush
* m_shadowBrush
;
564 int m_textMarginX
; // Gap between text and border
566 wxString m_regionName
;
567 bool m_maintainAspectRatio
;
568 int m_branchNeckLength
;
569 int m_branchStemLength
;
574 class WXDLLIMPEXP_OGL wxPolygonShape
: public wxShape
576 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
581 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
582 // Deletes user's points in destructor.
583 virtual void Create(wxList
*points
);
584 virtual void ClearPoints();
586 void GetBoundingBoxMin(double *w
, double *h
);
587 void CalculateBoundingBox();
588 bool GetPerimeterPoint(double x1
, double y1
,
589 double x2
, double y2
,
590 double *x3
, double *y3
);
591 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
592 void SetSize(double x
, double y
, bool recursive
= true);
593 void OnDraw(wxDC
& dc
);
594 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
596 // Control points ('handles') redirect control to the actual shape, to make it easier
597 // to override sizing behaviour.
598 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
599 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
600 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
602 // A polygon should have a control point at each vertex,
603 // with the option of moving the control points individually
604 // to change the shape.
605 void MakeControlPoints();
606 void ResetControlPoints();
608 // If we've changed the shape, must make the original
609 // points match the working points
610 void UpdateOriginalPoints();
612 // Add a control point after the given point
613 virtual void AddPolygonPoint(int pos
= 0);
615 // Delete a control point
616 virtual void DeletePolygonPoint(int pos
= 0);
618 // Recalculates the centre of the polygon
619 virtual void CalculatePolygonCentre();
622 void WriteAttributes(wxExpr
*clause
);
623 void ReadAttributes(wxExpr
*clause
);
626 int GetNumberOfAttachments() const;
627 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
628 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
629 bool AttachmentIsValid(int attachment
) const;
630 // Does the copying for this object
631 void Copy(wxShape
& copy
);
633 inline wxList
*GetPoints() { return m_points
; }
634 inline wxList
*GetOriginalPoints() { return m_originalPoints
; }
636 // Rotate about the given axis by the given amount in radians
637 virtual void Rotate(double x
, double y
, double theta
);
639 double GetOriginalWidth() const { return m_originalWidth
; }
640 double GetOriginalHeight() const { return m_originalHeight
; }
642 void SetOriginalWidth(double w
) { m_originalWidth
= w
; }
643 void SetOriginalHeight(double h
) { m_originalHeight
= h
; }
647 wxList
* m_originalPoints
;
649 double m_boundHeight
;
650 double m_originalWidth
;
651 double m_originalHeight
;
654 class WXDLLIMPEXP_OGL wxRectangleShape
: public wxShape
656 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
658 wxRectangleShape(double w
= 0.0, double h
= 0.0);
659 void GetBoundingBoxMin(double *w
, double *h
);
660 bool GetPerimeterPoint(double x1
, double y1
,
661 double x2
, double y2
,
662 double *x3
, double *y3
);
663 void OnDraw(wxDC
& dc
);
664 void SetSize(double x
, double y
, bool recursive
= true);
665 void SetCornerRadius(double rad
); // If > 0, rounded corners
666 double GetCornerRadius() const { return m_cornerRadius
; }
669 void WriteAttributes(wxExpr
*clause
);
670 void ReadAttributes(wxExpr
*clause
);
673 int GetNumberOfAttachments() const;
674 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
675 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
676 // Does the copying for this object
677 void Copy(wxShape
& copy
);
679 inline double GetWidth() const { return m_width
; }
680 inline double GetHeight() const { return m_height
; }
681 inline void SetWidth(double w
) { m_width
= w
; }
682 inline void SetHeight(double h
) { m_height
= h
; }
687 double m_cornerRadius
;
690 class WXDLLIMPEXP_OGL wxTextShape
: public wxRectangleShape
692 DECLARE_DYNAMIC_CLASS(wxTextShape
)
694 wxTextShape(double width
= 0.0, double height
= 0.0);
696 void OnDraw(wxDC
& dc
);
699 void WriteAttributes(wxExpr
*clause
);
702 // Does the copying for this object
703 void Copy(wxShape
& copy
);
706 class WXDLLIMPEXP_OGL wxEllipseShape
: public wxShape
708 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
710 wxEllipseShape(double w
= 0.0, double h
= 0.0);
712 void GetBoundingBoxMin(double *w
, double *h
);
713 bool GetPerimeterPoint(double x1
, double y1
,
714 double x2
, double y2
,
715 double *x3
, double *y3
);
717 void OnDraw(wxDC
& dc
);
718 void SetSize(double x
, double y
, bool recursive
= true);
721 void WriteAttributes(wxExpr
*clause
);
722 void ReadAttributes(wxExpr
*clause
);
725 int GetNumberOfAttachments() const;
726 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
727 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
729 // Does the copying for this object
730 void Copy(wxShape
& copy
);
732 inline double GetWidth() const { return m_width
; }
733 inline double GetHeight() const { return m_height
; }
735 inline void SetWidth(double w
) { m_width
= w
; }
736 inline void SetHeight(double h
) { m_height
= h
; }
743 class WXDLLIMPEXP_OGL wxCircleShape
: public wxEllipseShape
745 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
747 wxCircleShape(double w
= 0.0);
749 bool GetPerimeterPoint(double x1
, double y1
,
750 double x2
, double y2
,
751 double *x3
, double *y3
);
752 // Does the copying for this object
753 void Copy(wxShape
& copy
);