]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_gdicmn.i
log wxChoice events in the same format as wxComboBox ones to make it simpler to compa...
[wxWidgets.git] / wxPython / src / _gdicmn.i
CommitLineData
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
20enum wxBitmapType
21{
22 wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
23 wxBITMAP_TYPE_BMP,
d14a1e28 24 wxBITMAP_TYPE_ICO,
d14a1e28 25 wxBITMAP_TYPE_CUR,
d14a1e28
RD
26 wxBITMAP_TYPE_XBM,
27 wxBITMAP_TYPE_XBM_DATA,
28 wxBITMAP_TYPE_XPM,
29 wxBITMAP_TYPE_XPM_DATA,
30 wxBITMAP_TYPE_TIF,
d14a1e28 31 wxBITMAP_TYPE_GIF,
d14a1e28 32 wxBITMAP_TYPE_PNG,
d14a1e28 33 wxBITMAP_TYPE_JPEG,
d14a1e28 34 wxBITMAP_TYPE_PNM,
d14a1e28 35 wxBITMAP_TYPE_PCX,
d14a1e28 36 wxBITMAP_TYPE_PICT,
d14a1e28 37 wxBITMAP_TYPE_ICON,
d14a1e28
RD
38 wxBITMAP_TYPE_ANI,
39 wxBITMAP_TYPE_IFF,
40 wxBITMAP_TYPE_MACCURSOR,
64e8a1f0
RD
41
42// wxBITMAP_TYPE_BMP_RESOURCE,
43// wxBITMAP_TYPE_RESOURCE = wxBITMAP_TYPE_BMP_RESOURCE,
44// wxBITMAP_TYPE_ICO_RESOURCE,
45// wxBITMAP_TYPE_CUR_RESOURCE,
46// wxBITMAP_TYPE_TIF_RESOURCE,
47// wxBITMAP_TYPE_GIF_RESOURCE,
48// wxBITMAP_TYPE_PNG_RESOURCE,
49// wxBITMAP_TYPE_JPEG_RESOURCE,
50// wxBITMAP_TYPE_PNM_RESOURCE,
51// wxBITMAP_TYPE_PCX_RESOURCE,
52// wxBITMAP_TYPE_PICT_RESOURCE,
53// wxBITMAP_TYPE_ICON_RESOURCE,
54// wxBITMAP_TYPE_MACCURSOR_RESOURCE,
55
d14a1e28
RD
56 wxBITMAP_TYPE_ANY = 50
57};
58
59// Standard cursors
60enum wxStockCursor
61{
62 wxCURSOR_NONE, // should be 0
63 wxCURSOR_ARROW,
64 wxCURSOR_RIGHT_ARROW,
65 wxCURSOR_BULLSEYE,
66 wxCURSOR_CHAR,
67 wxCURSOR_CROSS,
68 wxCURSOR_HAND,
69 wxCURSOR_IBEAM,
70 wxCURSOR_LEFT_BUTTON,
71 wxCURSOR_MAGNIFIER,
72 wxCURSOR_MIDDLE_BUTTON,
73 wxCURSOR_NO_ENTRY,
74 wxCURSOR_PAINT_BRUSH,
75 wxCURSOR_PENCIL,
76 wxCURSOR_POINT_LEFT,
77 wxCURSOR_POINT_RIGHT,
78 wxCURSOR_QUESTION_ARROW,
79 wxCURSOR_RIGHT_BUTTON,
80 wxCURSOR_SIZENESW,
81 wxCURSOR_SIZENS,
82 wxCURSOR_SIZENWSE,
83 wxCURSOR_SIZEWE,
84 wxCURSOR_SIZING,
85 wxCURSOR_SPRAYCAN,
86 wxCURSOR_WAIT,
87 wxCURSOR_WATCH,
88 wxCURSOR_BLANK,
89 wxCURSOR_DEFAULT, // standard X11 cursor
90 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
91
92// #ifdef __X__
93// // Not yet implemented for Windows
94// wxCURSOR_CROSS_REVERSE,
95// wxCURSOR_DOUBLE_ARROW,
96// wxCURSOR_BASED_ARROW_UP,
97// wxCURSOR_BASED_ARROW_DOWN,
98// #endif // X11
99
100 wxCURSOR_ARROWWAIT,
101
102 wxCURSOR_MAX
103};
104
105%{
106#ifndef __WXMAC__
107#define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
108#endif
109%}
110
111//---------------------------------------------------------------------------
112%newgroup
d14a1e28 113
dd9f7fea 114DocStr( wxSize,
d07d2bc9 115"wx.Size is a useful data structure used to represent the size of
bea992c8
RD
116something. It simply contains integer width and height
117properties. In most places in wxPython where a wx.Size is
1b8c7ba6 118expected a (width, height) tuple can be used instead.", "");
dd9f7fea 119
d14a1e28
RD
120class wxSize
121{
122public:
1b8c7ba6
RD
123 %Rename(width, int, x);
124 %Rename(height,int, y);
61c5a8ac
RD
125 %pythoncode { x = width; y = height }
126
dd9f7fea
RD
127 DocCtorStr(
128 wxSize(int w=0, int h=0),
d07d2bc9 129 "Creates a size object.", "");
dd9f7fea 130
d14a1e28
RD
131 ~wxSize();
132
dce2bd22 133// None/NULL is now handled properly by the typemap, so these are not needed.
22faec7d 134// %extend {
a72f4631
RD
135// bool __eq__(const wxSize* other) { return other ? (*self == *other) : false; }
136// bool __ne__(const wxSize* other) { return other ? (*self != *other) : true; }
22faec7d
RD
137// }
138
dd9f7fea
RD
139 DocDeclStr(
140 bool, operator==(const wxSize& sz),
d07d2bc9 141 "Test for equality of wx.Size objects.", "");
dd9f7fea
RD
142
143 DocDeclStr(
144 bool, operator!=(const wxSize& sz),
d07d2bc9 145 "Test for inequality.", "");
d14a1e28 146
dd9f7fea
RD
147 DocDeclStr(
148 wxSize, operator+(const wxSize& sz),
d07d2bc9 149 "Add sz's proprties to this and return the result.", "");
d14a1e28 150
dd9f7fea
RD
151 DocDeclStr(
152 wxSize, operator-(const wxSize& sz),
d07d2bc9 153 "Subtract sz's properties from this and return the result.", "");
d14a1e28 154
dd9f7fea
RD
155 DocDeclStr(
156 void, IncTo(const wxSize& sz),
d07d2bc9
RD
157 "Increments this object so that both of its dimensions are not less
158than the corresponding dimensions of the size.", "");
dd9f7fea
RD
159
160 DocDeclStr(
161 void, DecTo(const wxSize& sz),
d07d2bc9
RD
162 "Decrements this object so that both of its dimensions are not greater
163than the corresponding dimensions of the size.", "");
dd9f7fea
RD
164
165 DocDeclStr(
166 void, Set(int w, int h),
d07d2bc9 167 "Set both width and height.", "");
dd9f7fea 168
d14a1e28
RD
169 void SetWidth(int w);
170 void SetHeight(int h);
171 int GetWidth() const;
172 int GetHeight() const;
173
93a163f6
RD
174
175 DocDeclStr(
176 bool , IsFullySpecified() const,
d07d2bc9 177 "Returns True if both components of the size are non-default values.", "");
93a163f6
RD
178
179
180 DocDeclStr(
181 void , SetDefaults(const wxSize& size),
d07d2bc9
RD
182 "Combine this size with the other one replacing the default components
183of this object (i.e. equal to -1) with those of the other.", "");
93a163f6
RD
184
185
dd9f7fea
RD
186 //int GetX() const;
187 //int GetY() const;
d14a1e28
RD
188
189 %extend {
dd9f7fea
RD
190 DocAStr(Get,
191 "Get() -> (width,height)",
d07d2bc9 192 "Returns the width and height properties as a tuple.", "");
dd9f7fea 193 PyObject* Get() {
6e6b3557 194 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
195 PyObject* tup = PyTuple_New(2);
196 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
197 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
da32eb53 198 wxPyEndBlockThreads(blocked);
d14a1e28
RD
199 return tup;
200 }
201 }
202 %pythoncode {
d07d2bc9 203 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
dd9f7fea
RD
204 def __str__(self): return str(self.Get())
205 def __repr__(self): return 'wx.Size'+str(self.Get())
206 def __len__(self): return len(self.Get())
207 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
208 def __setitem__(self, index, val):
209 if index == 0: self.width = val
210 elif index == 1: self.height = val
211 else: raise IndexError
dd9f7fea 212 def __nonzero__(self): return self.Get() != (0,0)
02376d73
RD
213 __safe_for_unpickling__ = True
214 def __reduce__(self): return (wx.Size, self.Get())
d14a1e28
RD
215 }
216
217};
218
219//---------------------------------------------------------------------------
220%newgroup
94d33c49 221
dd9f7fea 222DocStr( wxRealPoint,
d07d2bc9
RD
223"A data structure for representing a point or position with floating
224point x and y properties. In wxPython most places that expect a
225wx.RealPoint can also accept a (x,y) tuple.", "");
d14a1e28
RD
226class wxRealPoint
227{
228public:
229 double x;
230 double y;
231
dd9f7fea
RD
232 DocCtorStr(
233 wxRealPoint(double x=0.0, double y=0.0),
d07d2bc9 234 "Create a wx.RealPoint object", "");
dd9f7fea 235
d14a1e28
RD
236 ~wxRealPoint();
237
dd9f7fea
RD
238 DocDeclStr(
239 bool, operator==(const wxRealPoint& pt),
d07d2bc9 240 "Test for equality of wx.RealPoint objects.", "");
dd9f7fea
RD
241
242 DocDeclStr(
243 bool, operator!=(const wxRealPoint& pt),
d07d2bc9 244 "Test for inequality of wx.RealPoint objects.", "");
dd9f7fea
RD
245
246
247 DocDeclStr(
248 wxRealPoint, operator+(const wxRealPoint& pt),
d07d2bc9 249 "Add pt's proprties to this and return the result.", "");
dd9f7fea
RD
250
251 DocDeclStr(
252 wxRealPoint, operator-(const wxRealPoint& pt),
d07d2bc9 253 "Subtract pt's proprties from this and return the result", "");
d14a1e28 254
d14a1e28
RD
255
256 %extend {
d07d2bc9 257 DocStr(Set, "Set both the x and y properties", "");
d14a1e28
RD
258 void Set(double x, double y) {
259 self->x = x;
260 self->y = y;
261 }
dd9f7fea
RD
262
263 DocAStr(Get,
264 "Get() -> (x,y)",
d07d2bc9 265 "Return the x and y properties as a tuple. ", "");
dd9f7fea 266 PyObject* Get() {
6e6b3557 267 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
268 PyObject* tup = PyTuple_New(2);
269 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
270 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
da32eb53 271 wxPyEndBlockThreads(blocked);
d14a1e28
RD
272 return tup;
273 }
274 }
275
276 %pythoncode {
d07d2bc9 277 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
dd9f7fea
RD
278 def __str__(self): return str(self.Get())
279 def __repr__(self): return 'wx.RealPoint'+str(self.Get())
280 def __len__(self): return len(self.Get())
281 def __getitem__(self, index): return self.Get()[index]
d14a1e28 282 def __setitem__(self, index, val):
dd9f7fea
RD
283 if index == 0: self.x = val
284 elif index == 1: self.y = val
d14a1e28 285 else: raise IndexError
dd9f7fea 286 def __nonzero__(self): return self.Get() != (0.0, 0.0)
02376d73
RD
287 __safe_for_unpickling__ = True
288 def __reduce__(self): return (wx.RealPoint, self.Get())
d14a1e28
RD
289 }
290};
291
dd9f7fea 292
d14a1e28
RD
293//---------------------------------------------------------------------------
294%newgroup
94d33c49 295
d14a1e28 296
dd9f7fea 297DocStr(wxPoint,
d07d2bc9
RD
298"A data structure for representing a point or position with integer x
299and y properties. Most places in wxPython that expect a wx.Point can
300also accept a (x,y) tuple.", "");
dd9f7fea 301
d14a1e28
RD
302class wxPoint
303{
304public:
305 int x, y;
306
dd9f7fea
RD
307 DocCtorStr(
308 wxPoint(int x=0, int y=0),
d07d2bc9 309 "Create a wx.Point object", "");
dd9f7fea 310
d14a1e28
RD
311 ~wxPoint();
312
dd9f7fea
RD
313
314 DocDeclStr(
315 bool, operator==(const wxPoint& pt),
d07d2bc9 316 "Test for equality of wx.Point objects.", "");
d14a1e28 317
dd9f7fea
RD
318 DocDeclStr(
319 bool, operator!=(const wxPoint& pt),
d07d2bc9 320 "Test for inequality of wx.Point objects.", "");
d14a1e28 321
093d613e
RD
322
323
324// %nokwargs operator+;
325// %nokwargs operator-;
326// %nokwargs operator+=;
327// %nokwargs operator-=;
dd9f7fea
RD
328
329 DocDeclStr(
330 wxPoint, operator+(const wxPoint& pt),
d07d2bc9 331 "Add pt's proprties to this and return the result.", "");
d14a1e28 332
093d613e 333
dd9f7fea
RD
334 DocDeclStr(
335 wxPoint, operator-(const wxPoint& pt),
d07d2bc9 336 "Subtract pt's proprties from this and return the result", "");
dd9f7fea
RD
337
338
339 DocDeclStr(
340 wxPoint&, operator+=(const wxPoint& pt),
d07d2bc9 341 "Add pt to this object.", "");
dd9f7fea
RD
342
343 DocDeclStr(
344 wxPoint&, operator-=(const wxPoint& pt),
d07d2bc9 345 "Subtract pt from this object.", "");
dd9f7fea 346
093d613e
RD
347
348
349// DocDeclStr(
350// wxPoint, operator+(const wxSize& sz),
d07d2bc9 351// "Add sz to this Point and return the result.", "");
093d613e
RD
352
353// DocDeclStr(
354// wxPoint, operator-(const wxSize& sz),
d07d2bc9 355// "Subtract sz from this Point and return the result", "");
093d613e
RD
356
357
358// DocDeclStr(
359// wxPoint&, operator+=(const wxSize& sz),
d07d2bc9 360// "Add sz to this object.", "");
093d613e
RD
361
362// DocDeclStr(
363// wxPoint&, operator-=(const wxSize& sz),
d07d2bc9 364// "Subtract sz from this object.", "");
093d613e
RD
365
366
367
dd9f7fea 368
d14a1e28 369 %extend {
d07d2bc9 370 DocStr(Set, "Set both the x and y properties", "");
d14a1e28
RD
371 void Set(long x, long y) {
372 self->x = x;
373 self->y = y;
374 }
dd9f7fea
RD
375
376 DocAStr(Get,
377 "Get() -> (x,y)",
d07d2bc9 378 "Return the x and y properties as a tuple. ", "");
dd9f7fea 379 PyObject* Get() {
6e6b3557 380 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
381 PyObject* tup = PyTuple_New(2);
382 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
383 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
da32eb53 384 wxPyEndBlockThreads(blocked);
d14a1e28
RD
385 return tup;
386 }
387 }
388
389 %pythoncode {
d07d2bc9 390 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
dd9f7fea
RD
391 def __str__(self): return str(self.Get())
392 def __repr__(self): return 'wx.Point'+str(self.Get())
393 def __len__(self): return len(self.Get())
394 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
395 def __setitem__(self, index, val):
396 if index == 0: self.x = val
397 elif index == 1: self.y = val
398 else: raise IndexError
dd9f7fea 399 def __nonzero__(self): return self.Get() != (0,0)
02376d73
RD
400 __safe_for_unpickling__ = True
401 def __reduce__(self): return (wx.Point, self.Get())
d14a1e28
RD
402 }
403};
404
405//---------------------------------------------------------------------------
406%newgroup
94d33c49 407
d14a1e28 408
dd9f7fea 409DocStr(wxRect,
d07d2bc9
RD
410"A class for representing and manipulating rectangles. It has x, y,
411width and height properties. In wxPython most palces that expect a
412wx.Rect can also accept a (x,y,width,height) tuple.", "");
dd9f7fea 413
d14a1e28
RD
414class wxRect
415{
416public:
dd9f7fea
RD
417 DocCtorStr(
418 wxRect(int x=0, int y=0, int width=0, int height=0),
d07d2bc9 419 "Create a new Rect object.", "");
dd9f7fea
RD
420
421 DocCtorStrName(
422 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
d07d2bc9 423 "Create a new Rect object from Points representing two corners.", "",
dd9f7fea
RD
424 RectPP);
425
426 DocCtorStrName(
427 wxRect(const wxPoint& pos, const wxSize& size),
d07d2bc9 428 "Create a new Rect from a position and size.", "",
dd9f7fea 429 RectPS);
7aada1e0
RD
430
431 DocCtorStrName(
432 wxRect(const wxSize& size),
433 "Create a new Rect from a size only.", "",
434 RectS);
435
d14a1e28
RD
436 ~wxRect();
437
438 int GetX() const;
439 void SetX(int x);
440
441 int GetY();
442 void SetY(int y);
443
444 int GetWidth() const;
445 void SetWidth(int w);
446
447 int GetHeight() const;
448 void SetHeight(int h);
449
450 wxPoint GetPosition() const;
451 void SetPosition( const wxPoint &p );
452
453 wxSize GetSize() const;
454 void SetSize( const wxSize &s );
455
c3fc056e
RD
456 bool IsEmpty() const;
457
3f0ff538
RD
458 wxPoint GetTopLeft() const;
459 void SetTopLeft(const wxPoint &p);
460 wxPoint GetBottomRight() const;
461 void SetBottomRight(const wxPoint &p);
462
463// wxPoint GetLeftTop() const;
464// void SetLeftTop(const wxPoint &p);
465// wxPoint GetRightBottom() const;
466// void SetRightBottom(const wxPoint &p);
467
d14a1e28
RD
468 int GetLeft() const;
469 int GetTop() const;
470 int GetBottom() const;
471 int GetRight() const;
472
473 void SetLeft(int left);
474 void SetRight(int right);
475 void SetTop(int top);
476 void SetBottom(int bottom);
477
dd9f7fea
RD
478 %pythoncode {
479 position = property(GetPosition, SetPosition)
480 size = property(GetSize, SetSize)
481 left = property(GetLeft, SetLeft)
482 right = property(GetRight, SetRight)
483 top = property(GetTop, SetTop)
484 bottom = property(GetBottom, SetBottom)
485 }
486
487 DocDeclStr(
488 wxRect&, Inflate(wxCoord dx, wxCoord dy),
ca30acad
RD
489 "Increases the size of the rectangle.
490
491The left border is moved farther left and the right border is moved
492farther right by ``dx``. The upper border is moved farther up and the
493bottom border is moved farther down by ``dy``. (Note the the width and
494height of the rectangle thus change by ``2*dx`` and ``2*dy``,
495respectively.) If one or both of ``dx`` and ``dy`` are negative, the
496opposite happens: the rectangle size decreases in the respective
497direction.
498
499The change is made to the rectangle inplace, if instead you need a
500copy that is inflated, preserving the original then make the copy
501first::
502
503 copy = wx.Rect(*original)
504 copy.Inflate(10,15)
505
506", "
507Inflating and deflating behaves *naturally*. Defined more precisely,
508that means:
509
510 * Real inflates (that is, ``dx`` and/or ``dy`` >= 0) are not
511 constrained. Thus inflating a rectangle can cause its upper left
512 corner to move into the negative numbers. (The versions prior to
513 2.5.4 forced the top left coordinate to not fall below (0, 0),
514 which implied a forced move of the rectangle.)
515
516 * Deflates are clamped to not reduce the width or height of the
517 rectangle below zero. In such cases, the top-left corner is
518 nonetheless handled properly. For example, a rectangle at (10,
519 10) with size (20, 40) that is inflated by (-15, -15) will
520 become located at (20, 25) at size (0, 10). Finally, observe
521 that the width and height are treated independently. In the
522 above example, the width is reduced by 20, whereas the height is
523 reduced by the full 30 (rather than also stopping at 20, when
524 the width reached zero).
525
526:see: `Deflate`
527");
dd9f7fea
RD
528
529 DocDeclStr(
530 wxRect&, Deflate(wxCoord dx, wxCoord dy),
ca30acad
RD
531 "Decrease the rectangle size. This method is the opposite of `Inflate`
532in that Deflate(a,b) is equivalent to Inflate(-a,-b). Please refer to
533`Inflate` for a full description.", "");
dd9f7fea
RD
534
535 DocDeclStrName(
536 void, Offset(wxCoord dx, wxCoord dy),
d07d2bc9
RD
537 "Moves the rectangle by the specified offset. If dx is positive, the
538rectangle is moved to the right, if dy is positive, it is moved to the
539bottom, otherwise it is moved to the left or top respectively.", "",
dd9f7fea
RD
540 OffsetXY);
541
542 DocDeclStr(
543 void, Offset(const wxPoint& pt),
096e3ea1 544 "Same as `OffsetXY` but uses dx,dy from Point", "");
dd9f7fea
RD
545
546 DocDeclStr(
9eefe9f0
RD
547 wxRect, Intersect(const wxRect& rect),
548 "Returns the intersectsion of this rectangle and rect.", "");
d14a1e28 549
9eefe9f0
RD
550 DocDeclStr(
551 wxRect , Union(const wxRect& rect),
552 "Returns the union of this rectangle and rect.", "");
553
554
dd9f7fea
RD
555 DocDeclStr(
556 wxRect, operator+(const wxRect& rect) const,
d07d2bc9 557 "Add the properties of rect to this rectangle and return the result.", "");
d14a1e28 558
dd9f7fea
RD
559 DocDeclStr(
560 wxRect&, operator+=(const wxRect& rect),
d07d2bc9 561 "Add the properties of rect to this rectangle, updating this rectangle.", "");
d14a1e28 562
dd9f7fea
RD
563 DocDeclStr(
564 bool, operator==(const wxRect& rect) const,
d07d2bc9 565 "Test for equality.", "");
d14a1e28 566
dd9f7fea
RD
567 DocDeclStr(
568 bool, operator!=(const wxRect& rect) const,
d07d2bc9 569 "Test for inequality.", "");
d14a1e28 570
dd9f7fea 571
d07d2bc9 572 DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.", "");
1b8c7ba6 573 %Rename(InsideXY, bool, Inside(int x, int y) const);
d14a1e28
RD
574 bool Inside(const wxPoint& pt) const;
575
dd9f7fea
RD
576 DocDeclStr(
577 bool, Intersects(const wxRect& rect) const,
d07d2bc9 578 "Returns True if the rectangles have a non empty intersection.", "");
d14a1e28 579
096e3ea1
RD
580 DocDeclStr(
581 wxRect, CenterIn(const wxRect& r, int dir = wxBOTH),
582 "Center this rectangle within the one passed to the method, which is
583usually, but not necessarily, the larger one.", "");
584 %pythoncode { CentreIn = CenterIn }
585
dd9f7fea 586
d14a1e28
RD
587 int x, y, width, height;
588
589
590 %extend {
d07d2bc9 591 DocStr(Set, "Set all rectangle properties.", "");
dd9f7fea 592 void Set(int x=0, int y=0, int width=0, int height=0) {
d14a1e28
RD
593 self->x = x;
594 self->y = y;
595 self->width = width;
596 self->height = height;
597 }
598
dd9f7fea
RD
599 DocAStr(Get,
600 "Get() -> (x,y,width,height)",
d07d2bc9 601 "Return the rectangle properties as a tuple.", "");
dd9f7fea 602 PyObject* Get() {
6e6b3557 603 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
604 PyObject* tup = PyTuple_New(4);
605 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
606 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
607 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
608 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
da32eb53 609 wxPyEndBlockThreads(blocked);
d14a1e28
RD
610 return tup;
611 }
612 }
613
614 %pythoncode {
d07d2bc9 615 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
dd9f7fea
RD
616 def __str__(self): return str(self.Get())
617 def __repr__(self): return 'wx.Rect'+str(self.Get())
618 def __len__(self): return len(self.Get())
619 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
620 def __setitem__(self, index, val):
621 if index == 0: self.x = val
622 elif index == 1: self.y = val
623 elif index == 2: self.width = val
624 elif index == 3: self.height = val
625 else: raise IndexError
dd9f7fea 626 def __nonzero__(self): return self.Get() != (0,0,0,0)
02376d73
RD
627 __safe_for_unpickling__ = True
628 def __reduce__(self): return (wx.Rect, self.Get())
d14a1e28
RD
629 }
630};
631
632
ab1f7d2a
RD
633MustHaveApp(wxIntersectRect);
634
dd9f7fea
RD
635DocAStr(wxIntersectRect,
636 "IntersectRect(Rect r1, Rect r2) -> Rect",
d07d2bc9 637 "Calculate and return the intersection of r1 and r2.", "");
d14a1e28
RD
638%inline %{
639 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
640 wxRegion reg1(*r1);
641 wxRegion reg2(*r2);
642 wxRect dest(0,0,0,0);
643 PyObject* obj;
644
645 reg1.Intersect(reg2);
646 dest = reg1.GetBox();
647
648 if (dest != wxRect(0,0,0,0)) {
6e6b3557 649 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28 650 wxRect* newRect = new wxRect(dest);
a72f4631 651 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
da32eb53 652 wxPyEndBlockThreads(blocked);
d14a1e28
RD
653 return obj;
654 }
655 Py_INCREF(Py_None);
656 return Py_None;
657 }
658%}
659
660//---------------------------------------------------------------------------
661%newgroup
94d33c49 662
d14a1e28 663
dd9f7fea 664DocStr(wxPoint2D,
d07d2bc9
RD
665 "wx.Point2Ds represent a point or a vector in a 2d coordinate system
666with floating point values.", "");
d14a1e28
RD
667
668class wxPoint2D
669{
dd9f7fea 670public:
d07d2bc9 671 DocStr(wxPoint2D, "Create a w.Point2D object.", "");
d14a1e28 672 wxPoint2D( double x=0.0 , double y=0.0 );
1b8c7ba6
RD
673 %RenameCtor(Point2DCopy, wxPoint2D( const wxPoint2D &pt ));
674 %RenameCtor(Point2DFromPoint, wxPoint2D( const wxPoint &pt ));
d14a1e28 675
dd9f7fea
RD
676 DocDeclAStr(
677 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
678 "GetFloor() -> (x,y)",
d07d2bc9 679 "Convert to integer", "");
dd9f7fea
RD
680
681 DocDeclAStr(
682 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
683 "GetRounded() -> (x,y)",
d07d2bc9 684 "Convert to integer", "");
d14a1e28
RD
685
686 double GetVectorLength() const;
687 double GetVectorAngle() const ;
688 void SetVectorLength( double length );
689 void SetVectorAngle( double degrees );
dd9f7fea 690
d14a1e28
RD
691 // LinkError: void SetPolarCoordinates( double angle , double length );
692 // LinkError: void Normalize();
693 %pythoncode {
694 def SetPolarCoordinates(self, angle, length):
695 self.SetVectorLength(length)
696 self.SetVectorAngle(angle)
697 def Normalize(self):
698 self.SetVectorLength(1.0)
699 }
700
701 double GetDistance( const wxPoint2D &pt ) const;
702 double GetDistanceSquare( const wxPoint2D &pt ) const;
703 double GetDotProduct( const wxPoint2D &vec ) const;
704 double GetCrossProduct( const wxPoint2D &vec ) const;
705
dd9f7fea
RD
706 DocDeclStr(
707 wxPoint2D, operator-(),
d07d2bc9 708 "the reflection of this point", "");
d14a1e28
RD
709
710 wxPoint2D& operator+=(const wxPoint2D& pt);
711 wxPoint2D& operator-=(const wxPoint2D& pt);
712
713 wxPoint2D& operator*=(const wxPoint2D& pt);
714 wxPoint2D& operator/=(const wxPoint2D& pt);
715
dd9f7fea
RD
716 DocDeclStr(
717 bool, operator==(const wxPoint2D& pt) const,
d07d2bc9 718 "Test for equality", "");
dd9f7fea
RD
719
720 DocDeclStr(
721 bool, operator!=(const wxPoint2D& pt) const,
d07d2bc9 722 "Test for inequality", "");
d14a1e28 723
1b8c7ba6
RD
724 %Rename(x, double, m_x);
725 %Rename(y, double, m_y);
d14a1e28
RD
726
727 %extend {
728 void Set( double x=0 , double y=0 ) {
729 self->m_x = x;
730 self->m_y = y;
731 }
dd9f7fea
RD
732
733 DocAStr(Get,
734 "Get() -> (x,y)",
d07d2bc9 735 "Return x and y properties as a tuple.", "");
dd9f7fea 736 PyObject* Get() {
6e6b3557 737 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
738 PyObject* tup = PyTuple_New(2);
739 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
740 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
da32eb53 741 wxPyEndBlockThreads(blocked);
d14a1e28
RD
742 return tup;
743 }
744 }
745
746 %pythoncode {
d07d2bc9 747 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
dd9f7fea
RD
748 def __str__(self): return str(self.Get())
749 def __repr__(self): return 'wx.Point2D'+str(self.Get())
750 def __len__(self): return len(self.Get())
751 def __getitem__(self, index): return self.Get()[index]
d14a1e28 752 def __setitem__(self, index, val):
dd9f7fea
RD
753 if index == 0: self.x = val
754 elif index == 1: self.y = val
d14a1e28 755 else: raise IndexError
dd9f7fea 756 def __nonzero__(self): return self.Get() != (0.0, 0.0)
02376d73
RD
757 __safe_for_unpickling__ = True
758 def __reduce__(self): return (wx.Point2D, self.Get())
d14a1e28
RD
759 }
760};
761
762
763//---------------------------------------------------------------------------
764
765%immutable;
766const wxPoint wxDefaultPosition;
767const wxSize wxDefaultSize;
768%mutable;
769
770//---------------------------------------------------------------------------