1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG definitions for the wxWindows Object Graphics Library
7 // Created: 30-June-1999
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
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.)"
18 %module(package="wx", docstring=DOCSTRING) ogl
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "oglhelpers.h"
27 //---------------------------------------------------------------------------
30 %pythoncode { wx = _core }
31 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
35 warnings.warn("This module is deprecated. Please use the wx.lib.ogl package instead.",
36 DeprecationWarning, stacklevel=2)
40 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
42 %include _ogl_rename.i
47 %include _oglshapes2.i
52 ShapeCanvas = PyShapeCanvas
53 ShapeEvtHandler = PyShapeEvtHandler
55 RectangleShape = PyRectangleShape
56 BitmapShape = PyBitmapShape
57 DrawnShape = PyDrawnShape
58 CompositeShape = PyCompositeShape
59 DividedShape = PyDividedShape
60 DivisionShape = PyDivisionShape
61 EllipseShape = PyEllipseShape
62 CircleShape = PyCircleShape
63 LineShape = PyLineShape
64 PolygonShape = PyPolygonShape
65 TextShape = PyTextShape
66 ControlPoint = PyControlPoint
70 //---------------------------------------------------------------------------
89 CONTROL_POINT_VERTICAL,
90 CONTROL_POINT_HORIZONTAL,
91 CONTROL_POINT_DIAGONAL,
92 CONTROL_POINT_ENDPOINT_TO,
93 CONTROL_POINT_ENDPOINT_FROM,
98 FORMAT_SIZE_TO_CONTENTS,
101 LINE_ALIGNMENT_TO_NEXT_HANDLE,
112 // SHAPE_DIVIDED_RECTANGLE,
114 // SHAPE_CONTROL_POINT,
117 // SHAPE_LABEL_OBJECT,
119 // SHAPE_DIVIDED_OBJECT_CONTROL_POINT,
126 ATTACHMENT_MODE_NONE,
127 ATTACHMENT_MODE_EDGE,
128 ATTACHMENT_MODE_BRANCHING,
129 BRANCHING_ATTACHMENT_NORMAL,
130 BRANCHING_ATTACHMENT_BLOB,
132 gyCONSTRAINT_CENTRED_VERTICALLY,
133 gyCONSTRAINT_CENTRED_HORIZONTALLY,
134 gyCONSTRAINT_CENTRED_BOTH,
135 gyCONSTRAINT_LEFT_OF,
136 gyCONSTRAINT_RIGHT_OF,
139 gyCONSTRAINT_ALIGNED_TOP,
140 gyCONSTRAINT_ALIGNED_BOTTOM,
141 gyCONSTRAINT_ALIGNED_LEFT,
142 gyCONSTRAINT_ALIGNED_RIGHT,
143 gyCONSTRAINT_MIDALIGNED_TOP,
144 gyCONSTRAINT_MIDALIGNED_BOTTOM,
145 gyCONSTRAINT_MIDALIGNED_LEFT,
146 gyCONSTRAINT_MIDALIGNED_RIGHT,
152 DIVISION_SIDE_BOTTOM,
158 //---------------------------------------------------------------------------
160 MustHaveApp(wxOGLInitialize);
161 void wxOGLInitialize();
163 MustHaveApp(wxOGLCleanUp);
168 //---------------------------------------------------------------------------
170 // Convert from a Python list to a list of className objects. This one will
171 // work for any class for the VERY generic cases, but beyond that the helper
172 // needs to know more about the type.
173 wxList* wxPy_wxListHelper(PyObject* pyList, const wxChar* className) {
174 wxPyBlock_t blocked = wxPyBeginBlockThreads();
175 if (!PyList_Check(pyList)) {
176 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
177 wxPyEndBlockThreads(blocked);
180 int count = PyList_Size(pyList);
181 wxList* list = new wxList;
183 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
184 wxPyEndBlockThreads(blocked);
187 for (int x=0; x<count; x++) {
188 PyObject* pyo = PyList_GetItem(pyList, x);
189 wxObject* wxo = NULL;
191 if ( !wxPyConvertSwigPtr(pyo, (void **)&wxo, className) ) {
193 errmsg.Printf(wxT("Type error, expected list of %s objects"), className);
194 PyErr_SetString(PyExc_TypeError, errmsg.mb_str());
195 wxPyEndBlockThreads(blocked);
200 wxPyEndBlockThreads(blocked);
204 //---------------------------------------------------------------------------
206 wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) {
207 wxPyBlock_t blocked = wxPyBeginBlockThreads();
208 if (!PyList_Check(pyList)) {
209 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
210 wxPyEndBlockThreads(blocked);
213 int count = PyList_Size(pyList);
214 wxList* list = new wxList;
216 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
217 wxPyEndBlockThreads(blocked);
220 for (int x=0; x<count; x++) {
221 PyObject* pyo = PyList_GetItem(pyList, x);
223 if (PyTuple_Check(pyo)) {
224 PyObject* o1 = PyNumber_Float(PyTuple_GetItem(pyo, 0));
225 PyObject* o2 = PyNumber_Float(PyTuple_GetItem(pyo, 1));
227 double val1 = (o1 ? PyFloat_AsDouble(o1) : 0.0);
228 double val2 = (o2 ? PyFloat_AsDouble(o2) : 0.0);
230 list->Append((wxObject*) new wxRealPoint(val1, val2));
233 wxRealPoint* wxo = NULL;
234 if (wxPyConvertSwigPtr(pyo, (void **)&wxo, wxT("wxRealPoint"))) {
235 PyErr_SetString(PyExc_TypeError, "Type error, expected list of wxRealPoint objects or 2-tuples");
236 wxPyEndBlockThreads(blocked);
239 list->Append((wxObject*) new wxRealPoint(*wxo));
242 wxPyEndBlockThreads(blocked);
246 //---------------------------------------------------------------------------
248 PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source, bool setThisOwn) {
249 PyObject* target = NULL;
251 if (source && wxIsKindOf(source, wxShapeEvtHandler)) {
252 // If it's derived from wxShapeEvtHandler then there may
253 // already be a pointer to a Python object that we can use
255 wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source;
256 wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject();
258 target = data->m_obj;
263 target = wxPyMake_wxObject2(source, setThisOwn, false);
264 if (target != Py_None)
265 ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
270 //---------------------------------------------------------------------------
272 PyObject* wxPy_ConvertRealPointList(wxListBase* listbase) {
273 wxList* list = (wxList*)listbase;
277 wxNode* node = list->GetFirst();
279 wxPyBlock_t blocked = wxPyBeginBlockThreads();
280 pyList = PyList_New(0);
282 wxObj = node->GetData();
283 pyObj = wxPyConstructObject(wxObj, wxT("wxRealPoint"), 0);
284 PyList_Append(pyList, pyObj);
285 node = node->GetNext();
287 wxPyEndBlockThreads(blocked);
291 //---------------------------------------------------------------------------
293 PyObject* wxPy_ConvertShapeList(wxListBase* listbase) {
294 wxList* list = (wxList*)listbase;
298 wxNode* node = list->GetFirst();
300 wxPyBlock_t blocked = wxPyBeginBlockThreads();
301 pyList = PyList_New(0);
303 wxObj = node->GetData();
304 pyObj = wxPyMake_wxShapeEvtHandler((wxShapeEvtHandler*)wxObj, false);
305 PyList_Append(pyList, pyObj);
306 node = node->GetNext();
308 wxPyEndBlockThreads(blocked);
313 //---------------------------------------------------------------------------
315 IMPLEMENT_DYNAMIC_CLASS(wxPyShapeCanvas, wxShapeCanvas);
316 IMPLEMENT_DYNAMIC_CLASS(wxPyShapeEvtHandler, wxShapeEvtHandler);
317 IMPLEMENT_ABSTRACT_CLASS(wxPyShape, wxShape);
318 IMPLEMENT_DYNAMIC_CLASS(wxPyRectangleShape, wxRectangleShape);
319 IMPLEMENT_DYNAMIC_CLASS(wxPyControlPoint, wxControlPoint);
320 IMPLEMENT_DYNAMIC_CLASS(wxPyBitmapShape, wxBitmapShape);
321 IMPLEMENT_DYNAMIC_CLASS(wxPyDrawnShape, wxDrawnShape);
322 IMPLEMENT_DYNAMIC_CLASS(wxPyCompositeShape, wxCompositeShape);
323 IMPLEMENT_DYNAMIC_CLASS(wxPyDividedShape, wxDividedShape);
324 IMPLEMENT_DYNAMIC_CLASS(wxPyDivisionShape, wxDivisionShape);
325 IMPLEMENT_DYNAMIC_CLASS(wxPyEllipseShape, wxEllipseShape);
326 IMPLEMENT_DYNAMIC_CLASS(wxPyCircleShape, wxCircleShape);
327 IMPLEMENT_DYNAMIC_CLASS(wxPyLineShape, wxLineShape);
328 IMPLEMENT_DYNAMIC_CLASS(wxPyPolygonShape, wxPolygonShape);
329 IMPLEMENT_DYNAMIC_CLASS(wxPyTextShape, wxTextShape);
331 //---------------------------------------------------------------------------
333 // extern "C" SWIGEXPORT(void) initoglbasicc();
334 // extern "C" SWIGEXPORT(void) initoglshapesc();
335 // extern "C" SWIGEXPORT(void) initoglshapes2c();
336 // extern "C" SWIGEXPORT(void) initoglcanvasc();
344 // initoglshapes2c();
348 wxPyPtrTypeMap_Add("wxControlPoint", "wxPyControlPoint");
349 wxPyPtrTypeMap_Add("wxShapeCanvas", "wxPyShapeCanvas");
350 wxPyPtrTypeMap_Add("wxShapeEvtHandler", "wxPyShapeEvtHandler");
351 wxPyPtrTypeMap_Add("wxShape", "wxPyShape");
352 wxPyPtrTypeMap_Add("wxRectangleShape", "wxPyRectangleShape");
353 wxPyPtrTypeMap_Add("wxDrawnShape", "wxPyDrawnShape");
354 wxPyPtrTypeMap_Add("wxCompositeShape", "wxPyCompositeShape");
355 wxPyPtrTypeMap_Add("wxDividedShape", "wxPyDividedShape");
356 wxPyPtrTypeMap_Add("wxDivisionShape", "wxPyDivisionShape");
357 wxPyPtrTypeMap_Add("wxEllipseShape", "wxPyEllipseShape");
358 wxPyPtrTypeMap_Add("wxCircleShape", "wxPyCircleShape");
359 wxPyPtrTypeMap_Add("wxLineShape", "wxPyLineShape");
360 wxPyPtrTypeMap_Add("wxPolygonShape", "wxPyPolygonShape");
361 wxPyPtrTypeMap_Add("wxTextShape", "wxPyTextShape");
365 //---------------------------------------------------------------------------
366 //---------------------------------------------------------------------------