1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Basic OGL classes and definitions
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "basic.h"
19 #ifndef wxUSE_DEPRECATED
20 #define wxUSE_DEPRECATED 1
24 #include <wx/deprecated/setup.h>
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;
404 // Only get the attachment position at the _edge_ of the shape, ignoring
405 // branching mode. This is used e.g. to indicate the edge of interest, not the point
406 // on the attachment branch.
407 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
408 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
410 // Assuming the attachment lies along a vertical or horizontal line,
411 // calculate the position on that point.
412 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
413 int nth
, int noArcs
, wxLineShape
* line
);
415 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
416 // edge of the shape.
417 // attachmentPoint is the attachment point (= side) in question.
418 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
420 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
421 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
423 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
426 // Reorders the lines coming into the node image at this attachment
427 // position, in the order in which they appear in linesToSort.
428 virtual void SortLines(int attachment
, wxList
& linesToSort
);
430 // Apply an attachment ordering change
431 void ApplyAttachmentOrdering(wxList
& ordering
);
433 // Can override this to prevent or intercept line reordering.
434 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
436 //// New banching attachment code, 24/9/98
442 // shoulder1 ->---------<- shoulder2
444 // <- branching attachment point N-1
446 // This function gets the root point at the given attachment.
447 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
449 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
450 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
451 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
453 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
454 // at this attachment point.
455 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
457 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
458 wxRealPoint
& stemPoint
);
460 // Get the number of lines at this attachment position.
461 virtual int GetAttachmentLineCount(int attachment
) const;
463 // Draw the branches (not the actual arcs though)
464 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
465 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
467 // Branching attachment settings
468 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
469 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
471 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
472 inline int GetBranchStemLength() const { return m_branchStemLength
; }
474 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
475 inline int GetBranchSpacing() const { return m_branchSpacing
; }
477 // Further detail on branching style, e.g. blobs on interconnections
478 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
479 inline long GetBranchStyle() const { return m_branchStyle
; }
481 // Rotate the standard attachment point from physical (0 is always North)
482 // to logical (0 -> 1 if rotated by 90 degrees)
483 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
485 // Rotate the standard attachment point from logical
486 // to physical (0 is always North)
487 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
489 // This is really to distinguish between lines and other images.
490 // For lines, want to pass drag to canvas, since lines tend to prevent
491 // dragging on a canvas (they get in the way.)
492 virtual bool Draggable() const { return TRUE
; }
494 // Returns TRUE if image is a descendant of this image
495 bool HasDescendant(wxShape
*image
);
497 // Creates a copy of this shape.
498 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
500 // Does the copying for this object
501 virtual void Copy(wxShape
& copy
);
503 // Does the copying for this object, including copying event
504 // handler data if any. Calls the virtual Copy function.
505 void CopyWithHandler(wxShape
& copy
);
507 // Rotate about the given axis by the given amount in radians.
508 virtual void Rotate(double x
, double y
, double theta
);
509 virtual inline double GetRotation() const { return m_rotation
; }
511 void ClearAttachments();
513 // Recentres all the text regions for this object
514 void Recentre(wxDC
& dc
);
516 // Clears points from a list of wxRealPoints
517 void ClearPointList(wxList
& list
);
519 // Return pen or brush of the right colour for the background
520 wxPen
GetBackgroundPen();
521 wxBrush
GetBackgroundBrush();
525 wxShapeEvtHandler
* m_eventHandler
;
527 double m_xpos
, m_ypos
;
531 wxColour
* m_textColour
;
532 wxString m_textColourName
;
533 wxShapeCanvas
* m_canvas
;
536 wxList m_controlPoints
;
538 wxList m_attachmentPoints
;
543 bool m_highlighted
; // Different from selected: user-defined highlighting,
544 // e.g. thick border.
548 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
549 // 2 for branching attachments
550 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
553 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
554 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
555 wxList m_children
; // In case it's composite
556 wxShape
* m_parent
; // In case it's a child
559 wxBrush
* m_shadowBrush
;
562 int m_textMarginX
; // Gap between text and border
564 wxString m_regionName
;
565 bool m_maintainAspectRatio
;
566 int m_branchNeckLength
;
567 int m_branchStemLength
;
572 class WXDLLIMPEXP_OGL wxPolygonShape
: public wxShape
574 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
579 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
580 // Deletes user's points in destructor.
581 virtual void Create(wxList
*points
);
582 virtual void ClearPoints();
584 void GetBoundingBoxMin(double *w
, double *h
);
585 void CalculateBoundingBox();
586 bool GetPerimeterPoint(double x1
, double y1
,
587 double x2
, double y2
,
588 double *x3
, double *y3
);
589 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
590 void SetSize(double x
, double y
, bool recursive
= TRUE
);
591 void OnDraw(wxDC
& dc
);
592 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
594 // Control points ('handles') redirect control to the actual shape, to make it easier
595 // to override sizing behaviour.
596 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
597 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
598 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
600 // A polygon should have a control point at each vertex,
601 // with the option of moving the control points individually
602 // to change the shape.
603 void MakeControlPoints();
604 void ResetControlPoints();
606 // If we've changed the shape, must make the original
607 // points match the working points
608 void UpdateOriginalPoints();
610 // Add a control point after the given point
611 virtual void AddPolygonPoint(int pos
= 0);
613 // Delete a control point
614 virtual void DeletePolygonPoint(int pos
= 0);
616 // Recalculates the centre of the polygon
617 virtual void CalculatePolygonCentre();
620 void WriteAttributes(wxExpr
*clause
);
621 void ReadAttributes(wxExpr
*clause
);
624 int GetNumberOfAttachments() const;
625 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
626 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
627 bool AttachmentIsValid(int attachment
) const;
628 // Does the copying for this object
629 void Copy(wxShape
& copy
);
631 inline wxList
*GetPoints() { return m_points
; }
633 // Rotate about the given axis by the given amount in radians
634 virtual void Rotate(double x
, double y
, double theta
);
638 wxList
* m_originalPoints
;
640 double m_boundHeight
;
641 double m_originalWidth
;
642 double m_originalHeight
;
645 class WXDLLIMPEXP_OGL wxRectangleShape
: public wxShape
647 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
649 wxRectangleShape(double w
= 0.0, double h
= 0.0);
650 void GetBoundingBoxMin(double *w
, double *h
);
651 bool GetPerimeterPoint(double x1
, double y1
,
652 double x2
, double y2
,
653 double *x3
, double *y3
);
654 void OnDraw(wxDC
& dc
);
655 void SetSize(double x
, double y
, bool recursive
= TRUE
);
656 void SetCornerRadius(double rad
); // If > 0, rounded corners
659 void WriteAttributes(wxExpr
*clause
);
660 void ReadAttributes(wxExpr
*clause
);
663 int GetNumberOfAttachments() const;
664 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
665 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
666 // Does the copying for this object
667 void Copy(wxShape
& copy
);
669 inline double GetWidth() const { return m_width
; }
670 inline double GetHeight() const { return m_height
; }
671 inline void SetWidth(double w
) { m_width
= w
; }
672 inline void SetHeight(double h
) { m_height
= h
; }
677 double m_cornerRadius
;
680 class WXDLLIMPEXP_OGL wxTextShape
: public wxRectangleShape
682 DECLARE_DYNAMIC_CLASS(wxTextShape
)
684 wxTextShape(double width
= 0.0, double height
= 0.0);
686 void OnDraw(wxDC
& dc
);
689 void WriteAttributes(wxExpr
*clause
);
692 // Does the copying for this object
693 void Copy(wxShape
& copy
);
696 class WXDLLIMPEXP_OGL wxEllipseShape
: public wxShape
698 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
700 wxEllipseShape(double w
= 0.0, double h
= 0.0);
702 void GetBoundingBoxMin(double *w
, double *h
);
703 bool GetPerimeterPoint(double x1
, double y1
,
704 double x2
, double y2
,
705 double *x3
, double *y3
);
707 void OnDraw(wxDC
& dc
);
708 void SetSize(double x
, double y
, bool recursive
= TRUE
);
711 void WriteAttributes(wxExpr
*clause
);
712 void ReadAttributes(wxExpr
*clause
);
715 int GetNumberOfAttachments() const;
716 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
717 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
719 // Does the copying for this object
720 void Copy(wxShape
& copy
);
722 inline double GetWidth() const { return m_width
; }
723 inline double GetHeight() const { return m_height
; }
725 inline void SetWidth(double w
) { m_width
= w
; }
726 inline void SetHeight(double h
) { m_height
= h
; }
733 class WXDLLIMPEXP_OGL wxCircleShape
: public wxEllipseShape
735 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
737 wxCircleShape(double w
= 0.0);
739 bool GetPerimeterPoint(double x1
, double y1
,
740 double x2
, double y2
,
741 double *x3
, double *y3
);
742 // Does the copying for this object
743 void Copy(wxShape
& copy
);