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