]> git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/src/misc.i
some fixes and code regeneration
[wxWidgets.git] / utils / wxPython / src / misc.i
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
13 %module misc
14
15 %{
16 #include "helpers.h"
17 #include <wx/resource.h>
18 #include <wx/tooltip.h>
19 #include <wx/busyinfo.h>
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
30
31 //---------------------------------------------------------------------------
32
33
34 class wxSize {
35 public:
36 long x;
37 long y;
38 %name(width) long x;
39 %name(height)long y;
40
41 wxSize(long w=0, long h=0);
42 ~wxSize();
43 void Set(long w, long h);
44 long GetX();
45 long GetY();
46 long GetWidth();
47 long GetHeight();
48 void SetWidth(long w);
49 void SetHeight(long h);
50
51 %addmethods {
52 PyObject* asTuple() {
53 PyObject* tup = PyTuple_New(2);
54 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
55 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
56 return tup;
57 }
58 }
59 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
60 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
61
62 };
63
64 //---------------------------------------------------------------------------
65
66 class wxRealPoint {
67 public:
68 double x;
69 double y;
70 wxRealPoint(double x=0.0, double y=0.0);
71 ~wxRealPoint();
72
73 %addmethods {
74 void Set(double x, double y) {
75 self->x = x;
76 self->y = y;
77 }
78 PyObject* asTuple() {
79 PyObject* tup = PyTuple_New(2);
80 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
81 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
82 return tup;
83 }
84 }
85 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
86 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
87 };
88
89
90 class wxPoint {
91 public:
92 long x;
93 long y;
94 wxPoint(long x=0, long y=0);
95 ~wxPoint();
96
97 %addmethods {
98 void Set(long x, long y) {
99 self->x = x;
100 self->y = y;
101 }
102 PyObject* asTuple() {
103 PyObject* tup = PyTuple_New(2);
104 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
105 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
106 return tup;
107 }
108 }
109 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
110 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
111 };
112
113 //---------------------------------------------------------------------------
114
115 class wxRect {
116 public:
117 wxRect(int x=0, int y=0, int w=0, int h=0);
118 // TODO: do this one too... wxRect(const wxPoint& pos, const wxSize& size);
119 ~wxRect();
120
121 int GetX();
122 void SetX(int X);
123 int GetY();
124 void SetY(int Y);
125 int GetWidth();
126 void SetWidth(int w);
127 int GetHeight();
128 void SetHeight(int h);
129
130
131 wxPoint GetPosition();
132 wxSize GetSize();
133
134 int GetLeft();
135 int GetTop();
136 int GetBottom();
137 int GetRight();
138
139 void SetLeft(int left);
140 void SetRight(int right);
141 void SetTop(int top);
142 void SetBottom(int bottom);
143
144
145 int x, y, width, height;
146
147 %addmethods {
148 PyObject* asTuple() {
149 PyObject* tup = PyTuple_New(4);
150 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
151 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
152 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
153 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
154 return tup;
155 }
156 }
157 %pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
158 %pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
159 %pragma(python) addtoclass = "
160 # override the __getattr__ made by SWIG
161 def __getattr__(self, name):
162 d = {
163 'x' : miscc.wxRect_x_get,
164 'y' : miscc.wxRect_y_get,
165 'width' : miscc.wxRect_width_get,
166 'height' : miscc.wxRect_height_get,
167 'top' : miscc.wxRect_GetTop,
168 'bottom' : miscc.wxRect_GetBottom,
169 'left' : miscc.wxRect_GetLeft,
170 'right' : miscc.wxRect_GetRight,
171 }
172 try:
173 func = d[name]
174 except KeyError:
175 raise AttributeError,name
176 return func(self)
177
178 # and also the __setattr__
179 def __setattr__(self, name, value):
180 d = {
181 'x' : miscc.wxRect_x_set,
182 'y' : miscc.wxRect_y_set,
183 'width' : miscc.wxRect_width_set,
184 'height' : miscc.wxRect_height_set,
185 'top' : miscc.wxRect_SetTop,
186 'bottom' : miscc.wxRect_SetBottom,
187 'left' : miscc.wxRect_SetLeft,
188 'right' : miscc.wxRect_SetRight,
189 }
190 try:
191 func = d[name]
192 except KeyError:
193 self.__dict__[name] = value
194 return
195 func(self, value)
196 "
197
198 };
199
200
201 // %inline %{
202 // bool wxIntersectRect(wxRect* dest, wxRect* r1, wxRect* r2) {
203 // wxRegion reg1(*r1);
204 // wxRegion reg2(*r2);
205 // bool success;
206 // *dest = wxRect(0,0,0,0);
207 // success = reg1.Intersect(reg2);
208 // if (success) {
209 // *dest = reg1.GetBox();
210 // return *dest != wxRect(0,0,0,0);
211 // }
212 // return FALSE;
213 // }
214 // %}
215
216
217 %inline %{
218 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
219 wxRegion reg1(*r1);
220 wxRegion reg2(*r2);
221 wxRect dest(0,0,0,0);
222 PyObject* obj;
223
224 reg1.Intersect(reg2);
225 dest = reg1.GetBox();
226
227 if (dest != wxRect(0,0,0,0)) {
228 bool doSave = wxPyRestoreThread();
229 wxRect* newRect = new wxRect(dest);
230 obj = wxPyConstructObject((void*)newRect, "wxRect");
231 PyObject_SetAttrString(obj, "thisown", PyInt_FromLong(1));
232 wxPySaveThread(doSave);
233 return obj;
234 }
235 Py_INCREF(Py_None);
236 return Py_None;
237 }
238 %}
239
240
241 //---------------------------------------------------------------------------
242 // Miscellaneous functions
243
244 long wxNewId();
245 void wxRegisterId(long id);
246 %name(NewId) long wxNewId();
247 %name(RegisterId) void wxRegisterId(long id);
248
249 void wxBell();
250 void wxDisplaySize(int *OUTPUT, int *OUTPUT);
251 void wxEndBusyCursor();
252 long wxExecute(const wxString& command, int sync = FALSE);
253 long wxGetElapsedTime(bool resetTimer = TRUE);
254 #ifdef __WXMSW__
255 long wxGetFreeMemory();
256 #endif
257 void wxGetMousePosition(int* OUTPUT, int* OUTPUT);
258 bool wxIsBusy();
259 wxString wxNow();
260 bool wxShell(const wxString& command = wxPyEmptyStr);
261 void wxStartTimer();
262 int wxGetOsVersion(int *OUTPUT, int *OUTPUT);
263
264 void wxSleep(int secs);
265 bool wxYield();
266 bool wxSafeYield();
267 void wxEnableTopLevelWindows(bool enable);
268
269 %inline %{
270 char* wxGetResource(char *section, char *entry, char *file = NULL) {
271 char * retval;
272 wxGetResource(section, entry, &retval, file);
273 return retval;
274 }
275 %}
276
277 wxString wxStripMenuCodes(const wxString& in);
278
279 //----------------------------------------------------------------------
280
281 class wxPyTimer {
282 public:
283 wxPyTimer(PyObject* notify);
284 ~wxPyTimer();
285 int GetInterval();
286 bool IsOneShot();
287 void Start(int milliseconds=-1, int oneShot=FALSE);
288 void Stop();
289 };
290
291 //---------------------------------------------------------------------------
292
293 enum wxEdge { wxLeft, wxTop, wxRight, wxBottom, wxWidth, wxHeight,
294 wxCentre, wxCenter = wxCentre, wxCentreX, wxCentreY };
295 enum wxRelationship { wxUnconstrained = 0,
296 wxAsIs,
297 wxPercentOf,
298 wxAbove,
299 wxBelow,
300 wxLeftOf,
301 wxRightOf,
302 wxSameAs,
303 wxAbsolute };
304
305
306 class wxIndividualLayoutConstraint {
307 public:
308 // wxIndividualLayoutConstraint();
309 // ~wxIndividualLayoutConstraint();
310
311 void Above(wxWindow *otherWin, int margin=0);
312 void Absolute(int value);
313 void AsIs();
314 void Below(wxWindow *otherWin, int margin=0);
315 void Unconstrained();
316 void LeftOf(wxWindow *otherWin, int margin=0);
317 void PercentOf(wxWindow *otherWin, wxEdge edge, int percent);
318 void RightOf(wxWindow *otherWin, int margin=0);
319 void SameAs(wxWindow *otherWin, wxEdge edge, int margin=0);
320 void Set(wxRelationship rel, wxWindow *otherWin, wxEdge otherEdge, int value=0, int margin=0);
321 };
322
323
324 class wxLayoutConstraints {
325 public:
326 wxLayoutConstraints();
327
328 %readonly
329 wxIndividualLayoutConstraint bottom;
330 wxIndividualLayoutConstraint centreX;
331 wxIndividualLayoutConstraint centreY;
332 wxIndividualLayoutConstraint height;
333 wxIndividualLayoutConstraint left;
334 wxIndividualLayoutConstraint right;
335 wxIndividualLayoutConstraint top;
336 wxIndividualLayoutConstraint width;
337 %readwrite
338 }
339
340
341 //---------------------------------------------------------------------------
342 // Regions, etc.
343
344 enum wxRegionContain {
345 wxOutRegion, wxPartRegion, wxInRegion
346 };
347
348
349 class wxRegion {
350 public:
351 wxRegion();
352 ~wxRegion();
353
354 void Clear();
355 wxRegionContain Contains(long x, long y);
356 %name(ContainsPoint)wxRegionContain Contains(const wxPoint& pt);
357 %name(ContainsRect)wxRegionContain Contains(const wxRect& rect);
358 %name(ContainsRectDim)wxRegionContain Contains(long x, long y, long w, long h);
359
360 wxRect GetBox();
361
362 bool Intersect(long x, long y, long width, long height);
363 %name(IntersectRect)bool Intersect(const wxRect& rect);
364 %name(IntersectRegion)bool Intersect(const wxRegion& region);
365
366 bool IsEmpty();
367
368 bool Union(long x, long y, long width, long height);
369 %name(UnionRect)bool Union(const wxRect& rect);
370 %name(UnionRegion)bool Union(const wxRegion& region);
371
372 bool Subtract(long x, long y, long width, long height);
373 %name(SubtractRect)bool Subtract(const wxRect& rect);
374 %name(SubtractRegion)bool Subtract(const wxRegion& region);
375
376 bool Xor(long x, long y, long width, long height);
377 %name(XorRect)bool Xor(const wxRect& rect);
378 %name(XorRegion)bool Xor(const wxRegion& region);
379 };
380
381
382
383 class wxRegionIterator {
384 public:
385 wxRegionIterator(const wxRegion& region);
386 ~wxRegionIterator();
387
388 long GetX();
389 long GetY();
390 long GetW();
391 long GetWidth();
392 long GetH();
393 long GetHeight();
394 wxRect GetRect();
395 bool HaveRects();
396 void Reset();
397
398 %addmethods {
399 void Next() {
400 (*self) ++;
401 }
402 };
403 };
404
405
406
407 //---------------------------------------------------------------------------
408 // Accelerator Entry and Table
409
410 class wxAcceleratorEntry {
411 public:
412 wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0);
413 ~wxAcceleratorEntry();
414
415 void Set(int flags, int keyCode, int Cmd);
416 int GetFlags();
417 int GetKeyCode();
418 int GetCommand();
419 };
420
421
422 class wxAcceleratorTable {
423 public:
424 // Can also accept a list of 3-tuples
425 wxAcceleratorTable(int LCOUNT, wxAcceleratorEntry* choices);
426 ~wxAcceleratorTable();
427
428 };
429
430 //---------------------------------------------------------------------------
431
432 class wxBusyInfo {
433 public:
434 wxBusyInfo(const wxString& message);
435 ~wxBusyInfo();
436 };
437
438
439
440 //---------------------------------------------------------------------------
441
442