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