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