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