]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/ogl/ogl.i
fixed deadlock when calling wxPostEvent() from worker thread
[wxWidgets.git] / wxPython / contrib / ogl / ogl.i
CommitLineData
e91a9dfc
RD
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
c8fac2b6
RD
13%define DOCSTRING
14"The Object Graphics Library provides for simple drawing and manipulation
f847103a 15of 2D objects. (This version is deprecated, please use wx.lib.ogl instead.)"
c8fac2b6 16%enddef
b2eb030f
RD
17
18%module(package="wx", docstring=DOCSTRING) ogl
e91a9dfc
RD
19
20%{
d14a1e28
RD
21#include "wx/wxPython/wxPython.h"
22#include "wx/wxPython/pyclasses.h"
e91a9dfc 23#include "oglhelpers.h"
d14a1e28 24
e91a9dfc
RD
25%}
26
27//---------------------------------------------------------------------------
28
e91a9dfc 29%import windows.i
54f9ee45 30%pythoncode { wx = _core }
99109c0f 31%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
e91a9dfc 32
f847103a
RD
33%pythoncode {
34 import warnings
2ef5a0b0 35 warnings.warn("This module is deprecated. Please use the wx.lib.ogl package instead.",
f847103a
RD
36 DeprecationWarning, stacklevel=2)
37}
38
b2dc1044
RD
39
40MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
41
d14a1e28
RD
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
50ShapeCanvas = PyShapeCanvas
51ShapeEvtHandler = PyShapeEvtHandler
52Shape = PyShape
53RectangleShape = PyRectangleShape
54BitmapShape = PyBitmapShape
55DrawnShape = PyDrawnShape
56CompositeShape = PyCompositeShape
57DividedShape = PyDividedShape
58DivisionShape = PyDivisionShape
59EllipseShape = PyEllipseShape
60CircleShape = PyCircleShape
61LineShape = PyLineShape
62PolygonShape = PyPolygonShape
63TextShape = PyTextShape
64ControlPoint = PyControlPoint
65}
e91a9dfc 66
e91a9dfc
RD
67
68//---------------------------------------------------------------------------
69
70
71enum {
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
2ef5a0b0 158MustHaveApp(wxOGLInitialize);
e91a9dfc 159void wxOGLInitialize();
2ef5a0b0
RD
160
161MustHaveApp(wxOGLCleanUp);
e91a9dfc
RD
162void wxOGLCleanUp();
163
164
1e7ecb7b 165%{
e91a9dfc 166//---------------------------------------------------------------------------
1e7ecb7b 167
d14a1e28
RD
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.
171wxList* wxPy_wxListHelper(PyObject* pyList, const wxChar* className) {
6e6b3557 172 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1e7ecb7b
RD
173 if (!PyList_Check(pyList)) {
174 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
da32eb53 175 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
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");
da32eb53 182 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
183 return NULL;
184 }
185 for (int x=0; x<count; x++) {
186 PyObject* pyo = PyList_GetItem(pyList, x);
187 wxObject* wxo = NULL;
188
d14a1e28
RD
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());
da32eb53 193 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
194 return NULL;
195 }
196 list->Append(wxo);
197 }
da32eb53 198 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
199 return list;
200}
201
e91a9dfc 202//---------------------------------------------------------------------------
1e7ecb7b
RD
203
204wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) {
6e6b3557 205 wxPyBlock_t blocked = wxPyBeginBlockThreads();
1e7ecb7b
RD
206 if (!PyList_Check(pyList)) {
207 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
da32eb53 208 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
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");
da32eb53 215 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
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;
d14a1e28 232 if (wxPyConvertSwigPtr(pyo, (void **)&wxo, wxT("wxRealPoint"))) {
1e7ecb7b 233 PyErr_SetString(PyExc_TypeError, "Type error, expected list of wxRealPoint objects or 2-tuples");
da32eb53 234 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
235 return NULL;
236 }
237 list->Append((wxObject*) new wxRealPoint(*wxo));
238 }
239 }
da32eb53 240 wxPyEndBlockThreads(blocked);
1e7ecb7b
RD
241 return list;
242}
243
2f4e9287
RD
244//---------------------------------------------------------------------------
245
6d450e1a 246PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source, bool setThisOwn) {
2f4e9287
RD
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;
4acff284 254 wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject();
2f4e9287
RD
255 if (data) {
256 target = data->m_obj;
257 Py_INCREF(target);
258 }
259 }
260 if (! target) {
6d450e1a 261 target = wxPyMake_wxObject2(source, setThisOwn, false);
2f4e9287 262 if (target != Py_None)
4acff284 263 ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
2f4e9287
RD
264 }
265 return target;
266}
267
c893f25d
RD
268//---------------------------------------------------------------------------
269
d68a6b6d
RD
270PyObject* wxPy_ConvertRealPointList(wxListBase* listbase) {
271 wxList* list = (wxList*)listbase;
272 PyObject* pyList;
273 PyObject* pyObj;
274 wxObject* wxObj;
275 wxNode* node = list->GetFirst();
276
6e6b3557 277 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d68a6b6d
RD
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;
1ce56f78
RD
287}
288
289//---------------------------------------------------------------------------
290
d14a1e28 291PyObject* wxPy_ConvertShapeList(wxListBase* listbase) {
26b8693b 292 wxList* list = (wxList*)listbase;
c893f25d
RD
293 PyObject* pyList;
294 PyObject* pyObj;
295 wxObject* wxObj;
26b8693b 296 wxNode* node = list->GetFirst();
c893f25d 297
6e6b3557 298 wxPyBlock_t blocked = wxPyBeginBlockThreads();
c893f25d
RD
299 pyList = PyList_New(0);
300 while (node) {
26b8693b 301 wxObj = node->GetData();
6d450e1a 302 pyObj = wxPyMake_wxShapeEvtHandler((wxShapeEvtHandler*)wxObj, false);
c893f25d 303 PyList_Append(pyList, pyObj);
26b8693b 304 node = node->GetNext();
c893f25d 305 }
da32eb53 306 wxPyEndBlockThreads(blocked);
c893f25d
RD
307 return pyList;
308}
2f4e9287 309
1e7ecb7b 310
e91a9dfc 311//---------------------------------------------------------------------------
1e7ecb7b 312
9416aa89
RD
313IMPLEMENT_DYNAMIC_CLASS(wxPyShapeCanvas, wxShapeCanvas);
314IMPLEMENT_DYNAMIC_CLASS(wxPyShapeEvtHandler, wxShapeEvtHandler);
315IMPLEMENT_ABSTRACT_CLASS(wxPyShape, wxShape);
316IMPLEMENT_DYNAMIC_CLASS(wxPyRectangleShape, wxRectangleShape);
317IMPLEMENT_DYNAMIC_CLASS(wxPyControlPoint, wxControlPoint);
318IMPLEMENT_DYNAMIC_CLASS(wxPyBitmapShape, wxBitmapShape);
319IMPLEMENT_DYNAMIC_CLASS(wxPyDrawnShape, wxDrawnShape);
320IMPLEMENT_DYNAMIC_CLASS(wxPyCompositeShape, wxCompositeShape);
321IMPLEMENT_DYNAMIC_CLASS(wxPyDividedShape, wxDividedShape);
322IMPLEMENT_DYNAMIC_CLASS(wxPyDivisionShape, wxDivisionShape);
323IMPLEMENT_DYNAMIC_CLASS(wxPyEllipseShape, wxEllipseShape);
324IMPLEMENT_DYNAMIC_CLASS(wxPyCircleShape, wxCircleShape);
325IMPLEMENT_DYNAMIC_CLASS(wxPyLineShape, wxLineShape);
326IMPLEMENT_DYNAMIC_CLASS(wxPyPolygonShape, wxPolygonShape);
327IMPLEMENT_DYNAMIC_CLASS(wxPyTextShape, wxTextShape);
328
329//---------------------------------------------------------------------------
1e7ecb7b 330
d14a1e28
RD
331// extern "C" SWIGEXPORT(void) initoglbasicc();
332// extern "C" SWIGEXPORT(void) initoglshapesc();
333// extern "C" SWIGEXPORT(void) initoglshapes2c();
334// extern "C" SWIGEXPORT(void) initoglcanvasc();
e91a9dfc
RD
335%}
336
389c5527 337
e91a9dfc
RD
338%init %{
339
d14a1e28
RD
340// initoglbasicc();
341// initoglshapesc();
342// initoglshapes2c();
343// initoglcanvasc();
e91a9dfc
RD
344
345
856e03b7
RD
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
e91a9dfc
RD
361%}
362
e91a9dfc
RD
363//---------------------------------------------------------------------------
364//---------------------------------------------------------------------------