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 #define OGL_VERSION 2.0
21 #ifndef DEFAULT_MOUSE_TOLERANCE
22 #define DEFAULT_MOUSE_TOLERANCE 3
34 #define ARROW_MIDDLE 3
37 // Control point types
38 // Rectangle and most other shapes
39 #define CONTROL_POINT_VERTICAL 1
40 #define CONTROL_POINT_HORIZONTAL 2
41 #define CONTROL_POINT_DIAGONAL 3
44 #define CONTROL_POINT_ENDPOINT_TO 4
45 #define CONTROL_POINT_ENDPOINT_FROM 5
46 #define CONTROL_POINT_LINE 6
48 // Types of formatting: can be combined in a bit list
51 #define FORMAT_CENTRE_HORIZ 1
52 // Centre horizontally
53 #define FORMAT_CENTRE_VERT 2
55 #define FORMAT_SIZE_TO_CONTENTS 4
56 // Resize shape to contents
61 #define SHADOW_RIGHT 2
68 #define SHAPE_BASIC wxTYPE_USER + 1
69 #define SHAPE_RECTANGLE wxTYPE_USER + 2
70 #define SHAPE_ELLIPSE wxTYPE_USER + 3
71 #define SHAPE_POLYGON wxTYPE_USER + 4
72 #define SHAPE_CIRCLE wxTYPE_USER + 5
73 #define SHAPE_LINE wxTYPE_USER + 6
74 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
75 #define SHAPE_COMPOSITE wxTYPE_USER + 9
76 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
77 #define SHAPE_DRAWN wxTYPE_USER + 11
78 #define SHAPE_DIVISION wxTYPE_USER + 12
79 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
80 #define SHAPE_BITMAP wxTYPE_USER + 14
81 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
83 #define OBJECT_REGION wxTYPE_USER + 20
85 #define OP_CLICK_LEFT 1
86 #define OP_CLICK_RIGHT 2
87 #define OP_DRAG_LEFT 4
88 #define OP_DRAG_RIGHT 8
90 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
93 #define ATTACHMENT_MODE_NONE 0
94 #define ATTACHMENT_MODE_EDGE 1
95 #define ATTACHMENT_MODE_BRANCHING 2
97 // Sub-modes for branching attachment mode
98 #define BRANCHING_ATTACHMENT_NORMAL 1
99 #define BRANCHING_ATTACHMENT_BLOB 2
101 class wxShapeTextLine
;
104 class wxControlPoint
;
109 class WXDLLEXPORT wxExpr
;
110 class WXDLLEXPORT wxExprDatabase
;
114 #define WXROUND(x) ( (long) (x + 0.5) )
117 // logical function to use when drawing rubberband boxes, etc.
118 #define OGLRBLF wxINVERT
122 class wxShapeEvtHandler
: public wxObject
, public wxClientDataContainer
124 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
127 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
128 virtual ~wxShapeEvtHandler();
130 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
131 inline wxShape
*GetShape() const { return m_handlerShape
; }
133 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
134 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
136 // This is called when the _shape_ is deleted.
137 virtual void OnDelete();
138 virtual void OnDraw(wxDC
& dc
);
139 virtual void OnDrawContents(wxDC
& dc
);
140 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
141 virtual void OnMoveLinks(wxDC
& dc
);
142 virtual void OnErase(wxDC
& dc
);
143 virtual void OnEraseContents(wxDC
& dc
);
144 virtual void OnHighlight(wxDC
& dc
);
145 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
146 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
147 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
148 virtual void OnSize(double x
, double y
);
149 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
150 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
152 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
153 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
154 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
155 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
156 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
157 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
158 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
159 virtual void OnDrawControlPoints(wxDC
& dc
);
160 virtual void OnEraseControlPoints(wxDC
& dc
);
161 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= TRUE
);
163 // Control points ('handles') redirect control to the actual shape, to make it easier
164 // to override sizing behaviour.
165 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
166 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
167 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
169 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
170 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
172 // Can override this to prevent or intercept line reordering.
173 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
175 // Creates a copy of this event handler.
176 wxShapeEvtHandler
*CreateNewCopy();
178 // Does the copy - override for new event handlers which might store
179 // app-specific data.
180 virtual void CopyData(wxShapeEvtHandler
& copy
) {};
183 wxShapeEvtHandler
* m_previousHandler
;
184 wxShape
* m_handlerShape
;
187 class wxShape
: public wxShapeEvtHandler
189 DECLARE_ABSTRACT_CLASS(wxShape
)
193 wxShape(wxShapeCanvas
*can
= NULL
);
195 virtual void GetBoundingBoxMax(double *width
, double *height
);
196 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
197 virtual bool GetPerimeterPoint(double x1
, double y1
,
198 double x2
, double y2
,
199 double *x3
, double *y3
);
200 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
201 void SetCanvas(wxShapeCanvas
*the_canvas
);
202 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
203 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
205 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
206 inline double GetX() const { return m_xpos
; }
207 inline double GetY() const { return m_ypos
; }
208 inline void SetX(double x
) { m_xpos
= x
; }
209 inline void SetY(double y
) { m_ypos
= y
; }
211 inline wxShape
*GetParent() const { return m_parent
; }
212 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
213 wxShape
*GetTopAncestor();
214 inline wxList
& GetChildren() { return m_children
; }
216 virtual void OnDraw(wxDC
& dc
);
217 virtual void OnDrawContents(wxDC
& dc
);
218 virtual void OnMoveLinks(wxDC
& dc
);
219 virtual void Unlink() { };
220 void SetDrawHandles(bool drawH
);
221 inline bool GetDrawHandles() { return m_drawHandles
; }
222 virtual void OnErase(wxDC
& dc
);
223 virtual void OnEraseContents(wxDC
& dc
);
224 virtual void OnHighlight(wxDC
& dc
);
225 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
226 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0) {}
227 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
228 virtual void OnSize(double x
, double y
);
229 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
230 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
232 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
233 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
234 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
235 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
236 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
237 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
238 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
239 virtual void OnDrawControlPoints(wxDC
& dc
);
240 virtual void OnEraseControlPoints(wxDC
& dc
);
242 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
243 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
245 // Control points ('handles') redirect control to the actual shape, to make it easier
246 // to override sizing behaviour.
247 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
248 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
249 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
251 virtual void MakeControlPoints();
252 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
253 virtual void ResetControlPoints();
255 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
256 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
258 // Mandatory control points, e.g. the divided line moving handles
259 // should appear even if a child of the 'selected' image
260 virtual void MakeMandatoryControlPoints();
261 virtual void ResetMandatoryControlPoints();
263 inline virtual bool Recompute() { return TRUE
; };
264 // Calculate size recursively, if size changes. Size might depend on children.
265 inline virtual void CalculateSize() { };
266 virtual void Select(bool select
= TRUE
, wxDC
* dc
= NULL
);
267 virtual void SetHighlight(bool hi
= TRUE
, bool recurse
= FALSE
);
268 inline virtual bool IsHighlighted() const { return m_highlighted
; };
269 virtual bool Selected() const;
270 virtual bool AncestorSelected() const;
271 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= FALSE
);
272 int GetSensitivityFilter() const { return m_sensitivity
; }
273 void SetDraggable(bool drag
, bool recursive
= FALSE
);
274 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
275 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
276 inline bool GetFixedWidth() const { return m_fixedWidth
; }
277 inline bool GetFixedHeight() const { return m_fixedHeight
; }
278 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
279 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
280 void SetShadowMode(int mode
, bool redraw
= FALSE
);
281 inline int GetShadowMode() const { return m_shadowMode
; }
282 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
283 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
284 inline bool GetCentreResize() const { return m_centreResize
; }
285 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
286 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
287 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
288 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
289 inline bool GetDisableLabel() const { return m_disableLabel
; }
290 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
291 inline int GetAttachmentMode() const { return m_attachmentMode
; }
292 inline void SetId(long i
) { m_id
= i
; }
293 inline long GetId() const { return m_id
; }
295 void SetPen(wxPen
*pen
);
296 void SetBrush(wxBrush
*brush
);
298 virtual void Show(bool show
);
299 virtual bool IsShown() const { return m_visible
; }
300 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= TRUE
);
301 virtual void Erase(wxDC
& dc
);
302 virtual void EraseContents(wxDC
& dc
);
303 virtual void Draw(wxDC
& dc
);
304 virtual void Flash();
305 virtual void MoveLinks(wxDC
& dc
);
306 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
307 virtual void SetSize(double x
, double y
, bool recursive
= TRUE
);
308 virtual void SetAttachmentSize(double x
, double y
);
309 void Attach(wxShapeCanvas
*can
);
312 inline virtual bool Constrain() { return FALSE
; } ;
314 void AddLine(wxLineShape
*line
, wxShape
*other
,
315 int attachFrom
= 0, int attachTo
= 0,
317 int positionFrom
= -1, int positionTo
= -1);
319 // Return the zero-based position in m_lines of line.
320 int GetLinePosition(wxLineShape
* line
);
322 void AddText(const wxString
& string
);
324 inline wxPen
*GetPen() const { return m_pen
; }
325 inline wxBrush
*GetBrush() const { return m_brush
; }
328 * Region-specific functions (defaults to the default region
332 // Set the default, single region size to be consistent
333 // with the object size
334 void SetDefaultRegionSize();
335 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
336 virtual void SetFormatMode(int mode
, int regionId
= 0);
337 virtual int GetFormatMode(int regionId
= 0) const;
338 virtual void SetFont(wxFont
*font
, int regionId
= 0);
339 virtual wxFont
*GetFont(int regionId
= 0) const;
340 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
341 virtual wxString
GetTextColour(int regionId
= 0) const;
342 virtual inline int GetNumberOfTextRegions() const { return m_regions
.Number(); }
343 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
345 // Get the name representing the region for this image alone.
346 // I.e. this image's region ids go from 0 to N-1.
347 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
348 // So the last digit represents the region Id, the others represent positions
350 virtual wxString
GetRegionName(int regionId
);
352 // Gets the region corresponding to the name, or -1 if not found.
353 virtual int GetRegionId(const wxString
& name
);
355 // Construct names for regions, unique even for children of a composite.
356 virtual void NameRegions(const wxString
& parentName
= wxEmptyString
);
358 // Get list of regions
359 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
361 virtual void AddRegion(wxShapeRegion
*region
);
363 virtual void ClearRegions();
365 // Assign new ids to this image and children (if composite)
368 // Returns actual image (same as 'this' if non-composite) and region id
369 // for given region name.
370 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
372 // Finds all region names for this image (composite or simple).
373 // Supply empty string list.
374 virtual void FindRegionNames(wxStringList
& list
);
376 virtual void ClearText(int regionId
= 0);
377 void RemoveLine(wxLineShape
*line
);
381 virtual void WriteAttributes(wxExpr
*clause
);
382 virtual void ReadAttributes(wxExpr
*clause
);
384 // In case the object has constraints it needs to read in in a different pass
385 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
386 virtual void WriteRegions(wxExpr
*clause
);
387 virtual void ReadRegions(wxExpr
*clause
);
391 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
392 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
393 virtual int GetNumberOfAttachments() const;
394 virtual bool AttachmentIsValid(int attachment
) const;
396 // Only get the attachment position at the _edge_ of the shape, ignoring
397 // branching mode. This is used e.g. to indicate the edge of interest, not the point
398 // on the attachment branch.
399 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
400 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
402 // Assuming the attachment lies along a vertical or horizontal line,
403 // calculate the position on that point.
404 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
405 int nth
, int noArcs
, wxLineShape
* line
);
407 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
408 // edge of the shape.
409 // attachmentPoint is the attachment point (= side) in question.
410 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
412 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
413 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
415 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
418 // Reorders the lines coming into the node image at this attachment
419 // position, in the order in which they appear in linesToSort.
420 virtual void SortLines(int attachment
, wxList
& linesToSort
);
422 // Apply an attachment ordering change
423 void ApplyAttachmentOrdering(wxList
& ordering
);
425 // Can override this to prevent or intercept line reordering.
426 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
428 //// New banching attachment code, 24/9/98
434 // shoulder1 ->---------<- shoulder2
436 // <- branching attachment point N-1
438 // This function gets the root point at the given attachment.
439 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
441 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
442 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
443 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
445 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
446 // at this attachment point.
447 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
449 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
450 wxRealPoint
& stemPoint
);
452 // Get the number of lines at this attachment position.
453 virtual int GetAttachmentLineCount(int attachment
) const;
455 // Draw the branches (not the actual arcs though)
456 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
457 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
459 // Branching attachment settings
460 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
461 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
463 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
464 inline int GetBranchStemLength() const { return m_branchStemLength
; }
466 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
467 inline int GetBranchSpacing() const { return m_branchSpacing
; }
469 // Further detail on branching style, e.g. blobs on interconnections
470 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
471 inline long GetBranchStyle() const { return m_branchStyle
; }
473 // Rotate the standard attachment point from physical (0 is always North)
474 // to logical (0 -> 1 if rotated by 90 degrees)
475 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
477 // Rotate the standard attachment point from logical
478 // to physical (0 is always North)
479 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
481 // This is really to distinguish between lines and other images.
482 // For lines, want to pass drag to canvas, since lines tend to prevent
483 // dragging on a canvas (they get in the way.)
484 virtual bool Draggable() const { return TRUE
; }
486 // Returns TRUE if image is a descendant of this image
487 bool HasDescendant(wxShape
*image
);
489 // Creates a copy of this shape.
490 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
492 // Does the copying for this object
493 virtual void Copy(wxShape
& copy
);
495 // Does the copying for this object, including copying event
496 // handler data if any. Calls the virtual Copy function.
497 void CopyWithHandler(wxShape
& copy
);
499 // Rotate about the given axis by the given amount in radians.
500 virtual void Rotate(double x
, double y
, double theta
);
501 virtual inline double GetRotation() const { return m_rotation
; }
503 void ClearAttachments();
505 // Recentres all the text regions for this object
506 void Recentre(wxDC
& dc
);
508 // Clears points from a list of wxRealPoints
509 void ClearPointList(wxList
& list
);
511 // Return pen or brush of the right colour for the background
512 wxPen
GetBackgroundPen();
513 wxBrush
GetBackgroundBrush();
517 wxShapeEvtHandler
* m_eventHandler
;
519 double m_xpos
, m_ypos
;
523 wxColour
* m_textColour
;
524 wxString m_textColourName
;
525 wxShapeCanvas
* m_canvas
;
528 wxList m_controlPoints
;
530 wxList m_attachmentPoints
;
535 bool m_highlighted
; // Different from selected: user-defined highlighting,
536 // e.g. thick border.
540 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
541 // 2 for branching attachments
542 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
545 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
546 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
547 wxList m_children
; // In case it's composite
548 wxShape
* m_parent
; // In case it's a child
551 wxBrush
* m_shadowBrush
;
554 int m_textMarginX
; // Gap between text and border
556 wxString m_regionName
;
557 bool m_maintainAspectRatio
;
558 int m_branchNeckLength
;
559 int m_branchStemLength
;
564 class wxPolygonShape
: public wxShape
566 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
571 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
572 // Deletes user's points in destructor.
573 virtual void Create(wxList
*points
);
574 virtual void ClearPoints();
576 void GetBoundingBoxMin(double *w
, double *h
);
577 void CalculateBoundingBox();
578 bool GetPerimeterPoint(double x1
, double y1
,
579 double x2
, double y2
,
580 double *x3
, double *y3
);
581 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
582 void SetSize(double x
, double y
, bool recursive
= TRUE
);
583 void OnDraw(wxDC
& dc
);
584 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
586 // Control points ('handles') redirect control to the actual shape, to make it easier
587 // to override sizing behaviour.
588 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
589 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
590 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
592 // A polygon should have a control point at each vertex,
593 // with the option of moving the control points individually
594 // to change the shape.
595 void MakeControlPoints();
596 void ResetControlPoints();
598 // If we've changed the shape, must make the original
599 // points match the working points
600 void UpdateOriginalPoints();
602 // Add a control point after the given point
603 virtual void AddPolygonPoint(int pos
= 0);
605 // Delete a control point
606 virtual void DeletePolygonPoint(int pos
= 0);
608 // Recalculates the centre of the polygon
609 virtual void CalculatePolygonCentre();
612 void WriteAttributes(wxExpr
*clause
);
613 void ReadAttributes(wxExpr
*clause
);
616 int GetNumberOfAttachments() const;
617 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
618 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
619 bool AttachmentIsValid(int attachment
);
620 // Does the copying for this object
621 void Copy(wxShape
& copy
);
623 inline wxList
*GetPoints() { return m_points
; }
625 // Rotate about the given axis by the given amount in radians
626 virtual void Rotate(double x
, double y
, double theta
);
630 wxList
* m_originalPoints
;
632 double m_boundHeight
;
633 double m_originalWidth
;
634 double m_originalHeight
;
637 class wxRectangleShape
: public wxShape
639 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
641 wxRectangleShape(double w
= 0.0, double h
= 0.0);
642 void GetBoundingBoxMin(double *w
, double *h
);
643 bool GetPerimeterPoint(double x1
, double y1
,
644 double x2
, double y2
,
645 double *x3
, double *y3
);
646 void OnDraw(wxDC
& dc
);
647 void SetSize(double x
, double y
, bool recursive
= TRUE
);
648 void SetCornerRadius(double rad
); // If > 0, rounded corners
651 void WriteAttributes(wxExpr
*clause
);
652 void ReadAttributes(wxExpr
*clause
);
655 int GetNumberOfAttachments() const;
656 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
657 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
658 // Does the copying for this object
659 void Copy(wxShape
& copy
);
661 inline double GetWidth() const { return m_width
; }
662 inline double GetHeight() const { return m_height
; }
663 inline void SetWidth(double w
) { m_width
= w
; }
664 inline void SetHeight(double h
) { m_height
= h
; }
669 double m_cornerRadius
;
672 class wxTextShape
: public wxRectangleShape
674 DECLARE_DYNAMIC_CLASS(wxTextShape
)
676 wxTextShape(double width
= 0.0, double height
= 0.0);
678 void OnDraw(wxDC
& dc
);
681 void WriteAttributes(wxExpr
*clause
);
684 // Does the copying for this object
685 void Copy(wxShape
& copy
);
688 class wxEllipseShape
: public wxShape
690 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
692 wxEllipseShape(double w
= 0.0, double h
= 0.0);
694 void GetBoundingBoxMin(double *w
, double *h
);
695 bool GetPerimeterPoint(double x1
, double y1
,
696 double x2
, double y2
,
697 double *x3
, double *y3
);
699 void OnDraw(wxDC
& dc
);
700 void SetSize(double x
, double y
, bool recursive
= TRUE
);
703 void WriteAttributes(wxExpr
*clause
);
704 void ReadAttributes(wxExpr
*clause
);
707 int GetNumberOfAttachments() const;
708 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
709 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
711 // Does the copying for this object
712 void Copy(wxShape
& copy
);
714 inline double GetWidth() const { return m_width
; }
715 inline double GetHeight() const { return m_height
; }
717 inline void SetWidth(double w
) { m_width
= w
; }
718 inline void SetHeight(double h
) { m_height
= h
; }
725 class wxCircleShape
: public wxEllipseShape
727 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
729 wxCircleShape(double w
= 0.0);
731 bool GetPerimeterPoint(double x1
, double y1
,
732 double x2
, double y2
,
733 double *x3
, double *y3
);
734 // Does the copying for this object
735 void Copy(wxShape
& copy
);