]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: misc.i | |
3 | // Purpose: Definitions of miscelaneous functions and classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 7/3/97 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 1998 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
03e9bead | 13 | %module misc |
7bf85405 | 14 | |
03e9bead | 15 | %{ |
7bf85405 | 16 | #include "helpers.h" |
af309447 | 17 | #include <wx/tooltip.h> |
2abc0a0f | 18 | #include <wx/busyinfo.h> |
1e4a197e | 19 | #include <wx/geometry.h> |
7bf85405 RD |
20 | %} |
21 | ||
22 | //---------------------------------------------------------------------- | |
23 | ||
24 | %include typemaps.i | |
25 | %include my_typemaps.i | |
26 | ||
27 | // Import some definitions of other classes, etc. | |
28 | %import _defs.i | |
29 | ||
7bf85405 | 30 | |
137b5242 RD |
31 | //--------------------------------------------------------------------------- |
32 | %{ | |
33 | // Put some wx default wxChar* values into wxStrings. | |
34 | static const wxString wxPyEmptyString(wxT("")); | |
35 | %} | |
bb0054cd | 36 | //--------------------------------------------------------------------------- |
7bf85405 RD |
37 | |
38 | ||
9416aa89 RD |
39 | class wxObject { |
40 | public: | |
41 | ||
42 | %addmethods { | |
c8bc7bb8 | 43 | wxString GetClassName() { |
9416aa89 RD |
44 | return self->GetClassInfo()->GetClassName(); |
45 | } | |
46 | ||
47 | void Destroy() { | |
48 | delete self; | |
49 | } | |
50 | } | |
51 | }; | |
52 | ||
53 | //--------------------------------------------------------------------------- | |
54 | ||
7bf85405 RD |
55 | class wxSize { |
56 | public: | |
af309447 RD |
57 | long x; |
58 | long y; | |
7bf85405 RD |
59 | %name(width) long x; |
60 | %name(height)long y; | |
61 | ||
62 | wxSize(long w=0, long h=0); | |
63 | ~wxSize(); | |
64 | void Set(long w, long h); | |
af309447 RD |
65 | long GetX(); |
66 | long GetY(); | |
bb0054cd RD |
67 | long GetWidth(); |
68 | long GetHeight(); | |
69 | void SetWidth(long w); | |
70 | void SetHeight(long h); | |
7bf85405 | 71 | |
3ef86e32 RD |
72 | void IncTo(const wxSize& sz); |
73 | void DecTo(const wxSize& sz); | |
74 | ||
7bf85405 | 75 | %addmethods { |
af309447 | 76 | PyObject* asTuple() { |
7cdaed0b | 77 | wxPyBeginBlockThreads(); |
7bf85405 RD |
78 | PyObject* tup = PyTuple_New(2); |
79 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
80 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
7cdaed0b | 81 | wxPyEndBlockThreads(); |
7bf85405 RD |
82 | return tup; |
83 | } | |
419c299a | 84 | |
1e4a197e RD |
85 | bool __eq__(PyObject* obj) { |
86 | wxSize tmp; | |
87 | wxSize* ptr = &tmp; | |
88 | if (obj == Py_None) return FALSE; | |
89 | wxPyBLOCK_THREADS(bool success = wxSize_helper(obj, &ptr); PyErr_Clear()); | |
90 | if (! success) return FALSE; | |
91 | return *self == *ptr; | |
419c299a | 92 | } |
1e4a197e RD |
93 | bool __ne__(PyObject* obj) { |
94 | wxSize tmp; | |
95 | wxSize* ptr = &tmp; | |
96 | if (obj == Py_None) return TRUE; | |
97 | wxPyBLOCK_THREADS(bool success = wxSize_helper(obj, &ptr); PyErr_Clear()); | |
98 | if (! success) return TRUE; | |
99 | return *self != *ptr; | |
100 | } | |
101 | ||
7bf85405 | 102 | } |
1b62f00d RD |
103 | |
104 | %pragma(python) addtoclass = " | |
105 | def __str__(self): return str(self.asTuple()) | |
1e4a197e | 106 | def __repr__(self): return 'wxSize'+str(self.asTuple()) |
211a46cf | 107 | def __len__(self): return len(self.asTuple()) |
1b62f00d RD |
108 | def __getitem__(self, index): return self.asTuple()[index] |
109 | def __setitem__(self, index, val): | |
110 | if index == 0: self.width = val | |
111 | elif index == 1: self.height = val | |
112 | else: raise IndexError | |
1e4a197e RD |
113 | def __nonzero__(self): return self.asTuple() != (0,0) |
114 | def __getinitargs__(self): return () | |
115 | def __getstate__(self): return self.asTuple() | |
116 | def __setstate__(self, state): self.Set(*state) | |
1b62f00d | 117 | " |
af309447 | 118 | |
7bf85405 RD |
119 | }; |
120 | ||
121 | //--------------------------------------------------------------------------- | |
122 | ||
123 | class wxRealPoint { | |
124 | public: | |
125 | double x; | |
126 | double y; | |
127 | wxRealPoint(double x=0.0, double y=0.0); | |
128 | ~wxRealPoint(); | |
efc5f224 RD |
129 | |
130 | %addmethods { | |
131 | void Set(double x, double y) { | |
132 | self->x = x; | |
133 | self->y = y; | |
134 | } | |
135 | PyObject* asTuple() { | |
7cdaed0b | 136 | wxPyBeginBlockThreads(); |
efc5f224 RD |
137 | PyObject* tup = PyTuple_New(2); |
138 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x)); | |
139 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y)); | |
7cdaed0b | 140 | wxPyEndBlockThreads(); |
efc5f224 RD |
141 | return tup; |
142 | } | |
c368d904 | 143 | |
1e4a197e RD |
144 | wxRealPoint __add__(const wxRealPoint& p) { |
145 | return *self + p; | |
c368d904 RD |
146 | } |
147 | ||
1e4a197e RD |
148 | wxRealPoint __sub__(const wxRealPoint& p) { |
149 | return *self - p; | |
c368d904 RD |
150 | } |
151 | ||
1e4a197e RD |
152 | bool __eq__(PyObject* obj) { |
153 | wxRealPoint tmp; | |
154 | wxRealPoint* ptr = &tmp; | |
155 | if (obj == Py_None) return FALSE; | |
156 | wxPyBLOCK_THREADS(bool success = wxRealPoint_helper(obj, &ptr); PyErr_Clear()); | |
157 | if (! success) return FALSE; | |
158 | return *self == *ptr; | |
c368d904 | 159 | } |
1e4a197e RD |
160 | bool __ne__(PyObject* obj) { |
161 | wxRealPoint tmp; | |
162 | wxRealPoint* ptr = &tmp; | |
163 | if (obj == Py_None) return TRUE; | |
164 | wxPyBLOCK_THREADS(bool success = wxRealPoint_helper(obj, &ptr); PyErr_Clear()); | |
165 | if (! success) return TRUE; | |
166 | return *self != *ptr; | |
167 | } | |
168 | ||
efc5f224 | 169 | } |
1e4a197e | 170 | |
1b62f00d RD |
171 | %pragma(python) addtoclass = " |
172 | def __str__(self): return str(self.asTuple()) | |
1e4a197e | 173 | def __repr__(self): return 'wxRealPoint'+str(self.asTuple()) |
211a46cf | 174 | def __len__(self): return len(self.asTuple()) |
1b62f00d RD |
175 | def __getitem__(self, index): return self.asTuple()[index] |
176 | def __setitem__(self, index, val): | |
177 | if index == 0: self.width = val | |
178 | elif index == 1: self.height = val | |
179 | else: raise IndexError | |
1e4a197e RD |
180 | def __nonzero__(self): return self.asTuple() != (0.0, 0.0) |
181 | def __getinitargs__(self): return () | |
182 | def __getstate__(self): return self.asTuple() | |
183 | def __setstate__(self, state): self.Set(*state) | |
1b62f00d | 184 | " |
7bf85405 RD |
185 | }; |
186 | ||
efc5f224 | 187 | |
7bf85405 RD |
188 | class wxPoint { |
189 | public: | |
190 | long x; | |
191 | long y; | |
192 | wxPoint(long x=0, long y=0); | |
193 | ~wxPoint(); | |
194 | ||
195 | %addmethods { | |
196 | void Set(long x, long y) { | |
197 | self->x = x; | |
198 | self->y = y; | |
199 | } | |
af309447 | 200 | PyObject* asTuple() { |
7cdaed0b | 201 | wxPyBeginBlockThreads(); |
7bf85405 RD |
202 | PyObject* tup = PyTuple_New(2); |
203 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
204 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
7cdaed0b | 205 | wxPyEndBlockThreads(); |
7bf85405 RD |
206 | return tup; |
207 | } | |
c368d904 | 208 | |
1e4a197e RD |
209 | wxPoint __add__(const wxPoint& p) { |
210 | return *self + p; | |
c368d904 RD |
211 | } |
212 | ||
1e4a197e RD |
213 | wxPoint __sub__(const wxPoint& p) { |
214 | return *self - p; | |
c368d904 RD |
215 | } |
216 | ||
1e4a197e RD |
217 | bool __eq__(PyObject* obj) { |
218 | wxPoint tmp; | |
219 | wxPoint* ptr = &tmp; | |
220 | if (obj == Py_None) return FALSE; | |
221 | wxPyBLOCK_THREADS(bool success = wxPoint_helper(obj, &ptr); PyErr_Clear()); | |
222 | if (! success) return FALSE; | |
223 | return *self == *ptr; | |
224 | } | |
225 | bool __ne__(PyObject* obj) { | |
226 | wxPoint tmp; | |
227 | wxPoint* ptr = &tmp; | |
228 | if (obj == Py_None) return TRUE; | |
229 | wxPyBLOCK_THREADS(bool success = wxPoint_helper(obj, &ptr); PyErr_Clear()); | |
230 | if (! success) return TRUE; | |
231 | return *self != *ptr; | |
c368d904 | 232 | } |
1e4a197e | 233 | |
7bf85405 | 234 | } |
1e4a197e | 235 | |
1b62f00d RD |
236 | %pragma(python) addtoclass = " |
237 | def __str__(self): return str(self.asTuple()) | |
1e4a197e | 238 | def __repr__(self): return 'wxPoint'+str(self.asTuple()) |
211a46cf | 239 | def __len__(self): return len(self.asTuple()) |
1b62f00d RD |
240 | def __getitem__(self, index): return self.asTuple()[index] |
241 | def __setitem__(self, index, val): | |
242 | if index == 0: self.x = val | |
243 | elif index == 1: self.y = val | |
244 | else: raise IndexError | |
1e4a197e RD |
245 | def __nonzero__(self): return self.asTuple() != (0,0) |
246 | def __getinitargs__(self): return () | |
247 | def __getstate__(self): return self.asTuple() | |
248 | def __setstate__(self, state): self.Set(*state) | |
1b62f00d | 249 | " |
7bf85405 RD |
250 | }; |
251 | ||
252 | //--------------------------------------------------------------------------- | |
253 | ||
254 | class wxRect { | |
255 | public: | |
1e4a197e | 256 | wxRect(int x=0, int y=0, int width=0, int height=0); |
eb715945 RD |
257 | // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size); |
258 | ~wxRect(); | |
7bf85405 | 259 | |
eb715945 RD |
260 | int GetX(); |
261 | void SetX(int X); | |
262 | int GetY(); | |
263 | void SetY(int Y); | |
264 | int GetWidth(); | |
265 | void SetWidth(int w); | |
266 | int GetHeight(); | |
267 | void SetHeight(int h); | |
7bf85405 RD |
268 | |
269 | ||
eb715945 RD |
270 | wxPoint GetPosition(); |
271 | wxSize GetSize(); | |
3b5ccda1 RD |
272 | void SetPosition( const wxPoint &p ); |
273 | void SetSize( const wxSize &s ); | |
7bf85405 | 274 | |
eb715945 RD |
275 | int GetLeft(); |
276 | int GetTop(); | |
277 | int GetBottom(); | |
278 | int GetRight(); | |
7bf85405 | 279 | |
eb715945 RD |
280 | void SetLeft(int left); |
281 | void SetRight(int right); | |
282 | void SetTop(int top); | |
283 | void SetBottom(int bottom); | |
284 | ||
1e4a197e | 285 | void Deflate(int dx, int dy); |
f6bcfd97 | 286 | void Inflate(int dx, int dy); |
1e4a197e RD |
287 | %name(InsideXY)bool Inside(int cx, int cy); |
288 | bool Inside(const wxPoint& pt); | |
289 | bool Intersects(const wxRect& rect); | |
290 | %name(OffsetXY) void Offset(int dx, int dy); | |
291 | void Offset(const wxPoint& pt); | |
eb715945 RD |
292 | |
293 | int x, y, width, height; | |
af309447 RD |
294 | |
295 | %addmethods { | |
1e4a197e RD |
296 | void Set(int x=0, int y=0, int width=0, int height=0) { |
297 | self->x = x; | |
298 | self->y = y; | |
299 | self->width = width; | |
300 | self->height = height; | |
301 | } | |
302 | ||
af309447 | 303 | PyObject* asTuple() { |
7cdaed0b | 304 | wxPyBeginBlockThreads(); |
af309447 RD |
305 | PyObject* tup = PyTuple_New(4); |
306 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
307 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
f0261a72 RD |
308 | PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width)); |
309 | PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height)); | |
7cdaed0b | 310 | wxPyEndBlockThreads(); |
af309447 RD |
311 | return tup; |
312 | } | |
f6bcfd97 | 313 | |
1e4a197e RD |
314 | wxRect __add__(const wxRect& rect) { |
315 | return *self + rect; | |
f6bcfd97 BP |
316 | } |
317 | ||
1e4a197e RD |
318 | bool __eq__(PyObject* obj) { |
319 | wxRect tmp; | |
320 | wxRect* ptr = &tmp; | |
321 | if (obj == Py_None) return FALSE; | |
322 | wxPyBLOCK_THREADS(bool success = wxRect_helper(obj, &ptr); PyErr_Clear()); | |
323 | if (! success) return FALSE; | |
324 | return *self == *ptr; | |
325 | } | |
326 | bool __ne__(PyObject* obj) { | |
327 | wxRect tmp; | |
328 | wxRect* ptr = &tmp; | |
329 | if (obj == Py_None) return TRUE; | |
330 | wxPyBLOCK_THREADS(bool success = wxRect_helper(obj, &ptr); PyErr_Clear()); | |
331 | if (! success) return TRUE; | |
332 | return *self != *ptr; | |
f6bcfd97 | 333 | } |
1e4a197e | 334 | |
af309447 | 335 | } |
f6bcfd97 | 336 | |
9b3d3bc4 | 337 | %pragma(python) addtoclass = " |
1b62f00d | 338 | def __str__(self): return str(self.asTuple()) |
1e4a197e | 339 | def __repr__(self): return 'wxRect'+str(self.asTuple()) |
211a46cf | 340 | def __len__(self): return len(self.asTuple()) |
1b62f00d RD |
341 | def __getitem__(self, index): return self.asTuple()[index] |
342 | def __setitem__(self, index, val): | |
343 | if index == 0: self.x = val | |
344 | elif index == 1: self.y = val | |
345 | elif index == 2: self.width = val | |
346 | elif index == 3: self.height = val | |
347 | else: raise IndexError | |
1e4a197e RD |
348 | def __nonzero__(self): return self.asTuple() != (0,0,0,0) |
349 | def __getinitargs__(self): return () | |
350 | def __getstate__(self): return self.asTuple() | |
351 | def __setstate__(self, state): self.Set(*state) | |
1b62f00d | 352 | |
9b3d3bc4 RD |
353 | # override the __getattr__ made by SWIG |
354 | def __getattr__(self, name): | |
355 | d = { | |
356 | 'x' : miscc.wxRect_x_get, | |
357 | 'y' : miscc.wxRect_y_get, | |
358 | 'width' : miscc.wxRect_width_get, | |
359 | 'height' : miscc.wxRect_height_get, | |
360 | 'top' : miscc.wxRect_GetTop, | |
361 | 'bottom' : miscc.wxRect_GetBottom, | |
362 | 'left' : miscc.wxRect_GetLeft, | |
363 | 'right' : miscc.wxRect_GetRight, | |
364 | } | |
365 | try: | |
366 | func = d[name] | |
367 | except KeyError: | |
368 | raise AttributeError,name | |
369 | return func(self) | |
370 | ||
371 | # and also the __setattr__ | |
372 | def __setattr__(self, name, value): | |
373 | d = { | |
374 | 'x' : miscc.wxRect_x_set, | |
375 | 'y' : miscc.wxRect_y_set, | |
376 | 'width' : miscc.wxRect_width_set, | |
377 | 'height' : miscc.wxRect_height_set, | |
378 | 'top' : miscc.wxRect_SetTop, | |
379 | 'bottom' : miscc.wxRect_SetBottom, | |
380 | 'left' : miscc.wxRect_SetLeft, | |
381 | 'right' : miscc.wxRect_SetRight, | |
382 | } | |
383 | try: | |
384 | func = d[name] | |
385 | except KeyError: | |
386 | self.__dict__[name] = value | |
387 | return | |
388 | func(self, value) | |
389 | " | |
390 | ||
7bf85405 RD |
391 | }; |
392 | ||
393 | ||
eb715945 RD |
394 | %inline %{ |
395 | PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) { | |
396 | wxRegion reg1(*r1); | |
397 | wxRegion reg2(*r2); | |
398 | wxRect dest(0,0,0,0); | |
399 | PyObject* obj; | |
400 | ||
401 | reg1.Intersect(reg2); | |
402 | dest = reg1.GetBox(); | |
403 | ||
404 | if (dest != wxRect(0,0,0,0)) { | |
4268f798 | 405 | wxPyBeginBlockThreads(); |
eb715945 | 406 | wxRect* newRect = new wxRect(dest); |
1e4a197e | 407 | obj = wxPyConstructObject((void*)newRect, wxT("wxRect")); |
de20db99 RD |
408 | PyObject* one = PyInt_FromLong(1); |
409 | PyObject_SetAttrString(obj, "thisown", one); | |
410 | Py_DECREF(one); | |
4268f798 | 411 | wxPyEndBlockThreads(); |
eb715945 RD |
412 | return obj; |
413 | } | |
414 | Py_INCREF(Py_None); | |
415 | return Py_None; | |
416 | } | |
417 | %} | |
7bf85405 | 418 | |
7bf85405 | 419 | |
1e4a197e RD |
420 | |
421 | //--------------------------------------------------------------------------- | |
422 | // wxPoint2Ds represent a point or a vector in a 2d coordinate system | |
423 | ||
424 | class wxPoint2DDouble | |
425 | { | |
426 | public: | |
427 | double m_x; | |
428 | double m_y; | |
429 | ||
430 | %name(x)double m_x; | |
431 | %name(y)double m_y; | |
432 | ||
433 | wxPoint2DDouble( double x=0 , double y=0 ); | |
434 | %name(wxPoint2DDoubleCopy)wxPoint2DDouble( const wxPoint2DDouble &pt ); | |
435 | %name(wxPoint2DDoubleFromPoint)wxPoint2DDouble( const wxPoint &pt ); | |
436 | ||
437 | // two different conversions to integers, floor and rounding | |
438 | void GetFloor( int* OUTPUT , int* OUTPUT ) const; | |
439 | void GetRounded( int* OUTPUT , int* OUTPUT ) const; | |
440 | ||
441 | double GetVectorLength() const; | |
442 | double GetVectorAngle() const ; | |
443 | void SetVectorLength( double length ); | |
444 | void SetVectorAngle( double degrees ); | |
445 | // LinkError: void SetPolarCoordinates( double angle , double length ); | |
446 | // LinkError: void Normalize(); | |
447 | %pragma(python) addtoclass = " | |
448 | def SetPolarCoordinates(self, angle, length): | |
449 | self.SetVectorLength(length) | |
450 | self.SetVectorAngle(angle) | |
451 | def Normalize(self): | |
452 | self.SetVectorLength(1.0) | |
453 | " | |
454 | ||
455 | double GetDistance( const wxPoint2DDouble &pt ) const; | |
456 | double GetDistanceSquare( const wxPoint2DDouble &pt ) const; | |
457 | double GetDotProduct( const wxPoint2DDouble &vec ) const; | |
458 | double GetCrossProduct( const wxPoint2DDouble &vec ) const; | |
459 | ||
460 | %addmethods { | |
461 | void Set( double x=0 , double y=0 ) { | |
462 | self->m_x = x; | |
463 | self->m_y = y; | |
464 | } | |
465 | ||
466 | // the reflection of this point | |
467 | wxPoint2DDouble __neg__() { return -(*self); } | |
468 | ||
469 | wxPoint2DDouble& __iadd__(const wxPoint2DDouble& pt) { return (*self) += pt; } | |
470 | wxPoint2DDouble& __isub__(const wxPoint2DDouble& pt) { return (*self) -= pt; } | |
471 | wxPoint2DDouble& __imul__(const wxPoint2DDouble& pt) { return (*self) *= pt; } | |
472 | wxPoint2DDouble& __idiv__(const wxPoint2DDouble& pt) { return (*self) /= pt; } | |
473 | ||
474 | // TODO: | |
475 | //wxPoint2DDouble& operator*=(double n); | |
476 | //wxPoint2DDouble& operator*=(int n); | |
477 | //wxPoint2DDouble& operator/=(double n); | |
478 | //wxPoint2DDouble& operator/=(int n); | |
479 | ||
480 | bool __eq__(PyObject* obj) { | |
481 | wxPoint2DDouble tmp; | |
482 | wxPoint2DDouble* ptr = &tmp; | |
483 | if (obj == Py_None) return FALSE; | |
484 | wxPyBLOCK_THREADS(bool success = wxPoint2DDouble_helper(obj, &ptr); PyErr_Clear()); | |
485 | if (! success) return FALSE; | |
486 | return *self == *ptr; | |
487 | } | |
488 | bool __ne__(PyObject* obj) { | |
489 | wxPoint2DDouble tmp; | |
490 | wxPoint2DDouble* ptr = &tmp; | |
491 | if (obj == Py_None) return TRUE; | |
492 | wxPyBLOCK_THREADS(bool success = wxPoint2DDouble_helper(obj, &ptr); PyErr_Clear()); | |
493 | if (! success) return TRUE; | |
494 | return *self != *ptr; | |
495 | } | |
496 | ||
497 | ||
498 | PyObject* asTuple() { | |
499 | wxPyBeginBlockThreads(); | |
500 | PyObject* tup = PyTuple_New(2); | |
501 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x)); | |
502 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y)); | |
503 | wxPyEndBlockThreads(); | |
504 | return tup; | |
505 | } | |
506 | } | |
507 | ||
508 | %pragma(python) addtoclass = " | |
509 | def __str__(self): return str(self.asTuple()) | |
510 | def __repr__(self): return 'wxPoint2DDouble'+str(self.asTuple()) | |
511 | def __len__(self): return len(self.asTuple()) | |
512 | def __getitem__(self, index): return self.asTuple()[index] | |
513 | def __setitem__(self, index, val): | |
514 | if index == 0: self.m_x = val | |
515 | elif index == 1: self.m_yt = val | |
516 | else: raise IndexError | |
517 | def __nonzero__(self): return self.asTuple() != (0.0, 0.0) | |
518 | def __getinitargs__(self): return () | |
519 | def __getstate__(self): return self.asTuple() | |
520 | def __setstate__(self, state): self.Set(*state) | |
521 | " | |
522 | }; | |
523 | ||
524 | ||
7bf85405 RD |
525 | //--------------------------------------------------------------------------- |
526 | // Miscellaneous functions | |
527 | ||
cf694132 RD |
528 | long wxNewId(); |
529 | void wxRegisterId(long id); | |
83b18bab | 530 | long wxGetCurrentId(); |
cf694132 | 531 | |
7bf85405 | 532 | void wxBell(); |
7bf85405 | 533 | void wxEndBusyCursor(); |
c368d904 | 534 | |
7bf85405 | 535 | long wxGetElapsedTime(bool resetTimer = TRUE); |
bc29c5e0 | 536 | #ifdef __WXMSW__ |
7bf85405 | 537 | long wxGetFreeMemory(); |
bc29c5e0 | 538 | #endif |
7bf85405 RD |
539 | void wxGetMousePosition(int* OUTPUT, int* OUTPUT); |
540 | bool wxIsBusy(); | |
541 | wxString wxNow(); | |
137b5242 | 542 | bool wxShell(const wxString& command = wxPyEmptyString); |
7bf85405 | 543 | void wxStartTimer(); |
fb5e0af0 | 544 | int wxGetOsVersion(int *OUTPUT, int *OUTPUT); |
c368d904 | 545 | wxString wxGetOsDescription(); |
fb5e0af0 | 546 | |
b7fc54be RD |
547 | enum wxShutdownFlags |
548 | { | |
549 | wxSHUTDOWN_POWEROFF, // power off the computer | |
550 | wxSHUTDOWN_REBOOT // shutdown and reboot | |
551 | }; | |
552 | ||
553 | // Shutdown or reboot the PC | |
554 | bool wxShutdown(wxShutdownFlags wFlags); | |
555 | ||
556 | ||
bb0054cd | 557 | void wxSleep(int secs); |
c368d904 | 558 | void wxUsleep(unsigned long milliseconds); |
7bf85405 | 559 | bool wxYield(); |
83b18bab | 560 | bool wxYieldIfNeeded(); |
bb0054cd | 561 | void wxEnableTopLevelWindows(bool enable); |
7bf85405 | 562 | |
1e4a197e RD |
563 | #ifdef wxUSE_RESOURCES |
564 | inline %{ | |
c8bc7bb8 | 565 | wxString wxGetResource(const wxString& section, const wxString& entry, |
137b5242 | 566 | const wxString& file = wxPyEmptyString) { |
1e4a197e | 567 | wxChar* retval; |
7bf85405 RD |
568 | wxGetResource(section, entry, &retval, file); |
569 | return retval; | |
570 | } | |
571 | %} | |
1e4a197e | 572 | #endif |
7bf85405 | 573 | |
694759cf | 574 | wxString wxStripMenuCodes(const wxString& in); |
7bf85405 | 575 | |
c368d904 RD |
576 | |
577 | wxString wxGetEmailAddress(); | |
578 | wxString wxGetHostName(); | |
579 | wxString wxGetFullHostName(); | |
580 | wxString wxGetUserId(); | |
581 | wxString wxGetUserName(); | |
582 | wxString wxGetHomeDir(); | |
137b5242 | 583 | wxString wxGetUserHome(const wxString& user = wxPyEmptyString); |
c368d904 | 584 | |
0815db26 | 585 | unsigned long wxGetProcessId(); |
f9bd2c1b RD |
586 | |
587 | // When wxApp gets the virtual method magic then enable this. | |
588 | // bool wxHandleFatalExceptions(bool doIt = TRUE); | |
589 | ||
3628e088 RD |
590 | void wxTrap(); |
591 | ||
7bf85405 RD |
592 | //---------------------------------------------------------------------- |
593 | ||
7bf85405 RD |
594 | enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight, |
595 | wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY }; | |
596 | enum wxRelationship { wxUnconstrained = 0, | |
597 | wxAsIs, | |
598 | wxPercentOf, | |
599 | wxAbove, | |
600 | wxBelow, | |
601 | wxLeftOf, | |
602 | wxRightOf, | |
603 | wxSameAs, | |
604 | wxAbsolute }; | |
605 | ||
606 | ||
9416aa89 | 607 | class wxIndividualLayoutConstraint : public wxObject { |
7bf85405 RD |
608 | public: |
609 | // wxIndividualLayoutConstraint(); | |
610 | // ~wxIndividualLayoutConstraint(); | |
611 | ||
612 | void Above(wxWindow *otherWin, int margin=0); | |
613 | void Absolute(int value); | |
08127323 | 614 | void AsIs(); |
7bf85405 | 615 | void Below(wxWindow *otherWin, int margin=0); |
08127323 | 616 | void Unconstrained(); |
7bf85405 RD |
617 | void LeftOf(wxWindow *otherWin, int margin=0); |
618 | void PercentOf(wxWindow *otherWin, wxEdge edge, int percent); | |
619 | void RightOf(wxWindow *otherWin, int margin=0); | |
620 | void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0); | |
621 | void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0); | |
622 | }; | |
623 | ||
624 | ||
9416aa89 | 625 | class wxLayoutConstraints : public wxObject { |
7bf85405 RD |
626 | public: |
627 | wxLayoutConstraints(); | |
628 | ||
629 | %readonly | |
630 | wxIndividualLayoutConstraint bottom; | |
631 | wxIndividualLayoutConstraint centreX; | |
632 | wxIndividualLayoutConstraint centreY; | |
633 | wxIndividualLayoutConstraint height; | |
634 | wxIndividualLayoutConstraint left; | |
635 | wxIndividualLayoutConstraint right; | |
636 | wxIndividualLayoutConstraint top; | |
637 | wxIndividualLayoutConstraint width; | |
638 | %readwrite | |
639 | } | |
640 | ||
641 | ||
b639c3c5 | 642 | |
7bf85405 RD |
643 | //--------------------------------------------------------------------------- |
644 | // Accelerator Entry and Table | |
645 | ||
646 | class wxAcceleratorEntry { | |
647 | public: | |
648 | wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0); | |
2f90df85 | 649 | ~wxAcceleratorEntry(); |
7bf85405 RD |
650 | |
651 | void Set(int flags, int keyCode, int Cmd); | |
652 | int GetFlags(); | |
653 | int GetKeyCode(); | |
654 | int GetCommand(); | |
655 | }; | |
656 | ||
657 | ||
9416aa89 | 658 | class wxAcceleratorTable : public wxObject { |
7bf85405 RD |
659 | public: |
660 | // Can also accept a list of 3-tuples | |
eec92d76 | 661 | wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices); |
2f90df85 | 662 | ~wxAcceleratorTable(); |
7bf85405 RD |
663 | |
664 | }; | |
faf3cb35 | 665 | |
c368d904 | 666 | wxAcceleratorEntry *wxGetAccelFromString(const wxString& label); |
f6bcfd97 BP |
667 | |
668 | %readonly | |
669 | %{ | |
670 | #if 0 // we want to use the definition from the header, not the | |
671 | // one SWIG will generate. | |
672 | %} | |
dd116e73 | 673 | // See also wxPy_ReinitStockObjects in helpers.cpp |
f6bcfd97 BP |
674 | extern wxAcceleratorTable wxNullAcceleratorTable; |
675 | %{ | |
676 | #endif | |
677 | %} | |
678 | %readwrite | |
679 | ||
8bf5d46e | 680 | //--------------------------------------------------------------------------- |
2abc0a0f | 681 | |
9416aa89 | 682 | class wxBusyInfo : public wxObject { |
2abc0a0f RD |
683 | public: |
684 | wxBusyInfo(const wxString& message); | |
685 | ~wxBusyInfo(); | |
686 | }; | |
687 | ||
68bc8549 | 688 | |
8bf5d46e RD |
689 | //--------------------------------------------------------------------------- |
690 | ||
691 | ||
c368d904 | 692 |