]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/ogl/oglhelpers.h
use WX_DEFINE_ARRAY_PTR for anarray of pointers (fixes Sun CC warning)
[wxWidgets.git] / wxPython / contrib / ogl / oglhelpers.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: oglhelpers.h
3 // Purpose: Some Helper functions to help in data conversions in OGL
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 9-Sept-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef __wxp_ogl_helpers__
14 #define __wxp_ogl_helpers__
15
16
17 #include <wx/ogl/ogl.h>
18 #include <wx/ogl/basicp.h>
19 #include <wx/ogl/constrnt.h>
20 #include <wx/ogl/bmpshape.h>
21 #include <wx/ogl/drawn.h>
22
23
24 //---------------------------------------------------------------------------
25 // Define a macro that will be used in the class definintions below
26
27 #define WXSHAPE_DEC_CALLBACKS() \
28 DEC_PYCALLBACK__ (OnDelete); \
29 DEC_PYCALLBACK__DC (OnDraw); \
30 DEC_PYCALLBACK__DC (OnDrawContents); \
31 DEC_PYCALLBACK__DCBOOL (OnDrawBranches); \
32 DEC_PYCALLBACK__DC (OnMoveLinks); \
33 DEC_PYCALLBACK__DC (OnErase); \
34 DEC_PYCALLBACK__DC (OnEraseContents); \
35 DEC_PYCALLBACK__DC (OnHighlight); \
36 DEC_PYCALLBACK__2DBL2INT (OnLeftClick); \
37 DEC_PYCALLBACK__2DBL2INT (OnLeftDoubleClick); \
38 DEC_PYCALLBACK__2DBL2INT (OnRightClick); \
39 DEC_PYCALLBACK__2DBL (OnSize); \
40 DEC_PYCALLBACK_BOOL_DC4DBLBOOL (OnMovePre); \
41 DEC_PYCALLBACK__DC4DBLBOOL (OnMovePost); \
42 DEC_PYCALLBACK__BOOL2DBL2INT (OnDragLeft); \
43 DEC_PYCALLBACK__2DBL2INT (OnBeginDragLeft); \
44 DEC_PYCALLBACK__2DBL2INT (OnEndDragLeft); \
45 DEC_PYCALLBACK__BOOL2DBL2INT (OnDragRight); \
46 DEC_PYCALLBACK__2DBL2INT (OnBeginDragRight); \
47 DEC_PYCALLBACK__2DBL2INT (OnEndDragRight); \
48 DEC_PYCALLBACK__DC4DBL (OnDrawOutline); \
49 DEC_PYCALLBACK__DC (OnDrawControlPoints); \
50 DEC_PYCALLBACK__DC (OnEraseControlPoints); \
51 DEC_PYCALLBACK__DCBOOL (OnMoveLink); \
52 DEC_PYCALLBACK__WXCPBOOL2DBL2INT(OnSizingDragLeft); \
53 DEC_PYCALLBACK__WXCP2DBL2INT (OnSizingBeginDragLeft);\
54 DEC_PYCALLBACK__WXCP2DBL2INT (OnSizingEndDragLeft); \
55 DEC_PYCALLBACK__2DBL (OnBeginSize); \
56 DEC_PYCALLBACK__2DBL (OnEndSize); \
57 PYPRIVATE
58
59
60 #define WXSHAPE_IMP_CALLBACKS(CLASS, PARENT) \
61 IMP_PYCALLBACK__ (CLASS, PARENT, OnDelete); \
62 IMP_PYCALLBACK__DC (CLASS, PARENT, OnDraw); \
63 IMP_PYCALLBACK__DC (CLASS, PARENT, OnDrawContents); \
64 IMP_PYCALLBACK__DCBOOL (CLASS, PARENT, OnDrawBranches); \
65 IMP_PYCALLBACK__DC (CLASS, PARENT, OnMoveLinks); \
66 IMP_PYCALLBACK__DC (CLASS, PARENT, OnErase); \
67 IMP_PYCALLBACK__DC (CLASS, PARENT, OnEraseContents); \
68 IMP_PYCALLBACK__DC (CLASS, PARENT, OnHighlight); \
69 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnLeftClick); \
70 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnLeftDoubleClick); \
71 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnRightClick); \
72 IMP_PYCALLBACK__2DBL (CLASS, PARENT, OnSize); \
73 IMP_PYCALLBACK_BOOL_DC4DBLBOOL (CLASS, PARENT, OnMovePre); \
74 IMP_PYCALLBACK__DC4DBLBOOL (CLASS, PARENT, OnMovePost); \
75 IMP_PYCALLBACK__BOOL2DBL2INT (CLASS, PARENT, OnDragLeft); \
76 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnBeginDragLeft); \
77 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnEndDragLeft); \
78 IMP_PYCALLBACK__BOOL2DBL2INT (CLASS, PARENT, OnDragRight); \
79 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnBeginDragRight); \
80 IMP_PYCALLBACK__2DBL2INT (CLASS, PARENT, OnEndDragRight); \
81 IMP_PYCALLBACK__DC4DBL (CLASS, PARENT, OnDrawOutline); \
82 IMP_PYCALLBACK__DC (CLASS, PARENT, OnDrawControlPoints); \
83 IMP_PYCALLBACK__DC (CLASS, PARENT, OnEraseControlPoints); \
84 IMP_PYCALLBACK__DCBOOL (CLASS, PARENT, OnMoveLink); \
85 IMP_PYCALLBACK__WXCPBOOL2DBL2INT(CLASS, PARENT, OnSizingDragLeft); \
86 IMP_PYCALLBACK__WXCP2DBL2INT (CLASS, PARENT, OnSizingBeginDragLeft);\
87 IMP_PYCALLBACK__WXCP2DBL2INT (CLASS, PARENT, OnSizingEndDragLeft); \
88 IMP_PYCALLBACK__2DBL (CLASS, PARENT, OnBeginSize); \
89 IMP_PYCALLBACK__2DBL (CLASS, PARENT, OnEndSize)
90
91
92 // This one may be difficult...
93 //PYCALLBACK__??????? (PARENT, OnChangeAttachment);
94
95
96
97 //---------------------------------------------------------------------------
98 // These are prototypes of some helper functions found in ogl.i
99
100 wxList* wxPy_wxListHelper(PyObject* pyList, const wxChar* className);
101 wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList);
102 PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source);
103 PyObject* wxPy_ConvertShapeList(wxListBase* list);
104 PyObject* wxPy_ConvertRealPointList(wxListBase* list);
105
106
107 //---------------------------------------------------------------------------
108 // Classes that derive from the shapes and such, but which know how to turn
109 // virtual callbacks into Python callbacks.
110
111 class wxPyShapeCanvas : public wxShapeCanvas {
112 DECLARE_DYNAMIC_CLASS(wxPyShapeCanvas);
113 public:
114 wxPyShapeCanvas(wxWindow* parent = NULL, wxWindowID id = -1,
115 const wxPoint& pos = wxDefaultPosition,
116 const wxSize& size = wxDefaultSize,
117 long style = wxBORDER,
118 const wxString& name = wxT("shapeCanvas"))
119 : wxShapeCanvas(parent, id, pos, size, style, name) {}
120
121 DEC_PYCALLBACK__2DBLINT(OnBeginDragLeft);
122 DEC_PYCALLBACK__2DBLINT(OnBeginDragRight);
123 DEC_PYCALLBACK__2DBLINT(OnEndDragLeft);
124 DEC_PYCALLBACK__2DBLINT(OnEndDragRight);
125 DEC_PYCALLBACK__BOOL2DBLINT(OnDragLeft);
126 DEC_PYCALLBACK__BOOL2DBLINT(OnDragRight);
127 DEC_PYCALLBACK__2DBLINT(OnLeftClick);
128 DEC_PYCALLBACK__2DBLINT(OnRightClick);
129
130 PYPRIVATE;
131 };
132
133
134
135 class wxPyShapeEvtHandler : public wxShapeEvtHandler {
136 DECLARE_DYNAMIC_CLASS(wxPyShapeEvtHandler);
137 public:
138 wxPyShapeEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL)
139 : wxShapeEvtHandler(prev, shape) {}
140
141 WXSHAPE_DEC_CALLBACKS();
142 };
143
144
145 class wxPyShape : public wxShape {
146 DECLARE_ABSTRACT_CLASS(wxPyShape);
147 public:
148 wxPyShape(wxPyShapeCanvas *can = NULL)
149 : wxShape(can) {}
150
151 virtual void GetBoundingBoxMin(double *width, double *height)
152 {
153 if (width) *width = 0.0;
154 if (height) *height = 0.0;
155 }
156
157 WXSHAPE_DEC_CALLBACKS();
158
159 };
160
161
162 class wxPyRectangleShape : public wxRectangleShape {
163 DECLARE_DYNAMIC_CLASS(wxPyRectangleShape);
164 public:
165 wxPyRectangleShape(double width = 0.0, double height = 0.0)
166 : wxRectangleShape(width, height) {}
167
168 WXSHAPE_DEC_CALLBACKS();
169 };
170
171 class wxPyControlPoint : public wxControlPoint {
172 DECLARE_DYNAMIC_CLASS(wxPyControlPoint);
173 public:
174 wxPyControlPoint(wxPyShapeCanvas *the_canvas = NULL,
175 wxPyShape *object = NULL,
176 double size = 0.0, double the_xoffset = 0.0,
177 double the_yoffset = 0.0, int the_type = 0)
178 : wxControlPoint(the_canvas, object, size,
179 the_xoffset, the_yoffset, the_type) {}
180
181 WXSHAPE_DEC_CALLBACKS();
182 };
183
184
185
186 class wxPyBitmapShape : public wxBitmapShape {
187 DECLARE_DYNAMIC_CLASS(wxPyBitmapShape);
188 public:
189 wxPyBitmapShape() : wxBitmapShape() {}
190
191 WXSHAPE_DEC_CALLBACKS();
192 };
193
194
195
196 class wxPyDrawnShape : public wxDrawnShape {
197 DECLARE_DYNAMIC_CLASS(wxPyDrawnShape);
198 public:
199 wxPyDrawnShape() : wxDrawnShape() {}
200
201 WXSHAPE_DEC_CALLBACKS();
202 };
203
204
205 class wxPyCompositeShape : public wxCompositeShape {
206 DECLARE_DYNAMIC_CLASS(wxPyCompositeShape);
207 public:
208 wxPyCompositeShape() : wxCompositeShape() {}
209
210 WXSHAPE_DEC_CALLBACKS();
211 };
212
213
214 class wxPyDividedShape : public wxDividedShape {
215 DECLARE_DYNAMIC_CLASS(wxPyDividedShape);
216 public:
217 wxPyDividedShape(double width = 0.0, double height = 0.0)
218 : wxDividedShape(width, height) {}
219
220 WXSHAPE_DEC_CALLBACKS();
221 };
222
223
224 class wxPyDivisionShape : public wxDivisionShape {
225 DECLARE_DYNAMIC_CLASS(wxPyDivisionShape);
226 public:
227 wxPyDivisionShape() : wxDivisionShape() {}
228
229 WXSHAPE_DEC_CALLBACKS();
230 };
231
232
233 class wxPyEllipseShape : public wxEllipseShape {
234 DECLARE_DYNAMIC_CLASS(wxPyEllipseShape);
235 public:
236 wxPyEllipseShape(double width = 0.0, double height = 0.0)
237 : wxEllipseShape(width, height) {}
238
239 WXSHAPE_DEC_CALLBACKS();
240 };
241
242
243 class wxPyCircleShape : public wxCircleShape {
244 DECLARE_DYNAMIC_CLASS(wxPyCircleShape);
245 public:
246 wxPyCircleShape(double width = 0.0)
247 : wxCircleShape(width) {}
248
249 WXSHAPE_DEC_CALLBACKS();
250 };
251
252
253 class wxPyLineShape : public wxLineShape {
254 DECLARE_DYNAMIC_CLASS(wxPyLineShape);
255 public:
256 wxPyLineShape() : wxLineShape() {}
257
258 WXSHAPE_DEC_CALLBACKS();
259 };
260
261
262 class wxPyPolygonShape : public wxPolygonShape {
263 DECLARE_DYNAMIC_CLASS(wxPyPolygonShape);
264 public:
265 wxPyPolygonShape() : wxPolygonShape() {}
266
267 WXSHAPE_DEC_CALLBACKS();
268 };
269
270
271 class wxPyTextShape : public wxTextShape {
272 DECLARE_DYNAMIC_CLASS(wxPyTextShape);
273 public:
274 wxPyTextShape(double width = 0.0, double height = 0.0)
275 : wxTextShape(width, height) {}
276
277 WXSHAPE_DEC_CALLBACKS();
278 };
279
280
281
282 //---------------------------------------------------------------------------
283 //---------------------------------------------------------------------------
284 #endif
285
286