]>
git.saurik.com Git - wxWidgets.git/blob - utils/ogl/samples/studio/shapes.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Shape classes
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _STUDIO_SHAPES_H_
13 #define _STUDIO_SHAPES_H_
19 #include <wx/docview.h>
20 #include <wx/string.h>
21 #include <wx/wxexpr.h>
28 class csDiagramDocument
;
31 * Override a few members for this application
34 class csDiagram
: public wxDiagram
36 DECLARE_CLASS(csDiagram
)
38 csDiagram(csDiagramDocument
* doc
) { m_doc
= doc
; }
40 bool OnShapeSave(wxExprDatabase
& db
, wxShape
& shape
, wxExpr
& expr
);
41 bool OnShapeLoad(wxExprDatabase
& db
, wxShape
& shape
, wxExpr
& expr
);
43 inline csDiagramDocument
* GetDocument() const { return m_doc
; }
44 virtual void Redraw(wxDC
& dc
);
47 csDiagramDocument
* m_doc
;
50 class wxDiagramClipboard
: public wxDiagram
52 DECLARE_DYNAMIC_CLASS(wxDiagramClipboard
)
54 wxDiagramClipboard() {}
55 ~wxDiagramClipboard() {}
57 // Copy selection to clipboard
58 bool Copy(wxDiagram
* diagram
);
60 // Copy contents to the diagram, with new ids.
61 // If dc is non-NULL, the pasted shapes will be selected.
62 // The offsets are used to place the shapes at a different position
63 // from the original (for example, for duplicating shapes).
64 bool Paste(wxDiagram
* diagram
, wxDC
* dc
= NULL
,
65 int offsetX
= 0, int offsetY
= 0);
68 // Draw contents to a Windows metafile device context and bitmap, and then copy
69 // to the Windows clipboard.
70 bool CopyToClipboard(double scale
);
75 virtual bool OnStartCopy(wxDiagram
* diagramTo
) { return TRUE
; };
76 virtual bool OnEndCopy(wxDiagram
* diagramTo
) { return TRUE
; };
78 // Override this to e.g. have the shape added through a Do/Undo command system.
79 // By default, we'll just add it directly to the destination diagram, and
80 // select the shape (if dc is non-NULL).
81 virtual bool OnAddShape(wxDiagram
* diagramTo
, wxShape
* newShape
, wxDC
* dc
);
84 bool DoCopy(wxDiagram
* diagramFrom
, wxDiagram
* diagramTo
, bool newIds
,
85 wxDC
* dc
, int offsetX
= 0, int offsetY
= 0);
89 class csDiagramCommand
;
91 class csDiagramClipboard
: public wxDiagramClipboard
93 DECLARE_DYNAMIC_CLASS(csDiagramClipboard
)
95 csDiagramClipboard() { m_currentCmd
= NULL
; }
96 ~csDiagramClipboard() {}
99 bool OnStartCopy(wxDiagram
* diagramTo
);
100 bool OnEndCopy(wxDiagram
* diagramTo
);
102 bool OnAddShape(wxDiagram
* diagramTo
, wxShape
* newShape
, wxDC
* dc
);
105 csDiagramCommand
* m_currentCmd
;
111 * N.B. TODO: these should really all have another constructor
112 * for the ready-initialised shape, with the default one not having any
113 * data. Otherwise when copying a shape, you have to delete the old data
114 * first -> slightly less efficient. The initialised shapes are only required
115 * for the first creation of the shape in the palette, everything else is copied.
118 class csThinRectangleShape
: public wxDrawnShape
120 DECLARE_DYNAMIC_CLASS(csThinRectangleShape
)
122 csThinRectangleShape();
125 class csWideRectangleShape
: public wxDrawnShape
127 DECLARE_DYNAMIC_CLASS(csWideRectangleShape
)
129 csWideRectangleShape();
132 class csTriangleShape
: public wxDrawnShape
134 DECLARE_DYNAMIC_CLASS(csTriangleShape
)
139 class csSemiCircleShape
: public wxDrawnShape
141 DECLARE_DYNAMIC_CLASS(csSemiCircleShape
)
146 class csCircleShape
: public wxCircleShape
148 DECLARE_DYNAMIC_CLASS(csCircleShape
)
153 class csCircleShadowShape
: public wxCircleShape
155 DECLARE_DYNAMIC_CLASS(csCircleShadowShape
)
157 csCircleShadowShape();
160 class csOctagonShape
: public wxPolygonShape
162 DECLARE_DYNAMIC_CLASS(csOctagonShape
)
166 // The attachments are as if it's a rectangle
167 bool GetAttachmentPosition(int attachment
, double *x
, double *y
,
168 int nth
= 0, int no_arcs
= 1, wxLineShape
*line
= NULL
)
169 { return wxShape::GetAttachmentPosition(attachment
, x
, y
, nth
, no_arcs
, line
); }
170 int GetNumberOfAttachments() const
171 { return wxShape::GetNumberOfAttachments(); }
172 bool AttachmentIsValid(int attachment
) const
173 { return wxShape::AttachmentIsValid(attachment
); }
176 // This is a transparent shape for drawing around other shapes.
177 class csGroupShape
: public wxRectangleShape
179 DECLARE_DYNAMIC_CLASS(csGroupShape
)
183 void OnDraw(wxDC
& dc
);
184 // Must modify the hit-test so it doesn't obscure shapes that are inside.
185 bool HitTest(double x
, double y
, int* attachment
, double* distance
);
188 class csTextBoxShape
: public wxRectangleShape
190 DECLARE_DYNAMIC_CLASS(csTextBoxShape
)
195 class csLineShape
: public wxLineShape
197 DECLARE_DYNAMIC_CLASS(csLineShape
)
201 virtual bool OnMoveMiddleControlPoint(wxDC
& dc
, wxLineControlPoint
* lpt
, const wxRealPoint
& pt
);
202 wxLabelShape
* OnCreateLabelShape(wxLineShape
*parent
= NULL
, wxShapeRegion
*region
= NULL
, double w
= 0.0, double h
= 0.0);
206 * Temporary arc label object
209 class csLabelShape
: public wxLabelShape
211 DECLARE_DYNAMIC_CLASS(csLabelShape
)
214 csLabelShape(wxLineShape
*parent
= NULL
, wxShapeRegion
*region
= NULL
, double w
= 0.0, double h
= 0.0);
216 void OnEndDragLeft(double x
, double y
, int keys
=0, int attachment
= 0);
220 * All shape event behaviour is routed through this handler, so we don't
221 * have to derive from each shape class. We plug this in to each shape.
224 class csEvtHandler
: public wxShapeEvtHandler
226 DECLARE_DYNAMIC_CLASS(csEvtHandler
)
228 csEvtHandler(wxShapeEvtHandler
*prev
= NULL
, wxShape
*shape
= NULL
, const wxString
& lab
= "");
231 void OnLeftClick(double x
, double y
, int keys
= 0, int attachment
= 0);
232 void OnRightClick(double x
, double y
, int keys
= 0, int attachment
= 0);
233 void OnBeginDragRight(double x
, double y
, int keys
= 0, int attachment
= 0);
234 void OnDragRight(bool draw
, double x
, double y
, int keys
= 0, int attachment
= 0);
235 void OnEndDragRight(double x
, double y
, int keys
= 0, int attachment
= 0);
236 void OnEndSize(double x
, double y
);
237 void OnDragLeft(bool draw
, double x
, double y
, int keys
= 0, int attachment
= 0);
238 void OnBeginDragLeft(double x
, double y
, int keys
= 0, int attachment
= 0);
239 void OnEndDragLeft(double x
, double y
, int keys
= 0, int attachment
= 0);
240 void OnSizingEndDragLeft(wxControlPoint
* pt
, double x
, double y
, int keys
= 0, int attachment
= 0);
241 void OnChangeAttachment(int attachment
, wxLineShape
* line
, wxList
& ordering
);
243 void OnLeftDoubleClick(double x
, double y
, int keys
= 0, int attachment
= 0);
245 // Copy any event handler data
246 virtual void CopyData(wxShapeEvtHandler
& copy
);
248 // Popup up a property dialog
249 virtual bool EditProperties();
255 extern void studioShapeEditProc(wxMenu
& menu
, wxCommandEvent
& event
);