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 #include <wx/deprecated/setup.h>
21 #define OGL_VERSION 2.0
23 #ifndef DEFAULT_MOUSE_TOLERANCE
24 #define DEFAULT_MOUSE_TOLERANCE 3
36 #define ARROW_MIDDLE 3
39 // Control point types
40 // Rectangle and most other shapes
41 #define CONTROL_POINT_VERTICAL 1
42 #define CONTROL_POINT_HORIZONTAL 2
43 #define CONTROL_POINT_DIAGONAL 3
46 #define CONTROL_POINT_ENDPOINT_TO 4
47 #define CONTROL_POINT_ENDPOINT_FROM 5
48 #define CONTROL_POINT_LINE 6
50 // Types of formatting: can be combined in a bit list
53 #define FORMAT_CENTRE_HORIZ 1
54 // Centre horizontally
55 #define FORMAT_CENTRE_VERT 2
57 #define FORMAT_SIZE_TO_CONTENTS 4
58 // Resize shape to contents
63 #define SHADOW_RIGHT 2
70 #define SHAPE_BASIC wxTYPE_USER + 1
71 #define SHAPE_RECTANGLE wxTYPE_USER + 2
72 #define SHAPE_ELLIPSE wxTYPE_USER + 3
73 #define SHAPE_POLYGON wxTYPE_USER + 4
74 #define SHAPE_CIRCLE wxTYPE_USER + 5
75 #define SHAPE_LINE wxTYPE_USER + 6
76 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
77 #define SHAPE_COMPOSITE wxTYPE_USER + 9
78 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
79 #define SHAPE_DRAWN wxTYPE_USER + 11
80 #define SHAPE_DIVISION wxTYPE_USER + 12
81 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
82 #define SHAPE_BITMAP wxTYPE_USER + 14
83 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
85 #define OBJECT_REGION wxTYPE_USER + 20
87 #define OP_CLICK_LEFT 1
88 #define OP_CLICK_RIGHT 2
89 #define OP_DRAG_LEFT 4
90 #define OP_DRAG_RIGHT 8
92 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
95 #define ATTACHMENT_MODE_NONE 0
96 #define ATTACHMENT_MODE_EDGE 1
97 #define ATTACHMENT_MODE_BRANCHING 2
99 // Sub-modes for branching attachment mode
100 #define BRANCHING_ATTACHMENT_NORMAL 1
101 #define BRANCHING_ATTACHMENT_BLOB 2
103 class wxShapeTextLine
;
106 class wxControlPoint
;
111 class WXDLLEXPORT wxExpr
;
112 class WXDLLEXPORT wxExprDatabase
;
116 #define WXROUND(x) ( (long) (x + 0.5) )
119 // logical function to use when drawing rubberband boxes, etc.
120 #define OGLRBLF wxINVERT
124 class WXDLLIMPEXP_OGL wxShapeEvtHandler
: public wxObject
, public wxClientDataContainer
126 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
129 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
130 virtual ~wxShapeEvtHandler();
132 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
133 inline wxShape
*GetShape() const { return m_handlerShape
; }
135 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
136 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
138 // This is called when the _shape_ is deleted.
139 virtual void OnDelete();
140 virtual void OnDraw(wxDC
& dc
);
141 virtual void OnDrawContents(wxDC
& dc
);
142 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
143 virtual void OnMoveLinks(wxDC
& dc
);
144 virtual void OnErase(wxDC
& dc
);
145 virtual void OnEraseContents(wxDC
& dc
);
146 virtual void OnHighlight(wxDC
& dc
);
147 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
148 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
149 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
150 virtual void OnSize(double x
, double y
);
151 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
152 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
154 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
155 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
156 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
157 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
158 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
159 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
160 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
161 virtual void OnDrawControlPoints(wxDC
& dc
);
162 virtual void OnEraseControlPoints(wxDC
& dc
);
163 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= TRUE
);
165 // Control points ('handles') redirect control to the actual shape, to make it easier
166 // to override sizing behaviour.
167 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
168 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
169 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
171 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
172 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
174 // Can override this to prevent or intercept line reordering.
175 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
177 // Creates a copy of this event handler.
178 wxShapeEvtHandler
*CreateNewCopy();
180 // Does the copy - override for new event handlers which might store
181 // app-specific data.
182 virtual void CopyData(wxShapeEvtHandler
& WXUNUSED(copy
)) {};
185 wxShapeEvtHandler
* m_previousHandler
;
186 wxShape
* m_handlerShape
;
189 class WXDLLIMPEXP_OGL wxShape
: public wxShapeEvtHandler
191 DECLARE_ABSTRACT_CLASS(wxShape
)
195 wxShape(wxShapeCanvas
*can
= NULL
);
197 virtual void GetBoundingBoxMax(double *width
, double *height
);
198 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
199 virtual bool GetPerimeterPoint(double x1
, double y1
,
200 double x2
, double y2
,
201 double *x3
, double *y3
);
202 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
203 void SetCanvas(wxShapeCanvas
*the_canvas
);
204 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
205 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
207 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
208 inline double GetX() const { return m_xpos
; }
209 inline double GetY() const { return m_ypos
; }
210 inline void SetX(double x
) { m_xpos
= x
; }
211 inline void SetY(double y
) { m_ypos
= y
; }
213 inline wxShape
*GetParent() const { return m_parent
; }
214 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
215 wxShape
*GetTopAncestor();
216 inline wxList
& GetChildren() { return m_children
; }
218 virtual void OnDraw(wxDC
& dc
);
219 virtual void OnDrawContents(wxDC
& dc
);
220 virtual void OnMoveLinks(wxDC
& dc
);
221 virtual void Unlink() { };
222 void SetDrawHandles(bool drawH
);
223 inline bool GetDrawHandles() { return m_drawHandles
; }
224 virtual void OnErase(wxDC
& dc
);
225 virtual void OnEraseContents(wxDC
& dc
);
226 virtual void OnHighlight(wxDC
& dc
);
227 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
228 virtual void OnLeftDoubleClick(double WXUNUSED(x
), double WXUNUSED(y
), int WXUNUSED(keys
) = 0, int WXUNUSED(attachment
) = 0) {}
229 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
230 virtual void OnSize(double x
, double y
);
231 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
232 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= TRUE
);
234 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
235 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
236 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
237 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
238 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
239 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
240 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
241 virtual void OnDrawControlPoints(wxDC
& dc
);
242 virtual void OnEraseControlPoints(wxDC
& dc
);
244 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
245 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
247 // Control points ('handles') redirect control to the actual shape, to make it easier
248 // to override sizing behaviour.
249 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
250 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
251 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
253 virtual void MakeControlPoints();
254 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
255 virtual void ResetControlPoints();
257 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
258 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
260 // Mandatory control points, e.g. the divided line moving handles
261 // should appear even if a child of the 'selected' image
262 virtual void MakeMandatoryControlPoints();
263 virtual void ResetMandatoryControlPoints();
265 inline virtual bool Recompute() { return TRUE
; };
266 // Calculate size recursively, if size changes. Size might depend on children.
267 inline virtual void CalculateSize() { };
268 virtual void Select(bool select
= TRUE
, wxDC
* dc
= NULL
);
269 virtual void SetHighlight(bool hi
= TRUE
, bool recurse
= FALSE
);
270 inline virtual bool IsHighlighted() const { return m_highlighted
; };
271 virtual bool Selected() const;
272 virtual bool AncestorSelected() const;
273 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= FALSE
);
274 int GetSensitivityFilter() const { return m_sensitivity
; }
275 void SetDraggable(bool drag
, bool recursive
= FALSE
);
276 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
277 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
278 inline bool GetFixedWidth() const { return m_fixedWidth
; }
279 inline bool GetFixedHeight() const { return m_fixedHeight
; }
280 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
281 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
282 void SetShadowMode(int mode
, bool redraw
= FALSE
);
283 inline int GetShadowMode() const { return m_shadowMode
; }
284 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
285 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
286 inline bool GetCentreResize() const { return m_centreResize
; }
287 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
288 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
289 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
290 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
291 inline bool GetDisableLabel() const { return m_disableLabel
; }
292 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
293 inline int GetAttachmentMode() const { return m_attachmentMode
; }
294 inline void SetId(long i
) { m_id
= i
; }
295 inline long GetId() const { return m_id
; }
297 void SetPen(wxPen
*pen
);
298 void SetBrush(wxBrush
*brush
);
300 virtual void Show(bool show
);
301 virtual bool IsShown() const { return m_visible
; }
302 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= TRUE
);
303 virtual void Erase(wxDC
& dc
);
304 virtual void EraseContents(wxDC
& dc
);
305 virtual void Draw(wxDC
& dc
);
306 virtual void Flash();
307 virtual void MoveLinks(wxDC
& dc
);
308 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
309 virtual void SetSize(double x
, double y
, bool recursive
= TRUE
);
310 virtual void SetAttachmentSize(double x
, double y
);
311 void Attach(wxShapeCanvas
*can
);
314 inline virtual bool Constrain() { return FALSE
; } ;
316 void AddLine(wxLineShape
*line
, wxShape
*other
,
317 int attachFrom
= 0, int attachTo
= 0,
319 int positionFrom
= -1, int positionTo
= -1);
321 // Return the zero-based position in m_lines of line.
322 int GetLinePosition(wxLineShape
* line
);
324 void AddText(const wxString
& string
);
326 inline wxPen
*GetPen() const { return m_pen
; }
327 inline wxBrush
*GetBrush() const { return m_brush
; }
330 * Region-specific functions (defaults to the default region
334 // Set the default, single region size to be consistent
335 // with the object size
336 void SetDefaultRegionSize();
337 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
338 virtual void SetFormatMode(int mode
, int regionId
= 0);
339 virtual int GetFormatMode(int regionId
= 0) const;
340 virtual void SetFont(wxFont
*font
, int regionId
= 0);
341 virtual wxFont
*GetFont(int regionId
= 0) const;
342 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
343 virtual wxString
GetTextColour(int regionId
= 0) const;
344 virtual inline int GetNumberOfTextRegions() const { return m_regions
.GetCount(); }
345 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
347 // Get the name representing the region for this image alone.
348 // I.e. this image's region ids go from 0 to N-1.
349 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
350 // So the last digit represents the region Id, the others represent positions
352 virtual wxString
GetRegionName(int regionId
);
354 // Gets the region corresponding to the name, or -1 if not found.
355 virtual int GetRegionId(const wxString
& name
);
357 // Construct names for regions, unique even for children of a composite.
358 virtual void NameRegions(const wxString
& parentName
= wxEmptyString
);
360 // Get list of regions
361 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
363 virtual void AddRegion(wxShapeRegion
*region
);
365 virtual void ClearRegions();
367 // Assign new ids to this image and children (if composite)
370 // Returns actual image (same as 'this' if non-composite) and region id
371 // for given region name.
372 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
374 // Finds all region names for this image (composite or simple).
375 // Supply empty string list.
376 virtual void FindRegionNames(wxStringList
& list
);
378 virtual void ClearText(int regionId
= 0);
379 void RemoveLine(wxLineShape
*line
);
383 virtual void WriteAttributes(wxExpr
*clause
);
384 virtual void ReadAttributes(wxExpr
*clause
);
386 // In case the object has constraints it needs to read in in a different pass
387 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
388 virtual void WriteRegions(wxExpr
*clause
);
389 virtual void ReadRegions(wxExpr
*clause
);
393 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
394 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
395 virtual int GetNumberOfAttachments() const;
396 virtual bool AttachmentIsValid(int attachment
) const;
398 // Only get the attachment position at the _edge_ of the shape, ignoring
399 // branching mode. This is used e.g. to indicate the edge of interest, not the point
400 // on the attachment branch.
401 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
402 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
404 // Assuming the attachment lies along a vertical or horizontal line,
405 // calculate the position on that point.
406 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
407 int nth
, int noArcs
, wxLineShape
* line
);
409 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
410 // edge of the shape.
411 // attachmentPoint is the attachment point (= side) in question.
412 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
414 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
415 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
417 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
420 // Reorders the lines coming into the node image at this attachment
421 // position, in the order in which they appear in linesToSort.
422 virtual void SortLines(int attachment
, wxList
& linesToSort
);
424 // Apply an attachment ordering change
425 void ApplyAttachmentOrdering(wxList
& ordering
);
427 // Can override this to prevent or intercept line reordering.
428 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
430 //// New banching attachment code, 24/9/98
436 // shoulder1 ->---------<- shoulder2
438 // <- branching attachment point N-1
440 // This function gets the root point at the given attachment.
441 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
443 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
444 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
445 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
447 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
448 // at this attachment point.
449 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
451 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
452 wxRealPoint
& stemPoint
);
454 // Get the number of lines at this attachment position.
455 virtual int GetAttachmentLineCount(int attachment
) const;
457 // Draw the branches (not the actual arcs though)
458 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
459 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
461 // Branching attachment settings
462 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
463 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
465 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
466 inline int GetBranchStemLength() const { return m_branchStemLength
; }
468 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
469 inline int GetBranchSpacing() const { return m_branchSpacing
; }
471 // Further detail on branching style, e.g. blobs on interconnections
472 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
473 inline long GetBranchStyle() const { return m_branchStyle
; }
475 // Rotate the standard attachment point from physical (0 is always North)
476 // to logical (0 -> 1 if rotated by 90 degrees)
477 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
479 // Rotate the standard attachment point from logical
480 // to physical (0 is always North)
481 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
483 // This is really to distinguish between lines and other images.
484 // For lines, want to pass drag to canvas, since lines tend to prevent
485 // dragging on a canvas (they get in the way.)
486 virtual bool Draggable() const { return TRUE
; }
488 // Returns TRUE if image is a descendant of this image
489 bool HasDescendant(wxShape
*image
);
491 // Creates a copy of this shape.
492 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
494 // Does the copying for this object
495 virtual void Copy(wxShape
& copy
);
497 // Does the copying for this object, including copying event
498 // handler data if any. Calls the virtual Copy function.
499 void CopyWithHandler(wxShape
& copy
);
501 // Rotate about the given axis by the given amount in radians.
502 virtual void Rotate(double x
, double y
, double theta
);
503 virtual inline double GetRotation() const { return m_rotation
; }
505 void ClearAttachments();
507 // Recentres all the text regions for this object
508 void Recentre(wxDC
& dc
);
510 // Clears points from a list of wxRealPoints
511 void ClearPointList(wxList
& list
);
513 // Return pen or brush of the right colour for the background
514 wxPen
GetBackgroundPen();
515 wxBrush
GetBackgroundBrush();
519 wxShapeEvtHandler
* m_eventHandler
;
521 double m_xpos
, m_ypos
;
525 wxColour
* m_textColour
;
526 wxString m_textColourName
;
527 wxShapeCanvas
* m_canvas
;
530 wxList m_controlPoints
;
532 wxList m_attachmentPoints
;
537 bool m_highlighted
; // Different from selected: user-defined highlighting,
538 // e.g. thick border.
542 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
543 // 2 for branching attachments
544 bool m_spaceAttachments
; // TRUE if lines at one side should be spaced
547 bool m_centreResize
; // Default is to resize keeping the centre constant (TRUE)
548 bool m_drawHandles
; // Don't draw handles if FALSE, usually TRUE
549 wxList m_children
; // In case it's composite
550 wxShape
* m_parent
; // In case it's a child
553 wxBrush
* m_shadowBrush
;
556 int m_textMarginX
; // Gap between text and border
558 wxString m_regionName
;
559 bool m_maintainAspectRatio
;
560 int m_branchNeckLength
;
561 int m_branchStemLength
;
566 class WXDLLIMPEXP_OGL wxPolygonShape
: public wxShape
568 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
573 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
574 // Deletes user's points in destructor.
575 virtual void Create(wxList
*points
);
576 virtual void ClearPoints();
578 void GetBoundingBoxMin(double *w
, double *h
);
579 void CalculateBoundingBox();
580 bool GetPerimeterPoint(double x1
, double y1
,
581 double x2
, double y2
,
582 double *x3
, double *y3
);
583 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
584 void SetSize(double x
, double y
, bool recursive
= TRUE
);
585 void OnDraw(wxDC
& dc
);
586 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
588 // Control points ('handles') redirect control to the actual shape, to make it easier
589 // to override sizing behaviour.
590 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
591 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
592 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
594 // A polygon should have a control point at each vertex,
595 // with the option of moving the control points individually
596 // to change the shape.
597 void MakeControlPoints();
598 void ResetControlPoints();
600 // If we've changed the shape, must make the original
601 // points match the working points
602 void UpdateOriginalPoints();
604 // Add a control point after the given point
605 virtual void AddPolygonPoint(int pos
= 0);
607 // Delete a control point
608 virtual void DeletePolygonPoint(int pos
= 0);
610 // Recalculates the centre of the polygon
611 virtual void CalculatePolygonCentre();
614 void WriteAttributes(wxExpr
*clause
);
615 void ReadAttributes(wxExpr
*clause
);
618 int GetNumberOfAttachments() const;
619 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
620 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
621 bool AttachmentIsValid(int attachment
) const;
622 // Does the copying for this object
623 void Copy(wxShape
& copy
);
625 inline wxList
*GetPoints() { return m_points
; }
627 // Rotate about the given axis by the given amount in radians
628 virtual void Rotate(double x
, double y
, double theta
);
632 wxList
* m_originalPoints
;
634 double m_boundHeight
;
635 double m_originalWidth
;
636 double m_originalHeight
;
639 class WXDLLIMPEXP_OGL wxRectangleShape
: public wxShape
641 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
643 wxRectangleShape(double w
= 0.0, double h
= 0.0);
644 void GetBoundingBoxMin(double *w
, double *h
);
645 bool GetPerimeterPoint(double x1
, double y1
,
646 double x2
, double y2
,
647 double *x3
, double *y3
);
648 void OnDraw(wxDC
& dc
);
649 void SetSize(double x
, double y
, bool recursive
= TRUE
);
650 void SetCornerRadius(double rad
); // If > 0, rounded corners
653 void WriteAttributes(wxExpr
*clause
);
654 void ReadAttributes(wxExpr
*clause
);
657 int GetNumberOfAttachments() const;
658 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
659 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
660 // Does the copying for this object
661 void Copy(wxShape
& copy
);
663 inline double GetWidth() const { return m_width
; }
664 inline double GetHeight() const { return m_height
; }
665 inline void SetWidth(double w
) { m_width
= w
; }
666 inline void SetHeight(double h
) { m_height
= h
; }
671 double m_cornerRadius
;
674 class WXDLLIMPEXP_OGL wxTextShape
: public wxRectangleShape
676 DECLARE_DYNAMIC_CLASS(wxTextShape
)
678 wxTextShape(double width
= 0.0, double height
= 0.0);
680 void OnDraw(wxDC
& dc
);
683 void WriteAttributes(wxExpr
*clause
);
686 // Does the copying for this object
687 void Copy(wxShape
& copy
);
690 class WXDLLIMPEXP_OGL wxEllipseShape
: public wxShape
692 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
694 wxEllipseShape(double w
= 0.0, double h
= 0.0);
696 void GetBoundingBoxMin(double *w
, double *h
);
697 bool GetPerimeterPoint(double x1
, double y1
,
698 double x2
, double y2
,
699 double *x3
, double *y3
);
701 void OnDraw(wxDC
& dc
);
702 void SetSize(double x
, double y
, bool recursive
= TRUE
);
705 void WriteAttributes(wxExpr
*clause
);
706 void ReadAttributes(wxExpr
*clause
);
709 int GetNumberOfAttachments() const;
710 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
711 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
713 // Does the copying for this object
714 void Copy(wxShape
& copy
);
716 inline double GetWidth() const { return m_width
; }
717 inline double GetHeight() const { return m_height
; }
719 inline void SetWidth(double w
) { m_width
= w
; }
720 inline void SetHeight(double h
) { m_height
= h
; }
727 class WXDLLIMPEXP_OGL wxCircleShape
: public wxEllipseShape
729 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
731 wxCircleShape(double w
= 0.0);
733 bool GetPerimeterPoint(double x1
, double y1
,
734 double x2
, double y2
,
735 double *x3
, double *y3
);
736 // Does the copying for this object
737 void Copy(wxShape
& copy
);