]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/ogl/ogl.i
fix warnings about calling an inline function before it is defined inline
[wxWidgets.git] / wxPython / contrib / ogl / ogl.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ogl.i
3 // Purpose: SWIG definitions for the wxWindows Object Graphics Library
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 30-June-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %define DOCSTRING
14 "The Object Graphics Library provides for simple drawing and manipulation
15 of 2D objects. (This version is deprecated, please use wx.lib.ogl instead.)"
16 %enddef
17
18 %module(package="wx", docstring=DOCSTRING) ogl
19
20 %{
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "oglhelpers.h"
24
25 %}
26
27 //---------------------------------------------------------------------------
28
29 %import windows.i
30 %pythoncode { wx = _core }
31 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
32
33 %pythoncode {
34 import warnings
35 warnings.warn("This module is deprecated. Please use the wx.lib.ogl package instead.",
36 DeprecationWarning, stacklevel=2)
37 }
38
39
40 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
41
42 %include _ogldefs.i
43 %include _oglbasic.i
44 %include _oglshapes.i
45 %include _oglshapes2.i
46 %include _oglcanvas.i
47
48 %pythoncode {
49 %# Aliases
50 ShapeCanvas = PyShapeCanvas
51 ShapeEvtHandler = PyShapeEvtHandler
52 Shape = PyShape
53 RectangleShape = PyRectangleShape
54 BitmapShape = PyBitmapShape
55 DrawnShape = PyDrawnShape
56 CompositeShape = PyCompositeShape
57 DividedShape = PyDividedShape
58 DivisionShape = PyDivisionShape
59 EllipseShape = PyEllipseShape
60 CircleShape = PyCircleShape
61 LineShape = PyLineShape
62 PolygonShape = PyPolygonShape
63 TextShape = PyTextShape
64 ControlPoint = PyControlPoint
65 }
66
67
68 //---------------------------------------------------------------------------
69
70
71 enum {
72 KEY_SHIFT,
73 KEY_CTRL,
74 ARROW_NONE,
75 ARROW_END,
76 ARROW_BOTH,
77 ARROW_MIDDLE,
78 ARROW_START,
79 ARROW_HOLLOW_CIRCLE,
80 ARROW_FILLED_CIRCLE,
81 ARROW_ARROW,
82 ARROW_SINGLE_OBLIQUE,
83 ARROW_DOUBLE_OBLIQUE,
84 ARROW_METAFILE,
85 ARROW_POSITION_END,
86 ARROW_POSITION_START,
87 CONTROL_POINT_VERTICAL,
88 CONTROL_POINT_HORIZONTAL,
89 CONTROL_POINT_DIAGONAL,
90 CONTROL_POINT_ENDPOINT_TO,
91 CONTROL_POINT_ENDPOINT_FROM,
92 CONTROL_POINT_LINE,
93 FORMAT_NONE,
94 FORMAT_CENTRE_HORIZ,
95 FORMAT_CENTRE_VERT,
96 FORMAT_SIZE_TO_CONTENTS,
97 LINE_ALIGNMENT_HORIZ,
98 LINE_ALIGNMENT_VERT,
99 LINE_ALIGNMENT_TO_NEXT_HANDLE,
100 LINE_ALIGNMENT_NONE,
101 SHADOW_NONE,
102 SHADOW_LEFT,
103 SHADOW_RIGHT,
104 // SHAPE_BASIC,
105 // SHAPE_RECTANGLE,
106 // SHAPE_ELLIPSE,
107 // SHAPE_POLYGON,
108 // SHAPE_CIRCLE,
109 // SHAPE_LINE,
110 // SHAPE_DIVIDED_RECTANGLE,
111 // SHAPE_COMPOSITE,
112 // SHAPE_CONTROL_POINT,
113 // SHAPE_DRAWN,
114 // SHAPE_DIVISION,
115 // SHAPE_LABEL_OBJECT,
116 // SHAPE_BITMAP,
117 // SHAPE_DIVIDED_OBJECT_CONTROL_POINT,
118 // OBJECT_REGION,
119 OP_CLICK_LEFT,
120 OP_CLICK_RIGHT,
121 OP_DRAG_LEFT,
122 OP_DRAG_RIGHT,
123 OP_ALL,
124 ATTACHMENT_MODE_NONE,
125 ATTACHMENT_MODE_EDGE,
126 ATTACHMENT_MODE_BRANCHING,
127 BRANCHING_ATTACHMENT_NORMAL,
128 BRANCHING_ATTACHMENT_BLOB,
129
130 gyCONSTRAINT_CENTRED_VERTICALLY,
131 gyCONSTRAINT_CENTRED_HORIZONTALLY,
132 gyCONSTRAINT_CENTRED_BOTH,
133 gyCONSTRAINT_LEFT_OF,
134 gyCONSTRAINT_RIGHT_OF,
135 gyCONSTRAINT_ABOVE,
136 gyCONSTRAINT_BELOW,
137 gyCONSTRAINT_ALIGNED_TOP,
138 gyCONSTRAINT_ALIGNED_BOTTOM,
139 gyCONSTRAINT_ALIGNED_LEFT,
140 gyCONSTRAINT_ALIGNED_RIGHT,
141 gyCONSTRAINT_MIDALIGNED_TOP,
142 gyCONSTRAINT_MIDALIGNED_BOTTOM,
143 gyCONSTRAINT_MIDALIGNED_LEFT,
144 gyCONSTRAINT_MIDALIGNED_RIGHT,
145
146 DIVISION_SIDE_NONE,
147 DIVISION_SIDE_LEFT,
148 DIVISION_SIDE_TOP,
149 DIVISION_SIDE_RIGHT,
150 DIVISION_SIDE_BOTTOM,
151
152 };
153
154
155
156 //---------------------------------------------------------------------------
157
158 MustHaveApp(wxOGLInitialize);
159 void wxOGLInitialize();
160
161 MustHaveApp(wxOGLCleanUp);
162 void wxOGLCleanUp();
163
164
165 %{
166 //---------------------------------------------------------------------------
167
168 // Convert from a Python list to a list of className objects. This one will
169 // work for any class for the VERY generic cases, but beyond that the helper
170 // needs to know more about the type.
171 wxList* wxPy_wxListHelper(PyObject* pyList, const wxChar* className) {
172 wxPyBlock_t blocked = wxPyBeginBlockThreads();
173 if (!PyList_Check(pyList)) {
174 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
175 wxPyEndBlockThreads(blocked);
176 return NULL;
177 }
178 int count = PyList_Size(pyList);
179 wxList* list = new wxList;
180 if (! list) {
181 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
182 wxPyEndBlockThreads(blocked);
183 return NULL;
184 }
185 for (int x=0; x<count; x++) {
186 PyObject* pyo = PyList_GetItem(pyList, x);
187 wxObject* wxo = NULL;
188
189 if ( !wxPyConvertSwigPtr(pyo, (void **)&wxo, className) ) {
190 wxString errmsg;
191 errmsg.Printf(wxT("Type error, expected list of %s objects"), className);
192 PyErr_SetString(PyExc_TypeError, errmsg.mb_str());
193 wxPyEndBlockThreads(blocked);
194 return NULL;
195 }
196 list->Append(wxo);
197 }
198 wxPyEndBlockThreads(blocked);
199 return list;
200 }
201
202 //---------------------------------------------------------------------------
203
204 wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) {
205 wxPyBlock_t blocked = wxPyBeginBlockThreads();
206 if (!PyList_Check(pyList)) {
207 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
208 wxPyEndBlockThreads(blocked);
209 return NULL;
210 }
211 int count = PyList_Size(pyList);
212 wxList* list = new wxList;
213 if (! list) {
214 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
215 wxPyEndBlockThreads(blocked);
216 return NULL;
217 }
218 for (int x=0; x<count; x++) {
219 PyObject* pyo = PyList_GetItem(pyList, x);
220
221 if (PyTuple_Check(pyo)) {
222 PyObject* o1 = PyNumber_Float(PyTuple_GetItem(pyo, 0));
223 PyObject* o2 = PyNumber_Float(PyTuple_GetItem(pyo, 1));
224
225 double val1 = (o1 ? PyFloat_AsDouble(o1) : 0.0);
226 double val2 = (o2 ? PyFloat_AsDouble(o2) : 0.0);
227
228 list->Append((wxObject*) new wxRealPoint(val1, val2));
229
230 } else {
231 wxRealPoint* wxo = NULL;
232 if (wxPyConvertSwigPtr(pyo, (void **)&wxo, wxT("wxRealPoint"))) {
233 PyErr_SetString(PyExc_TypeError, "Type error, expected list of wxRealPoint objects or 2-tuples");
234 wxPyEndBlockThreads(blocked);
235 return NULL;
236 }
237 list->Append((wxObject*) new wxRealPoint(*wxo));
238 }
239 }
240 wxPyEndBlockThreads(blocked);
241 return list;
242 }
243
244 //---------------------------------------------------------------------------
245
246 PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source, bool setThisOwn) {
247 PyObject* target = NULL;
248
249 if (source && wxIsKindOf(source, wxShapeEvtHandler)) {
250 // If it's derived from wxShapeEvtHandler then there may
251 // already be a pointer to a Python object that we can use
252 // in the OOR data.
253 wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source;
254 wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject();
255 if (data) {
256 target = data->m_obj;
257 Py_INCREF(target);
258 }
259 }
260 if (! target) {
261 target = wxPyMake_wxObject2(source, setThisOwn, false);
262 if (target != Py_None)
263 ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
264 }
265 return target;
266 }
267
268 //---------------------------------------------------------------------------
269
270 PyObject* wxPy_ConvertRealPointList(wxListBase* listbase) {
271 wxList* list = (wxList*)listbase;
272 PyObject* pyList;
273 PyObject* pyObj;
274 wxObject* wxObj;
275 wxNode* node = list->GetFirst();
276
277 wxPyBlock_t blocked = wxPyBeginBlockThreads();
278 pyList = PyList_New(0);
279 while (node) {
280 wxObj = node->GetData();
281 pyObj = wxPyConstructObject(wxObj, wxT("wxRealPoint"), 0);
282 PyList_Append(pyList, pyObj);
283 node = node->GetNext();
284 }
285 wxPyEndBlockThreads(blocked);
286 return pyList;
287 }
288
289 //---------------------------------------------------------------------------
290
291 PyObject* wxPy_ConvertShapeList(wxListBase* listbase) {
292 wxList* list = (wxList*)listbase;
293 PyObject* pyList;
294 PyObject* pyObj;
295 wxObject* wxObj;
296 wxNode* node = list->GetFirst();
297
298 wxPyBlock_t blocked = wxPyBeginBlockThreads();
299 pyList = PyList_New(0);
300 while (node) {
301 wxObj = node->GetData();
302 pyObj = wxPyMake_wxShapeEvtHandler((wxShapeEvtHandler*)wxObj, false);
303 PyList_Append(pyList, pyObj);
304 node = node->GetNext();
305 }
306 wxPyEndBlockThreads(blocked);
307 return pyList;
308 }
309
310
311 //---------------------------------------------------------------------------
312
313 IMPLEMENT_DYNAMIC_CLASS(wxPyShapeCanvas, wxShapeCanvas);
314 IMPLEMENT_DYNAMIC_CLASS(wxPyShapeEvtHandler, wxShapeEvtHandler);
315 IMPLEMENT_ABSTRACT_CLASS(wxPyShape, wxShape);
316 IMPLEMENT_DYNAMIC_CLASS(wxPyRectangleShape, wxRectangleShape);
317 IMPLEMENT_DYNAMIC_CLASS(wxPyControlPoint, wxControlPoint);
318 IMPLEMENT_DYNAMIC_CLASS(wxPyBitmapShape, wxBitmapShape);
319 IMPLEMENT_DYNAMIC_CLASS(wxPyDrawnShape, wxDrawnShape);
320 IMPLEMENT_DYNAMIC_CLASS(wxPyCompositeShape, wxCompositeShape);
321 IMPLEMENT_DYNAMIC_CLASS(wxPyDividedShape, wxDividedShape);
322 IMPLEMENT_DYNAMIC_CLASS(wxPyDivisionShape, wxDivisionShape);
323 IMPLEMENT_DYNAMIC_CLASS(wxPyEllipseShape, wxEllipseShape);
324 IMPLEMENT_DYNAMIC_CLASS(wxPyCircleShape, wxCircleShape);
325 IMPLEMENT_DYNAMIC_CLASS(wxPyLineShape, wxLineShape);
326 IMPLEMENT_DYNAMIC_CLASS(wxPyPolygonShape, wxPolygonShape);
327 IMPLEMENT_DYNAMIC_CLASS(wxPyTextShape, wxTextShape);
328
329 //---------------------------------------------------------------------------
330
331 // extern "C" SWIGEXPORT(void) initoglbasicc();
332 // extern "C" SWIGEXPORT(void) initoglshapesc();
333 // extern "C" SWIGEXPORT(void) initoglshapes2c();
334 // extern "C" SWIGEXPORT(void) initoglcanvasc();
335 %}
336
337
338 %init %{
339
340 // initoglbasicc();
341 // initoglshapesc();
342 // initoglshapes2c();
343 // initoglcanvasc();
344
345
346 wxPyPtrTypeMap_Add("wxControlPoint", "wxPyControlPoint");
347 wxPyPtrTypeMap_Add("wxShapeCanvas", "wxPyShapeCanvas");
348 wxPyPtrTypeMap_Add("wxShapeEvtHandler", "wxPyShapeEvtHandler");
349 wxPyPtrTypeMap_Add("wxShape", "wxPyShape");
350 wxPyPtrTypeMap_Add("wxRectangleShape", "wxPyRectangleShape");
351 wxPyPtrTypeMap_Add("wxDrawnShape", "wxPyDrawnShape");
352 wxPyPtrTypeMap_Add("wxCompositeShape", "wxPyCompositeShape");
353 wxPyPtrTypeMap_Add("wxDividedShape", "wxPyDividedShape");
354 wxPyPtrTypeMap_Add("wxDivisionShape", "wxPyDivisionShape");
355 wxPyPtrTypeMap_Add("wxEllipseShape", "wxPyEllipseShape");
356 wxPyPtrTypeMap_Add("wxCircleShape", "wxPyCircleShape");
357 wxPyPtrTypeMap_Add("wxLineShape", "wxPyLineShape");
358 wxPyPtrTypeMap_Add("wxPolygonShape", "wxPyPolygonShape");
359 wxPyPtrTypeMap_Add("wxTextShape", "wxPyTextShape");
360
361 %}
362
363 //---------------------------------------------------------------------------
364 //---------------------------------------------------------------------------