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