]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/ogl/basic.h
wxMutexGuiEnter/Leave didn't work because this file is compiled with wxUSE_GUI=0
[wxWidgets.git] / contrib / include / wx / ogl / basic.h
CommitLineData
1fc25a89
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
ab7ce33c 15#if defined(__GNUG__) && !defined(__APPLE__)
1fc25a89
JS
16#pragma interface "basic.h"
17#endif
18
5f331691 19
1fc25a89
JS
20#define OGL_VERSION 2.0
21
22#ifndef DEFAULT_MOUSE_TOLERANCE
23#define DEFAULT_MOUSE_TOLERANCE 3
24#endif
25
1fc25a89
JS
26// Key identifiers
27#define KEY_SHIFT 1
28#define KEY_CTRL 2
29
30// Arrow styles
31
32#define ARROW_NONE 0
33#define ARROW_END 1
34#define ARROW_BOTH 2
35#define ARROW_MIDDLE 3
36#define ARROW_START 4
37
38// Control point types
39// Rectangle and most other shapes
40#define CONTROL_POINT_VERTICAL 1
41#define CONTROL_POINT_HORIZONTAL 2
42#define CONTROL_POINT_DIAGONAL 3
43
44// Line
45#define CONTROL_POINT_ENDPOINT_TO 4
46#define CONTROL_POINT_ENDPOINT_FROM 5
47#define CONTROL_POINT_LINE 6
48
49// Types of formatting: can be combined in a bit list
50#define FORMAT_NONE 0
51 // Left justification
52#define FORMAT_CENTRE_HORIZ 1
53 // Centre horizontally
54#define FORMAT_CENTRE_VERT 2
55 // Centre vertically
56#define FORMAT_SIZE_TO_CONTENTS 4
57 // Resize shape to contents
58
59// Shadow mode
60#define SHADOW_NONE 0
61#define SHADOW_LEFT 1
62#define SHADOW_RIGHT 2
63
64/*
65 * Declare types
66 *
67 */
68
69#define SHAPE_BASIC wxTYPE_USER + 1
70#define SHAPE_RECTANGLE wxTYPE_USER + 2
71#define SHAPE_ELLIPSE wxTYPE_USER + 3
72#define SHAPE_POLYGON wxTYPE_USER + 4
73#define SHAPE_CIRCLE wxTYPE_USER + 5
74#define SHAPE_LINE wxTYPE_USER + 6
75#define SHAPE_DIVIDED_RECTANGLE wxTYPE_USER + 8
76#define SHAPE_COMPOSITE wxTYPE_USER + 9
77#define SHAPE_CONTROL_POINT wxTYPE_USER + 10
78#define SHAPE_DRAWN wxTYPE_USER + 11
79#define SHAPE_DIVISION wxTYPE_USER + 12
80#define SHAPE_LABEL_OBJECT wxTYPE_USER + 13
81#define SHAPE_BITMAP wxTYPE_USER + 14
82#define SHAPE_DIVIDED_OBJECT_CONTROL_POINT wxTYPE_USER + 15
83
84#define OBJECT_REGION wxTYPE_USER + 20
85
86#define OP_CLICK_LEFT 1
87#define OP_CLICK_RIGHT 2
88#define OP_DRAG_LEFT 4
89#define OP_DRAG_RIGHT 8
90
91#define OP_ALL (OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_LEFT | OP_DRAG_RIGHT)
92
93// Attachment modes
94#define ATTACHMENT_MODE_NONE 0
95#define ATTACHMENT_MODE_EDGE 1
96#define ATTACHMENT_MODE_BRANCHING 2
97
98// Sub-modes for branching attachment mode
99#define BRANCHING_ATTACHMENT_NORMAL 1
100#define BRANCHING_ATTACHMENT_BLOB 2
101
102class wxShapeTextLine;
103class wxShapeCanvas;
104class wxLineShape;
105class wxControlPoint;
106class wxShapeRegion;
107class wxShape;
108
2b5f62a0 109#if wxUSE_PROLOGIO
1fc25a89
JS
110class WXDLLEXPORT wxExpr;
111class WXDLLEXPORT wxExprDatabase;
112#endif
113
114// Round up
115#define WXROUND(x) ( (long) (x + 0.5) )
116
117
118// logical function to use when drawing rubberband boxes, etc.
119#define OGLRBLF wxINVERT
120
121
122
5f331691 123class WXDLLIMPEXP_OGL wxShapeEvtHandler: public wxObject, public wxClientDataContainer
1fc25a89
JS
124{
125 DECLARE_DYNAMIC_CLASS(wxShapeEvtHandler)
126
127 public:
128 wxShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL);
129 virtual ~wxShapeEvtHandler();
130
131 inline void SetShape(wxShape *sh) { m_handlerShape = sh; }
132 inline wxShape *GetShape() const { return m_handlerShape; }
133
134 inline void SetPreviousHandler(wxShapeEvtHandler* handler) { m_previousHandler = handler; }
135 inline wxShapeEvtHandler* GetPreviousHandler() const { return m_previousHandler; }
136
137 // This is called when the _shape_ is deleted.
138 virtual void OnDelete();
139 virtual void OnDraw(wxDC& dc);
140 virtual void OnDrawContents(wxDC& dc);
141 virtual void OnDrawBranches(wxDC& dc, bool erase = FALSE);
142 virtual void OnMoveLinks(wxDC& dc);
143 virtual void OnErase(wxDC& dc);
144 virtual void OnEraseContents(wxDC& dc);
145 virtual void OnHighlight(wxDC& dc);
146 virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
147 virtual void OnLeftDoubleClick(double x, double y, int keys = 0, int attachment = 0);
148 virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
149 virtual void OnSize(double x, double y);
150 virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
151 virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
152
153 virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
154 virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
155 virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
156 virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
157 virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
158 virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
159 virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
160 virtual void OnDrawControlPoints(wxDC& dc);
161 virtual void OnEraseControlPoints(wxDC& dc);
162 virtual void OnMoveLink(wxDC& dc, bool moveControlPoints = TRUE);
163
164 // Control points ('handles') redirect control to the actual shape, to make it easier
165 // to override sizing behaviour.
166 virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
167 virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
168 virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
169
170 virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
171 virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
172
173 // Can override this to prevent or intercept line reordering.
174 virtual void OnChangeAttachment(int attachment, wxLineShape* line, wxList& ordering);
175
176 // Creates a copy of this event handler.
177 wxShapeEvtHandler *CreateNewCopy();
178
179 // Does the copy - override for new event handlers which might store
180 // app-specific data.
0a2c0398 181 virtual void CopyData(wxShapeEvtHandler& WXUNUSED(copy)) {};
1fc25a89
JS
182
183 private:
184 wxShapeEvtHandler* m_previousHandler;
185 wxShape* m_handlerShape;
186};
187
5f331691 188class WXDLLIMPEXP_OGL wxShape: public wxShapeEvtHandler
1fc25a89
JS
189{
190 DECLARE_ABSTRACT_CLASS(wxShape)
191
192 public:
193
194 wxShape(wxShapeCanvas *can = NULL);
195 virtual ~wxShape();
196 virtual void GetBoundingBoxMax(double *width, double *height);
197 virtual void GetBoundingBoxMin(double *width, double *height) = 0;
198 virtual bool GetPerimeterPoint(double x1, double y1,
199 double x2, double y2,
200 double *x3, double *y3);
201 inline wxShapeCanvas *GetCanvas() { return m_canvas; }
202 void SetCanvas(wxShapeCanvas *the_canvas);
203 virtual void AddToCanvas(wxShapeCanvas *the_canvas, wxShape *addAfter = NULL);
204 virtual void InsertInCanvas(wxShapeCanvas *the_canvas);
205
206 virtual void RemoveFromCanvas(wxShapeCanvas *the_canvas);
207 inline double GetX() const { return m_xpos; }
208 inline double GetY() const { return m_ypos; }
209 inline void SetX(double x) { m_xpos = x; }
210 inline void SetY(double y) { m_ypos = y; }
211
212 inline wxShape *GetParent() const { return m_parent; }
213 inline void SetParent(wxShape *p) { m_parent = p; }
214 wxShape *GetTopAncestor();
215 inline wxList& GetChildren() { return m_children; }
216
217 virtual void OnDraw(wxDC& dc);
218 virtual void OnDrawContents(wxDC& dc);
219 virtual void OnMoveLinks(wxDC& dc);
220 virtual void Unlink() { };
221 void SetDrawHandles(bool drawH);
222 inline bool GetDrawHandles() { return m_drawHandles; }
223 virtual void OnErase(wxDC& dc);
224 virtual void OnEraseContents(wxDC& dc);
225 virtual void OnHighlight(wxDC& dc);
226 virtual void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
0a2c0398 227 virtual void OnLeftDoubleClick(double WXUNUSED(x), double WXUNUSED(y), int WXUNUSED(keys) = 0, int WXUNUSED(attachment) = 0) {}
1fc25a89
JS
228 virtual void OnRightClick(double x, double y, int keys = 0, int attachment = 0);
229 virtual void OnSize(double x, double y);
230 virtual bool OnMovePre(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
231 virtual void OnMovePost(wxDC& dc, double x, double y, double old_x, double old_y, bool display = TRUE);
232
233 virtual void OnDragLeft(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
234 virtual void OnBeginDragLeft(double x, double y, int keys=0, int attachment = 0);
235 virtual void OnEndDragLeft(double x, double y, int keys=0, int attachment = 0);
236 virtual void OnDragRight(bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
237 virtual void OnBeginDragRight(double x, double y, int keys=0, int attachment = 0);
238 virtual void OnEndDragRight(double x, double y, int keys=0, int attachment = 0);
239 virtual void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
240 virtual void OnDrawControlPoints(wxDC& dc);
241 virtual void OnEraseControlPoints(wxDC& dc);
242
243 virtual void OnBeginSize(double WXUNUSED(w), double WXUNUSED(h)) { }
244 virtual void OnEndSize(double WXUNUSED(w), double WXUNUSED(h)) { }
245
246 // Control points ('handles') redirect control to the actual shape, to make it easier
247 // to override sizing behaviour.
248 virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0); // Erase if draw false
249 virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
250 virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
251
252 virtual void MakeControlPoints();
253 virtual void DeleteControlPoints(wxDC *dc = NULL);
254 virtual void ResetControlPoints();
255
256 inline wxShapeEvtHandler *GetEventHandler() { return m_eventHandler; }
257 inline void SetEventHandler(wxShapeEvtHandler *handler) { m_eventHandler = handler; }
258
259 // Mandatory control points, e.g. the divided line moving handles
260 // should appear even if a child of the 'selected' image
261 virtual void MakeMandatoryControlPoints();
262 virtual void ResetMandatoryControlPoints();
263
264 inline virtual bool Recompute() { return TRUE; };
265 // Calculate size recursively, if size changes. Size might depend on children.
266 inline virtual void CalculateSize() { };
267 virtual void Select(bool select = TRUE, wxDC* dc = NULL);
268 virtual void SetHighlight(bool hi = TRUE, bool recurse = FALSE);
269 inline virtual bool IsHighlighted() const { return m_highlighted; };
270 virtual bool Selected() const;
271 virtual bool AncestorSelected() const;
272 void SetSensitivityFilter(int sens = OP_ALL, bool recursive = FALSE);
273 int GetSensitivityFilter() const { return m_sensitivity; }
274 void SetDraggable(bool drag, bool recursive = FALSE);
275 inline void SetFixedSize(bool x, bool y) { m_fixedWidth = x; m_fixedHeight = y; };
276 inline void GetFixedSize(bool *x, bool *y) const { *x = m_fixedWidth; *y = m_fixedHeight; };
277 inline bool GetFixedWidth() const { return m_fixedWidth; }
278 inline bool GetFixedHeight() const { return m_fixedHeight; }
279 inline void SetSpaceAttachments(bool sp) { m_spaceAttachments = sp; };
280 inline bool GetSpaceAttachments() const { return m_spaceAttachments; };
281 void SetShadowMode(int mode, bool redraw = FALSE);
282 inline int GetShadowMode() const { return m_shadowMode; }
283 virtual bool HitTest(double x, double y, int *attachment, double *distance);
284 inline void SetCentreResize(bool cr) { m_centreResize = cr; }
285 inline bool GetCentreResize() const { return m_centreResize; }
286 inline void SetMaintainAspectRatio(bool ar) { m_maintainAspectRatio = ar; }
287 inline bool GetMaintainAspectRatio() const { return m_maintainAspectRatio; }
288 inline wxList& GetLines() const { return (wxList&) m_lines; }
289 inline void SetDisableLabel(bool flag) { m_disableLabel = flag; }
290 inline bool GetDisableLabel() const { return m_disableLabel; }
291 inline void SetAttachmentMode(int mode) { m_attachmentMode = mode; }
292 inline int GetAttachmentMode() const { return m_attachmentMode; }
293 inline void SetId(long i) { m_id = i; }
294 inline long GetId() const { return m_id; }
295
296 void SetPen(wxPen *pen);
297 void SetBrush(wxBrush *brush);
1fc25a89
JS
298
299 virtual void Show(bool show);
300 virtual bool IsShown() const { return m_visible; }
301 virtual void Move(wxDC& dc, double x1, double y1, bool display = TRUE);
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
308 virtual void SetSize(double x, double y, bool recursive = TRUE);
309 virtual void SetAttachmentSize(double x, double y);
310 void Attach(wxShapeCanvas *can);
311 void Detach();
312
313 inline virtual bool Constrain() { return FALSE; } ;
314
315 void AddLine(wxLineShape *line, wxShape *other,
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
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;
b9ac87bc 343 virtual inline int GetNumberOfTextRegions() const { return m_regions.GetCount(); }
1fc25a89
JS
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.
9e053640 357 virtual void NameRegions(const wxString& parentName = wxEmptyString);
1fc25a89
JS
358
359 // Get list of regions
360 inline wxList& GetRegions() const { return (wxList&) m_regions; }
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
2b5f62a0 380#if wxUSE_PROLOGIO
1fc25a89
JS
381 // I/O
382 virtual void WriteAttributes(wxExpr *clause);
383 virtual void ReadAttributes(wxExpr *clause);
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
391 // Attachment code
392 virtual bool GetAttachmentPosition(int attachment, double *x, double *y,
393 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
394 virtual int GetNumberOfAttachments() const;
395 virtual bool AttachmentIsValid(int attachment) const;
396
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
403 // Assuming the attachment lies along a vertical or horizontal line,
404 // calculate the position on that point.
405 virtual wxRealPoint CalcSimpleAttachment(const wxRealPoint& pt1, const wxRealPoint& pt2,
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.
411 virtual bool AttachmentSortTest(int attachmentPoint, const wxRealPoint& pt1, const wxRealPoint& pt2);
412
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
416 virtual bool MoveLineToNewAttachment(wxDC& dc, wxLineShape *to_move,
417 double x, double y);
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
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
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
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
490 // Creates a copy of this shape.
491 wxShape *CreateNewCopy(bool resetMapping = TRUE, bool recompute = TRUE);
492
493 // Does the copying for this object
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);
499
500 // Rotate about the given axis by the given amount in radians.
501 virtual void Rotate(double x, double y, double theta);
502 virtual inline double GetRotation() const { return m_rotation; }
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
67d54b58
RD
512 // Return pen or brush of the right colour for the background
513 wxPen GetBackgroundPen();
514 wxBrush GetBackgroundBrush();
515
516
1fc25a89
JS
517 protected:
518 wxShapeEvtHandler* m_eventHandler;
519 bool m_formatted;
520 double m_xpos, m_ypos;
521 wxPen* m_pen;
522 wxBrush* m_brush;
523 wxFont* m_font;
524 wxColour* m_textColour;
525 wxString m_textColourName;
526 wxShapeCanvas* m_canvas;
527 wxList m_lines;
528 wxList m_text;
529 wxList m_controlPoints;
530 wxList m_regions;
531 wxList m_attachmentPoints;
532 bool m_visible;
533 bool m_disableLabel;
534 long m_id;
535 bool m_selected;
536 bool m_highlighted; // Different from selected: user-defined highlighting,
537 // e.g. thick border.
538 double m_rotation;
539 int m_sensitivity;
540 bool m_draggable;
541 int m_attachmentMode; // 0 for no attachments, 1 if using normal attachments,
542 // 2 for branching attachments
543 bool m_spaceAttachments; // TRUE if lines at one side should be spaced
544 bool m_fixedWidth;
545 bool m_fixedHeight;
546 bool m_centreResize; // Default is to resize keeping the centre constant (TRUE)
547 bool m_drawHandles; // Don't draw handles if FALSE, usually TRUE
548 wxList m_children; // In case it's composite
549 wxShape* m_parent; // In case it's a child
550 int m_formatMode;
551 int m_shadowMode;
552 wxBrush* m_shadowBrush;
553 int m_shadowOffsetX;
554 int m_shadowOffsetY;
555 int m_textMarginX; // Gap between text and border
556 int m_textMarginY;
557 wxString m_regionName;
558 bool m_maintainAspectRatio;
559 int m_branchNeckLength;
560 int m_branchStemLength;
561 int m_branchSpacing;
562 long m_branchStyle;
563};
564
5f331691 565class WXDLLIMPEXP_OGL wxPolygonShape: public wxShape
1fc25a89
JS
566{
567 DECLARE_DYNAMIC_CLASS(wxPolygonShape)
568 public:
569 wxPolygonShape();
570 ~wxPolygonShape();
571
572 // Takes a list of wxRealPoints; each point is an OFFSET from the centre.
573 // Deletes user's points in destructor.
574 virtual void Create(wxList *points);
575 virtual void ClearPoints();
576
577 void GetBoundingBoxMin(double *w, double *h);
578 void CalculateBoundingBox();
579 bool GetPerimeterPoint(double x1, double y1,
580 double x2, double y2,
581 double *x3, double *y3);
582 bool HitTest(double x, double y, int *attachment, double *distance);
583 void SetSize(double x, double y, bool recursive = TRUE);
584 void OnDraw(wxDC& dc);
585 void OnDrawOutline(wxDC& dc, double x, double y, double w, double h);
586
587 // Control points ('handles') redirect control to the actual shape, to make it easier
588 // to override sizing behaviour.
589 virtual void OnSizingDragLeft(wxControlPoint* pt, bool draw, double x, double y, int keys=0, int attachment = 0);
590 virtual void OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
591 virtual void OnSizingEndDragLeft(wxControlPoint* pt, double x, double y, int keys=0, int attachment = 0);
592
593 // A polygon should have a control point at each vertex,
594 // with the option of moving the control points individually
595 // to change the shape.
596 void MakeControlPoints();
597 void ResetControlPoints();
598
599 // If we've changed the shape, must make the original
600 // points match the working points
601 void UpdateOriginalPoints();
602
603 // Add a control point after the given point
604 virtual void AddPolygonPoint(int pos = 0);
605
606 // Delete a control point
607 virtual void DeletePolygonPoint(int pos = 0);
608
609 // Recalculates the centre of the polygon
610 virtual void CalculatePolygonCentre();
611
2b5f62a0 612#if wxUSE_PROLOGIO
1fc25a89
JS
613 void WriteAttributes(wxExpr *clause);
614 void ReadAttributes(wxExpr *clause);
615#endif
616
617 int GetNumberOfAttachments() const;
618 bool GetAttachmentPosition(int attachment, double *x, double *y,
619 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
0a2c0398 620 bool AttachmentIsValid(int attachment) const;
1fc25a89
JS
621 // Does the copying for this object
622 void Copy(wxShape& copy);
623
624 inline wxList *GetPoints() { return m_points; }
625
626 // Rotate about the given axis by the given amount in radians
627 virtual void Rotate(double x, double y, double theta);
628
629 private:
630 wxList* m_points;
631 wxList* m_originalPoints;
632 double m_boundWidth;
633 double m_boundHeight;
634 double m_originalWidth;
635 double m_originalHeight;
636};
637
5f331691 638class WXDLLIMPEXP_OGL wxRectangleShape: public wxShape
1fc25a89
JS
639{
640 DECLARE_DYNAMIC_CLASS(wxRectangleShape)
641 public:
642 wxRectangleShape(double w = 0.0, double h = 0.0);
643 void GetBoundingBoxMin(double *w, double *h);
644 bool GetPerimeterPoint(double x1, double y1,
645 double x2, double y2,
646 double *x3, double *y3);
647 void OnDraw(wxDC& dc);
648 void SetSize(double x, double y, bool recursive = TRUE);
649 void SetCornerRadius(double rad); // If > 0, rounded corners
650
2b5f62a0 651#if wxUSE_PROLOGIO
1fc25a89
JS
652 void WriteAttributes(wxExpr *clause);
653 void ReadAttributes(wxExpr *clause);
654#endif
655
656 int GetNumberOfAttachments() const;
657 bool GetAttachmentPosition(int attachment, double *x, double *y,
658 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
659 // Does the copying for this object
660 void Copy(wxShape& copy);
661
662 inline double GetWidth() const { return m_width; }
663 inline double GetHeight() const { return m_height; }
664 inline void SetWidth(double w) { m_width = w; }
665 inline void SetHeight(double h) { m_height = h; }
666
667protected:
668 double m_width;
669 double m_height;
670 double m_cornerRadius;
671};
672
5f331691 673class WXDLLIMPEXP_OGL wxTextShape: public wxRectangleShape
1fc25a89
JS
674{
675 DECLARE_DYNAMIC_CLASS(wxTextShape)
676 public:
677 wxTextShape(double width = 0.0, double height = 0.0);
678
679 void OnDraw(wxDC& dc);
680
2b5f62a0
VZ
681#if wxUSE_PROLOGIO
682 void WriteAttributes(wxExpr *clause);
1fc25a89
JS
683#endif
684
685 // Does the copying for this object
686 void Copy(wxShape& copy);
687};
688
5f331691 689class WXDLLIMPEXP_OGL wxEllipseShape: public wxShape
1fc25a89
JS
690{
691 DECLARE_DYNAMIC_CLASS(wxEllipseShape)
692 public:
693 wxEllipseShape(double w = 0.0, double h = 0.0);
694
695 void GetBoundingBoxMin(double *w, double *h);
696 bool GetPerimeterPoint(double x1, double y1,
697 double x2, double y2,
698 double *x3, double *y3);
699
700 void OnDraw(wxDC& dc);
701 void SetSize(double x, double y, bool recursive = TRUE);
702
2b5f62a0 703#if wxUSE_PROLOGIO
1fc25a89
JS
704 void WriteAttributes(wxExpr *clause);
705 void ReadAttributes(wxExpr *clause);
706#endif
707
708 int GetNumberOfAttachments() const;
709 bool GetAttachmentPosition(int attachment, double *x, double *y,
710 int nth = 0, int no_arcs = 1, wxLineShape *line = NULL);
711
712 // Does the copying for this object
713 void Copy(wxShape& copy);
714
715 inline double GetWidth() const { return m_width; }
716 inline double GetHeight() const { return m_height; }
717
718 inline void SetWidth(double w) { m_width = w; }
719 inline void SetHeight(double h) { m_height = h; }
720
721protected:
722 double m_width;
723 double m_height;
724};
725
5f331691 726class WXDLLIMPEXP_OGL wxCircleShape: public wxEllipseShape
1fc25a89
JS
727{
728 DECLARE_DYNAMIC_CLASS(wxCircleShape)
729 public:
730 wxCircleShape(double w = 0.0);
731
732 bool GetPerimeterPoint(double x1, double y1,
733 double x2, double y2,
734 double *x3, double *y3);
735 // Does the copying for this object
736 void Copy(wxShape& copy);
737};
738
739#endif
740 // _OGL_BASIC_H_