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"
20 #define OGL_VERSION 2.0
22 #ifndef DEFAULT_MOUSE_TOLERANCE
23 #define DEFAULT_MOUSE_TOLERANCE 3
35 #define ARROW_MIDDLE 3
38 // Control point types
39 // Rectangle and most other shapes
40 #define CONTROL_POINT_VERTICAL 1
41 #define CONTROL_POINT_HORIZONTAL 2
42 #define CONTROL_POINT_DIAGONAL 3
45 #define CONTROL_POINT_ENDPOINT_TO 4
46 #define CONTROL_POINT_ENDPOINT_FROM 5
47 #define CONTROL_POINT_LINE 6
49 // Types of formatting: can be combined in a bit list
52 #define FORMAT_CENTRE_HORIZ 1
53 // Centre horizontally
54 #define FORMAT_CENTRE_VERT 2
56 #define FORMAT_SIZE_TO_CONTENTS 4
57 // Resize shape to contents
62 #define SHADOW_RIGHT 2
69 #define SHAPE_BASIC wxTYPE_USER + 1
70 #define SHAPE_RECTANGLE wxTYPE_USER + 2
71 #define SHAPE_ELLIPSE wxTYPE_USER + 3
72 #define SHAPE_POLYGON wxTYPE_USER + 4
73 #define SHAPE_CIRCLE wxTYPE_USER + 5
74 #define SHAPE_LINE wxTYPE_USER + 6
75 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
76 #define SHAPE_COMPOSITE wxTYPE_USER + 9
77 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
78 #define SHAPE_DRAWN wxTYPE_USER + 11
79 #define SHAPE_DIVISION wxTYPE_USER + 12
80 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
81 #define SHAPE_BITMAP wxTYPE_USER + 14
82 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
84 #define OBJECT_REGION wxTYPE_USER + 20
86 #define OP_CLICK_LEFT 1
87 #define OP_CLICK_RIGHT 2
88 #define OP_DRAG_LEFT 4
89 #define OP_DRAG_RIGHT 8
91 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
94 #define ATTACHMENT_MODE_NONE 0
95 #define ATTACHMENT_MODE_EDGE 1
96 #define ATTACHMENT_MODE_BRANCHING 2
98 // Sub-modes for branching attachment mode
99 #define BRANCHING_ATTACHMENT_NORMAL 1
100 #define BRANCHING_ATTACHMENT_BLOB 2
102 class wxShapeTextLine
;
105 class wxControlPoint
;
110 class WXDLLEXPORT wxExpr
;
111 class WXDLLEXPORT wxExprDatabase
;
115 #define WXROUND(x) ( (long) (x + 0.5) )
118 // logical function to use when drawing rubberband boxes, etc.
119 #define OGLRBLF wxINVERT
123 class WXDLLIMPEXP_OGL wxShapeEvtHandler
: public wxObject
, public wxClientDataContainer
125 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
128 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
129 virtual ~wxShapeEvtHandler();
131 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
132 inline wxShape
*GetShape() const { return m_handlerShape
; }
134 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
135 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
137 // This is called when the _shape_ is deleted.
138 virtual void OnDelete();
139 virtual void OnDraw(wxDC
& dc
);
140 virtual void OnDrawContents(wxDC
& dc
);
141 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
142 virtual void OnMoveLinks(wxDC
& dc
);
143 virtual void OnErase(wxDC
& dc
);
144 virtual void OnEraseContents(wxDC
& dc
);
145 virtual void OnHighlight(wxDC
& dc
);
146 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
147 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
148 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
149 virtual void OnSize(double x
, double y
);
150 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
151 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
153 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
154 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
155 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
156 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
157 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
158 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
159 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
160 virtual void OnDrawControlPoints(wxDC
& dc
);
161 virtual void OnEraseControlPoints(wxDC
& dc
);
162 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= TRUE
);
164 // Control points ('handles') redirect control to the actual shape, to make it easier
165 // to override sizing behaviour.
166 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
167 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
168 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
170 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
171 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
173 // Can override this to prevent or intercept line reordering.
174 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
176 // Creates a copy of this event handler.
177 wxShapeEvtHandler
*CreateNewCopy();
179 // Does the copy - override for new event handlers which might store
180 // app-specific data.
181 virtual void CopyData(wxShapeEvtHandler
& WXUNUSED(copy
)) {};
184 wxShapeEvtHandler
* m_previousHandler
;
185 wxShape
* m_handlerShape
;
188 class WXDLLIMPEXP_OGL wxShape
: public wxShapeEvtHandler
190 DECLARE_ABSTRACT_CLASS(wxShape
)
194 wxShape(wxShapeCanvas
*can
= NULL
);
196 virtual void GetBoundingBoxMax(double *width
, double *height
);
197 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
198 virtual bool GetPerimeterPoint(double x1
, double y1
,
199 double x2
, double y2
,
200 double *x3
, double *y3
);
201 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
202 void SetCanvas(wxShapeCanvas
*the_canvas
);
203 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
204 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
206 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
207 inline double GetX() const { return m_xpos
; }
208 inline double GetY() const { return m_ypos
; }
209 inline void SetX(double x
) { m_xpos
= x
; }
210 inline void SetY(double y
) { m_ypos
= y
; }
212 inline wxShape
*GetParent() const { return m_parent
; }
213 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
214 wxShape
*GetTopAncestor();
215 inline wxList
& GetChildren() { return m_children
; }
217 virtual void OnDraw(wxDC
& dc
);
218 virtual void OnDrawContents(wxDC
& dc
);
219 virtual void OnMoveLinks(wxDC
& dc
);
220 virtual void Unlink() { };
221 void SetDrawHandles(bool drawH
);
222 inline bool GetDrawHandles() { return m_drawHandles
; }
223 virtual void OnErase(wxDC
& dc
);
224 virtual void OnEraseContents(wxDC
& dc
);
225 virtual void OnHighlight(wxDC
& dc
);
226 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
227 virtual void OnLeftDoubleClick(double WXUNUSED(x
), double WXUNUSED(y
), int WXUNUSED(keys
) = 0, int WXUNUSED(attachment
) = 0) {}
228 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
229 virtual void OnSize(double x
, double y
);
230 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
231 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
233 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
234 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
235 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
236 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
237 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
238 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
239 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
240 virtual void OnDrawControlPoints(wxDC
& dc
);
241 virtual void OnEraseControlPoints(wxDC
& dc
);
243 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
244 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
246 // Control points ('handles') redirect control to the actual shape, to make it easier
247 // to override sizing behaviour.
248 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
249 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
250 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
252 virtual void MakeControlPoints();
253 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
254 virtual void ResetControlPoints();
256 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
257 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
259 // Mandatory control points, e.g. the divided line moving handles
260 // should appear even if a child of the 'selected' image
261 virtual void MakeMandatoryControlPoints();
262 virtual void ResetMandatoryControlPoints();
264 inline virtual bool Recompute() { return TRUE
; };
265 // Calculate size recursively, if size changes. Size might depend on children.
266 inline virtual void CalculateSize() { };
267 virtual void Select(bool select
= TRUE
, wxDC
* dc
= NULL
);
268 virtual void SetHighlight(bool hi
= TRUE
, bool recurse
= FALSE
);
269 inline virtual bool IsHighlighted() const { return m_highlighted
; };
270 virtual bool Selected() const;
271 virtual bool AncestorSelected() const;
272 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= FALSE
);
273 int GetSensitivityFilter() const { return m_sensitivity
; }
274 void SetDraggable(bool drag
, bool recursive
= FALSE
);
275 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
276 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
277 inline bool GetFixedWidth() const { return m_fixedWidth
; }
278 inline bool GetFixedHeight() const { return m_fixedHeight
; }
279 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
280 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
281 void SetShadowMode(int mode
, bool redraw
= FALSE
);
282 inline int GetShadowMode() const { return m_shadowMode
; }
283 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
284 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
285 inline bool GetCentreResize() const { return m_centreResize
; }
286 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
287 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
288 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
289 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
290 inline bool GetDisableLabel() const { return m_disableLabel
; }
291 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
292 inline int GetAttachmentMode() const { return m_attachmentMode
; }
293 inline void SetId(long i
) { m_id
= i
; }
294 inline long GetId() const { return m_id
; }
296 void SetPen(wxPen
*pen
);
297 void SetBrush(wxBrush
*brush
);
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
.GetCount(); }
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
= wxEmptyString
);
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
);
512 // Return pen or brush of the right colour for the background
513 wxPen
GetBackgroundPen();
514 wxBrush
GetBackgroundBrush();
518 wxShapeEvtHandler
* m_eventHandler
;
520 double m_xpos
, m_ypos
;
524 wxColour
* m_textColour
;
525 wxString m_textColourName
;
526 wxShapeCanvas
* m_canvas
;
529 wxList m_controlPoints
;
531 wxList m_attachmentPoints
;
536 bool m_highlighted
; // Different from selected: user-defined highlighting,
537 // e.g. thick border.
541 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
542 // 2 for branching attachments
543 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
546 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
547 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
548 wxList m_children
; // In case it's composite
549 wxShape
* m_parent
; // In case it's a child
552 wxBrush
* m_shadowBrush
;
555 int m_textMarginX
; // Gap between text and border
557 wxString m_regionName
;
558 bool m_maintainAspectRatio
;
559 int m_branchNeckLength
;
560 int m_branchStemLength
;
565 class WXDLLIMPEXP_OGL wxPolygonShape
: public wxShape
567 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
572 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
573 // Deletes user's points in destructor.
574 virtual void Create(wxList
*points
);
575 virtual void ClearPoints();
577 void GetBoundingBoxMin(double *w
, double *h
);
578 void CalculateBoundingBox();
579 bool GetPerimeterPoint(double x1
, double y1
,
580 double x2
, double y2
,
581 double *x3
, double *y3
);
582 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
583 void SetSize(double x
, double y
, bool recursive
= TRUE
);
584 void OnDraw(wxDC
& dc
);
585 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
587 // Control points ('handles') redirect control to the actual shape, to make it easier
588 // to override sizing behaviour.
589 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
590 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
591 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
593 // A polygon should have a control point at each vertex,
594 // with the option of moving the control points individually
595 // to change the shape.
596 void MakeControlPoints();
597 void ResetControlPoints();
599 // If we've changed the shape, must make the original
600 // points match the working points
601 void UpdateOriginalPoints();
603 // Add a control point after the given point
604 virtual void AddPolygonPoint(int pos
= 0);
606 // Delete a control point
607 virtual void DeletePolygonPoint(int pos
= 0);
609 // Recalculates the centre of the polygon
610 virtual void CalculatePolygonCentre();
613 void WriteAttributes(wxExpr
*clause
);
614 void ReadAttributes(wxExpr
*clause
);
617 int GetNumberOfAttachments() const;
618 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
619 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
620 bool AttachmentIsValid(int attachment
) const;
621 // Does the copying for this object
622 void Copy(wxShape
& copy
);
624 inline wxList
*GetPoints() { return m_points
; }
626 // Rotate about the given axis by the given amount in radians
627 virtual void Rotate(double x
, double y
, double theta
);
631 wxList
* m_originalPoints
;
633 double m_boundHeight
;
634 double m_originalWidth
;
635 double m_originalHeight
;
638 class WXDLLIMPEXP_OGL wxRectangleShape
: public wxShape
640 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
642 wxRectangleShape(double w
= 0.0, double h
= 0.0);
643 void GetBoundingBoxMin(double *w
, double *h
);
644 bool GetPerimeterPoint(double x1
, double y1
,
645 double x2
, double y2
,
646 double *x3
, double *y3
);
647 void OnDraw(wxDC
& dc
);
648 void SetSize(double x
, double y
, bool recursive
= TRUE
);
649 void SetCornerRadius(double rad
); // If > 0, rounded corners
652 void WriteAttributes(wxExpr
*clause
);
653 void ReadAttributes(wxExpr
*clause
);
656 int GetNumberOfAttachments() const;
657 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
658 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
659 // Does the copying for this object
660 void Copy(wxShape
& copy
);
662 inline double GetWidth() const { return m_width
; }
663 inline double GetHeight() const { return m_height
; }
664 inline void SetWidth(double w
) { m_width
= w
; }
665 inline void SetHeight(double h
) { m_height
= h
; }
670 double m_cornerRadius
;
673 class WXDLLIMPEXP_OGL wxTextShape
: public wxRectangleShape
675 DECLARE_DYNAMIC_CLASS(wxTextShape
)
677 wxTextShape(double width
= 0.0, double height
= 0.0);
679 void OnDraw(wxDC
& dc
);
682 void WriteAttributes(wxExpr
*clause
);
685 // Does the copying for this object
686 void Copy(wxShape
& copy
);
689 class WXDLLIMPEXP_OGL wxEllipseShape
: public wxShape
691 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
693 wxEllipseShape(double w
= 0.0, double h
= 0.0);
695 void GetBoundingBoxMin(double *w
, double *h
);
696 bool GetPerimeterPoint(double x1
, double y1
,
697 double x2
, double y2
,
698 double *x3
, double *y3
);
700 void OnDraw(wxDC
& dc
);
701 void SetSize(double x
, double y
, bool recursive
= TRUE
);
704 void WriteAttributes(wxExpr
*clause
);
705 void ReadAttributes(wxExpr
*clause
);
708 int GetNumberOfAttachments() const;
709 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
710 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
712 // Does the copying for this object
713 void Copy(wxShape
& copy
);
715 inline double GetWidth() const { return m_width
; }
716 inline double GetHeight() const { return m_height
; }
718 inline void SetWidth(double w
) { m_width
= w
; }
719 inline void SetHeight(double h
) { m_height
= h
; }
726 class WXDLLIMPEXP_OGL wxCircleShape
: public wxEllipseShape
728 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
730 wxCircleShape(double w
= 0.0);
732 bool GetPerimeterPoint(double x1
, double y1
,
733 double x2
, double y2
,
734 double *x3
, double *y3
);
735 // Does the copying for this object
736 void Copy(wxShape
& copy
);