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) )
122 // logical function to use when drawing rubberband boxes, etc.
123 #define OGLRBLF wxINVERT
127 class wxShapeEvtHandler
: public wxObject
129 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
132 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
133 virtual ~wxShapeEvtHandler();
135 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
136 inline wxShape
*GetShape() const { return m_handlerShape
; }
138 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
139 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
141 // This is called when the _shape_ is deleted.
142 virtual void OnDelete();
143 virtual void OnDraw(wxDC
& dc
);
144 virtual void OnDrawContents(wxDC
& dc
);
145 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
146 virtual void OnMoveLinks(wxDC
& dc
);
147 virtual void OnErase(wxDC
& dc
);
148 virtual void OnEraseContents(wxDC
& dc
);
149 virtual void OnHighlight(wxDC
& dc
);
150 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
151 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
152 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
153 virtual void OnSize(double x
, double y
);
154 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
155 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
157 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
158 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
159 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
160 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
161 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
162 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
163 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
164 virtual void OnDrawControlPoints(wxDC
& dc
);
165 virtual void OnEraseControlPoints(wxDC
& dc
);
166 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= TRUE
);
168 // Control points ('handles') redirect control to the actual shape, to make it easier
169 // to override sizing behaviour.
170 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
171 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
172 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
174 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
175 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
177 // Can override this to prevent or intercept line reordering.
178 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
180 // Creates a copy of this event handler.
181 wxShapeEvtHandler
*CreateNewCopy();
183 // Does the copy - override for new event handlers which might store
184 // app-specific data.
185 virtual void CopyData(wxShapeEvtHandler
& copy
) {};
188 wxShapeEvtHandler
* m_previousHandler
;
189 wxShape
* m_handlerShape
;
192 class wxShape
: public wxShapeEvtHandler
194 DECLARE_ABSTRACT_CLASS(wxShape
)
198 wxShape(wxShapeCanvas
*can
= NULL
);
200 virtual void GetBoundingBoxMax(double *width
, double *height
);
201 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
202 virtual bool GetPerimeterPoint(double x1
, double y1
,
203 double x2
, double y2
,
204 double *x3
, double *y3
);
205 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
206 void SetCanvas(wxShapeCanvas
*the_canvas
);
207 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
208 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
210 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
211 inline double GetX() const { return m_xpos
; }
212 inline double GetY() const { return m_ypos
; }
213 inline void SetX(double x
) { m_xpos
= x
; }
214 inline void SetY(double y
) { m_ypos
= y
; }
216 inline wxShape
*GetParent() const { return m_parent
; }
217 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
218 wxShape
*GetTopAncestor();
219 inline wxList
& GetChildren() { return m_children
; }
221 virtual void OnDraw(wxDC
& dc
);
222 virtual void OnDrawContents(wxDC
& dc
);
223 virtual void OnMoveLinks(wxDC
& dc
);
224 virtual void Unlink() { };
225 void SetDrawHandles(bool drawH
);
226 inline bool GetDrawHandles() { return m_drawHandles
; }
227 virtual void OnErase(wxDC
& dc
);
228 virtual void OnEraseContents(wxDC
& dc
);
229 virtual void OnHighlight(wxDC
& dc
);
230 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
231 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0) {}
232 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
233 virtual void OnSize(double x
, double y
);
234 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
235 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
237 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
238 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
239 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
240 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
241 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
242 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
243 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
244 virtual void OnDrawControlPoints(wxDC
& dc
);
245 virtual void OnEraseControlPoints(wxDC
& dc
);
247 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
248 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
250 // Control points ('handles') redirect control to the actual shape, to make it easier
251 // to override sizing behaviour.
252 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
253 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
254 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
256 virtual void MakeControlPoints();
257 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
258 virtual void ResetControlPoints();
260 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
261 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
263 // Mandatory control points, e.g. the divided line moving handles
264 // should appear even if a child of the 'selected' image
265 virtual void MakeMandatoryControlPoints();
266 virtual void ResetMandatoryControlPoints();
268 inline virtual bool Recompute() { return TRUE
; };
269 // Calculate size recursively, if size changes. Size might depend on children.
270 inline virtual void CalculateSize() { };
271 virtual void Select(bool select
= TRUE
, wxDC
* dc
= NULL
);
272 virtual void SetHighlight(bool hi
= TRUE
, bool recurse
= FALSE
);
273 inline virtual bool IsHighlighted() const { return m_highlighted
; };
274 virtual bool Selected() const;
275 virtual bool AncestorSelected() const;
276 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= FALSE
);
277 int GetSensitivityFilter() const { return m_sensitivity
; }
278 void SetDraggable(bool drag
, bool recursive
= FALSE
);
279 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
280 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
281 inline bool GetFixedWidth() const { return m_fixedWidth
; }
282 inline bool GetFixedHeight() const { return m_fixedHeight
; }
283 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
284 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
285 void SetShadowMode(int mode
, bool redraw
= FALSE
);
286 inline int GetShadowMode() const { return m_shadowMode
; }
287 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
288 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
289 inline bool GetCentreResize() const { return m_centreResize
; }
290 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
291 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
292 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
293 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
294 inline bool GetDisableLabel() const { return m_disableLabel
; }
295 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
296 inline int GetAttachmentMode() const { return m_attachmentMode
; }
297 inline void SetId(long i
) { m_id
= i
; }
298 inline long GetId() const { return m_id
; }
300 void SetPen(wxPen
*pen
);
301 void SetBrush(wxBrush
*brush
);
302 inline void SetClientData(wxObject
*client_data
) { m_clientData
= client_data
; };
303 inline wxObject
*GetClientData() const { return m_clientData
; };
305 virtual void Show(bool show
);
306 virtual bool IsShown() const { return m_visible
; }
307 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= TRUE
);
308 virtual void Erase(wxDC
& dc
);
309 virtual void EraseContents(wxDC
& dc
);
310 virtual void Draw(wxDC
& dc
);
311 virtual void Flash();
312 virtual void MoveLinks(wxDC
& dc
);
313 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
314 virtual void SetSize(double x
, double y
, bool recursive
= TRUE
);
315 virtual void SetAttachmentSize(double x
, double y
);
316 void Attach(wxShapeCanvas
*can
);
319 inline virtual bool Constrain() { return FALSE
; } ;
321 void AddLine(wxLineShape
*line
, wxShape
*other
,
322 int attachFrom
= 0, int attachTo
= 0,
324 int positionFrom
= -1, int positionTo
= -1);
326 // Return the zero-based position in m_lines of line.
327 int GetLinePosition(wxLineShape
* line
);
329 void AddText(const wxString
& string
);
331 inline wxPen
*GetPen() const { return m_pen
; }
332 inline wxBrush
*GetBrush() const { return m_brush
; }
335 * Region-specific functions (defaults to the default region
339 // Set the default, single region size to be consistent
340 // with the object size
341 void SetDefaultRegionSize();
342 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
343 virtual void SetFormatMode(int mode
, int regionId
= 0);
344 virtual int GetFormatMode(int regionId
= 0) const;
345 virtual void SetFont(wxFont
*font
, int regionId
= 0);
346 virtual wxFont
*GetFont(int regionId
= 0) const;
347 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
348 virtual wxString
GetTextColour(int regionId
= 0) const;
349 virtual inline int GetNumberOfTextRegions() const { return m_regions
.Number(); }
350 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
352 // Get the name representing the region for this image alone.
353 // I.e. this image's region ids go from 0 to N-1.
354 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
355 // So the last digit represents the region Id, the others represent positions
357 virtual wxString
GetRegionName(int regionId
);
359 // Gets the region corresponding to the name, or -1 if not found.
360 virtual int GetRegionId(const wxString
& name
);
362 // Construct names for regions, unique even for children of a composite.
363 virtual void NameRegions(const wxString
& parentName
= "");
365 // Get list of regions
366 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
368 virtual void AddRegion(wxShapeRegion
*region
);
370 virtual void ClearRegions();
372 // Assign new ids to this image and children (if composite)
375 // Returns actual image (same as 'this' if non-composite) and region id
376 // for given region name.
377 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
379 // Finds all region names for this image (composite or simple).
380 // Supply empty string list.
381 virtual void FindRegionNames(wxStringList
& list
);
383 virtual void ClearText(int regionId
= 0);
384 void RemoveLine(wxLineShape
*line
);
388 virtual void WriteAttributes(wxExpr
*clause
);
389 virtual void ReadAttributes(wxExpr
*clause
);
391 // In case the object has constraints it needs to read in in a different pass
392 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
393 virtual void WriteRegions(wxExpr
*clause
);
394 virtual void ReadRegions(wxExpr
*clause
);
398 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
399 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
400 virtual int GetNumberOfAttachments() const;
401 virtual bool AttachmentIsValid(int attachment
) const;
403 // Only get the attachment position at the _edge_ of the shape, ignoring
404 // branching mode. This is used e.g. to indicate the edge of interest, not the point
405 // on the attachment branch.
406 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
407 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
409 // Assuming the attachment lies along a vertical or horizontal line,
410 // calculate the position on that point.
411 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
412 int nth
, int noArcs
, wxLineShape
* line
);
414 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
415 // edge of the shape.
416 // attachmentPoint is the attachment point (= side) in question.
417 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
419 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
420 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
422 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
425 // Reorders the lines coming into the node image at this attachment
426 // position, in the order in which they appear in linesToSort.
427 virtual void SortLines(int attachment
, wxList
& linesToSort
);
429 // Apply an attachment ordering change
430 void ApplyAttachmentOrdering(wxList
& ordering
);
432 // Can override this to prevent or intercept line reordering.
433 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
435 //// New banching attachment code, 24/9/98
441 // shoulder1 ->---------<- shoulder2
443 // <- branching attachment point N-1
445 // This function gets the root point at the given attachment.
446 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
448 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
449 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
450 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
452 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
453 // at this attachment point.
454 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
456 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
457 wxRealPoint
& stemPoint
);
459 // Get the number of lines at this attachment position.
460 virtual int GetAttachmentLineCount(int attachment
) const;
462 // Draw the branches (not the actual arcs though)
463 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
464 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
466 // Branching attachment settings
467 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
468 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
470 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
471 inline int GetBranchStemLength() const { return m_branchStemLength
; }
473 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
474 inline int GetBranchSpacing() const { return m_branchSpacing
; }
476 // Further detail on branching style, e.g. blobs on interconnections
477 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
478 inline long GetBranchStyle() const { return m_branchStyle
; }
480 // Rotate the standard attachment point from physical (0 is always North)
481 // to logical (0 -> 1 if rotated by 90 degrees)
482 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
484 // Rotate the standard attachment point from logical
485 // to physical (0 is always North)
486 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
488 // This is really to distinguish between lines and other images.
489 // For lines, want to pass drag to canvas, since lines tend to prevent
490 // dragging on a canvas (they get in the way.)
491 virtual bool Draggable() const { return TRUE
; }
493 // Returns TRUE if image is a descendant of this image
494 bool HasDescendant(wxShape
*image
);
496 // Creates a copy of this shape.
497 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
499 // Does the copying for this object
500 virtual void Copy(wxShape
& copy
);
502 // Does the copying for this object, including copying event
503 // handler data if any. Calls the virtual Copy function.
504 void CopyWithHandler(wxShape
& copy
);
506 // Rotate about the given axis by the given amount in radians.
507 virtual void Rotate(double x
, double y
, double theta
);
508 virtual inline double GetRotation() const { return m_rotation
; }
510 void ClearAttachments();
512 // Recentres all the text regions for this object
513 void Recentre(wxDC
& dc
);
515 // Clears points from a list of wxRealPoints
516 void ClearPointList(wxList
& list
);
519 wxObject
* m_clientData
;
522 wxShapeEvtHandler
* m_eventHandler
;
524 double m_xpos
, m_ypos
;
528 wxColour
* m_textColour
;
529 wxString m_textColourName
;
530 wxShapeCanvas
* m_canvas
;
533 wxList m_controlPoints
;
535 wxList m_attachmentPoints
;
540 bool m_highlighted
; // Different from selected: user-defined highlighting,
541 // e.g. thick border.
545 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
546 // 2 for branching attachments
547 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
550 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
551 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
552 wxList m_children
; // In case it's composite
553 wxShape
* m_parent
; // In case it's a child
556 wxBrush
* m_shadowBrush
;
559 int m_textMarginX
; // Gap between text and border
561 wxString m_regionName
;
562 bool m_maintainAspectRatio
;
563 int m_branchNeckLength
;
564 int m_branchStemLength
;
569 class wxPolygonShape
: public wxShape
571 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
576 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
577 // Deletes user's points in destructor.
578 virtual void Create(wxList
*points
);
579 virtual void ClearPoints();
581 void GetBoundingBoxMin(double *w
, double *h
);
582 void CalculateBoundingBox();
583 bool GetPerimeterPoint(double x1
, double y1
,
584 double x2
, double y2
,
585 double *x3
, double *y3
);
586 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
587 void SetSize(double x
, double y
, bool recursive
= TRUE
);
588 void OnDraw(wxDC
& dc
);
589 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
591 // Control points ('handles') redirect control to the actual shape, to make it easier
592 // to override sizing behaviour.
593 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
594 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
595 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
597 // A polygon should have a control point at each vertex,
598 // with the option of moving the control points individually
599 // to change the shape.
600 void MakeControlPoints();
601 void ResetControlPoints();
603 // If we've changed the shape, must make the original
604 // points match the working points
605 void UpdateOriginalPoints();
607 // Add a control point after the given point
608 virtual void AddPolygonPoint(int pos
= 0);
610 // Delete a control point
611 virtual void DeletePolygonPoint(int pos
= 0);
613 // Recalculates the centre of the polygon
614 virtual void CalculatePolygonCentre();
617 void WriteAttributes(wxExpr
*clause
);
618 void ReadAttributes(wxExpr
*clause
);
621 int GetNumberOfAttachments() const;
622 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
623 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
624 bool AttachmentIsValid(int attachment
);
625 // Does the copying for this object
626 void Copy(wxShape
& copy
);
628 inline wxList
*GetPoints() { return m_points
; }
630 // Rotate about the given axis by the given amount in radians
631 virtual void Rotate(double x
, double y
, double theta
);
635 wxList
* m_originalPoints
;
637 double m_boundHeight
;
638 double m_originalWidth
;
639 double m_originalHeight
;
642 class wxRectangleShape
: public wxShape
644 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
646 wxRectangleShape(double w
= 0.0, double h
= 0.0);
647 void GetBoundingBoxMin(double *w
, double *h
);
648 bool GetPerimeterPoint(double x1
, double y1
,
649 double x2
, double y2
,
650 double *x3
, double *y3
);
651 void OnDraw(wxDC
& dc
);
652 void SetSize(double x
, double y
, bool recursive
= TRUE
);
653 void SetCornerRadius(double rad
); // If > 0, rounded corners
656 void WriteAttributes(wxExpr
*clause
);
657 void ReadAttributes(wxExpr
*clause
);
660 int GetNumberOfAttachments() const;
661 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
662 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
663 // Does the copying for this object
664 void Copy(wxShape
& copy
);
666 inline double GetWidth() const { return m_width
; }
667 inline double GetHeight() const { return m_height
; }
668 inline void SetWidth(double w
) { m_width
= w
; }
669 inline void SetHeight(double h
) { m_height
= h
; }
674 double m_cornerRadius
;
677 class wxTextShape
: public wxRectangleShape
679 DECLARE_DYNAMIC_CLASS(wxTextShape
)
681 wxTextShape(double width
= 0.0, double height
= 0.0);
683 void OnDraw(wxDC
& dc
);
686 void WriteAttributes(wxExpr
*clause
);
689 // Does the copying for this object
690 void Copy(wxShape
& copy
);
693 class wxEllipseShape
: public wxShape
695 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
697 wxEllipseShape(double w
= 0.0, double h
= 0.0);
699 void GetBoundingBoxMin(double *w
, double *h
);
700 bool GetPerimeterPoint(double x1
, double y1
,
701 double x2
, double y2
,
702 double *x3
, double *y3
);
704 void OnDraw(wxDC
& dc
);
705 void SetSize(double x
, double y
, bool recursive
= TRUE
);
708 void WriteAttributes(wxExpr
*clause
);
709 void ReadAttributes(wxExpr
*clause
);
712 int GetNumberOfAttachments() const;
713 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
714 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
716 // Does the copying for this object
717 void Copy(wxShape
& copy
);
719 inline double GetWidth() const { return m_width
; }
720 inline double GetHeight() const { return m_height
; }
722 inline void SetWidth(double w
) { m_width
= w
; }
723 inline void SetHeight(double h
) { m_height
= h
; }
730 class wxCircleShape
: public wxEllipseShape
732 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
734 wxCircleShape(double w
= 0.0);
736 bool GetPerimeterPoint(double x1
, double y1
,
737 double x2
, double y2
,
738 double *x3
, double *y3
);
739 // Does the copying for this object
740 void Copy(wxShape
& copy
);