]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/ogl/ogl.i
Removed obsolete -WE flags from WIN32 BC++ makefiles
[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%{
1e7ecb7b 17#include "export.h"
e91a9dfc 18#include "oglhelpers.h"
e91a9dfc
RD
19%}
20
21//---------------------------------------------------------------------------
22
23%include typemaps.i
24%include my_typemaps.i
25
26%extern wx.i
27%import windows.i
28%extern _defs.i
29%extern misc.i
30%extern gdi.i
31
32%include _ogldefs.i
33
34%import oglbasic.i
35%import oglshapes.i
36%import oglshapes2.i
37%import oglcanvas.i
38
39
e91a9dfc
RD
40%pragma(python) code = "import wx"
41
42//---------------------------------------------------------------------------
43
44
45enum {
46 KEY_SHIFT,
47 KEY_CTRL,
48 ARROW_NONE,
49 ARROW_END,
50 ARROW_BOTH,
51 ARROW_MIDDLE,
52 ARROW_START,
53 ARROW_HOLLOW_CIRCLE,
54 ARROW_FILLED_CIRCLE,
55 ARROW_ARROW,
56 ARROW_SINGLE_OBLIQUE,
57 ARROW_DOUBLE_OBLIQUE,
58 ARROW_METAFILE,
59 ARROW_POSITION_END,
60 ARROW_POSITION_START,
61 CONTROL_POINT_VERTICAL,
62 CONTROL_POINT_HORIZONTAL,
63 CONTROL_POINT_DIAGONAL,
64 CONTROL_POINT_ENDPOINT_TO,
65 CONTROL_POINT_ENDPOINT_FROM,
66 CONTROL_POINT_LINE,
67 FORMAT_NONE,
68 FORMAT_CENTRE_HORIZ,
69 FORMAT_CENTRE_VERT,
70 FORMAT_SIZE_TO_CONTENTS,
71 LINE_ALIGNMENT_HORIZ,
72 LINE_ALIGNMENT_VERT,
73 LINE_ALIGNMENT_TO_NEXT_HANDLE,
74 LINE_ALIGNMENT_NONE,
75 SHADOW_NONE,
76 SHADOW_LEFT,
77 SHADOW_RIGHT,
78// SHAPE_BASIC,
79// SHAPE_RECTANGLE,
80// SHAPE_ELLIPSE,
81// SHAPE_POLYGON,
82// SHAPE_CIRCLE,
83// SHAPE_LINE,
84// SHAPE_DIVIDED_RECTANGLE,
85// SHAPE_COMPOSITE,
86// SHAPE_CONTROL_POINT,
87// SHAPE_DRAWN,
88// SHAPE_DIVISION,
89// SHAPE_LABEL_OBJECT,
90// SHAPE_BITMAP,
91// SHAPE_DIVIDED_OBJECT_CONTROL_POINT,
92// OBJECT_REGION,
93 OP_CLICK_LEFT,
94 OP_CLICK_RIGHT,
95 OP_DRAG_LEFT,
96 OP_DRAG_RIGHT,
97 OP_ALL,
98 ATTACHMENT_MODE_NONE,
99 ATTACHMENT_MODE_EDGE,
100 ATTACHMENT_MODE_BRANCHING,
101 BRANCHING_ATTACHMENT_NORMAL,
102 BRANCHING_ATTACHMENT_BLOB,
103
104 gyCONSTRAINT_CENTRED_VERTICALLY,
105 gyCONSTRAINT_CENTRED_HORIZONTALLY,
106 gyCONSTRAINT_CENTRED_BOTH,
107 gyCONSTRAINT_LEFT_OF,
108 gyCONSTRAINT_RIGHT_OF,
109 gyCONSTRAINT_ABOVE,
110 gyCONSTRAINT_BELOW,
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,
119
120 DIVISION_SIDE_NONE,
121 DIVISION_SIDE_LEFT,
122 DIVISION_SIDE_TOP,
123 DIVISION_SIDE_RIGHT,
124 DIVISION_SIDE_BOTTOM,
125
126};
127
128
129
130//---------------------------------------------------------------------------
131
132void wxOGLInitialize();
133void wxOGLCleanUp();
134
135
1e7ecb7b 136%{
e91a9dfc 137//---------------------------------------------------------------------------
1e7ecb7b
RD
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.
140
141wxList* wxPy_wxListHelper(PyObject* pyList, char* className) {
4268f798 142 wxPyBeginBlockThreads();
1e7ecb7b
RD
143 if (!PyList_Check(pyList)) {
144 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
4268f798 145 wxPyEndBlockThreads();
1e7ecb7b
RD
146 return NULL;
147 }
148 int count = PyList_Size(pyList);
149 wxList* list = new wxList;
150 if (! list) {
151 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
4268f798 152 wxPyEndBlockThreads();
1e7ecb7b
RD
153 return NULL;
154 }
155 for (int x=0; x<count; x++) {
156 PyObject* pyo = PyList_GetItem(pyList, x);
157 wxObject* wxo = NULL;
158
159 if (SWIG_GetPtrObj(pyo, (void **)&wxo, className)) {
160 char errmsg[1024];
161 sprintf(errmsg, "Type error, expected list of %s objects", className);
162 PyErr_SetString(PyExc_TypeError, errmsg);
4268f798 163 wxPyEndBlockThreads();
1e7ecb7b
RD
164 return NULL;
165 }
166 list->Append(wxo);
167 }
4268f798 168 wxPyEndBlockThreads();
1e7ecb7b
RD
169 return list;
170}
171
e91a9dfc 172//---------------------------------------------------------------------------
1e7ecb7b
RD
173
174wxList* wxPy_wxRealPoint_ListHelper(PyObject* pyList) {
4268f798 175 wxPyBeginBlockThreads();
1e7ecb7b
RD
176 if (!PyList_Check(pyList)) {
177 PyErr_SetString(PyExc_TypeError, "Expected a list object.");
4268f798 178 wxPyEndBlockThreads();
1e7ecb7b
RD
179 return NULL;
180 }
181 int count = PyList_Size(pyList);
182 wxList* list = new wxList;
183 if (! list) {
184 PyErr_SetString(PyExc_MemoryError, "Unable to allocate wxList object");
4268f798 185 wxPyEndBlockThreads();
1e7ecb7b
RD
186 return NULL;
187 }
188 for (int x=0; x<count; x++) {
189 PyObject* pyo = PyList_GetItem(pyList, x);
190
191 if (PyTuple_Check(pyo)) {
192 PyObject* o1 = PyNumber_Float(PyTuple_GetItem(pyo, 0));
193 PyObject* o2 = PyNumber_Float(PyTuple_GetItem(pyo, 1));
194
195 double val1 = (o1 ? PyFloat_AsDouble(o1) : 0.0);
196 double val2 = (o2 ? PyFloat_AsDouble(o2) : 0.0);
197
198 list->Append((wxObject*) new wxRealPoint(val1, val2));
199
200 } else {
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");
4268f798 204 wxPyEndBlockThreads();
1e7ecb7b
RD
205 return NULL;
206 }
207 list->Append((wxObject*) new wxRealPoint(*wxo));
208 }
209 }
4268f798 210 wxPyEndBlockThreads();
1e7ecb7b
RD
211 return list;
212}
213
2f4e9287
RD
214//---------------------------------------------------------------------------
215
216PyObject* wxPyMake_wxShapeEvtHandler(wxShapeEvtHandler* source) {
217 PyObject* target = NULL;
218
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
222 // in the OOR data.
223 wxShapeEvtHandler* seh = (wxShapeEvtHandler*)source;
224 wxPyClientData* data = (wxPyClientData*)seh->GetClientObject();
225 if (data) {
226 target = data->m_obj;
227 Py_INCREF(target);
228 }
229 }
230 if (! target) {
231 target = wxPyMake_wxObject2(source, FALSE);
232 if (target != Py_None)
233 ((wxShapeEvtHandler*)source)->SetClientObject(new wxPyClientData(target));
234 }
235 return target;
236}
237
238
1e7ecb7b 239
e91a9dfc 240//---------------------------------------------------------------------------
1e7ecb7b 241
9416aa89
RD
242IMPLEMENT_DYNAMIC_CLASS(wxPyShapeCanvas, wxShapeCanvas);
243IMPLEMENT_DYNAMIC_CLASS(wxPyShapeEvtHandler, wxShapeEvtHandler);
244IMPLEMENT_ABSTRACT_CLASS(wxPyShape, wxShape);
245IMPLEMENT_DYNAMIC_CLASS(wxPyRectangleShape, wxRectangleShape);
246IMPLEMENT_DYNAMIC_CLASS(wxPyControlPoint, wxControlPoint);
247IMPLEMENT_DYNAMIC_CLASS(wxPyBitmapShape, wxBitmapShape);
248IMPLEMENT_DYNAMIC_CLASS(wxPyDrawnShape, wxDrawnShape);
249IMPLEMENT_DYNAMIC_CLASS(wxPyCompositeShape, wxCompositeShape);
250IMPLEMENT_DYNAMIC_CLASS(wxPyDividedShape, wxDividedShape);
251IMPLEMENT_DYNAMIC_CLASS(wxPyDivisionShape, wxDivisionShape);
252IMPLEMENT_DYNAMIC_CLASS(wxPyEllipseShape, wxEllipseShape);
253IMPLEMENT_DYNAMIC_CLASS(wxPyCircleShape, wxCircleShape);
254IMPLEMENT_DYNAMIC_CLASS(wxPyLineShape, wxLineShape);
255IMPLEMENT_DYNAMIC_CLASS(wxPyPolygonShape, wxPolygonShape);
256IMPLEMENT_DYNAMIC_CLASS(wxPyTextShape, wxTextShape);
257
258//---------------------------------------------------------------------------
1e7ecb7b 259
e91a9dfc
RD
260extern "C" SWIGEXPORT(void) initoglbasicc();
261extern "C" SWIGEXPORT(void) initoglshapesc();
262extern "C" SWIGEXPORT(void) initoglshapes2c();
263extern "C" SWIGEXPORT(void) initoglcanvasc();
264%}
265
389c5527 266
e91a9dfc
RD
267%init %{
268
269 initoglbasicc();
270 initoglshapesc();
271 initoglshapes2c();
272 initoglcanvasc();
273
274
e508a2b6
RD
275 wxClassInfo::CleanUpClasses();
276 wxClassInfo::InitializeClasses();
e91a9dfc 277
856e03b7
RD
278 wxPyPtrTypeMap_Add("wxControlPoint", "wxPyControlPoint");
279 wxPyPtrTypeMap_Add("wxShapeCanvas", "wxPyShapeCanvas");
280 wxPyPtrTypeMap_Add("wxShapeEvtHandler", "wxPyShapeEvtHandler");
281 wxPyPtrTypeMap_Add("wxShape", "wxPyShape");
282 wxPyPtrTypeMap_Add("wxRectangleShape", "wxPyRectangleShape");
283 wxPyPtrTypeMap_Add("wxDrawnShape", "wxPyDrawnShape");
284 wxPyPtrTypeMap_Add("wxCompositeShape", "wxPyCompositeShape");
285 wxPyPtrTypeMap_Add("wxDividedShape", "wxPyDividedShape");
286 wxPyPtrTypeMap_Add("wxDivisionShape", "wxPyDivisionShape");
287 wxPyPtrTypeMap_Add("wxEllipseShape", "wxPyEllipseShape");
288 wxPyPtrTypeMap_Add("wxCircleShape", "wxPyCircleShape");
289 wxPyPtrTypeMap_Add("wxLineShape", "wxPyLineShape");
290 wxPyPtrTypeMap_Add("wxPolygonShape", "wxPyPolygonShape");
291 wxPyPtrTypeMap_Add("wxTextShape", "wxPyTextShape");
292
e91a9dfc
RD
293%}
294
295//----------------------------------------------------------------------
296// And this gets appended to the shadow class file.
297//----------------------------------------------------------------------
298
c368d904 299%pragma(python) include="_oglextras.py";
e91a9dfc
RD
300
301//---------------------------------------------------------------------------
302//---------------------------------------------------------------------------