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 #ifndef wxUSE_DEPRECATED
20 #define wxUSE_DEPRECATED 0
24 #include <wx/deprecated/setup.h>
27 #ifndef wxUSE_PROLOGIO
28 #define wxUSE_PROLOGIO 0
31 #define OGL_VERSION 2.0
33 #ifndef DEFAULT_MOUSE_TOLERANCE
34 #define DEFAULT_MOUSE_TOLERANCE 3
46 #define ARROW_MIDDLE 3
49 // Control point types
50 // Rectangle and most other shapes
51 #define CONTROL_POINT_VERTICAL 1
52 #define CONTROL_POINT_HORIZONTAL 2
53 #define CONTROL_POINT_DIAGONAL 3
56 #define CONTROL_POINT_ENDPOINT_TO 4
57 #define CONTROL_POINT_ENDPOINT_FROM 5
58 #define CONTROL_POINT_LINE 6
60 // Types of formatting: can be combined in a bit list
63 #define FORMAT_CENTRE_HORIZ 1
64 // Centre horizontally
65 #define FORMAT_CENTRE_VERT 2
67 #define FORMAT_SIZE_TO_CONTENTS 4
68 // Resize shape to contents
73 #define SHADOW_RIGHT 2
80 #define SHAPE_BASIC wxTYPE_USER + 1
81 #define SHAPE_RECTANGLE wxTYPE_USER + 2
82 #define SHAPE_ELLIPSE wxTYPE_USER + 3
83 #define SHAPE_POLYGON wxTYPE_USER + 4
84 #define SHAPE_CIRCLE wxTYPE_USER + 5
85 #define SHAPE_LINE wxTYPE_USER + 6
86 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
87 #define SHAPE_COMPOSITE wxTYPE_USER + 9
88 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
89 #define SHAPE_DRAWN wxTYPE_USER + 11
90 #define SHAPE_DIVISION wxTYPE_USER + 12
91 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
92 #define SHAPE_BITMAP wxTYPE_USER + 14
93 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
95 #define OBJECT_REGION wxTYPE_USER + 20
97 #define OP_CLICK_LEFT 1
98 #define OP_CLICK_RIGHT 2
99 #define OP_DRAG_LEFT 4
100 #define OP_DRAG_RIGHT 8
102 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
105 #define ATTACHMENT_MODE_NONE 0
106 #define ATTACHMENT_MODE_EDGE 1
107 #define ATTACHMENT_MODE_BRANCHING 2
109 // Sub-modes for branching attachment mode
110 #define BRANCHING_ATTACHMENT_NORMAL 1
111 #define BRANCHING_ATTACHMENT_BLOB 2
113 class wxShapeTextLine
;
116 class wxControlPoint
;
121 class WXDLLEXPORT wxExpr
;
122 class WXDLLEXPORT wxExprDatabase
;
126 #define WXROUND(x) ( (long) (x + 0.5) )
129 // logical function to use when drawing rubberband boxes, etc.
130 #define OGLRBLF wxINVERT
134 class WXDLLIMPEXP_OGL wxShapeEvtHandler
: public wxObject
, public wxClientDataContainer
136 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler
)
139 wxShapeEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
);
140 virtual ~wxShapeEvtHandler();
142 inline void SetShape(wxShape
*sh
) { m_handlerShape
= sh
; }
143 inline wxShape
*GetShape() const { return m_handlerShape
; }
145 inline void SetPreviousHandler(wxShapeEvtHandler
* handler
) { m_previousHandler
= handler
; }
146 inline wxShapeEvtHandler
* GetPreviousHandler() const { return m_previousHandler
; }
148 // This is called when the _shape_ is deleted.
149 virtual void OnDelete();
150 virtual void OnDraw(wxDC
& dc
);
151 virtual void OnDrawContents(wxDC
& dc
);
152 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= false);
153 virtual void OnMoveLinks(wxDC
& dc
);
154 virtual void OnErase(wxDC
& dc
);
155 virtual void OnEraseContents(wxDC
& dc
);
156 virtual void OnHighlight(wxDC
& dc
);
157 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
158 virtual void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
159 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
160 virtual void OnSize(double x
, double y
);
161 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
162 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
164 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
165 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
166 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
167 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
168 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
169 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
170 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
171 virtual void OnDrawControlPoints(wxDC
& dc
);
172 virtual void OnEraseControlPoints(wxDC
& dc
);
173 virtual void OnMoveLink(wxDC
& dc
, bool moveControlPoints
= true);
175 // Control points ('handles') redirect control to the actual shape, to make it easier
176 // to override sizing behaviour.
177 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
178 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
179 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
181 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
182 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
184 // Can override this to prevent or intercept line reordering.
185 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
187 // Creates a copy of this event handler.
188 wxShapeEvtHandler
*CreateNewCopy();
190 // Does the copy - override for new event handlers which might store
191 // app-specific data.
192 virtual void CopyData(wxShapeEvtHandler
& WXUNUSED(copy
)) {};
195 wxShapeEvtHandler
* m_previousHandler
;
196 wxShape
* m_handlerShape
;
199 class WXDLLIMPEXP_OGL wxShape
: public wxShapeEvtHandler
201 DECLARE_ABSTRACT_CLASS(wxShape
)
205 wxShape(wxShapeCanvas
*can
= NULL
);
207 virtual void GetBoundingBoxMax(double *width
, double *height
);
208 virtual void GetBoundingBoxMin(double *width
, double *height
) = 0;
209 virtual bool GetPerimeterPoint(double x1
, double y1
,
210 double x2
, double y2
,
211 double *x3
, double *y3
);
212 inline wxShapeCanvas
*GetCanvas() { return m_canvas
; }
213 void SetCanvas(wxShapeCanvas
*the_canvas
);
214 virtual void AddToCanvas(wxShapeCanvas
*the_canvas
, wxShape
*addAfter
= NULL
);
215 virtual void InsertInCanvas(wxShapeCanvas
*the_canvas
);
217 virtual void RemoveFromCanvas(wxShapeCanvas
*the_canvas
);
218 inline double GetX() const { return m_xpos
; }
219 inline double GetY() const { return m_ypos
; }
220 inline void SetX(double x
) { m_xpos
= x
; }
221 inline void SetY(double y
) { m_ypos
= y
; }
223 inline wxShape
*GetParent() const { return m_parent
; }
224 inline void SetParent(wxShape
*p
) { m_parent
= p
; }
225 wxShape
*GetTopAncestor();
226 inline wxList
& GetChildren() { return m_children
; }
228 virtual void OnDraw(wxDC
& dc
);
229 virtual void OnDrawContents(wxDC
& dc
);
230 virtual void OnMoveLinks(wxDC
& dc
);
231 virtual void Unlink() { };
232 void SetDrawHandles(bool drawH
);
233 inline bool GetDrawHandles() { return m_drawHandles
; }
234 virtual void OnErase(wxDC
& dc
);
235 virtual void OnEraseContents(wxDC
& dc
);
236 virtual void OnHighlight(wxDC
& dc
);
237 virtual void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
238 virtual void OnLeftDoubleClick(double WXUNUSED(x
), double WXUNUSED(y
), int WXUNUSED(keys
) = 0, int WXUNUSED(attachment
) = 0) {}
239 virtual void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
240 virtual void OnSize(double x
, double y
);
241 virtual bool OnMovePre(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
242 virtual void OnMovePost(wxDC
& dc
, double x
, double y
, double old_x
, double old_y
, bool display
= true);
244 virtual void OnDragLeft(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
245 virtual void OnBeginDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
246 virtual void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
247 virtual void OnDragRight(bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
248 virtual void OnBeginDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
249 virtual void OnEndDragRight(double x
, double y
, int keys
=0, int attachment
= 0);
250 virtual void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
251 virtual void OnDrawControlPoints(wxDC
& dc
);
252 virtual void OnEraseControlPoints(wxDC
& dc
);
254 virtual void OnBeginSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
255 virtual void OnEndSize(double WXUNUSED(w
), double WXUNUSED(h
)) { }
257 // Control points ('handles') redirect control to the actual shape, to make it easier
258 // to override sizing behaviour.
259 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0); // Erase if draw false
260 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
261 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
263 virtual void MakeControlPoints();
264 virtual void DeleteControlPoints(wxDC
*dc
= NULL
);
265 virtual void ResetControlPoints();
267 inline wxShapeEvtHandler
*GetEventHandler() { return m_eventHandler
; }
268 inline void SetEventHandler(wxShapeEvtHandler
*handler
) { m_eventHandler
= handler
; }
270 // Mandatory control points, e.g. the divided line moving handles
271 // should appear even if a child of the 'selected' image
272 virtual void MakeMandatoryControlPoints();
273 virtual void ResetMandatoryControlPoints();
275 inline virtual bool Recompute() { return true; };
276 // Calculate size recursively, if size changes. Size might depend on children.
277 inline virtual void CalculateSize() { };
278 virtual void Select(bool select
= true, wxDC
* dc
= NULL
);
279 virtual void SetHighlight(bool hi
= true, bool recurse
= false);
280 inline virtual bool IsHighlighted() const { return m_highlighted
; };
281 virtual bool Selected() const;
282 virtual bool AncestorSelected() const;
283 void SetSensitivityFilter(int sens
= OP_ALL
, bool recursive
= false);
284 int GetSensitivityFilter() const { return m_sensitivity
; }
285 void SetDraggable(bool drag
, bool recursive
= false);
286 inline void SetFixedSize(bool x
, bool y
) { m_fixedWidth
= x
; m_fixedHeight
= y
; };
287 inline void GetFixedSize(bool *x
, bool *y
) const { *x
= m_fixedWidth
; *y
= m_fixedHeight
; };
288 inline bool GetFixedWidth() const { return m_fixedWidth
; }
289 inline bool GetFixedHeight() const { return m_fixedHeight
; }
290 inline void SetSpaceAttachments(bool sp
) { m_spaceAttachments
= sp
; };
291 inline bool GetSpaceAttachments() const { return m_spaceAttachments
; };
292 void SetShadowMode(int mode
, bool redraw
= false);
293 inline int GetShadowMode() const { return m_shadowMode
; }
294 virtual bool HitTest(double x
, double y
, int *attachment
, double *distance
);
295 inline void SetCentreResize(bool cr
) { m_centreResize
= cr
; }
296 inline bool GetCentreResize() const { return m_centreResize
; }
297 inline void SetMaintainAspectRatio(bool ar
) { m_maintainAspectRatio
= ar
; }
298 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio
; }
299 inline wxList
& GetLines() const { return (wxList
&) m_lines
; }
300 inline void SetDisableLabel(bool flag
) { m_disableLabel
= flag
; }
301 inline bool GetDisableLabel() const { return m_disableLabel
; }
302 inline void SetAttachmentMode(int mode
) { m_attachmentMode
= mode
; }
303 inline int GetAttachmentMode() const { return m_attachmentMode
; }
304 inline void SetId(long i
) { m_id
= i
; }
305 inline long GetId() const { return m_id
; }
307 void SetPen(wxPen
*pen
);
308 void SetBrush(wxBrush
*brush
);
310 virtual void Show(bool show
);
311 virtual bool IsShown() const { return m_visible
; }
312 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= true);
313 virtual void Erase(wxDC
& dc
);
314 virtual void EraseContents(wxDC
& dc
);
315 virtual void Draw(wxDC
& dc
);
316 virtual void Flash();
317 virtual void MoveLinks(wxDC
& dc
);
318 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
319 virtual void SetSize(double x
, double y
, bool recursive
= true);
320 virtual void SetAttachmentSize(double x
, double y
);
321 void Attach(wxShapeCanvas
*can
);
324 inline virtual bool Constrain() { return false; } ;
326 void AddLine(wxLineShape
*line
, wxShape
*other
,
327 int attachFrom
= 0, int attachTo
= 0,
329 int positionFrom
= -1, int positionTo
= -1);
331 // Return the zero-based position in m_lines of line.
332 int GetLinePosition(wxLineShape
* line
);
334 void AddText(const wxString
& string
);
336 inline wxPen
*GetPen() const { return m_pen
; }
337 inline wxBrush
*GetBrush() const { return m_brush
; }
340 * Region-specific functions (defaults to the default region
344 // Set the default, single region size to be consistent
345 // with the object size
346 void SetDefaultRegionSize();
347 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
348 virtual void SetFormatMode(int mode
, int regionId
= 0);
349 virtual int GetFormatMode(int regionId
= 0) const;
350 virtual void SetFont(wxFont
*font
, int regionId
= 0);
351 virtual wxFont
*GetFont(int regionId
= 0) const;
352 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
353 virtual wxString
GetTextColour(int regionId
= 0) const;
354 virtual inline int GetNumberOfTextRegions() const { return m_regions
.GetCount(); }
355 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
357 // Get the name representing the region for this image alone.
358 // I.e. this image's region ids go from 0 to N-1.
359 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
360 // So the last digit represents the region Id, the others represent positions
362 virtual wxString
GetRegionName(int regionId
);
364 // Gets the region corresponding to the name, or -1 if not found.
365 virtual int GetRegionId(const wxString
& name
);
367 // Construct names for regions, unique even for children of a composite.
368 virtual void NameRegions(const wxString
& parentName
= wxEmptyString
);
370 // Get list of regions
371 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
373 virtual void AddRegion(wxShapeRegion
*region
);
375 virtual void ClearRegions();
377 // Assign new ids to this image and children (if composite)
380 // Returns actual image (same as 'this' if non-composite) and region id
381 // for given region name.
382 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
384 // Finds all region names for this image (composite or simple).
385 // Supply empty string list.
386 virtual void FindRegionNames(wxStringList
& list
);
388 virtual void ClearText(int regionId
= 0);
389 void RemoveLine(wxLineShape
*line
);
393 virtual void WriteAttributes(wxExpr
*clause
);
394 virtual void ReadAttributes(wxExpr
*clause
);
396 // In case the object has constraints it needs to read in in a different pass
397 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
398 virtual void WriteRegions(wxExpr
*clause
);
399 virtual void ReadRegions(wxExpr
*clause
);
403 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
404 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
405 virtual int GetNumberOfAttachments() const;
406 virtual bool AttachmentIsValid(int attachment
) const;
407 virtual wxList
& GetAttachments() { return m_attachmentPoints
; }
409 // Only get the attachment position at the _edge_ of the shape, ignoring
410 // branching mode. This is used e.g. to indicate the edge of interest, not the point
411 // on the attachment branch.
412 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
413 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
415 // Assuming the attachment lies along a vertical or horizontal line,
416 // calculate the position on that point.
417 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
418 int nth
, int noArcs
, wxLineShape
* line
);
420 // Returns true if pt1 <= pt2 in the sense that one point comes before another on an
421 // edge of the shape.
422 // attachmentPoint is the attachment point (= side) in question.
423 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
425 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= false);
426 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= false);
428 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
431 // Reorders the lines coming into the node image at this attachment
432 // position, in the order in which they appear in linesToSort.
433 virtual void SortLines(int attachment
, wxList
& linesToSort
);
435 // Apply an attachment ordering change
436 void ApplyAttachmentOrdering(wxList
& ordering
);
438 // Can override this to prevent or intercept line reordering.
439 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
441 //// New banching attachment code, 24/9/98
447 // shoulder1 ->---------<- shoulder2
449 // <- branching attachment point N-1
451 // This function gets the root point at the given attachment.
452 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
454 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
455 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
456 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
458 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
459 // at this attachment point.
460 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
462 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
463 wxRealPoint
& stemPoint
);
465 // Get the number of lines at this attachment position.
466 virtual int GetAttachmentLineCount(int attachment
) const;
468 // Draw the branches (not the actual arcs though)
469 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= false);
470 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= false);
472 // Branching attachment settings
473 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
474 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
476 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
477 inline int GetBranchStemLength() const { return m_branchStemLength
; }
479 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
480 inline int GetBranchSpacing() const { return m_branchSpacing
; }
482 // Further detail on branching style, e.g. blobs on interconnections
483 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
484 inline long GetBranchStyle() const { return m_branchStyle
; }
486 // Rotate the standard attachment point from physical (0 is always North)
487 // to logical (0 -> 1 if rotated by 90 degrees)
488 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
490 // Rotate the standard attachment point from logical
491 // to physical (0 is always North)
492 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
494 // This is really to distinguish between lines and other images.
495 // For lines, want to pass drag to canvas, since lines tend to prevent
496 // dragging on a canvas (they get in the way.)
497 virtual bool Draggable() const { return true; }
499 // Returns true if image is a descendant of this image
500 bool HasDescendant(wxShape
*image
);
502 // Creates a copy of this shape.
503 wxShape
*CreateNewCopy(bool resetMapping
= true, bool recompute
= true);
505 // Does the copying for this object
506 virtual void Copy(wxShape
& copy
);
508 // Does the copying for this object, including copying event
509 // handler data if any. Calls the virtual Copy function.
510 void CopyWithHandler(wxShape
& copy
);
512 // Rotate about the given axis by the given amount in radians.
513 virtual void Rotate(double x
, double y
, double theta
);
514 virtual double GetRotation() const { return m_rotation
; }
515 virtual void SetRotation(double rotation
) { m_rotation
= rotation
; }
517 void ClearAttachments();
519 // Recentres all the text regions for this object
520 void Recentre(wxDC
& dc
);
522 // Clears points from a list of wxRealPoints
523 void ClearPointList(wxList
& list
);
525 // Return pen or brush of the right colour for the background
526 wxPen
GetBackgroundPen();
527 wxBrush
GetBackgroundBrush();
531 wxShapeEvtHandler
* m_eventHandler
;
533 double m_xpos
, m_ypos
;
537 wxColour m_textColour
;
538 wxString m_textColourName
;
539 wxShapeCanvas
* m_canvas
;
542 wxList m_controlPoints
;
544 wxList m_attachmentPoints
;
549 bool m_highlighted
; // Different from selected: user-defined highlighting,
550 // e.g. thick border.
554 int m_attachmentMode
; // 0 for no attachments, 1 if using normal attachments,
555 // 2 for branching attachments
556 bool m_spaceAttachments
; // true if lines at one side should be spaced
559 bool m_centreResize
; // Default is to resize keeping the centre constant (true)
560 bool m_drawHandles
; // Don't draw handles if false, usually true
561 wxList m_children
; // In case it's composite
562 wxShape
* m_parent
; // In case it's a child
565 wxBrush
* m_shadowBrush
;
568 int m_textMarginX
; // Gap between text and border
570 wxString m_regionName
;
571 bool m_maintainAspectRatio
;
572 int m_branchNeckLength
;
573 int m_branchStemLength
;
578 class WXDLLIMPEXP_OGL wxPolygonShape
: public wxShape
580 DECLARE_DYNAMIC_CLASS(wxPolygonShape
)
585 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
586 // Deletes user's points in destructor.
587 virtual void Create(wxList
*points
);
588 virtual void ClearPoints();
590 void GetBoundingBoxMin(double *w
, double *h
);
591 void CalculateBoundingBox();
592 bool GetPerimeterPoint(double x1
, double y1
,
593 double x2
, double y2
,
594 double *x3
, double *y3
);
595 bool HitTest(double x
, double y
, int *attachment
, double *distance
);
596 void SetSize(double x
, double y
, bool recursive
= true);
597 void OnDraw(wxDC
& dc
);
598 void OnDrawOutline(wxDC
& dc
, double x
, double y
, double w
, double h
);
600 // Control points ('handles') redirect control to the actual shape, to make it easier
601 // to override sizing behaviour.
602 virtual void OnSizingDragLeft(wxControlPoint
* pt
, bool draw
, double x
, double y
, int keys
=0, int attachment
= 0);
603 virtual void OnSizingBeginDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
604 virtual void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
=0, int attachment
= 0);
606 // A polygon should have a control point at each vertex,
607 // with the option of moving the control points individually
608 // to change the shape.
609 void MakeControlPoints();
610 void ResetControlPoints();
612 // If we've changed the shape, must make the original
613 // points match the working points
614 void UpdateOriginalPoints();
616 // Add a control point after the given point
617 virtual void AddPolygonPoint(int pos
= 0);
619 // Delete a control point
620 virtual void DeletePolygonPoint(int pos
= 0);
622 // Recalculates the centre of the polygon
623 virtual void CalculatePolygonCentre();
626 void WriteAttributes(wxExpr
*clause
);
627 void ReadAttributes(wxExpr
*clause
);
630 int GetNumberOfAttachments() const;
631 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
632 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
633 bool AttachmentIsValid(int attachment
) const;
634 // Does the copying for this object
635 void Copy(wxShape
& copy
);
637 inline wxList
*GetPoints() { return m_points
; }
638 inline wxList
*GetOriginalPoints() { return m_originalPoints
; }
640 // Rotate about the given axis by the given amount in radians
641 virtual void Rotate(double x
, double y
, double theta
);
643 double GetOriginalWidth() const { return m_originalWidth
; }
644 double GetOriginalHeight() const { return m_originalHeight
; }
646 void SetOriginalWidth(double w
) { m_originalWidth
= w
; }
647 void SetOriginalHeight(double h
) { m_originalHeight
= h
; }
651 wxList
* m_originalPoints
;
653 double m_boundHeight
;
654 double m_originalWidth
;
655 double m_originalHeight
;
658 class WXDLLIMPEXP_OGL wxRectangleShape
: public wxShape
660 DECLARE_DYNAMIC_CLASS(wxRectangleShape
)
662 wxRectangleShape(double w
= 0.0, double h
= 0.0);
663 void GetBoundingBoxMin(double *w
, double *h
);
664 bool GetPerimeterPoint(double x1
, double y1
,
665 double x2
, double y2
,
666 double *x3
, double *y3
);
667 void OnDraw(wxDC
& dc
);
668 void SetSize(double x
, double y
, bool recursive
= true);
669 void SetCornerRadius(double rad
); // If > 0, rounded corners
670 double GetCornerRadius() const { return m_cornerRadius
; }
673 void WriteAttributes(wxExpr
*clause
);
674 void ReadAttributes(wxExpr
*clause
);
677 int GetNumberOfAttachments() const;
678 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
679 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
680 // Does the copying for this object
681 void Copy(wxShape
& copy
);
683 inline double GetWidth() const { return m_width
; }
684 inline double GetHeight() const { return m_height
; }
685 inline void SetWidth(double w
) { m_width
= w
; }
686 inline void SetHeight(double h
) { m_height
= h
; }
691 double m_cornerRadius
;
694 class WXDLLIMPEXP_OGL wxTextShape
: public wxRectangleShape
696 DECLARE_DYNAMIC_CLASS(wxTextShape
)
698 wxTextShape(double width
= 0.0, double height
= 0.0);
700 void OnDraw(wxDC
& dc
);
703 void WriteAttributes(wxExpr
*clause
);
706 // Does the copying for this object
707 void Copy(wxShape
& copy
);
710 class WXDLLIMPEXP_OGL wxEllipseShape
: public wxShape
712 DECLARE_DYNAMIC_CLASS(wxEllipseShape
)
714 wxEllipseShape(double w
= 0.0, double h
= 0.0);
716 void GetBoundingBoxMin(double *w
, double *h
);
717 bool GetPerimeterPoint(double x1
, double y1
,
718 double x2
, double y2
,
719 double *x3
, double *y3
);
721 void OnDraw(wxDC
& dc
);
722 void SetSize(double x
, double y
, bool recursive
= true);
725 void WriteAttributes(wxExpr
*clause
);
726 void ReadAttributes(wxExpr
*clause
);
729 int GetNumberOfAttachments() const;
730 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
731 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
733 // Does the copying for this object
734 void Copy(wxShape
& copy
);
736 inline double GetWidth() const { return m_width
; }
737 inline double GetHeight() const { return m_height
; }
739 inline void SetWidth(double w
) { m_width
= w
; }
740 inline void SetHeight(double h
) { m_height
= h
; }
747 class WXDLLIMPEXP_OGL wxCircleShape
: public wxEllipseShape
749 DECLARE_DYNAMIC_CLASS(wxCircleShape
)
751 wxCircleShape(double w
= 0.0);
753 bool GetPerimeterPoint(double x1
, double y1
,
754 double x2
, double y2
,
755 double *x3
, double *y3
);
756 // Does the copying for this object
757 void Copy(wxShape
& copy
);