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