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