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