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