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