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 OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
146 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
147 virtual void OnSize(double x
, double y
);
148 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
149 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
151 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
152 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
153 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
154 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
155 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
156 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
157 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
158 virtual void OnDrawControlPoints(wxDC
& dc
);
159 virtual void OnEraseControlPoints(wxDC
& dc
);
160 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= TRUE
);
162 // Control points ('handles') redirect control to the actual shape, to make it easier
163 // to override sizing behaviour.
164 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
165 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
166 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
168 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
169 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
171 // Can override this to prevent or intercept line reordering.
172 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
174 // Creates a copy of this event handler.
175 wxShapeEvtHandler
*CreateNewCopy();
177 // Does the copy - override for new event handlers which might store
178 // app-specific data.
179 virtual void CopyData(wxShapeEvtHandler
& copy
) {};
182 wxShapeEvtHandler
* m_previousHandler
;
183 wxShape
* m_handlerShape
;
186 class wxShape
: public wxShapeEvtHandler
188 DECLARE_ABSTRACT_CLASS(wxShape
)
192 wxShape(wxShapeCanvas
*can
= NULL
);
194 virtual void GetBoundingBoxMax(double *width
, double *height
);
195 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
196 virtual bool GetPerimeterPoint(double x1
, double y1
,
197 double x2
, double y2
,
198 double *x3
, double *y3
);
199 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
200 void SetCanvas(wxShapeCanvas
*the_canvas
);
201 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
202 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
204 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
205 inline double GetX() const { return m_xpos
; }
206 inline double GetY() const { return m_ypos
; }
207 inline void SetX(double x
) { m_xpos
= x
; }
208 inline void SetY(double y
) { m_ypos
= y
; }
210 inline wxShape
*GetParent() const { return m_parent
; }
211 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
212 wxShape
*GetTopAncestor();
213 inline wxList
& GetChildren() { return m_children
; }
215 virtual void OnDraw(wxDC
& dc
);
216 virtual void OnDrawContents(wxDC
& dc
);
217 virtual void OnMoveLinks(wxDC
& dc
);
218 virtual void Unlink() { };
219 void SetDrawHandles(bool drawH
);
220 inline bool GetDrawHandles() { return m_drawHandles
; }
221 virtual void OnErase(wxDC
& dc
);
222 virtual void OnEraseContents(wxDC
& dc
);
223 virtual void OnHighlight(wxDC
& dc
);
224 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
225 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0) {}
226 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
227 virtual void OnSize(double x
, double y
);
228 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
229 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
231 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
232 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
233 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
234 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
235 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
236 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
237 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
238 virtual void OnDrawControlPoints(wxDC
& dc
);
239 virtual void OnEraseControlPoints(wxDC
& dc
);
241 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
242 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
244 // Control points ('handles') redirect control to the actual shape, to make it easier
245 // to override sizing behaviour.
246 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
247 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
248 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
250 virtual void MakeControlPoints();
251 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
252 virtual void ResetControlPoints();
254 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
255 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
257 // Mandatory control points, e.g. the divided line moving handles
258 // should appear even if a child of the 'selected' image
259 virtual void MakeMandatoryControlPoints();
260 virtual void ResetMandatoryControlPoints();
262 inline virtual bool Recompute() { return TRUE
; };
263 // Calculate size recursively, if size changes. Size might depend on children.
264 inline virtual void CalculateSize() { };
265 virtual void Select(bool select
= TRUE
, wxDC
* dc
= NULL
);
266 virtual void SetHighlight(bool hi
= TRUE
, bool recurse
= FALSE
);
267 inline virtual bool IsHighlighted() const { return m_highlighted
; };
268 virtual bool Selected() const;
269 virtual bool AncestorSelected() const;
270 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= FALSE
);
271 int GetSensitivityFilter() const { return m_sensitivity
; }
272 void SetDraggable(bool drag
, bool recursive
= FALSE
);
273 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
274 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
275 inline bool GetFixedWidth() const { return m_fixedWidth
; }
276 inline bool GetFixedHeight() const { return m_fixedHeight
; }
277 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
278 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
279 void SetShadowMode(int mode
, bool redraw
= FALSE
);
280 inline int GetShadowMode() const { return m_shadowMode
; }
281 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
282 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
283 inline bool GetCentreResize() const { return m_centreResize
; }
284 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
285 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
286 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
287 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
288 inline bool GetDisableLabel() const { return m_disableLabel
; }
289 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
290 inline int GetAttachmentMode() const { return m_attachmentMode
; }
291 inline void SetId(long i
) { m_id
= i
; }
292 inline long GetId() const { return m_id
; }
294 void SetPen(wxPen
*pen
);
295 void SetBrush(wxBrush
*brush
);
296 inline void SetClientData(wxObject
*client_data
) { m_clientData
= client_data
; };
297 inline wxObject
*GetClientData() const { return m_clientData
; };
299 virtual void Show(bool show
);
300 virtual bool IsShown() const { return m_visible
; }
301 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= TRUE
);
302 virtual void Erase(wxDC
& dc
);
303 virtual void EraseContents(wxDC
& dc
);
304 virtual void Draw(wxDC
& dc
);
305 virtual void Flash();
306 virtual void MoveLinks(wxDC
& dc
);
307 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
308 virtual void SetSize(double x
, double y
, bool recursive
= TRUE
);
309 virtual void SetAttachmentSize(double x
, double y
);
310 void Attach(wxShapeCanvas
*can
);
313 inline virtual bool Constrain() { return FALSE
; } ;
315 void AddLine(wxLineShape
*line
, wxShape
*other
,
316 int attachFrom
= 0, int attachTo
= 0,
318 int positionFrom
= -1, int positionTo
= -1);
320 // Return the zero-based position in m_lines of line.
321 int GetLinePosition(wxLineShape
* line
);
323 void AddText(const wxString
& string
);
325 inline wxPen
*GetPen() const { return m_pen
; }
326 inline wxBrush
*GetBrush() const { return m_brush
; }
329 * Region-specific functions (defaults to the default region
333 // Set the default, single region size to be consistent
334 // with the object size
335 void SetDefaultRegionSize();
336 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
337 virtual void SetFormatMode(int mode
, int regionId
= 0);
338 virtual int GetFormatMode(int regionId
= 0) const;
339 virtual void SetFont(wxFont
*font
, int regionId
= 0);
340 virtual wxFont
*GetFont(int regionId
= 0) const;
341 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
342 virtual wxString
GetTextColour(int regionId
= 0) const;
343 virtual inline int GetNumberOfTextRegions() const { return m_regions
.Number(); }
344 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
346 // Get the name representing the region for this image alone.
347 // I.e. this image's region ids go from 0 to N-1.
348 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
349 // So the last digit represents the region Id, the others represent positions
351 virtual wxString
GetRegionName(int regionId
);
353 // Gets the region corresponding to the name, or -1 if not found.
354 virtual int GetRegionId(const wxString
& name
);
356 // Construct names for regions, unique even for children of a composite.
357 virtual void NameRegions(const wxString
& parentName
= "");
359 // Get list of regions
360 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
362 virtual void AddRegion(wxShapeRegion
*region
);
364 virtual void ClearRegions();
366 // Assign new ids to this image and children (if composite)
369 // Returns actual image (same as 'this' if non-composite) and region id
370 // for given region name.
371 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
373 // Finds all region names for this image (composite or simple).
374 // Supply empty string list.
375 virtual void FindRegionNames(wxStringList
& list
);
377 virtual void ClearText(int regionId
= 0);
378 void RemoveLine(wxLineShape
*line
);
382 virtual void WriteAttributes(wxExpr
*clause
);
383 virtual void ReadAttributes(wxExpr
*clause
);
385 // In case the object has constraints it needs to read in in a different pass
386 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
387 virtual void WriteRegions(wxExpr
*clause
);
388 virtual void ReadRegions(wxExpr
*clause
);
392 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
393 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
394 virtual int GetNumberOfAttachments() const;
395 virtual bool AttachmentIsValid(int attachment
) const;
397 // Only get the attachment position at the _edge_ of the shape, ignoring
398 // branching mode. This is used e.g. to indicate the edge of interest, not the point
399 // on the attachment branch.
400 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
401 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
403 // Assuming the attachment lies along a vertical or horizontal line,
404 // calculate the position on that point.
405 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
406 int nth
, int noArcs
, wxLineShape
* line
);
408 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
409 // edge of the shape.
410 // attachmentPoint is the attachment point (= side) in question.
411 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
413 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
414 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
416 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
419 // Reorders the lines coming into the node image at this attachment
420 // position, in the order in which they appear in linesToSort.
421 virtual void SortLines(int attachment
, wxList
& linesToSort
);
423 // Apply an attachment ordering change
424 void ApplyAttachmentOrdering(wxList
& ordering
);
426 // Can override this to prevent or intercept line reordering.
427 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
429 //// New banching attachment code, 24/9/98
435 // shoulder1 ->---------<- shoulder2
437 // <- branching attachment point N-1
439 // This function gets the root point at the given attachment.
440 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
442 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
443 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
444 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
446 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
447 // at this attachment point.
448 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
450 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
451 wxRealPoint
& stemPoint
);
453 // Get the number of lines at this attachment position.
454 virtual int GetAttachmentLineCount(int attachment
) const;
456 // Draw the branches (not the actual arcs though)
457 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
458 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
460 // Branching attachment settings
461 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
462 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
464 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
465 inline int GetBranchStemLength() const { return m_branchStemLength
; }
467 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
468 inline int GetBranchSpacing() const { return m_branchSpacing
; }
470 // Further detail on branching style, e.g. blobs on interconnections
471 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
472 inline long GetBranchStyle() const { return m_branchStyle
; }
474 // Rotate the standard attachment point from physical (0 is always North)
475 // to logical (0 -> 1 if rotated by 90 degrees)
476 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
478 // Rotate the standard attachment point from logical
479 // to physical (0 is always North)
480 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
482 // This is really to distinguish between lines and other images.
483 // For lines, want to pass drag to canvas, since lines tend to prevent
484 // dragging on a canvas (they get in the way.)
485 virtual bool Draggable() const { return TRUE
; }
487 // Returns TRUE if image is a descendant of this image
488 bool HasDescendant(wxShape
*image
);
490 // Creates a copy of this shape.
491 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
493 // Does the copying for this object
494 virtual void Copy(wxShape
& copy
);
496 // Does the copying for this object, including copying event
497 // handler data if any. Calls the virtual Copy function.
498 void CopyWithHandler(wxShape
& copy
);
500 // Rotate about the given axis by the given amount in radians.
501 virtual void Rotate(double x
, double y
, double theta
);
502 virtual inline double GetRotation() const { return m_rotation
; }
504 void ClearAttachments();
506 // Recentres all the text regions for this object
507 void Recentre(wxDC
& dc
);
509 // Clears points from a list of wxRealPoints
510 void ClearPointList(wxList
& list
);
513 wxObject
* m_clientData
;
516 wxShapeEvtHandler
* m_eventHandler
;
518 double m_xpos
, m_ypos
;
522 wxColour
* m_textColour
;
523 wxString m_textColourName
;
524 wxShapeCanvas
* m_canvas
;
527 wxList m_controlPoints
;
529 wxList m_attachmentPoints
;
534 bool m_highlighted
; // Different from selected: user-defined highlighting,
535 // e.g. thick border.
539 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
540 // 2 for branching attachments
541 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
544 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
545 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
546 wxList m_children
; // In case it's composite
547 wxShape
* m_parent
; // In case it's a child
550 wxBrush
* m_shadowBrush
;
553 int m_textMarginX
; // Gap between text and border
555 wxString m_regionName
;
556 bool m_maintainAspectRatio
;
557 int m_branchNeckLength
;
558 int m_branchStemLength
;
563 class wxPolygonShape
: public wxShape
565 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
570 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
571 // Deletes user's points in destructor.
572 virtual void Create(wxList
*points
);
573 virtual void ClearPoints();
575 void GetBoundingBoxMin(double *w
, double *h
);
576 void CalculateBoundingBox();
577 bool GetPerimeterPoint(double x1
, double y1
,
578 double x2
, double y2
,
579 double *x3
, double *y3
);
580 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
581 void SetSize(double x
, double y
, bool recursive
= TRUE
);
582 void OnDraw(wxDC
& dc
);
583 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
585 // Control points ('handles') redirect control to the actual shape, to make it easier
586 // to override sizing behaviour.
587 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
588 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
589 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
591 // A polygon should have a control point at each vertex,
592 // with the option of moving the control points individually
593 // to change the shape.
594 void MakeControlPoints();
595 void ResetControlPoints();
597 // If we've changed the shape, must make the original
598 // points match the working points
599 void UpdateOriginalPoints();
601 // Add a control point after the given point
602 virtual void AddPolygonPoint(int pos
= 0);
604 // Delete a control point
605 virtual void DeletePolygonPoint(int pos
= 0);
607 // Recalculates the centre of the polygon
608 virtual void CalculatePolygonCentre();
611 void WriteAttributes(wxExpr
*clause
);
612 void ReadAttributes(wxExpr
*clause
);
615 int GetNumberOfAttachments() const;
616 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
617 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
618 bool AttachmentIsValid(int attachment
);
619 // Does the copying for this object
620 void Copy(wxShape
& copy
);
622 inline wxList
*GetPoints() { return m_points
; }
624 // Rotate about the given axis by the given amount in radians
625 virtual void Rotate(double x
, double y
, double theta
);
629 wxList
* m_originalPoints
;
631 double m_boundHeight
;
632 double m_originalWidth
;
633 double m_originalHeight
;
636 class wxRectangleShape
: public wxShape
638 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
640 wxRectangleShape(double w
= 0.0, double h
= 0.0);
641 void GetBoundingBoxMin(double *w
, double *h
);
642 bool GetPerimeterPoint(double x1
, double y1
,
643 double x2
, double y2
,
644 double *x3
, double *y3
);
645 void OnDraw(wxDC
& dc
);
646 void SetSize(double x
, double y
, bool recursive
= TRUE
);
647 void SetCornerRadius(double rad
); // If > 0, rounded corners
650 void WriteAttributes(wxExpr
*clause
);
651 void ReadAttributes(wxExpr
*clause
);
654 int GetNumberOfAttachments() const;
655 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
656 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
657 // Does the copying for this object
658 void Copy(wxShape
& copy
);
660 inline double GetWidth() const { return m_width
; }
661 inline double GetHeight() const { return m_height
; }
662 inline void SetWidth(double w
) { m_width
= w
; }
663 inline void SetHeight(double h
) { m_height
= h
; }
668 double m_cornerRadius
;
671 class wxTextShape
: public wxRectangleShape
673 DECLARE_DYNAMIC_CLASS(wxTextShape
)
675 wxTextShape(double width
= 0.0, double height
= 0.0);
677 void OnDraw(wxDC
& dc
);
680 void WriteAttributes(wxExpr
*clause
);
683 // Does the copying for this object
684 void Copy(wxShape
& copy
);
687 class wxEllipseShape
: public wxShape
689 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
691 wxEllipseShape(double w
= 0.0, double h
= 0.0);
693 void GetBoundingBoxMin(double *w
, double *h
);
694 bool GetPerimeterPoint(double x1
, double y1
,
695 double x2
, double y2
,
696 double *x3
, double *y3
);
698 void OnDraw(wxDC
& dc
);
699 void SetSize(double x
, double y
, bool recursive
= TRUE
);
702 void WriteAttributes(wxExpr
*clause
);
703 void ReadAttributes(wxExpr
*clause
);
706 int GetNumberOfAttachments() const;
707 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
708 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
710 // Does the copying for this object
711 void Copy(wxShape
& copy
);
713 inline double GetWidth() const { return m_width
; }
714 inline double GetHeight() const { return m_height
; }
716 inline void SetWidth(double w
) { m_width
= w
; }
717 inline void SetHeight(double h
) { m_height
= h
; }
724 class wxCircleShape
: public wxEllipseShape
726 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
728 wxCircleShape(double w
= 0.0);
730 bool GetPerimeterPoint(double x1
, double y1
,
731 double x2
, double y2
,
732 double *x3
, double *y3
);
733 // Does the copying for this object
734 void Copy(wxShape
& copy
);