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);
45 %include _oglshapes2.i
50 ShapeCanvas = PyShapeCanvas
51 ShapeEvtHandler = PyShapeEvtHandler
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
68 //---------------------------------------------------------------------------
87 CONTROL_POINT_VERTICAL,
88 CONTROL_POINT_HORIZONTAL,
89 CONTROL_POINT_DIAGONAL,
90 CONTROL_POINT_ENDPOINT_TO,
91 CONTROL_POINT_ENDPOINT_FROM,
96 FORMAT_SIZE_TO_CONTENTS,
99 LINE_ALIGNMENT_TO_NEXT_HANDLE,
110 // SHAPE_DIVIDED_RECTANGLE,
112 // SHAPE_CONTROL_POINT,
115 // SHAPE_LABEL_OBJECT,
117 // SHAPE_DIVIDED_OBJECT_CONTROL_POINT,
124 ATTACHMENT_MODE_NONE,
125 ATTACHMENT_MODE_EDGE,
126 ATTACHMENT_MODE_BRANCHING,
127 BRANCHING_ATTACHMENT_NORMAL,
128 BRANCHING_ATTACHMENT_BLOB,
130 gyCONSTRAINT_CENTRED_VERTICALLY,
131 gyCONSTRAINT_CENTRED_HORIZONTALLY,
132 gyCONSTRAINT_CENTRED_BOTH,
133 gyCONSTRAINT_LEFT_OF,
134 gyCONSTRAINT_RIGHT_OF,
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,
150 DIVISION_SIDE_BOTTOM,
156 //---------------------------------------------------------------------------
158 MustHaveApp(wxOGLInitialize);
159 void wxOGLInitialize();
161 MustHaveApp(wxOGLCleanUp);
166 //---------------------------------------------------------------------------
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);
178 int count = PyList_Size(pyList);
179 wxList* list = new wxList;
181 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
182 wxPyEndBlockThreads(blocked);
185 for (int x=0; x<count; x++) {
186 PyObject* pyo = PyList_GetItem(pyList, x);
187 wxObject* wxo = NULL;
189 if ( !wxPyConvertSwigPtr(pyo, (void **)&wxo, className) ) {
191 errmsg.Printf(wxT("Type error, expected list of %s objects"), className);
192 PyErr_SetString(PyExc_TypeError, errmsg.mb_str());
193 wxPyEndBlockThreads(blocked);
198 wxPyEndBlockThreads(blocked);
202 //---------------------------------------------------------------------------
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);
211 int count = PyList_Size(pyList);
212 wxList* list = new wxList;
214 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
215 wxPyEndBlockThreads(blocked);
218 for (int x=0; x<count; x++) {
219 PyObject* pyo = PyList_GetItem(pyList, x);
221 if (PyTuple_Check(pyo)) {
222 PyObject* o1 = PyNumber_Float(PyTuple_GetItem(pyo, 0));
223 PyObject* o2 = PyNumber_Float(PyTuple_GetItem(pyo, 1));
225 double val1 = (o1 ? PyFloat_AsDouble(o1) : 0.0);
226 double val2 = (o2 ? PyFloat_AsDouble(o2) : 0.0);
228 list->Append((wxObject*) new wxRealPoint(val1, val2));
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);
237 list->Append((wxObject*) new wxRealPoint(*wxo));
240 wxPyEndBlockThreads(blocked);
244 //---------------------------------------------------------------------------
246 PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source, bool setThisOwn) {
247 PyObject* target = NULL;
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
253 wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source;
254 wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject();
256 target = data->m_obj;
261 target = wxPyMake_wxObject2(source, setThisOwn, false);
262 if (target != Py_None)
263 ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
268 //---------------------------------------------------------------------------
270 PyObject* wxPy_ConvertRealPointList(wxListBase* listbase) {
271 wxList* list = (wxList*)listbase;
275 wxNode* node = list->GetFirst();
277 wxPyBlock_t blocked = wxPyBeginBlockThreads();
278 pyList = PyList_New(0);
280 wxObj = node->GetData();
281 pyObj = wxPyConstructObject(wxObj, wxT("wxRealPoint"), 0);
282 PyList_Append(pyList, pyObj);
283 node = node->GetNext();
285 wxPyEndBlockThreads(blocked);
289 //---------------------------------------------------------------------------
291 PyObject* wxPy_ConvertShapeList(wxListBase* listbase) {
292 wxList* list = (wxList*)listbase;
296 wxNode* node = list->GetFirst();
298 wxPyBlock_t blocked = wxPyBeginBlockThreads();
299 pyList = PyList_New(0);
301 wxObj = node->GetData();
302 pyObj = wxPyMake_wxShapeEvtHandler((wxShapeEvtHandler*)wxObj, false);
303 PyList_Append(pyList, pyObj);
304 node = node->GetNext();
306 wxPyEndBlockThreads(blocked);
311 //---------------------------------------------------------------------------
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);
329 //---------------------------------------------------------------------------
331 // extern "C" SWIGEXPORT(void) initoglbasicc();
332 // extern "C" SWIGEXPORT(void) initoglshapesc();
333 // extern "C" SWIGEXPORT(void) initoglshapes2c();
334 // extern "C" SWIGEXPORT(void) initoglcanvasc();
342 // initoglshapes2c();
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");
363 //---------------------------------------------------------------------------
364 //---------------------------------------------------------------------------