]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _gdicmn.i | |
3 | // Purpose: SWIG interface for common GDI stuff and misc classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 13-Sept-2003 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2003 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | %newgroup | |
18 | ||
19 | ||
debe38c9 RD |
20 | // Turn off the aquisition of the Global Interpreter Lock for the classes and |
21 | // functions in this file | |
22 | %threadWrapperOff | |
23 | ||
24 | ||
d14a1e28 RD |
25 | enum wxBitmapType |
26 | { | |
27 | wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility! | |
28 | wxBITMAP_TYPE_BMP, | |
d14a1e28 | 29 | wxBITMAP_TYPE_ICO, |
d14a1e28 | 30 | wxBITMAP_TYPE_CUR, |
d14a1e28 RD |
31 | wxBITMAP_TYPE_XBM, |
32 | wxBITMAP_TYPE_XBM_DATA, | |
33 | wxBITMAP_TYPE_XPM, | |
34 | wxBITMAP_TYPE_XPM_DATA, | |
35 | wxBITMAP_TYPE_TIF, | |
d14a1e28 | 36 | wxBITMAP_TYPE_GIF, |
d14a1e28 | 37 | wxBITMAP_TYPE_PNG, |
d14a1e28 | 38 | wxBITMAP_TYPE_JPEG, |
d14a1e28 | 39 | wxBITMAP_TYPE_PNM, |
d14a1e28 | 40 | wxBITMAP_TYPE_PCX, |
d14a1e28 | 41 | wxBITMAP_TYPE_PICT, |
d14a1e28 | 42 | wxBITMAP_TYPE_ICON, |
d14a1e28 RD |
43 | wxBITMAP_TYPE_ANI, |
44 | wxBITMAP_TYPE_IFF, | |
45 | wxBITMAP_TYPE_MACCURSOR, | |
64e8a1f0 RD |
46 | |
47 | // wxBITMAP_TYPE_BMP_RESOURCE, | |
48 | // wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE, | |
49 | // wxBITMAP_TYPE_ICO_RESOURCE, | |
50 | // wxBITMAP_TYPE_CUR_RESOURCE, | |
51 | // wxBITMAP_TYPE_TIF_RESOURCE, | |
52 | // wxBITMAP_TYPE_GIF_RESOURCE, | |
53 | // wxBITMAP_TYPE_PNG_RESOURCE, | |
54 | // wxBITMAP_TYPE_JPEG_RESOURCE, | |
55 | // wxBITMAP_TYPE_PNM_RESOURCE, | |
56 | // wxBITMAP_TYPE_PCX_RESOURCE, | |
57 | // wxBITMAP_TYPE_PICT_RESOURCE, | |
58 | // wxBITMAP_TYPE_ICON_RESOURCE, | |
59 | // wxBITMAP_TYPE_MACCURSOR_RESOURCE, | |
60 | ||
d14a1e28 RD |
61 | wxBITMAP_TYPE_ANY = 50 |
62 | }; | |
63 | ||
64 | // Standard cursors | |
65 | enum wxStockCursor | |
66 | { | |
67 | wxCURSOR_NONE, // should be 0 | |
68 | wxCURSOR_ARROW, | |
69 | wxCURSOR_RIGHT_ARROW, | |
70 | wxCURSOR_BULLSEYE, | |
71 | wxCURSOR_CHAR, | |
72 | wxCURSOR_CROSS, | |
73 | wxCURSOR_HAND, | |
74 | wxCURSOR_IBEAM, | |
75 | wxCURSOR_LEFT_BUTTON, | |
76 | wxCURSOR_MAGNIFIER, | |
77 | wxCURSOR_MIDDLE_BUTTON, | |
78 | wxCURSOR_NO_ENTRY, | |
79 | wxCURSOR_PAINT_BRUSH, | |
80 | wxCURSOR_PENCIL, | |
81 | wxCURSOR_POINT_LEFT, | |
82 | wxCURSOR_POINT_RIGHT, | |
83 | wxCURSOR_QUESTION_ARROW, | |
84 | wxCURSOR_RIGHT_BUTTON, | |
85 | wxCURSOR_SIZENESW, | |
86 | wxCURSOR_SIZENS, | |
87 | wxCURSOR_SIZENWSE, | |
88 | wxCURSOR_SIZEWE, | |
89 | wxCURSOR_SIZING, | |
90 | wxCURSOR_SPRAYCAN, | |
91 | wxCURSOR_WAIT, | |
92 | wxCURSOR_WATCH, | |
93 | wxCURSOR_BLANK, | |
94 | wxCURSOR_DEFAULT, // standard X11 cursor | |
95 | wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow | |
96 | ||
97 | // #ifdef __X__ | |
98 | // // Not yet implemented for Windows | |
99 | // wxCURSOR_CROSS_REVERSE, | |
100 | // wxCURSOR_DOUBLE_ARROW, | |
101 | // wxCURSOR_BASED_ARROW_UP, | |
102 | // wxCURSOR_BASED_ARROW_DOWN, | |
103 | // #endif // X11 | |
104 | ||
105 | wxCURSOR_ARROWWAIT, | |
106 | ||
107 | wxCURSOR_MAX | |
108 | }; | |
109 | ||
110 | %{ | |
111 | #ifndef __WXMAC__ | |
112 | #define wxCURSOR_COPY_ARROW wxCURSOR_ARROW | |
113 | #endif | |
114 | %} | |
115 | ||
116 | //--------------------------------------------------------------------------- | |
117 | %newgroup | |
d14a1e28 | 118 | |
dd9f7fea | 119 | DocStr( wxSize, |
d07d2bc9 | 120 | "wx.Size is a useful data structure used to represent the size of |
bea992c8 RD |
121 | something. It simply contains integer width and height |
122 | properties. In most places in wxPython where a wx.Size is | |
1b8c7ba6 | 123 | expected a (width, height) tuple can be used instead.", ""); |
dd9f7fea | 124 | |
d14a1e28 RD |
125 | class wxSize |
126 | { | |
127 | public: | |
1b8c7ba6 RD |
128 | %Rename(width, int, x); |
129 | %Rename(height,int, y); | |
61c5a8ac RD |
130 | %pythoncode { x = width; y = height } |
131 | ||
dd9f7fea RD |
132 | DocCtorStr( |
133 | wxSize(int w=0, int h=0), | |
d07d2bc9 | 134 | "Creates a size object.", ""); |
dd9f7fea | 135 | |
d14a1e28 RD |
136 | ~wxSize(); |
137 | ||
1fce4e96 RD |
138 | |
139 | %extend { | |
debe38c9 | 140 | //KeepGIL(__eq__); |
1fce4e96 RD |
141 | DocStr(__eq__, "Test for equality of wx.Size objects.", ""); |
142 | bool __eq__(PyObject* other) { | |
143 | wxSize temp, *obj = &temp; | |
144 | if ( other == Py_None ) return false; | |
145 | if ( ! wxSize_helper(other, &obj) ) { | |
146 | PyErr_Clear(); | |
147 | return false; | |
148 | } | |
149 | return self->operator==(*obj); | |
150 | } | |
dd9f7fea | 151 | |
1fce4e96 | 152 | |
debe38c9 | 153 | //KeepGIL(__ne__); |
1fce4e96 RD |
154 | DocStr(__ne__, "Test for inequality of wx.Size objects.", ""); |
155 | bool __ne__(PyObject* other) { | |
156 | wxSize temp, *obj = &temp; | |
157 | if ( other == Py_None ) return true; | |
158 | if ( ! wxSize_helper(other, &obj)) { | |
159 | PyErr_Clear(); | |
160 | return true; | |
161 | } | |
162 | return self->operator!=(*obj); | |
163 | } | |
164 | } | |
d14a1e28 | 165 | |
dd9f7fea RD |
166 | DocDeclStr( |
167 | wxSize, operator+(const wxSize& sz), | |
d07d2bc9 | 168 | "Add sz's proprties to this and return the result.", ""); |
d14a1e28 | 169 | |
dd9f7fea RD |
170 | DocDeclStr( |
171 | wxSize, operator-(const wxSize& sz), | |
d07d2bc9 | 172 | "Subtract sz's properties from this and return the result.", ""); |
d14a1e28 | 173 | |
dd9f7fea RD |
174 | DocDeclStr( |
175 | void, IncTo(const wxSize& sz), | |
d07d2bc9 RD |
176 | "Increments this object so that both of its dimensions are not less |
177 | than the corresponding dimensions of the size.", ""); | |
dd9f7fea RD |
178 | |
179 | DocDeclStr( | |
180 | void, DecTo(const wxSize& sz), | |
d07d2bc9 RD |
181 | "Decrements this object so that both of its dimensions are not greater |
182 | than the corresponding dimensions of the size.", ""); | |
dd9f7fea | 183 | |
f5263701 RD |
184 | |
185 | DocDeclStr( | |
186 | void , IncBy(int dx, int dy), | |
187 | "", ""); | |
188 | ||
189 | ||
190 | DocDeclStr( | |
191 | void , DecBy(int dx, int dy), | |
192 | "", ""); | |
193 | ||
194 | // TODO: handle these overloads too? | |
195 | // void IncBy(const wxSize& sz); | |
196 | // void IncBy(int d); | |
197 | // void DecBy(const wxSize& sz); | |
198 | // void DecBy(int d); | |
6aaca5ba RD |
199 | |
200 | DocDeclStr( | |
201 | void , Scale(float xscale, float yscale), | |
202 | "Scales the dimensions of this object by the given factors.", ""); | |
203 | ||
dd9f7fea RD |
204 | DocDeclStr( |
205 | void, Set(int w, int h), | |
d07d2bc9 | 206 | "Set both width and height.", ""); |
dd9f7fea | 207 | |
d14a1e28 RD |
208 | void SetWidth(int w); |
209 | void SetHeight(int h); | |
210 | int GetWidth() const; | |
211 | int GetHeight() const; | |
212 | ||
93a163f6 RD |
213 | |
214 | DocDeclStr( | |
215 | bool , IsFullySpecified() const, | |
d07d2bc9 | 216 | "Returns True if both components of the size are non-default values.", ""); |
93a163f6 RD |
217 | |
218 | ||
219 | DocDeclStr( | |
220 | void , SetDefaults(const wxSize& size), | |
d07d2bc9 RD |
221 | "Combine this size with the other one replacing the default components |
222 | of this object (i.e. equal to -1) with those of the other.", ""); | |
93a163f6 RD |
223 | |
224 | ||
dd9f7fea RD |
225 | //int GetX() const; |
226 | //int GetY() const; | |
d14a1e28 RD |
227 | |
228 | %extend { | |
dd9f7fea RD |
229 | DocAStr(Get, |
230 | "Get() -> (width,height)", | |
d07d2bc9 | 231 | "Returns the width and height properties as a tuple.", ""); |
dd9f7fea | 232 | PyObject* Get() { |
debe38c9 | 233 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
234 | PyObject* tup = PyTuple_New(2); |
235 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
236 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
debe38c9 | 237 | //wxPyEndBlockThreads(blocked); |
d14a1e28 RD |
238 | return tup; |
239 | } | |
240 | } | |
241 | %pythoncode { | |
d07d2bc9 | 242 | asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead") |
dd9f7fea RD |
243 | def __str__(self): return str(self.Get()) |
244 | def __repr__(self): return 'wx.Size'+str(self.Get()) | |
245 | def __len__(self): return len(self.Get()) | |
246 | def __getitem__(self, index): return self.Get()[index] | |
d14a1e28 RD |
247 | def __setitem__(self, index, val): |
248 | if index == 0: self.width = val | |
249 | elif index == 1: self.height = val | |
250 | else: raise IndexError | |
dd9f7fea | 251 | def __nonzero__(self): return self.Get() != (0,0) |
02376d73 RD |
252 | __safe_for_unpickling__ = True |
253 | def __reduce__(self): return (wx.Size, self.Get()) | |
d14a1e28 RD |
254 | } |
255 | ||
256 | }; | |
257 | ||
258 | //--------------------------------------------------------------------------- | |
259 | %newgroup | |
94d33c49 | 260 | |
dd9f7fea | 261 | DocStr( wxRealPoint, |
d07d2bc9 RD |
262 | "A data structure for representing a point or position with floating |
263 | point x and y properties. In wxPython most places that expect a | |
264 | wx.RealPoint can also accept a (x,y) tuple.", ""); | |
d14a1e28 RD |
265 | class wxRealPoint |
266 | { | |
267 | public: | |
268 | double x; | |
269 | double y; | |
270 | ||
dd9f7fea RD |
271 | DocCtorStr( |
272 | wxRealPoint(double x=0.0, double y=0.0), | |
d07d2bc9 | 273 | "Create a wx.RealPoint object", ""); |
dd9f7fea | 274 | |
d14a1e28 RD |
275 | ~wxRealPoint(); |
276 | ||
1fce4e96 | 277 | %extend { |
debe38c9 | 278 | //KeepGIL(__eq__); |
1fce4e96 RD |
279 | DocStr(__eq__, "Test for equality of wx.RealPoint objects.", ""); |
280 | bool __eq__(PyObject* other) { | |
281 | wxRealPoint temp, *obj = &temp; | |
282 | if ( other == Py_None ) return false; | |
283 | if ( ! wxRealPoint_helper(other, &obj) ) { | |
284 | PyErr_Clear(); | |
285 | return false; | |
286 | } | |
287 | return self->operator==(*obj); | |
288 | } | |
dd9f7fea | 289 | |
1fce4e96 | 290 | |
debe38c9 | 291 | //KeepGIL(__ne__); |
1fce4e96 RD |
292 | DocStr(__ne__, "Test for inequality of wx.RealPoint objects.", ""); |
293 | bool __ne__(PyObject* other) { | |
294 | wxRealPoint temp, *obj = &temp; | |
295 | if ( other == Py_None ) return true; | |
296 | if ( ! wxRealPoint_helper(other, &obj)) { | |
297 | PyErr_Clear(); | |
298 | return true; | |
299 | } | |
300 | return self->operator!=(*obj); | |
301 | } | |
302 | } | |
dd9f7fea RD |
303 | |
304 | ||
305 | DocDeclStr( | |
306 | wxRealPoint, operator+(const wxRealPoint& pt), | |
d07d2bc9 | 307 | "Add pt's proprties to this and return the result.", ""); |
dd9f7fea RD |
308 | |
309 | DocDeclStr( | |
310 | wxRealPoint, operator-(const wxRealPoint& pt), | |
d07d2bc9 | 311 | "Subtract pt's proprties from this and return the result", ""); |
d14a1e28 | 312 | |
d14a1e28 RD |
313 | |
314 | %extend { | |
d07d2bc9 | 315 | DocStr(Set, "Set both the x and y properties", ""); |
d14a1e28 RD |
316 | void Set(double x, double y) { |
317 | self->x = x; | |
318 | self->y = y; | |
319 | } | |
dd9f7fea RD |
320 | |
321 | DocAStr(Get, | |
322 | "Get() -> (x,y)", | |
d07d2bc9 | 323 | "Return the x and y properties as a tuple. ", ""); |
dd9f7fea | 324 | PyObject* Get() { |
debe38c9 | 325 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
326 | PyObject* tup = PyTuple_New(2); |
327 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x)); | |
328 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y)); | |
debe38c9 | 329 | //PyEndBlockThreads(blocked); |
d14a1e28 RD |
330 | return tup; |
331 | } | |
332 | } | |
333 | ||
334 | %pythoncode { | |
d07d2bc9 | 335 | asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead") |
dd9f7fea RD |
336 | def __str__(self): return str(self.Get()) |
337 | def __repr__(self): return 'wx.RealPoint'+str(self.Get()) | |
338 | def __len__(self): return len(self.Get()) | |
339 | def __getitem__(self, index): return self.Get()[index] | |
d14a1e28 | 340 | def __setitem__(self, index, val): |
dd9f7fea RD |
341 | if index == 0: self.x = val |
342 | elif index == 1: self.y = val | |
d14a1e28 | 343 | else: raise IndexError |
dd9f7fea | 344 | def __nonzero__(self): return self.Get() != (0.0, 0.0) |
02376d73 RD |
345 | __safe_for_unpickling__ = True |
346 | def __reduce__(self): return (wx.RealPoint, self.Get()) | |
d14a1e28 RD |
347 | } |
348 | }; | |
349 | ||
dd9f7fea | 350 | |
d14a1e28 RD |
351 | //--------------------------------------------------------------------------- |
352 | %newgroup | |
94d33c49 | 353 | |
d14a1e28 | 354 | |
dd9f7fea | 355 | DocStr(wxPoint, |
d07d2bc9 RD |
356 | "A data structure for representing a point or position with integer x |
357 | and y properties. Most places in wxPython that expect a wx.Point can | |
358 | also accept a (x,y) tuple.", ""); | |
dd9f7fea | 359 | |
d14a1e28 RD |
360 | class wxPoint |
361 | { | |
362 | public: | |
363 | int x, y; | |
364 | ||
dd9f7fea RD |
365 | DocCtorStr( |
366 | wxPoint(int x=0, int y=0), | |
d07d2bc9 | 367 | "Create a wx.Point object", ""); |
dd9f7fea | 368 | |
d14a1e28 RD |
369 | ~wxPoint(); |
370 | ||
dd9f7fea | 371 | |
1fce4e96 | 372 | %extend { |
debe38c9 | 373 | //KeepGIL(__eq__); |
1fce4e96 RD |
374 | DocStr(__eq__, "Test for equality of wx.Point objects.", ""); |
375 | bool __eq__(PyObject* other) { | |
376 | wxPoint temp, *obj = &temp; | |
377 | if ( other == Py_None ) return false; | |
378 | if ( ! wxPoint_helper(other, &obj) ) { | |
379 | PyErr_Clear(); | |
380 | return false; | |
381 | } | |
382 | return self->operator==(*obj); | |
383 | } | |
d14a1e28 | 384 | |
1fce4e96 | 385 | |
debe38c9 | 386 | //KeepGIL(__ne__); |
1fce4e96 RD |
387 | DocStr(__ne__, "Test for inequality of wx.Point objects.", ""); |
388 | bool __ne__(PyObject* other) { | |
389 | wxPoint temp, *obj = &temp; | |
390 | if ( other == Py_None ) return true; | |
391 | if ( ! wxPoint_helper(other, &obj)) { | |
392 | PyErr_Clear(); | |
393 | return true; | |
394 | } | |
395 | return self->operator!=(*obj); | |
396 | } | |
397 | } | |
093d613e RD |
398 | |
399 | ||
400 | // %nokwargs operator+; | |
401 | // %nokwargs operator-; | |
402 | // %nokwargs operator+=; | |
403 | // %nokwargs operator-=; | |
dd9f7fea RD |
404 | |
405 | DocDeclStr( | |
406 | wxPoint, operator+(const wxPoint& pt), | |
d07d2bc9 | 407 | "Add pt's proprties to this and return the result.", ""); |
d14a1e28 | 408 | |
093d613e | 409 | |
dd9f7fea RD |
410 | DocDeclStr( |
411 | wxPoint, operator-(const wxPoint& pt), | |
d07d2bc9 | 412 | "Subtract pt's proprties from this and return the result", ""); |
dd9f7fea RD |
413 | |
414 | ||
415 | DocDeclStr( | |
416 | wxPoint&, operator+=(const wxPoint& pt), | |
d07d2bc9 | 417 | "Add pt to this object.", ""); |
dd9f7fea RD |
418 | |
419 | DocDeclStr( | |
420 | wxPoint&, operator-=(const wxPoint& pt), | |
d07d2bc9 | 421 | "Subtract pt from this object.", ""); |
dd9f7fea | 422 | |
093d613e RD |
423 | |
424 | ||
425 | // DocDeclStr( | |
426 | // wxPoint, operator+(const wxSize& sz), | |
d07d2bc9 | 427 | // "Add sz to this Point and return the result.", ""); |
093d613e RD |
428 | |
429 | // DocDeclStr( | |
430 | // wxPoint, operator-(const wxSize& sz), | |
d07d2bc9 | 431 | // "Subtract sz from this Point and return the result", ""); |
093d613e RD |
432 | |
433 | ||
434 | // DocDeclStr( | |
435 | // wxPoint&, operator+=(const wxSize& sz), | |
d07d2bc9 | 436 | // "Add sz to this object.", ""); |
093d613e RD |
437 | |
438 | // DocDeclStr( | |
439 | // wxPoint&, operator-=(const wxSize& sz), | |
d07d2bc9 | 440 | // "Subtract sz from this object.", ""); |
093d613e RD |
441 | |
442 | ||
443 | ||
dd9f7fea | 444 | |
d14a1e28 | 445 | %extend { |
d07d2bc9 | 446 | DocStr(Set, "Set both the x and y properties", ""); |
d14a1e28 RD |
447 | void Set(long x, long y) { |
448 | self->x = x; | |
449 | self->y = y; | |
450 | } | |
dd9f7fea RD |
451 | |
452 | DocAStr(Get, | |
453 | "Get() -> (x,y)", | |
d07d2bc9 | 454 | "Return the x and y properties as a tuple. ", ""); |
dd9f7fea | 455 | PyObject* Get() { |
debe38c9 | 456 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
457 | PyObject* tup = PyTuple_New(2); |
458 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
459 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
debe38c9 | 460 | //wxPyEndBlockThreads(blocked); |
d14a1e28 RD |
461 | return tup; |
462 | } | |
463 | } | |
464 | ||
465 | %pythoncode { | |
d07d2bc9 | 466 | asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead") |
dd9f7fea RD |
467 | def __str__(self): return str(self.Get()) |
468 | def __repr__(self): return 'wx.Point'+str(self.Get()) | |
469 | def __len__(self): return len(self.Get()) | |
470 | def __getitem__(self, index): return self.Get()[index] | |
d14a1e28 RD |
471 | def __setitem__(self, index, val): |
472 | if index == 0: self.x = val | |
473 | elif index == 1: self.y = val | |
474 | else: raise IndexError | |
dd9f7fea | 475 | def __nonzero__(self): return self.Get() != (0,0) |
02376d73 RD |
476 | __safe_for_unpickling__ = True |
477 | def __reduce__(self): return (wx.Point, self.Get()) | |
d14a1e28 RD |
478 | } |
479 | }; | |
480 | ||
481 | //--------------------------------------------------------------------------- | |
482 | %newgroup | |
94d33c49 | 483 | |
d14a1e28 | 484 | |
dd9f7fea | 485 | DocStr(wxRect, |
d07d2bc9 RD |
486 | "A class for representing and manipulating rectangles. It has x, y, |
487 | width and height properties. In wxPython most palces that expect a | |
488 | wx.Rect can also accept a (x,y,width,height) tuple.", ""); | |
dd9f7fea | 489 | |
d14a1e28 RD |
490 | class wxRect |
491 | { | |
492 | public: | |
dd9f7fea RD |
493 | DocCtorStr( |
494 | wxRect(int x=0, int y=0, int width=0, int height=0), | |
d07d2bc9 | 495 | "Create a new Rect object.", ""); |
dd9f7fea RD |
496 | |
497 | DocCtorStrName( | |
498 | wxRect(const wxPoint& topLeft, const wxPoint& bottomRight), | |
d07d2bc9 | 499 | "Create a new Rect object from Points representing two corners.", "", |
dd9f7fea RD |
500 | RectPP); |
501 | ||
502 | DocCtorStrName( | |
503 | wxRect(const wxPoint& pos, const wxSize& size), | |
d07d2bc9 | 504 | "Create a new Rect from a position and size.", "", |
dd9f7fea | 505 | RectPS); |
7aada1e0 RD |
506 | |
507 | DocCtorStrName( | |
508 | wxRect(const wxSize& size), | |
509 | "Create a new Rect from a size only.", "", | |
510 | RectS); | |
511 | ||
d14a1e28 RD |
512 | ~wxRect(); |
513 | ||
514 | int GetX() const; | |
515 | void SetX(int x); | |
516 | ||
517 | int GetY(); | |
518 | void SetY(int y); | |
519 | ||
520 | int GetWidth() const; | |
521 | void SetWidth(int w); | |
522 | ||
523 | int GetHeight() const; | |
524 | void SetHeight(int h); | |
525 | ||
526 | wxPoint GetPosition() const; | |
527 | void SetPosition( const wxPoint &p ); | |
528 | ||
529 | wxSize GetSize() const; | |
530 | void SetSize( const wxSize &s ); | |
531 | ||
c3fc056e RD |
532 | bool IsEmpty() const; |
533 | ||
3f0ff538 RD |
534 | wxPoint GetTopLeft() const; |
535 | void SetTopLeft(const wxPoint &p); | |
536 | wxPoint GetBottomRight() const; | |
537 | void SetBottomRight(const wxPoint &p); | |
538 | ||
5acb46e0 RD |
539 | wxPoint GetTopRight() const; |
540 | void SetTopRight(const wxPoint &p); | |
541 | wxPoint GetBottomLeft() const; | |
542 | void SetBottomLeft(const wxPoint &p); | |
543 | ||
3f0ff538 RD |
544 | // wxPoint GetLeftTop() const; |
545 | // void SetLeftTop(const wxPoint &p); | |
546 | // wxPoint GetRightBottom() const; | |
547 | // void SetRightBottom(const wxPoint &p); | |
5acb46e0 RD |
548 | // wxPoint GetRightTop() const; |
549 | // void SetRightTop(const wxPoint &p); | |
550 | // wxPoint GetLeftBottom() const; | |
551 | // void SetLeftBottom(const wxPoint &p); | |
3f0ff538 | 552 | |
d14a1e28 RD |
553 | int GetLeft() const; |
554 | int GetTop() const; | |
555 | int GetBottom() const; | |
556 | int GetRight() const; | |
557 | ||
558 | void SetLeft(int left); | |
559 | void SetRight(int right); | |
560 | void SetTop(int top); | |
561 | void SetBottom(int bottom); | |
562 | ||
dd9f7fea RD |
563 | %pythoncode { |
564 | position = property(GetPosition, SetPosition) | |
565 | size = property(GetSize, SetSize) | |
566 | left = property(GetLeft, SetLeft) | |
567 | right = property(GetRight, SetRight) | |
568 | top = property(GetTop, SetTop) | |
569 | bottom = property(GetBottom, SetBottom) | |
570 | } | |
571 | ||
a9b95496 | 572 | |
dd9f7fea RD |
573 | DocDeclStr( |
574 | wxRect&, Inflate(wxCoord dx, wxCoord dy), | |
ca30acad RD |
575 | "Increases the size of the rectangle. |
576 | ||
577 | The left border is moved farther left and the right border is moved | |
578 | farther right by ``dx``. The upper border is moved farther up and the | |
579 | bottom border is moved farther down by ``dy``. (Note the the width and | |
580 | height of the rectangle thus change by ``2*dx`` and ``2*dy``, | |
581 | respectively.) If one or both of ``dx`` and ``dy`` are negative, the | |
582 | opposite happens: the rectangle size decreases in the respective | |
583 | direction. | |
584 | ||
585 | The change is made to the rectangle inplace, if instead you need a | |
586 | copy that is inflated, preserving the original then make the copy | |
587 | first:: | |
588 | ||
589 | copy = wx.Rect(*original) | |
590 | copy.Inflate(10,15) | |
591 | ||
592 | ", " | |
593 | Inflating and deflating behaves *naturally*. Defined more precisely, | |
594 | that means: | |
595 | ||
596 | * Real inflates (that is, ``dx`` and/or ``dy`` >= 0) are not | |
597 | constrained. Thus inflating a rectangle can cause its upper left | |
598 | corner to move into the negative numbers. (The versions prior to | |
599 | 2.5.4 forced the top left coordinate to not fall below (0, 0), | |
600 | which implied a forced move of the rectangle.) | |
601 | ||
602 | * Deflates are clamped to not reduce the width or height of the | |
603 | rectangle below zero. In such cases, the top-left corner is | |
604 | nonetheless handled properly. For example, a rectangle at (10, | |
605 | 10) with size (20, 40) that is inflated by (-15, -15) will | |
606 | become located at (20, 25) at size (0, 10). Finally, observe | |
607 | that the width and height are treated independently. In the | |
608 | above example, the width is reduced by 20, whereas the height is | |
609 | reduced by the full 30 (rather than also stopping at 20, when | |
610 | the width reached zero). | |
611 | ||
612 | :see: `Deflate` | |
613 | "); | |
dd9f7fea | 614 | |
a9b95496 RD |
615 | // There are also these versions... |
616 | //wxRect& Inflate(const wxSize& d); | |
617 | //wxRect& Inflate(wxCoord d); | |
618 | ||
619 | ||
dd9f7fea RD |
620 | DocDeclStr( |
621 | wxRect&, Deflate(wxCoord dx, wxCoord dy), | |
ca30acad RD |
622 | "Decrease the rectangle size. This method is the opposite of `Inflate` |
623 | in that Deflate(a,b) is equivalent to Inflate(-a,-b). Please refer to | |
624 | `Inflate` for a full description.", ""); | |
dd9f7fea | 625 | |
a9b95496 RD |
626 | // There are also these versions... |
627 | //wxRect& Deflate(const wxSize& d) { return Inflate(-d.x, -d.y); } | |
628 | //wxRect& Deflate(wxCoord d) { return Inflate(-d); } | |
629 | ||
dd9f7fea RD |
630 | DocDeclStrName( |
631 | void, Offset(wxCoord dx, wxCoord dy), | |
d07d2bc9 RD |
632 | "Moves the rectangle by the specified offset. If dx is positive, the |
633 | rectangle is moved to the right, if dy is positive, it is moved to the | |
634 | bottom, otherwise it is moved to the left or top respectively.", "", | |
dd9f7fea RD |
635 | OffsetXY); |
636 | ||
637 | DocDeclStr( | |
638 | void, Offset(const wxPoint& pt), | |
096e3ea1 | 639 | "Same as `OffsetXY` but uses dx,dy from Point", ""); |
dd9f7fea RD |
640 | |
641 | DocDeclStr( | |
9eefe9f0 RD |
642 | wxRect, Intersect(const wxRect& rect), |
643 | "Returns the intersectsion of this rectangle and rect.", ""); | |
d14a1e28 | 644 | |
9eefe9f0 RD |
645 | DocDeclStr( |
646 | wxRect , Union(const wxRect& rect), | |
647 | "Returns the union of this rectangle and rect.", ""); | |
648 | ||
649 | ||
dd9f7fea RD |
650 | DocDeclStr( |
651 | wxRect, operator+(const wxRect& rect) const, | |
d07d2bc9 | 652 | "Add the properties of rect to this rectangle and return the result.", ""); |
d14a1e28 | 653 | |
dd9f7fea RD |
654 | DocDeclStr( |
655 | wxRect&, operator+=(const wxRect& rect), | |
d07d2bc9 | 656 | "Add the properties of rect to this rectangle, updating this rectangle.", ""); |
d14a1e28 | 657 | |
1fce4e96 | 658 | %extend { |
debe38c9 | 659 | //KeepGIL(__eq__); |
1fce4e96 RD |
660 | DocStr(__eq__, "Test for equality of wx.Rect objects.", ""); |
661 | bool __eq__(PyObject* other) { | |
662 | wxRect temp, *obj = &temp; | |
663 | if ( other == Py_None ) return false; | |
664 | if ( ! wxRect_helper(other, &obj) ) { | |
665 | PyErr_Clear(); | |
666 | return false; | |
667 | } | |
668 | return self->operator==(*obj); | |
669 | } | |
d14a1e28 | 670 | |
1fce4e96 | 671 | |
debe38c9 | 672 | //KeepGIL(__ne__); |
1fce4e96 RD |
673 | DocStr(__ne__, "Test for inequality of wx.Rect objects.", ""); |
674 | bool __ne__(PyObject* other) { | |
675 | wxRect temp, *obj = &temp; | |
676 | if ( other == Py_None ) return true; | |
677 | if ( ! wxRect_helper(other, &obj)) { | |
678 | PyErr_Clear(); | |
679 | return true; | |
680 | } | |
681 | return self->operator!=(*obj); | |
682 | } | |
683 | } | |
d14a1e28 | 684 | |
dd9f7fea | 685 | |
8546a549 RD |
686 | DocStr( Contains, "Return True if the point is inside the rect.", ""); |
687 | %Rename(ContainsXY, bool, Contains(int x, int y) const); | |
688 | bool Contains(const wxPoint& pt) const; | |
d14a1e28 | 689 | |
8e1222c7 | 690 | DocDeclStrName( |
8546a549 | 691 | bool, Contains(const wxRect& rect) const, |
8e1222c7 RD |
692 | "Returns ``True`` if the given rectangle is completely inside this |
693 | rectangle or touches its boundary.", "", | |
8546a549 | 694 | ContainsRect); |
ce60dd8e | 695 | |
8546a549 | 696 | %pythoncode { |
ce60dd8e RD |
697 | %#Inside = wx._deprecated(Contains, "Use `Contains` instead.") |
698 | %#InsideXY = wx._deprecated(ContainsXY, "Use `ContainsXY` instead.") | |
699 | %#InsideRect = wx._deprecated(ContainsRect, "Use `ContainsRect` instead.") | |
700 | Inside = Contains | |
701 | InsideXY = ContainsXY | |
702 | InsideRect = ContainsRect | |
8546a549 | 703 | } |
8e1222c7 | 704 | |
dd9f7fea RD |
705 | DocDeclStr( |
706 | bool, Intersects(const wxRect& rect) const, | |
d07d2bc9 | 707 | "Returns True if the rectangles have a non empty intersection.", ""); |
d14a1e28 | 708 | |
096e3ea1 RD |
709 | DocDeclStr( |
710 | wxRect, CenterIn(const wxRect& r, int dir = wxBOTH), | |
711 | "Center this rectangle within the one passed to the method, which is | |
712 | usually, but not necessarily, the larger one.", ""); | |
713 | %pythoncode { CentreIn = CenterIn } | |
714 | ||
dd9f7fea | 715 | |
d14a1e28 RD |
716 | int x, y, width, height; |
717 | ||
718 | ||
719 | %extend { | |
d07d2bc9 | 720 | DocStr(Set, "Set all rectangle properties.", ""); |
dd9f7fea | 721 | void Set(int x=0, int y=0, int width=0, int height=0) { |
d14a1e28 RD |
722 | self->x = x; |
723 | self->y = y; | |
724 | self->width = width; | |
725 | self->height = height; | |
726 | } | |
727 | ||
dd9f7fea RD |
728 | DocAStr(Get, |
729 | "Get() -> (x,y,width,height)", | |
d07d2bc9 | 730 | "Return the rectangle properties as a tuple.", ""); |
dd9f7fea | 731 | PyObject* Get() { |
debe38c9 | 732 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
733 | PyObject* tup = PyTuple_New(4); |
734 | PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x)); | |
735 | PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); | |
736 | PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width)); | |
737 | PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height)); | |
debe38c9 | 738 | //wxPyEndBlockThreads(blocked); |
d14a1e28 RD |
739 | return tup; |
740 | } | |
741 | } | |
742 | ||
743 | %pythoncode { | |
d07d2bc9 | 744 | asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead") |
dd9f7fea RD |
745 | def __str__(self): return str(self.Get()) |
746 | def __repr__(self): return 'wx.Rect'+str(self.Get()) | |
747 | def __len__(self): return len(self.Get()) | |
748 | def __getitem__(self, index): return self.Get()[index] | |
d14a1e28 RD |
749 | def __setitem__(self, index, val): |
750 | if index == 0: self.x = val | |
751 | elif index == 1: self.y = val | |
752 | elif index == 2: self.width = val | |
753 | elif index == 3: self.height = val | |
754 | else: raise IndexError | |
dd9f7fea | 755 | def __nonzero__(self): return self.Get() != (0,0,0,0) |
02376d73 RD |
756 | __safe_for_unpickling__ = True |
757 | def __reduce__(self): return (wx.Rect, self.Get()) | |
d14a1e28 | 758 | } |
7012bb9f RD |
759 | |
760 | ||
761 | %property(Bottom, GetBottom, SetBottom, doc="See `GetBottom` and `SetBottom`"); | |
762 | %property(BottomRight, GetBottomRight, SetBottomRight, doc="See `GetBottomRight` and `SetBottomRight`"); | |
5acb46e0 | 763 | %property(BottomLeft, GetBottomLeft, SetBottomLeft, doc="See `GetBottomLeft` and `SetBottomLeft`"); |
7012bb9f RD |
764 | %property(Height, GetHeight, SetHeight, doc="See `GetHeight` and `SetHeight`"); |
765 | %property(Left, GetLeft, SetLeft, doc="See `GetLeft` and `SetLeft`"); | |
766 | %property(Position, GetPosition, SetPosition, doc="See `GetPosition` and `SetPosition`"); | |
767 | %property(Right, GetRight, SetRight, doc="See `GetRight` and `SetRight`"); | |
768 | %property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`"); | |
769 | %property(Top, GetTop, SetTop, doc="See `GetTop` and `SetTop`"); | |
770 | %property(TopLeft, GetTopLeft, SetTopLeft, doc="See `GetTopLeft` and `SetTopLeft`"); | |
5acb46e0 | 771 | %property(TopRight, GetTopRight, SetTopRight, doc="See `GetTopRight` and `SetTopRight`"); |
7012bb9f RD |
772 | %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`"); |
773 | %property(X, GetX, SetX, doc="See `GetX` and `SetX`"); | |
774 | %property(Y, GetY, SetY, doc="See `GetY` and `SetY`"); | |
775 | ||
776 | %property(Empty, IsEmpty, doc="See `IsEmpty`"); | |
d14a1e28 RD |
777 | }; |
778 | ||
779 | ||
ab1f7d2a RD |
780 | MustHaveApp(wxIntersectRect); |
781 | ||
dd9f7fea RD |
782 | DocAStr(wxIntersectRect, |
783 | "IntersectRect(Rect r1, Rect r2) -> Rect", | |
d07d2bc9 | 784 | "Calculate and return the intersection of r1 and r2.", ""); |
d14a1e28 RD |
785 | %inline %{ |
786 | PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) { | |
787 | wxRegion reg1(*r1); | |
788 | wxRegion reg2(*r2); | |
789 | wxRect dest(0,0,0,0); | |
790 | PyObject* obj; | |
791 | ||
792 | reg1.Intersect(reg2); | |
793 | dest = reg1.GetBox(); | |
794 | ||
795 | if (dest != wxRect(0,0,0,0)) { | |
debe38c9 | 796 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d14a1e28 | 797 | wxRect* newRect = new wxRect(dest); |
a72f4631 | 798 | obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true); |
debe38c9 | 799 | //wxPyEndBlockThreads(blocked); |
d14a1e28 RD |
800 | return obj; |
801 | } | |
802 | Py_INCREF(Py_None); | |
803 | return Py_None; | |
804 | } | |
805 | %} | |
806 | ||
807 | //--------------------------------------------------------------------------- | |
808 | %newgroup | |
94d33c49 | 809 | |
d14a1e28 | 810 | |
dd9f7fea | 811 | DocStr(wxPoint2D, |
d07d2bc9 RD |
812 | "wx.Point2Ds represent a point or a vector in a 2d coordinate system |
813 | with floating point values.", ""); | |
d14a1e28 RD |
814 | |
815 | class wxPoint2D | |
816 | { | |
dd9f7fea | 817 | public: |
d07d2bc9 | 818 | DocStr(wxPoint2D, "Create a w.Point2D object.", ""); |
d14a1e28 | 819 | wxPoint2D( double x=0.0 , double y=0.0 ); |
1b8c7ba6 RD |
820 | %RenameCtor(Point2DCopy, wxPoint2D( const wxPoint2D &pt )); |
821 | %RenameCtor(Point2DFromPoint, wxPoint2D( const wxPoint &pt )); | |
d14a1e28 | 822 | |
7b497846 RD |
823 | ~wxPoint2D(); |
824 | ||
dd9f7fea RD |
825 | DocDeclAStr( |
826 | void, GetFloor( int *OUTPUT , int *OUTPUT ) const, | |
827 | "GetFloor() -> (x,y)", | |
d07d2bc9 | 828 | "Convert to integer", ""); |
dd9f7fea RD |
829 | |
830 | DocDeclAStr( | |
831 | void, GetRounded( int *OUTPUT , int *OUTPUT ) const, | |
832 | "GetRounded() -> (x,y)", | |
d07d2bc9 | 833 | "Convert to integer", ""); |
d14a1e28 RD |
834 | |
835 | double GetVectorLength() const; | |
836 | double GetVectorAngle() const ; | |
837 | void SetVectorLength( double length ); | |
838 | void SetVectorAngle( double degrees ); | |
dd9f7fea | 839 | |
d14a1e28 RD |
840 | // LinkError: void SetPolarCoordinates( double angle , double length ); |
841 | // LinkError: void Normalize(); | |
842 | %pythoncode { | |
843 | def SetPolarCoordinates(self, angle, length): | |
844 | self.SetVectorLength(length) | |
845 | self.SetVectorAngle(angle) | |
846 | def Normalize(self): | |
847 | self.SetVectorLength(1.0) | |
848 | } | |
849 | ||
850 | double GetDistance( const wxPoint2D &pt ) const; | |
851 | double GetDistanceSquare( const wxPoint2D &pt ) const; | |
852 | double GetDotProduct( const wxPoint2D &vec ) const; | |
853 | double GetCrossProduct( const wxPoint2D &vec ) const; | |
854 | ||
dd9f7fea RD |
855 | DocDeclStr( |
856 | wxPoint2D, operator-(), | |
d07d2bc9 | 857 | "the reflection of this point", ""); |
d14a1e28 RD |
858 | |
859 | wxPoint2D& operator+=(const wxPoint2D& pt); | |
860 | wxPoint2D& operator-=(const wxPoint2D& pt); | |
861 | ||
862 | wxPoint2D& operator*=(const wxPoint2D& pt); | |
863 | wxPoint2D& operator/=(const wxPoint2D& pt); | |
864 | ||
1fce4e96 | 865 | %extend { |
debe38c9 | 866 | //KeepGIL(__eq__); |
1fce4e96 RD |
867 | DocStr(__eq__, "Test for equality of wx.Point2D objects.", ""); |
868 | bool __eq__(PyObject* other) { | |
869 | wxPoint2D temp, *obj = &temp; | |
870 | if ( other == Py_None ) return false; | |
871 | if ( ! wxPoint2D_helper(other, &obj) ) { | |
872 | PyErr_Clear(); | |
873 | return false; | |
874 | } | |
875 | return self->operator==(*obj); | |
876 | } | |
877 | ||
878 | ||
debe38c9 | 879 | //KeepGIL(__ne__); |
1fce4e96 RD |
880 | DocStr(__ne__, "Test for inequality of wx.Point2D objects.", ""); |
881 | bool __ne__(PyObject* other) { | |
882 | wxPoint2D temp, *obj = &temp; | |
883 | if ( other == Py_None ) return true; | |
884 | if ( ! wxPoint2D_helper(other, &obj)) { | |
885 | PyErr_Clear(); | |
886 | return true; | |
887 | } | |
888 | return self->operator!=(*obj); | |
889 | } | |
890 | } | |
d14a1e28 | 891 | |
1b8c7ba6 RD |
892 | %Rename(x, double, m_x); |
893 | %Rename(y, double, m_y); | |
d14a1e28 RD |
894 | |
895 | %extend { | |
896 | void Set( double x=0 , double y=0 ) { | |
897 | self->m_x = x; | |
898 | self->m_y = y; | |
899 | } | |
dd9f7fea RD |
900 | |
901 | DocAStr(Get, | |
902 | "Get() -> (x,y)", | |
d07d2bc9 | 903 | "Return x and y properties as a tuple.", ""); |
dd9f7fea | 904 | PyObject* Get() { |
debe38c9 | 905 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
906 | PyObject* tup = PyTuple_New(2); |
907 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x)); | |
908 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y)); | |
debe38c9 | 909 | //wxPyEndBlockThreads(blocked); |
d14a1e28 RD |
910 | return tup; |
911 | } | |
912 | } | |
913 | ||
914 | %pythoncode { | |
d07d2bc9 | 915 | asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead") |
dd9f7fea RD |
916 | def __str__(self): return str(self.Get()) |
917 | def __repr__(self): return 'wx.Point2D'+str(self.Get()) | |
918 | def __len__(self): return len(self.Get()) | |
919 | def __getitem__(self, index): return self.Get()[index] | |
d14a1e28 | 920 | def __setitem__(self, index, val): |
dd9f7fea RD |
921 | if index == 0: self.x = val |
922 | elif index == 1: self.y = val | |
d14a1e28 | 923 | else: raise IndexError |
dd9f7fea | 924 | def __nonzero__(self): return self.Get() != (0.0, 0.0) |
02376d73 RD |
925 | __safe_for_unpickling__ = True |
926 | def __reduce__(self): return (wx.Point2D, self.Get()) | |
d14a1e28 | 927 | } |
7012bb9f RD |
928 | |
929 | %property(Floor, GetFloor, doc="See `GetFloor`"); | |
930 | %property(Rounded, GetRounded, doc="See `GetRounded`"); | |
931 | %property(VectorAngle, GetVectorAngle, SetVectorAngle, doc="See `GetVectorAngle` and `SetVectorAngle`"); | |
932 | %property(VectorLength, GetVectorLength, SetVectorLength, doc="See `GetVectorLength` and `SetVectorLength`"); | |
933 | ||
d14a1e28 RD |
934 | }; |
935 | ||
936 | ||
debe38c9 RD |
937 | //--------------------------------------------------------------------------- |
938 | %newgroup | |
939 | ||
940 | ||
941 | enum wxOutCode | |
942 | { | |
943 | wxInside = 0x00 , | |
944 | wxOutLeft = 0x01 , | |
945 | wxOutRight = 0x02 , | |
946 | wxOutTop = 0x08 , | |
947 | wxOutBottom = 0x04 | |
948 | }; | |
949 | ||
950 | ||
951 | DocStr(wxRect2D, | |
952 | "wx.Rect2D is a rectangle, with position and size, in a 2D coordinate system | |
953 | with floating point component values.", ""); | |
954 | ||
955 | class wxRect2D | |
956 | { | |
957 | public: | |
958 | wxRect2D(wxDouble x=0.0, wxDouble y=0.0, wxDouble w=0.0, wxDouble h=0.0); | |
959 | ||
960 | ~wxRect2D(); | |
961 | ||
962 | wxPoint2D GetPosition(); | |
963 | wxSize GetSize(); | |
964 | ||
965 | // for the edge and corner accessors there are two setters conterparts, | |
966 | // the Set.. functions keep the other corners at their position whenever | |
967 | // sensible, the Move.. functions keep the size of the rect and move the | |
968 | // other corners apropriately | |
969 | ||
970 | wxDouble GetLeft() const; | |
971 | void SetLeft( wxDouble n ); | |
972 | void MoveLeftTo( wxDouble n ); | |
973 | wxDouble GetTop() const; | |
974 | void SetTop( wxDouble n ); | |
975 | void MoveTopTo( wxDouble n ); | |
976 | wxDouble GetBottom() const; | |
977 | void SetBottom( wxDouble n ); | |
978 | void MoveBottomTo( wxDouble n ); | |
979 | wxDouble GetRight() const; | |
980 | void SetRight( wxDouble n ); | |
981 | void MoveRightTo( wxDouble n ); | |
982 | ||
983 | wxPoint2D GetLeftTop() const; | |
984 | void SetLeftTop( const wxPoint2D &pt ); | |
985 | void MoveLeftTopTo( const wxPoint2D &pt ); | |
986 | wxPoint2D GetLeftBottom() const; | |
987 | void SetLeftBottom( const wxPoint2D &pt ); | |
988 | void MoveLeftBottomTo( const wxPoint2D &pt ); | |
989 | wxPoint2D GetRightTop() const; | |
990 | void SetRightTop( const wxPoint2D &pt ); | |
991 | void MoveRightTopTo( const wxPoint2D &pt ); | |
992 | wxPoint2D GetRightBottom() const; | |
993 | void SetRightBottom( const wxPoint2D &pt ); | |
994 | void MoveRightBottomTo( const wxPoint2D &pt ); | |
995 | wxPoint2D GetCentre() const; | |
996 | void SetCentre( const wxPoint2D &pt ); | |
997 | void MoveCentreTo( const wxPoint2D &pt ); | |
998 | wxOutCode GetOutcode(const wxPoint2D &pt) const; | |
999 | bool Contains( const wxPoint2D &pt ) const; | |
1000 | %Rename(ContainsRect, bool , Contains( const wxRect2D &rect ) const); | |
1001 | bool IsEmpty() const; | |
1002 | bool HaveEqualSize( const wxRect2D &rect ) const; | |
1003 | ||
1004 | %nokwargs Inset; | |
1005 | void Inset( wxDouble x , wxDouble y ); | |
1006 | void Inset( wxDouble left , wxDouble top ,wxDouble right , wxDouble bottom ); | |
1007 | void Offset( const wxPoint2D &pt ); | |
1008 | ||
1009 | void ConstrainTo( const wxRect2D &rect ); | |
1010 | ||
1011 | wxPoint2D Interpolate( wxInt32 widthfactor , wxInt32 heightfactor ); | |
1012 | ||
1013 | //static void Intersect( const wxRect2D &src1 , const wxRect2D &src2 , wxRect2D *dest ); | |
1014 | ||
1015 | void Intersect( const wxRect2D &otherRect ); | |
1016 | wxRect2D CreateIntersection( const wxRect2D &otherRect ) const; | |
1017 | bool Intersects( const wxRect2D &rect ) const; | |
1018 | ||
1019 | // static void Union( const wxRect2D &src1 , const wxRect2D &src2 , wxRect2D *dest ); | |
1020 | ||
1021 | void Union( const wxRect2D &otherRect ); | |
1022 | //void Union( const wxPoint2D &pt ); | |
1023 | ||
1024 | wxRect2D CreateUnion( const wxRect2D &otherRect ) const; | |
1025 | ||
1026 | %nokwargs Scale; | |
1027 | void Scale( wxDouble f ); | |
1028 | void Scale( int num , int denum ); | |
1029 | ||
1030 | //wxRect2D& operator = (const wxRect2D& rect); | |
1031 | //bool operator == (const wxRect2D& rect) const; | |
1032 | //bool operator != (const wxRect2D& rect) const; | |
1033 | ||
1034 | %extend { | |
1035 | //KeepGIL(__eq__); | |
1036 | DocStr(__eq__, "Test for equality of wx.Rect2D objects.", ""); | |
1037 | bool __eq__(PyObject* other) { | |
1038 | wxRect2D temp, *obj = &temp; | |
1039 | if ( other == Py_None ) return false; | |
1040 | if ( ! wxRect2D_helper(other, &obj) ) { | |
1041 | PyErr_Clear(); | |
1042 | return false; | |
1043 | } | |
1044 | return self->operator==(*obj); | |
1045 | } | |
1046 | ||
1047 | ||
1048 | //KeepGIL(__ne__); | |
1049 | DocStr(__ne__, "Test for inequality of wx.Rect2D objects.", ""); | |
1050 | bool __ne__(PyObject* other) { | |
1051 | wxRect2D temp, *obj = &temp; | |
1052 | if ( other == Py_None ) return true; | |
1053 | if ( ! wxRect2D_helper(other, &obj)) { | |
1054 | PyErr_Clear(); | |
1055 | return true; | |
1056 | } | |
1057 | return self->operator!=(*obj); | |
1058 | } | |
1059 | } | |
1060 | ||
1061 | ||
1062 | %Rename(x, wxDouble , m_x); | |
1063 | %Rename(y, wxDouble , m_y); | |
1064 | %Rename(width, wxDouble , m_width); | |
1065 | %Rename(height, wxDouble , m_height); | |
1066 | ||
1067 | %extend { | |
1068 | void Set( wxDouble x=0 , wxDouble y=0, wxDouble width=0, wxDouble height=0 ) { | |
1069 | self->m_x = x; | |
1070 | self->m_y = y; | |
1071 | self->m_width = width; | |
1072 | self->m_height = height; | |
1073 | } | |
1074 | ||
1075 | DocAStr(Get, | |
1076 | "Get() -> (x,y, width, height)", | |
1077 | "Return x, y, width and height y properties as a tuple.", ""); | |
1078 | PyObject* Get() { | |
1079 | //wxPyBlock_t blocked = wxPyBeginBlockThreads(); | |
1080 | PyObject* tup = PyTuple_New(4); | |
1081 | PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x)); | |
1082 | PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y)); | |
1083 | PyTuple_SET_ITEM(tup, 2, PyFloat_FromDouble(self->m_width)); | |
1084 | PyTuple_SET_ITEM(tup, 3, PyFloat_FromDouble(self->m_height)); | |
1085 | //wxPyEndBlockThreads(blocked); | |
1086 | return tup; | |
1087 | } | |
1088 | } | |
1089 | ||
1090 | %pythoncode { | |
1091 | def __str__(self): return str(self.Get()) | |
1092 | def __repr__(self): return 'wx.Rect2D'+str(self.Get()) | |
1093 | def __len__(self): return len(self.Get()) | |
1094 | def __getitem__(self, index): return self.Get()[index] | |
1095 | def __setitem__(self, index, val): | |
1096 | if index == 0: self.x = val | |
1097 | elif index == 1: self.y = val | |
1098 | elif index == 2: self.width = val | |
1099 | elif index == 3: self.height = val | |
1100 | else: raise IndexError | |
1101 | def __nonzero__(self): return self.Get() != (0.0, 0.0, 0.0, 0.0) | |
1102 | __safe_for_unpickling__ = True | |
1103 | def __reduce__(self): return (wx.Rect2D, self.Get()) | |
1104 | } | |
1105 | ||
1106 | }; | |
1107 | ||
d14a1e28 RD |
1108 | //--------------------------------------------------------------------------- |
1109 | ||
1110 | %immutable; | |
1111 | const wxPoint wxDefaultPosition; | |
1112 | const wxSize wxDefaultSize; | |
1113 | %mutable; | |
1114 | ||
1115 | //--------------------------------------------------------------------------- | |
debe38c9 RD |
1116 | |
1117 | // Turn GIL acquisition back on. | |
1118 | %threadWrapperOn |