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 /////////////////////////////////////////////////////////////////////////////
18 #include "oglhelpers.h"
21 //---------------------------------------------------------------------------
24 %include my_typemaps.i
40 %pragma(python) code = "import wx"
42 //---------------------------------------------------------------------------
61 CONTROL_POINT_VERTICAL,
62 CONTROL_POINT_HORIZONTAL,
63 CONTROL_POINT_DIAGONAL,
64 CONTROL_POINT_ENDPOINT_TO,
65 CONTROL_POINT_ENDPOINT_FROM,
70 FORMAT_SIZE_TO_CONTENTS,
73 LINE_ALIGNMENT_TO_NEXT_HANDLE,
84 // SHAPE_DIVIDED_RECTANGLE,
86 // SHAPE_CONTROL_POINT,
89 // SHAPE_LABEL_OBJECT,
91 // SHAPE_DIVIDED_OBJECT_CONTROL_POINT,
100 ATTACHMENT_MODE_BRANCHING,
101 BRANCHING_ATTACHMENT_NORMAL,
102 BRANCHING_ATTACHMENT_BLOB,
104 gyCONSTRAINT_CENTRED_VERTICALLY,
105 gyCONSTRAINT_CENTRED_HORIZONTALLY,
106 gyCONSTRAINT_CENTRED_BOTH,
107 gyCONSTRAINT_LEFT_OF,
108 gyCONSTRAINT_RIGHT_OF,
111 gyCONSTRAINT_ALIGNED_TOP,
112 gyCONSTRAINT_ALIGNED_BOTTOM,
113 gyCONSTRAINT_ALIGNED_LEFT,
114 gyCONSTRAINT_ALIGNED_RIGHT,
115 gyCONSTRAINT_MIDALIGNED_TOP,
116 gyCONSTRAINT_MIDALIGNED_BOTTOM,
117 gyCONSTRAINT_MIDALIGNED_LEFT,
118 gyCONSTRAINT_MIDALIGNED_RIGHT,
124 DIVISION_SIDE_BOTTOM,
130 //---------------------------------------------------------------------------
132 void wxOGLInitialize();
137 //---------------------------------------------------------------------------
138 // This one will work for any class for the VERY generic cases, but beyond that
139 // the helper needs to know more about the type.
141 wxList* wxPy_wxListHelper(PyObject* pyList, char* className) {
142 wxPyBeginBlockThreads();
143 if (!PyList_Check(pyList)) {
144 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
145 wxPyEndBlockThreads();
148 int count = PyList_Size(pyList);
149 wxList* list = new wxList;
151 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
152 wxPyEndBlockThreads();
155 for (int x=0; x<count; x++) {
156 PyObject* pyo = PyList_GetItem(pyList, x);
157 wxObject* wxo = NULL;
159 if (SWIG_GetPtrObj(pyo, (void **)&wxo, className)) {
161 sprintf(errmsg, "Type error, expected list of %s objects", className);
162 PyErr_SetString(PyExc_TypeError, errmsg);
163 wxPyEndBlockThreads();
168 wxPyEndBlockThreads();
172 //---------------------------------------------------------------------------
174 wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) {
175 wxPyBeginBlockThreads();
176 if (!PyList_Check(pyList)) {
177 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
178 wxPyEndBlockThreads();
181 int count = PyList_Size(pyList);
182 wxList* list = new wxList;
184 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
185 wxPyEndBlockThreads();
188 for (int x=0; x<count; x++) {
189 PyObject* pyo = PyList_GetItem(pyList, x);
191 if (PyTuple_Check(pyo)) {
192 PyObject* o1 = PyNumber_Float(PyTuple_GetItem(pyo, 0));
193 PyObject* o2 = PyNumber_Float(PyTuple_GetItem(pyo, 1));
195 double val1 = (o1 ? PyFloat_AsDouble(o1) : 0.0);
196 double val2 = (o2 ? PyFloat_AsDouble(o2) : 0.0);
198 list->Append((wxObject*) new wxRealPoint(val1, val2));
201 wxRealPoint* wxo = NULL;
202 if (SWIG_GetPtrObj(pyo, (void **)&wxo, "_wxRealPoint_p")) {
203 PyErr_SetString(PyExc_TypeError, "Type error, expected list of wxRealPoint objects or 2-tuples");
204 wxPyEndBlockThreads();
207 list->Append((wxObject*) new wxRealPoint(*wxo));
210 wxPyEndBlockThreads();
214 //---------------------------------------------------------------------------
216 PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source) {
217 PyObject* target = NULL;
219 if (source && wxIsKindOf(source, wxShapeEvtHandler)) {
220 // If it's derived from wxShapeEvtHandler then there may
221 // already be a pointer to a Python object that we can use
223 wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source;
224 wxPyOORClientData* data = (wxPyOORClientData*)seh->GetClientObject();
226 target = data->m_obj;
231 target = wxPyMake_wxObject2(source, FALSE);
232 if (target != Py_None)
233 ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyOORClientData(target));
238 //---------------------------------------------------------------------------
240 PyObject* wxPy_ConvertShapeList(wxListBase* listbase, const char* className) {
241 wxList* list = (wxList*)listbase;
245 wxNode* node = list->GetFirst();
247 wxPyBeginBlockThreads();
248 pyList = PyList_New(0);
250 wxObj = node->GetData();
251 pyObj = wxPyMake_wxShapeEvtHandler((wxShapeEvtHandler*)wxObj);
252 PyList_Append(pyList, pyObj);
253 node = node->GetNext();
255 wxPyEndBlockThreads();
260 //---------------------------------------------------------------------------
262 IMPLEMENT_DYNAMIC_CLASS(wxPyShapeCanvas, wxShapeCanvas);
263 IMPLEMENT_DYNAMIC_CLASS(wxPyShapeEvtHandler, wxShapeEvtHandler);
264 IMPLEMENT_ABSTRACT_CLASS(wxPyShape, wxShape);
265 IMPLEMENT_DYNAMIC_CLASS(wxPyRectangleShape, wxRectangleShape);
266 IMPLEMENT_DYNAMIC_CLASS(wxPyControlPoint, wxControlPoint);
267 IMPLEMENT_DYNAMIC_CLASS(wxPyBitmapShape, wxBitmapShape);
268 IMPLEMENT_DYNAMIC_CLASS(wxPyDrawnShape, wxDrawnShape);
269 IMPLEMENT_DYNAMIC_CLASS(wxPyCompositeShape, wxCompositeShape);
270 IMPLEMENT_DYNAMIC_CLASS(wxPyDividedShape, wxDividedShape);
271 IMPLEMENT_DYNAMIC_CLASS(wxPyDivisionShape, wxDivisionShape);
272 IMPLEMENT_DYNAMIC_CLASS(wxPyEllipseShape, wxEllipseShape);
273 IMPLEMENT_DYNAMIC_CLASS(wxPyCircleShape, wxCircleShape);
274 IMPLEMENT_DYNAMIC_CLASS(wxPyLineShape, wxLineShape);
275 IMPLEMENT_DYNAMIC_CLASS(wxPyPolygonShape, wxPolygonShape);
276 IMPLEMENT_DYNAMIC_CLASS(wxPyTextShape, wxTextShape);
278 //---------------------------------------------------------------------------
280 extern "C" SWIGEXPORT(void) initoglbasicc();
281 extern "C" SWIGEXPORT(void) initoglshapesc();
282 extern "C" SWIGEXPORT(void) initoglshapes2c();
283 extern "C" SWIGEXPORT(void) initoglcanvasc();
295 wxPyPtrTypeMap_Add("wxControlPoint", "wxPyControlPoint");
296 wxPyPtrTypeMap_Add("wxShapeCanvas", "wxPyShapeCanvas");
297 wxPyPtrTypeMap_Add("wxShapeEvtHandler", "wxPyShapeEvtHandler");
298 wxPyPtrTypeMap_Add("wxShape", "wxPyShape");
299 wxPyPtrTypeMap_Add("wxRectangleShape", "wxPyRectangleShape");
300 wxPyPtrTypeMap_Add("wxDrawnShape", "wxPyDrawnShape");
301 wxPyPtrTypeMap_Add("wxCompositeShape", "wxPyCompositeShape");
302 wxPyPtrTypeMap_Add("wxDividedShape", "wxPyDividedShape");
303 wxPyPtrTypeMap_Add("wxDivisionShape", "wxPyDivisionShape");
304 wxPyPtrTypeMap_Add("wxEllipseShape", "wxPyEllipseShape");
305 wxPyPtrTypeMap_Add("wxCircleShape", "wxPyCircleShape");
306 wxPyPtrTypeMap_Add("wxLineShape", "wxPyLineShape");
307 wxPyPtrTypeMap_Add("wxPolygonShape", "wxPyPolygonShape");
308 wxPyPtrTypeMap_Add("wxTextShape", "wxPyTextShape");
312 //----------------------------------------------------------------------
313 // And this gets appended to the shadow class file.
314 //----------------------------------------------------------------------
316 %pragma(python) include="_oglextras.py";
318 //---------------------------------------------------------------------------
319 //---------------------------------------------------------------------------