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
, public wxClientDataContainer
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
);
303 virtual void Show(bool show
);
304 virtual bool IsShown() const { return m_visible
; }
305 virtual void Move(wxDC
& dc
, double x1
, double y1
, bool display
= TRUE
);
306 virtual void Erase(wxDC
& dc
);
307 virtual void EraseContents(wxDC
& dc
);
308 virtual void Draw(wxDC
& dc
);
309 virtual void Flash();
310 virtual void MoveLinks(wxDC
& dc
);
311 virtual void DrawContents(wxDC
& dc
); // E.g. for drawing text label
312 virtual void SetSize(double x
, double y
, bool recursive
= TRUE
);
313 virtual void SetAttachmentSize(double x
, double y
);
314 void Attach(wxShapeCanvas
*can
);
317 inline virtual bool Constrain() { return FALSE
; } ;
319 void AddLine(wxLineShape
*line
, wxShape
*other
,
320 int attachFrom
= 0, int attachTo
= 0,
322 int positionFrom
= -1, int positionTo
= -1);
324 // Return the zero-based position in m_lines of line.
325 int GetLinePosition(wxLineShape
* line
);
327 void AddText(const wxString
& string
);
329 inline wxPen
*GetPen() const { return m_pen
; }
330 inline wxBrush
*GetBrush() const { return m_brush
; }
333 * Region-specific functions (defaults to the default region
337 // Set the default, single region size to be consistent
338 // with the object size
339 void SetDefaultRegionSize();
340 virtual void FormatText(wxDC
& dc
, const wxString
& s
, int regionId
= 0);
341 virtual void SetFormatMode(int mode
, int regionId
= 0);
342 virtual int GetFormatMode(int regionId
= 0) const;
343 virtual void SetFont(wxFont
*font
, int regionId
= 0);
344 virtual wxFont
*GetFont(int regionId
= 0) const;
345 virtual void SetTextColour(const wxString
& colour
, int regionId
= 0);
346 virtual wxString
GetTextColour(int regionId
= 0) const;
347 virtual inline int GetNumberOfTextRegions() const { return m_regions
.Number(); }
348 virtual void SetRegionName(const wxString
& name
, int regionId
= 0);
350 // Get the name representing the region for this image alone.
351 // I.e. this image's region ids go from 0 to N-1.
352 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
353 // So the last digit represents the region Id, the others represent positions
355 virtual wxString
GetRegionName(int regionId
);
357 // Gets the region corresponding to the name, or -1 if not found.
358 virtual int GetRegionId(const wxString
& name
);
360 // Construct names for regions, unique even for children of a composite.
361 virtual void NameRegions(const wxString
& parentName
= "");
363 // Get list of regions
364 inline wxList
& GetRegions() const { return (wxList
&) m_regions
; }
366 virtual void AddRegion(wxShapeRegion
*region
);
368 virtual void ClearRegions();
370 // Assign new ids to this image and children (if composite)
373 // Returns actual image (same as 'this' if non-composite) and region id
374 // for given region name.
375 virtual wxShape
*FindRegion(const wxString
& regionName
, int *regionId
);
377 // Finds all region names for this image (composite or simple).
378 // Supply empty string list.
379 virtual void FindRegionNames(wxStringList
& list
);
381 virtual void ClearText(int regionId
= 0);
382 void RemoveLine(wxLineShape
*line
);
386 virtual void WriteAttributes(wxExpr
*clause
);
387 virtual void ReadAttributes(wxExpr
*clause
);
389 // In case the object has constraints it needs to read in in a different pass
390 inline virtual void ReadConstraints(wxExpr
*WXUNUSED(clause
), wxExprDatabase
*WXUNUSED(database
)) { };
391 virtual void WriteRegions(wxExpr
*clause
);
392 virtual void ReadRegions(wxExpr
*clause
);
396 virtual bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
397 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
398 virtual int GetNumberOfAttachments() const;
399 virtual bool AttachmentIsValid(int attachment
) const;
401 // Only get the attachment position at the _edge_ of the shape, ignoring
402 // branching mode. This is used e.g. to indicate the edge of interest, not the point
403 // on the attachment branch.
404 virtual bool GetAttachmentPositionEdge(int attachment
, double *x
, double *y
,
405 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
);
407 // Assuming the attachment lies along a vertical or horizontal line,
408 // calculate the position on that point.
409 virtual wxRealPoint
CalcSimpleAttachment(const wxRealPoint
& pt1
, const wxRealPoint
& pt2
,
410 int nth
, int noArcs
, wxLineShape
* line
);
412 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
413 // edge of the shape.
414 // attachmentPoint is the attachment point (= side) in question.
415 virtual bool AttachmentSortTest(int attachmentPoint
, const wxRealPoint
& pt1
, const wxRealPoint
& pt2
);
417 virtual void EraseLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
418 virtual void DrawLinks(wxDC
& dc
, int attachment
= -1, bool recurse
= FALSE
);
420 virtual bool MoveLineToNewAttachment(wxDC
& dc
, wxLineShape
*to_move
,
423 // Reorders the lines coming into the node image at this attachment
424 // position, in the order in which they appear in linesToSort.
425 virtual void SortLines(int attachment
, wxList
& linesToSort
);
427 // Apply an attachment ordering change
428 void ApplyAttachmentOrdering(wxList
& ordering
);
430 // Can override this to prevent or intercept line reordering.
431 virtual void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
433 //// New banching attachment code, 24/9/98
439 // shoulder1 ->---------<- shoulder2
441 // <- branching attachment point N-1
443 // This function gets the root point at the given attachment.
444 virtual wxRealPoint
GetBranchingAttachmentRoot(int attachment
);
446 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
447 virtual bool GetBranchingAttachmentInfo(int attachment
, wxRealPoint
& root
, wxRealPoint
& neck
,
448 wxRealPoint
& shoulder1
, wxRealPoint
& shoulder2
);
450 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
451 // at this attachment point.
452 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
454 virtual bool GetBranchingAttachmentPoint(int attachment
, int n
, wxRealPoint
& attachmentPoint
,
455 wxRealPoint
& stemPoint
);
457 // Get the number of lines at this attachment position.
458 virtual int GetAttachmentLineCount(int attachment
) const;
460 // Draw the branches (not the actual arcs though)
461 virtual void OnDrawBranches(wxDC
& dc
, int attachment
, bool erase
= FALSE
);
462 virtual void OnDrawBranches(wxDC
& dc
, bool erase
= FALSE
);
464 // Branching attachment settings
465 inline void SetBranchNeckLength(int len
) { m_branchNeckLength
= len
; }
466 inline int GetBranchNeckLength() const { return m_branchNeckLength
; }
468 inline void SetBranchStemLength(int len
) { m_branchStemLength
= len
; }
469 inline int GetBranchStemLength() const { return m_branchStemLength
; }
471 inline void SetBranchSpacing(int len
) { m_branchSpacing
= len
; }
472 inline int GetBranchSpacing() const { return m_branchSpacing
; }
474 // Further detail on branching style, e.g. blobs on interconnections
475 inline void SetBranchStyle(long style
) { m_branchStyle
= style
; }
476 inline long GetBranchStyle() const { return m_branchStyle
; }
478 // Rotate the standard attachment point from physical (0 is always North)
479 // to logical (0 -> 1 if rotated by 90 degrees)
480 virtual int PhysicalToLogicalAttachment(int physicalAttachment
) const;
482 // Rotate the standard attachment point from logical
483 // to physical (0 is always North)
484 virtual int LogicalToPhysicalAttachment(int logicalAttachment
) const;
486 // This is really to distinguish between lines and other images.
487 // For lines, want to pass drag to canvas, since lines tend to prevent
488 // dragging on a canvas (they get in the way.)
489 virtual bool Draggable() const { return TRUE
; }
491 // Returns TRUE if image is a descendant of this image
492 bool HasDescendant(wxShape
*image
);
494 // Creates a copy of this shape.
495 wxShape
*CreateNewCopy(bool resetMapping
= TRUE
, bool recompute
= TRUE
);
497 // Does the copying for this object
498 virtual void Copy(wxShape
& copy
);
500 // Does the copying for this object, including copying event
501 // handler data if any. Calls the virtual Copy function.
502 void CopyWithHandler(wxShape
& copy
);
504 // Rotate about the given axis by the given amount in radians.
505 virtual void Rotate(double x
, double y
, double theta
);
506 virtual inline double GetRotation() const { return m_rotation
; }
508 void ClearAttachments();
510 // Recentres all the text regions for this object
511 void Recentre(wxDC
& dc
);
513 // Clears points from a list of wxRealPoints
514 void ClearPointList(wxList
& list
);
516 // Return pen or brush of the right colour for the background
517 wxPen
GetBackgroundPen();
518 wxBrush
GetBackgroundBrush();
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
);