]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/ogl/basic.h
Added DoDragOver and DoDropText from Angelo Mandato, and ensured that
[wxWidgets.git] / contrib / include / wx / ogl / basic.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: basic.h
3 // Purpose: Basic OGL classes and definitions
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 12/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _OGL_BASIC_H_
13 #define _OGL_BASIC_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "basic.h"
17 #endif
18
19 #ifndef wxUSE_DEPRECATED
20 #define wxUSE_DEPRECATED 1
21 #endif
22
23 #if wxUSE_DEPRECATED
24 #include <wx/deprecated/setup.h>
25 #endif
26
27 #define OGL_VERSION 2.0
28
29 #ifndef DEFAULT_MOUSE_TOLERANCE
30 #define DEFAULT_MOUSE_TOLERANCE 3
31 #endif
32
33 // Key identifiers
34 #define KEY_SHIFT 1
35 #define KEY_CTRL 2
36
37 // Arrow styles
38
39 #define ARROW_NONE 0
40 #define ARROW_END 1
41 #define ARROW_BOTH 2
42 #define ARROW_MIDDLE 3
43 #define ARROW_START 4
44
45 // Control point types
46 // Rectangle and most other shapes
47 #define CONTROL_POINT_VERTICAL 1
48 #define CONTROL_POINT_HORIZONTAL 2
49 #define CONTROL_POINT_DIAGONAL 3
50
51 // Line
52 #define CONTROL_POINT_ENDPOINT_TO 4
53 #define CONTROL_POINT_ENDPOINT_FROM 5
54 #define CONTROL_POINT_LINE 6
55
56 // Types of formatting: can be combined in a bit list
57 #define FORMAT_NONE 0
58 // Left justification
59 #define FORMAT_CENTRE_HORIZ 1
60 // Centre horizontally
61 #define FORMAT_CENTRE_VERT 2
62 // Centre vertically
63 #define FORMAT_SIZE_TO_CONTENTS 4
64 // Resize shape to contents
65
66 // Shadow mode
67 #define SHADOW_NONE 0
68 #define SHADOW_LEFT 1
69 #define SHADOW_RIGHT 2
70
71 /*
72 * Declare types
73 *
74 */
75
76 #define SHAPE_BASIC wxTYPE_USER + 1
77 #define SHAPE_RECTANGLE wxTYPE_USER + 2
78 #define SHAPE_ELLIPSE wxTYPE_USER + 3
79 #define SHAPE_POLYGON wxTYPE_USER + 4
80 #define SHAPE_CIRCLE wxTYPE_USER + 5
81 #define SHAPE_LINE wxTYPE_USER + 6
82 #define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
83 #define SHAPE_COMPOSITE wxTYPE_USER + 9
84 #define SHAPE_CONTROL_POINT wxTYPE_USER + 10
85 #define SHAPE_DRAWN wxTYPE_USER + 11
86 #define SHAPE_DIVISION wxTYPE_USER + 12
87 #define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
88 #define SHAPE_BITMAP wxTYPE_USER + 14
89 #define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
90
91 #define OBJECT_REGION wxTYPE_USER + 20
92
93 #define OP_CLICK_LEFT 1
94 #define OP_CLICK_RIGHT 2
95 #define OP_DRAG_LEFT 4
96 #define OP_DRAG_RIGHT 8
97
98 #define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
99
100 // Attachment modes
101 #define ATTACHMENT_MODE_NONE 0
102 #define ATTACHMENT_MODE_EDGE 1
103 #define ATTACHMENT_MODE_BRANCHING 2
104
105 // Sub-modes for branching attachment mode
106 #define BRANCHING_ATTACHMENT_NORMAL 1
107 #define BRANCHING_ATTACHMENT_BLOB 2
108
109 class wxShapeTextLine;
110 class wxShapeCanvas;
111 class wxLineShape;
112 class wxControlPoint;
113 class wxShapeRegion;
114 class wxShape;
115
116 #if wxUSE_PROLOGIO
117 class WXDLLEXPORT wxExpr;
118 class WXDLLEXPORT wxExprDatabase;
119 #endif
120
121 // Round up
122 #define WXROUND(x) ( (long) (x + 0.5) )
123
124
125 // logical function to use when drawing rubberband boxes, etc.
126 #define OGLRBLF wxINVERT
127
128
129
130 class WXDLLIMPEXP_OGL wxShapeEvtHandler: public wxObject, public wxClientDataContainer
131 {
132 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler)
133
134 public:
135 wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL);
136 virtual ~wxShapeEvtHandler();
137
138 inline void SetShape(wxShape *sh) { m_handlerShape = sh; }
139 inline wxShape *GetShape() const { return m_handlerShape; }
140
141 inline void SetPreviousHandler(wxShapeEvtHandler* handler) { m_previousHandler = handler; }
142 inline wxShapeEvtHandler* GetPreviousHandler() const { return m_previousHandler; }
143
144 // This is called when the _shape_ is deleted.
145 virtual void OnDelete();
146 virtual void OnDraw(wxDC& dc);
147 virtual void OnDrawContents(wxDC& dc);
148 virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
149 virtual void OnMoveLinks(wxDC& dc);
150 virtual void OnErase(wxDC& dc);
151 virtual void OnEraseContents(wxDC& dc);
152 virtual void OnHighlight(wxDC& dc);
153 virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
154 virtual void OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
155 virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
156 virtual void OnSize(double x, double y);
157 virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
158 virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
159
160 virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
161 virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
162 virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
163 virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
164 virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
165 virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
166 virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
167 virtual void OnDrawControlPoints(wxDC& dc);
168 virtual void OnEraseControlPoints(wxDC& dc);
169 virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
170
171 // Control points ('handles') redirect control to the actual shape, to make it easier
172 // to override sizing behaviour.
173 virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
174 virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
175 virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
176
177 virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
178 virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
179
180 // Can override this to prevent or intercept line reordering.
181 virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
182
183 // Creates a copy of this event handler.
184 wxShapeEvtHandler *CreateNewCopy();
185
186 // Does the copy - override for new event handlers which might store
187 // app-specific data.
188 virtual void CopyData(wxShapeEvtHandler& WXUNUSED(copy)) {};
189
190 private:
191 wxShapeEvtHandler* m_previousHandler;
192 wxShape* m_handlerShape;
193 };
194
195 class WXDLLIMPEXP_OGL wxShape: public wxShapeEvtHandler
196 {
197 DECLARE_ABSTRACT_CLASS(wxShape)
198
199 public:
200
201 wxShape(wxShapeCanvas *can = NULL);
202 virtual ~wxShape();
203 virtual void GetBoundingBoxMax(double *width, double *height);
204 virtual void GetBoundingBoxMin(double *width, double *height) = 0;
205 virtual bool GetPerimeterPoint(double x1, double y1,
206 double x2, double y2,
207 double *x3, double *y3);
208 inline wxShapeCanvas *GetCanvas() { return m_canvas; }
209 void SetCanvas(wxShapeCanvas *the_canvas);
210 virtual void AddToCanvas(wxShapeCanvas *the_canvas, wxShape *addAfter = NULL);
211 virtual void InsertInCanvas(wxShapeCanvas *the_canvas);
212
213 virtual void RemoveFromCanvas(wxShapeCanvas *the_canvas);
214 inline double GetX() const { return m_xpos; }
215 inline double GetY() const { return m_ypos; }
216 inline void SetX(double x) { m_xpos = x; }
217 inline void SetY(double y) { m_ypos = y; }
218
219 inline wxShape *GetParent() const { return m_parent; }
220 inline void SetParent(wxShape *p) { m_parent = p; }
221 wxShape *GetTopAncestor();
222 inline wxList& GetChildren() { return m_children; }
223
224 virtual void OnDraw(wxDC& dc);
225 virtual void OnDrawContents(wxDC& dc);
226 virtual void OnMoveLinks(wxDC& dc);
227 virtual void Unlink() { };
228 void SetDrawHandles(bool drawH);
229 inline bool GetDrawHandles() { return m_drawHandles; }
230 virtual void OnErase(wxDC& dc);
231 virtual void OnEraseContents(wxDC& dc);
232 virtual void OnHighlight(wxDC& dc);
233 virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
234 virtual void OnLeftDoubleClick(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys) = 0, int WXUNUSED(attachment) = 0) {}
235 virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
236 virtual void OnSize(double x, double y);
237 virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
238 virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
239
240 virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
241 virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
242 virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
243 virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
244 virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
245 virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
246 virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
247 virtual void OnDrawControlPoints(wxDC& dc);
248 virtual void OnEraseControlPoints(wxDC& dc);
249
250 virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
251 virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
252
253 // Control points ('handles') redirect control to the actual shape, to make it easier
254 // to override sizing behaviour.
255 virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
256 virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
257 virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
258
259 virtual void MakeControlPoints();
260 virtual void DeleteControlPoints(wxDC *dc = NULL);
261 virtual void ResetControlPoints();
262
263 inline wxShapeEvtHandler *GetEventHandler() { return m_eventHandler; }
264 inline void SetEventHandler(wxShapeEvtHandler *handler) { m_eventHandler = handler; }
265
266 // Mandatory control points, e.g. the divided line moving handles
267 // should appear even if a child of the 'selected' image
268 virtual void MakeMandatoryControlPoints();
269 virtual void ResetMandatoryControlPoints();
270
271 inline virtual bool Recompute() { return TRUE; };
272 // Calculate size recursively, if size changes. Size might depend on children.
273 inline virtual void CalculateSize() { };
274 virtual void Select(bool select = TRUE, wxDC* dc = NULL);
275 virtual void SetHighlight(bool hi = TRUE, bool recurse = FALSE);
276 inline virtual bool IsHighlighted() const { return m_highlighted; };
277 virtual bool Selected() const;
278 virtual bool AncestorSelected() const;
279 void SetSensitivityFilter(int sens = OP_ALL, bool recursive = FALSE);
280 int GetSensitivityFilter() const { return m_sensitivity; }
281 void SetDraggable(bool drag, bool recursive = FALSE);
282 inline void SetFixedSize(bool x, bool y) { m_fixedWidth = x; m_fixedHeight = y; };
283 inline void GetFixedSize(bool *x, bool *y) const { *x = m_fixedWidth; *y = m_fixedHeight; };
284 inline bool GetFixedWidth() const { return m_fixedWidth; }
285 inline bool GetFixedHeight() const { return m_fixedHeight; }
286 inline void SetSpaceAttachments(bool sp) { m_spaceAttachments = sp; };
287 inline bool GetSpaceAttachments() const { return m_spaceAttachments; };
288 void SetShadowMode(int mode, bool redraw = FALSE);
289 inline int GetShadowMode() const { return m_shadowMode; }
290 virtual bool HitTest(double x, double y, int *attachment, double *distance);
291 inline void SetCentreResize(bool cr) { m_centreResize = cr; }
292 inline bool GetCentreResize() const { return m_centreResize; }
293 inline void SetMaintainAspectRatio(bool ar) { m_maintainAspectRatio = ar; }
294 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio; }
295 inline wxList& GetLines() const { return (wxList&) m_lines; }
296 inline void SetDisableLabel(bool flag) { m_disableLabel = flag; }
297 inline bool GetDisableLabel() const { return m_disableLabel; }
298 inline void SetAttachmentMode(int mode) { m_attachmentMode = mode; }
299 inline int GetAttachmentMode() const { return m_attachmentMode; }
300 inline void SetId(long i) { m_id = i; }
301 inline long GetId() const { return m_id; }
302
303 void SetPen(wxPen *pen);
304 void SetBrush(wxBrush *brush);
305
306 virtual void Show(bool show);
307 virtual bool IsShown() const { return m_visible; }
308 virtual void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
309 virtual void Erase(wxDC& dc);
310 virtual void EraseContents(wxDC& dc);
311 virtual void Draw(wxDC& dc);
312 virtual void Flash();
313 virtual void MoveLinks(wxDC& dc);
314 virtual void DrawContents(wxDC& dc); // E.g. for drawing text label
315 virtual void SetSize(double x, double y, bool recursive = TRUE);
316 virtual void SetAttachmentSize(double x, double y);
317 void Attach(wxShapeCanvas *can);
318 void Detach();
319
320 inline virtual bool Constrain() { return FALSE; } ;
321
322 void AddLine(wxLineShape *line, wxShape *other,
323 int attachFrom = 0, int attachTo = 0,
324 // The line ordering
325 int positionFrom = -1, int positionTo = -1);
326
327 // Return the zero-based position in m_lines of line.
328 int GetLinePosition(wxLineShape* line);
329
330 void AddText(const wxString& string);
331
332 inline wxPen *GetPen() const { return m_pen; }
333 inline wxBrush *GetBrush() const { return m_brush; }
334
335 /*
336 * Region-specific functions (defaults to the default region
337 * for simple objects
338 */
339
340 // Set the default, single region size to be consistent
341 // with the object size
342 void SetDefaultRegionSize();
343 virtual void FormatText(wxDC& dc, const wxString& s, int regionId = 0);
344 virtual void SetFormatMode(int mode, int regionId = 0);
345 virtual int GetFormatMode(int regionId = 0) const;
346 virtual void SetFont(wxFont *font, int regionId = 0);
347 virtual wxFont *GetFont(int regionId = 0) const;
348 virtual void SetTextColour(const wxString& colour, int regionId = 0);
349 virtual wxString GetTextColour(int regionId = 0) const;
350 virtual inline int GetNumberOfTextRegions() const { return m_regions.GetCount(); }
351 virtual void SetRegionName(const wxString& name, int regionId = 0);
352
353 // Get the name representing the region for this image alone.
354 // I.e. this image's region ids go from 0 to N-1.
355 // But the names might be "0.2.0", "0.2.1" etc. depending on position in composite.
356 // So the last digit represents the region Id, the others represent positions
357 // in composites.
358 virtual wxString GetRegionName(int regionId);
359
360 // Gets the region corresponding to the name, or -1 if not found.
361 virtual int GetRegionId(const wxString& name);
362
363 // Construct names for regions, unique even for children of a composite.
364 virtual void NameRegions(const wxString& parentName = wxEmptyString);
365
366 // Get list of regions
367 inline wxList& GetRegions() const { return (wxList&) m_regions; }
368
369 virtual void AddRegion(wxShapeRegion *region);
370
371 virtual void ClearRegions();
372
373 // Assign new ids to this image and children (if composite)
374 void AssignNewIds();
375
376 // Returns actual image (same as 'this' if non-composite) and region id
377 // for given region name.
378 virtual wxShape *FindRegion(const wxString& regionName, int *regionId);
379
380 // Finds all region names for this image (composite or simple).
381 // Supply empty string list.
382 virtual void FindRegionNames(wxStringList& list);
383
384 virtual void ClearText(int regionId = 0);
385 void RemoveLine(wxLineShape *line);
386
387 #if wxUSE_PROLOGIO
388 // I/O
389 virtual void WriteAttributes(wxExpr *clause);
390 virtual void ReadAttributes(wxExpr *clause);
391
392 // In case the object has constraints it needs to read in in a different pass
393 inline virtual void ReadConstraints(wxExpr *WXUNUSED(clause), wxExprDatabase *WXUNUSED(database)) { };
394 virtual void WriteRegions(wxExpr *clause);
395 virtual void ReadRegions(wxExpr *clause);
396 #endif
397
398 // Attachment code
399 virtual bool GetAttachmentPosition(int attachment, double *x, double *y,
400 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
401 virtual int GetNumberOfAttachments() const;
402 virtual bool AttachmentIsValid(int attachment) const;
403
404 // Only get the attachment position at the _edge_ of the shape, ignoring
405 // branching mode. This is used e.g. to indicate the edge of interest, not the point
406 // on the attachment branch.
407 virtual bool GetAttachmentPositionEdge(int attachment, double *x, double *y,
408 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
409
410 // Assuming the attachment lies along a vertical or horizontal line,
411 // calculate the position on that point.
412 virtual wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
413 int nth, int noArcs, wxLineShape* line);
414
415 // Returns TRUE if pt1 <= pt2 in the sense that one point comes before another on an
416 // edge of the shape.
417 // attachmentPoint is the attachment point (= side) in question.
418 virtual bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
419
420 virtual void EraseLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
421 virtual void DrawLinks(wxDC& dc, int attachment = -1, bool recurse = FALSE);
422
423 virtual bool MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move,
424 double x, double y);
425
426 // Reorders the lines coming into the node image at this attachment
427 // position, in the order in which they appear in linesToSort.
428 virtual void SortLines(int attachment, wxList& linesToSort);
429
430 // Apply an attachment ordering change
431 void ApplyAttachmentOrdering(wxList& ordering);
432
433 // Can override this to prevent or intercept line reordering.
434 virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
435
436 //// New banching attachment code, 24/9/98
437
438 //
439 // |________|
440 // | <- root
441 // | <- neck
442 // shoulder1 ->---------<- shoulder2
443 // | | | | |<- stem
444 // <- branching attachment point N-1
445
446 // This function gets the root point at the given attachment.
447 virtual wxRealPoint GetBranchingAttachmentRoot(int attachment);
448
449 // This function gets information about where branching connections go (calls GetBranchingAttachmentRoot)
450 virtual bool GetBranchingAttachmentInfo(int attachment, wxRealPoint& root, wxRealPoint& neck,
451 wxRealPoint& shoulder1, wxRealPoint& shoulder2);
452
453 // n is the number of the adjoining line, from 0 to N-1 where N is the number of lines
454 // at this attachment point.
455 // attachmentPoint is where the arc meets the stem, and stemPoint is where the stem meets the
456 // shoulder.
457 virtual bool GetBranchingAttachmentPoint(int attachment, int n, wxRealPoint& attachmentPoint,
458 wxRealPoint& stemPoint);
459
460 // Get the number of lines at this attachment position.
461 virtual int GetAttachmentLineCount(int attachment) const;
462
463 // Draw the branches (not the actual arcs though)
464 virtual void OnDrawBranches(wxDC& dc, int attachment, bool erase = FALSE);
465 virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
466
467 // Branching attachment settings
468 inline void SetBranchNeckLength(int len) { m_branchNeckLength = len; }
469 inline int GetBranchNeckLength() const { return m_branchNeckLength; }
470
471 inline void SetBranchStemLength(int len) { m_branchStemLength = len; }
472 inline int GetBranchStemLength() const { return m_branchStemLength; }
473
474 inline void SetBranchSpacing(int len) { m_branchSpacing = len; }
475 inline int GetBranchSpacing() const { return m_branchSpacing; }
476
477 // Further detail on branching style, e.g. blobs on interconnections
478 inline void SetBranchStyle(long style) { m_branchStyle = style; }
479 inline long GetBranchStyle() const { return m_branchStyle; }
480
481 // Rotate the standard attachment point from physical (0 is always North)
482 // to logical (0 -> 1 if rotated by 90 degrees)
483 virtual int PhysicalToLogicalAttachment(int physicalAttachment) const;
484
485 // Rotate the standard attachment point from logical
486 // to physical (0 is always North)
487 virtual int LogicalToPhysicalAttachment(int logicalAttachment) const;
488
489 // This is really to distinguish between lines and other images.
490 // For lines, want to pass drag to canvas, since lines tend to prevent
491 // dragging on a canvas (they get in the way.)
492 virtual bool Draggable() const { return TRUE; }
493
494 // Returns TRUE if image is a descendant of this image
495 bool HasDescendant(wxShape *image);
496
497 // Creates a copy of this shape.
498 wxShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
499
500 // Does the copying for this object
501 virtual void Copy(wxShape& copy);
502
503 // Does the copying for this object, including copying event
504 // handler data if any. Calls the virtual Copy function.
505 void CopyWithHandler(wxShape& copy);
506
507 // Rotate about the given axis by the given amount in radians.
508 virtual void Rotate(double x, double y, double theta);
509 virtual inline double GetRotation() const { return m_rotation; }
510
511 void ClearAttachments();
512
513 // Recentres all the text regions for this object
514 void Recentre(wxDC& dc);
515
516 // Clears points from a list of wxRealPoints
517 void ClearPointList(wxList& list);
518
519 // Return pen or brush of the right colour for the background
520 wxPen GetBackgroundPen();
521 wxBrush GetBackgroundBrush();
522
523
524 protected:
525 wxShapeEvtHandler* m_eventHandler;
526 bool m_formatted;
527 double m_xpos, m_ypos;
528 wxPen* m_pen;
529 wxBrush* m_brush;
530 wxFont* m_font;
531 wxColour* m_textColour;
532 wxString m_textColourName;
533 wxShapeCanvas* m_canvas;
534 wxList m_lines;
535 wxList m_text;
536 wxList m_controlPoints;
537 wxList m_regions;
538 wxList m_attachmentPoints;
539 bool m_visible;
540 bool m_disableLabel;
541 long m_id;
542 bool m_selected;
543 bool m_highlighted; // Different from selected: user-defined highlighting,
544 // e.g. thick border.
545 double m_rotation;
546 int m_sensitivity;
547 bool m_draggable;
548 int m_attachmentMode; // 0 for no attachments, 1 if using normal attachments,
549 // 2 for branching attachments
550 bool m_spaceAttachments; // TRUE if lines at one side should be spaced
551 bool m_fixedWidth;
552 bool m_fixedHeight;
553 bool m_centreResize; // Default is to resize keeping the centre constant (TRUE)
554 bool m_drawHandles; // Don't draw handles if FALSE, usually TRUE
555 wxList m_children; // In case it's composite
556 wxShape* m_parent; // In case it's a child
557 int m_formatMode;
558 int m_shadowMode;
559 wxBrush* m_shadowBrush;
560 int m_shadowOffsetX;
561 int m_shadowOffsetY;
562 int m_textMarginX; // Gap between text and border
563 int m_textMarginY;
564 wxString m_regionName;
565 bool m_maintainAspectRatio;
566 int m_branchNeckLength;
567 int m_branchStemLength;
568 int m_branchSpacing;
569 long m_branchStyle;
570 };
571
572 class WXDLLIMPEXP_OGL wxPolygonShape: public wxShape
573 {
574 DECLARE_DYNAMIC_CLASS(wxPolygonShape)
575 public:
576 wxPolygonShape();
577 ~wxPolygonShape();
578
579 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
580 // Deletes user's points in destructor.
581 virtual void Create(wxList *points);
582 virtual void ClearPoints();
583
584 void GetBoundingBoxMin(double *w, double *h);
585 void CalculateBoundingBox();
586 bool GetPerimeterPoint(double x1, double y1,
587 double x2, double y2,
588 double *x3, double *y3);
589 bool HitTest(double x, double y, int *attachment, double *distance);
590 void SetSize(double x, double y, bool recursive = TRUE);
591 void OnDraw(wxDC& dc);
592 void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
593
594 // Control points ('handles') redirect control to the actual shape, to make it easier
595 // to override sizing behaviour.
596 virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
597 virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
598 virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
599
600 // A polygon should have a control point at each vertex,
601 // with the option of moving the control points individually
602 // to change the shape.
603 void MakeControlPoints();
604 void ResetControlPoints();
605
606 // If we've changed the shape, must make the original
607 // points match the working points
608 void UpdateOriginalPoints();
609
610 // Add a control point after the given point
611 virtual void AddPolygonPoint(int pos = 0);
612
613 // Delete a control point
614 virtual void DeletePolygonPoint(int pos = 0);
615
616 // Recalculates the centre of the polygon
617 virtual void CalculatePolygonCentre();
618
619 #if wxUSE_PROLOGIO
620 void WriteAttributes(wxExpr *clause);
621 void ReadAttributes(wxExpr *clause);
622 #endif
623
624 int GetNumberOfAttachments() const;
625 bool GetAttachmentPosition(int attachment, double *x, double *y,
626 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
627 bool AttachmentIsValid(int attachment) const;
628 // Does the copying for this object
629 void Copy(wxShape& copy);
630
631 inline wxList *GetPoints() { return m_points; }
632
633 // Rotate about the given axis by the given amount in radians
634 virtual void Rotate(double x, double y, double theta);
635
636 private:
637 wxList* m_points;
638 wxList* m_originalPoints;
639 double m_boundWidth;
640 double m_boundHeight;
641 double m_originalWidth;
642 double m_originalHeight;
643 };
644
645 class WXDLLIMPEXP_OGL wxRectangleShape: public wxShape
646 {
647 DECLARE_DYNAMIC_CLASS(wxRectangleShape)
648 public:
649 wxRectangleShape(double w = 0.0, double h = 0.0);
650 void GetBoundingBoxMin(double *w, double *h);
651 bool GetPerimeterPoint(double x1, double y1,
652 double x2, double y2,
653 double *x3, double *y3);
654 void OnDraw(wxDC& dc);
655 void SetSize(double x, double y, bool recursive = TRUE);
656 void SetCornerRadius(double rad); // If > 0, rounded corners
657
658 #if wxUSE_PROLOGIO
659 void WriteAttributes(wxExpr *clause);
660 void ReadAttributes(wxExpr *clause);
661 #endif
662
663 int GetNumberOfAttachments() const;
664 bool GetAttachmentPosition(int attachment, double *x, double *y,
665 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
666 // Does the copying for this object
667 void Copy(wxShape& copy);
668
669 inline double GetWidth() const { return m_width; }
670 inline double GetHeight() const { return m_height; }
671 inline void SetWidth(double w) { m_width = w; }
672 inline void SetHeight(double h) { m_height = h; }
673
674 protected:
675 double m_width;
676 double m_height;
677 double m_cornerRadius;
678 };
679
680 class WXDLLIMPEXP_OGL wxTextShape: public wxRectangleShape
681 {
682 DECLARE_DYNAMIC_CLASS(wxTextShape)
683 public:
684 wxTextShape(double width = 0.0, double height = 0.0);
685
686 void OnDraw(wxDC& dc);
687
688 #if wxUSE_PROLOGIO
689 void WriteAttributes(wxExpr *clause);
690 #endif
691
692 // Does the copying for this object
693 void Copy(wxShape& copy);
694 };
695
696 class WXDLLIMPEXP_OGL wxEllipseShape: public wxShape
697 {
698 DECLARE_DYNAMIC_CLASS(wxEllipseShape)
699 public:
700 wxEllipseShape(double w = 0.0, double h = 0.0);
701
702 void GetBoundingBoxMin(double *w, double *h);
703 bool GetPerimeterPoint(double x1, double y1,
704 double x2, double y2,
705 double *x3, double *y3);
706
707 void OnDraw(wxDC& dc);
708 void SetSize(double x, double y, bool recursive = TRUE);
709
710 #if wxUSE_PROLOGIO
711 void WriteAttributes(wxExpr *clause);
712 void ReadAttributes(wxExpr *clause);
713 #endif
714
715 int GetNumberOfAttachments() const;
716 bool GetAttachmentPosition(int attachment, double *x, double *y,
717 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
718
719 // Does the copying for this object
720 void Copy(wxShape& copy);
721
722 inline double GetWidth() const { return m_width; }
723 inline double GetHeight() const { return m_height; }
724
725 inline void SetWidth(double w) { m_width = w; }
726 inline void SetHeight(double h) { m_height = h; }
727
728 protected:
729 double m_width;
730 double m_height;
731 };
732
733 class WXDLLIMPEXP_OGL wxCircleShape: public wxEllipseShape
734 {
735 DECLARE_DYNAMIC_CLASS(wxCircleShape)
736 public:
737 wxCircleShape(double w = 0.0);
738
739 bool GetPerimeterPoint(double x1, double y1,
740 double x2, double y2,
741 double *x3, double *y3);
742 // Does the copying for this object
743 void Copy(wxShape& copy);
744 };
745
746 #endif
747 // _OGL_BASIC_H_