]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_gdicmn.i
reSWIGged
[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
RD
114DocStr( wxSize,
115"wx.Size is a useful data structure used to represent the size of something.
116It simply contians integer width and height proprtites. In most places in
117wxPython where a wx.Size is expected a (width,height) tuple can be used
118instead.");
119
d14a1e28
RD
120class wxSize
121{
122public:
d14a1e28
RD
123 %name(width) int x;
124 %name(height)int y;
61c5a8ac
RD
125 %pythoncode { x = width; y = height }
126
dd9f7fea
RD
127 DocCtorStr(
128 wxSize(int w=0, int h=0),
129 "Creates a size object.");
130
d14a1e28
RD
131 ~wxSize();
132
22faec7d
RD
133// %extend {
134// bool __eq__(const wxSize* other) { return other ? (*self == *other) : False; }
135// bool __ne__(const wxSize* other) { return other ? (*self != *other) : True; }
136// }
137
dd9f7fea
RD
138 DocDeclStr(
139 bool, operator==(const wxSize& sz),
140 "Test for equality of wx.Size objects.");
141
142 DocDeclStr(
143 bool, operator!=(const wxSize& sz),
144 "Test for inequality.");
d14a1e28 145
dd9f7fea
RD
146 DocDeclStr(
147 wxSize, operator+(const wxSize& sz),
148 "Add sz's proprties to this and return the result.");
d14a1e28 149
dd9f7fea
RD
150 DocDeclStr(
151 wxSize, operator-(const wxSize& sz),
152 "Subtract sz's properties from this and return the result.");
d14a1e28 153
dd9f7fea
RD
154 DocDeclStr(
155 void, IncTo(const wxSize& sz),
156 "Increments this object so that both of its dimensions are not less\n"
157 "than the corresponding dimensions of the size.");
158
159 DocDeclStr(
160 void, DecTo(const wxSize& sz),
161 "Decrements this object so that both of its dimensions are not greater\n"
162 "than the corresponding dimensions of the size.");
163
164 DocDeclStr(
165 void, Set(int w, int h),
166 "Set both width and height.");
167
d14a1e28
RD
168 void SetWidth(int w);
169 void SetHeight(int h);
170 int GetWidth() const;
171 int GetHeight() const;
172
dd9f7fea
RD
173 //int GetX() const;
174 //int GetY() const;
d14a1e28
RD
175
176 %extend {
dd9f7fea
RD
177 DocAStr(Get,
178 "Get() -> (width,height)",
179 "Returns the width and height properties as a tuple.");
180 PyObject* Get() {
d14a1e28
RD
181 wxPyBeginBlockThreads();
182 PyObject* tup = PyTuple_New(2);
183 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
184 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
185 wxPyEndBlockThreads();
186 return tup;
187 }
188 }
189 %pythoncode {
dd9f7fea
RD
190 asTuple = Get
191 def __str__(self): return str(self.Get())
192 def __repr__(self): return 'wx.Size'+str(self.Get())
193 def __len__(self): return len(self.Get())
194 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
195 def __setitem__(self, index, val):
196 if index == 0: self.width = val
197 elif index == 1: self.height = val
198 else: raise IndexError
dd9f7fea 199 def __nonzero__(self): return self.Get() != (0,0)
02376d73
RD
200 __safe_for_unpickling__ = True
201 def __reduce__(self): return (wx.Size, self.Get())
d14a1e28
RD
202 }
203
204};
205
206//---------------------------------------------------------------------------
207%newgroup
94d33c49 208
dd9f7fea
RD
209DocStr( wxRealPoint,
210"A data structure for representing a point or position with floating point x
211and y properties. In wxPython most places that expect a wx.RealPoint can also
212accept a (x,y) tuple.");
d14a1e28
RD
213class wxRealPoint
214{
215public:
216 double x;
217 double y;
218
dd9f7fea
RD
219 DocCtorStr(
220 wxRealPoint(double x=0.0, double y=0.0),
221 "Create a wx.RealPoint object");
222
d14a1e28
RD
223 ~wxRealPoint();
224
dd9f7fea
RD
225 DocDeclStr(
226 bool, operator==(const wxRealPoint& pt),
227 "Test for equality of wx.RealPoint objects.");
228
229 DocDeclStr(
230 bool, operator!=(const wxRealPoint& pt),
231 "Test for inequality of wx.RealPoint objects.");
232
233
234 DocDeclStr(
235 wxRealPoint, operator+(const wxRealPoint& pt),
236 "Add pt's proprties to this and return the result.");
237
238 DocDeclStr(
239 wxRealPoint, operator-(const wxRealPoint& pt),
240 "Subtract pt's proprties from this and return the result");
d14a1e28 241
d14a1e28
RD
242
243 %extend {
dd9f7fea 244 DocStr(Set, "Set both the x and y properties");
d14a1e28
RD
245 void Set(double x, double y) {
246 self->x = x;
247 self->y = y;
248 }
dd9f7fea
RD
249
250 DocAStr(Get,
251 "Get() -> (x,y)",
252 "Return the x and y properties as a tuple. ");
253 PyObject* Get() {
d14a1e28
RD
254 wxPyBeginBlockThreads();
255 PyObject* tup = PyTuple_New(2);
256 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
257 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
258 wxPyEndBlockThreads();
259 return tup;
260 }
261 }
262
263 %pythoncode {
dd9f7fea
RD
264 asTuple = Get
265 def __str__(self): return str(self.Get())
266 def __repr__(self): return 'wx.RealPoint'+str(self.Get())
267 def __len__(self): return len(self.Get())
268 def __getitem__(self, index): return self.Get()[index]
d14a1e28 269 def __setitem__(self, index, val):
dd9f7fea
RD
270 if index == 0: self.x = val
271 elif index == 1: self.y = val
d14a1e28 272 else: raise IndexError
dd9f7fea 273 def __nonzero__(self): return self.Get() != (0.0, 0.0)
02376d73
RD
274 __safe_for_unpickling__ = True
275 def __reduce__(self): return (wx.RealPoint, self.Get())
d14a1e28
RD
276 }
277};
278
dd9f7fea 279
d14a1e28
RD
280//---------------------------------------------------------------------------
281%newgroup
94d33c49 282
d14a1e28 283
dd9f7fea
RD
284DocStr(wxPoint,
285"A data structure for representing a point or position with integer x and y
286properties. Most places in wxPython that expect a wx.Point can also accept a
287(x,y) tuple.");
288
d14a1e28
RD
289class wxPoint
290{
291public:
292 int x, y;
293
dd9f7fea
RD
294 DocCtorStr(
295 wxPoint(int x=0, int y=0),
296 "Create a wx.Point object");
297
d14a1e28
RD
298 ~wxPoint();
299
dd9f7fea
RD
300
301 DocDeclStr(
302 bool, operator==(const wxPoint& pt),
303 "Test for equality of wx.Point objects.");
d14a1e28 304
dd9f7fea
RD
305 DocDeclStr(
306 bool, operator!=(const wxPoint& pt),
307 "Test for inequality of wx.Point objects.");
d14a1e28 308
093d613e
RD
309
310
311// %nokwargs operator+;
312// %nokwargs operator-;
313// %nokwargs operator+=;
314// %nokwargs operator-=;
dd9f7fea
RD
315
316 DocDeclStr(
317 wxPoint, operator+(const wxPoint& pt),
318 "Add pt's proprties to this and return the result.");
d14a1e28 319
093d613e 320
dd9f7fea
RD
321 DocDeclStr(
322 wxPoint, operator-(const wxPoint& pt),
323 "Subtract pt's proprties from this and return the result");
324
325
326 DocDeclStr(
327 wxPoint&, operator+=(const wxPoint& pt),
328 "Add pt to this object.");
329
330 DocDeclStr(
331 wxPoint&, operator-=(const wxPoint& pt),
332 "Subtract pt from this object.");
333
093d613e
RD
334
335
336// DocDeclStr(
337// wxPoint, operator+(const wxSize& sz),
338// "Add sz to this Point and return the result.");
339
340// DocDeclStr(
341// wxPoint, operator-(const wxSize& sz),
342// "Subtract sz from this Point and return the result");
343
344
345// DocDeclStr(
346// wxPoint&, operator+=(const wxSize& sz),
347// "Add sz to this object.");
348
349// DocDeclStr(
350// wxPoint&, operator-=(const wxSize& sz),
351// "Subtract sz from this object.");
352
353
354
dd9f7fea 355
d14a1e28 356 %extend {
dd9f7fea 357 DocStr(Set, "Set both the x and y properties");
d14a1e28
RD
358 void Set(long x, long y) {
359 self->x = x;
360 self->y = y;
361 }
dd9f7fea
RD
362
363 DocAStr(Get,
364 "Get() -> (x,y)",
365 "Return the x and y properties as a tuple. ");
366 PyObject* Get() {
d14a1e28
RD
367 wxPyBeginBlockThreads();
368 PyObject* tup = PyTuple_New(2);
369 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
370 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
371 wxPyEndBlockThreads();
372 return tup;
373 }
374 }
375
376 %pythoncode {
dd9f7fea
RD
377 asTuple = Get
378 def __str__(self): return str(self.Get())
379 def __repr__(self): return 'wx.Point'+str(self.Get())
380 def __len__(self): return len(self.Get())
381 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
382 def __setitem__(self, index, val):
383 if index == 0: self.x = val
384 elif index == 1: self.y = val
385 else: raise IndexError
dd9f7fea 386 def __nonzero__(self): return self.Get() != (0,0)
02376d73
RD
387 __safe_for_unpickling__ = True
388 def __reduce__(self): return (wx.Point, self.Get())
d14a1e28
RD
389 }
390};
391
392//---------------------------------------------------------------------------
393%newgroup
94d33c49 394
d14a1e28 395
dd9f7fea
RD
396DocStr(wxRect,
397"A class for representing and manipulating rectangles. It has x, y, width and
398height properties. In wxPython most palces that expect a wx.Rect can also
399accept a (x,y,width,height) tuple.");
400
d14a1e28
RD
401class wxRect
402{
403public:
dd9f7fea
RD
404 DocCtorStr(
405 wxRect(int x=0, int y=0, int width=0, int height=0),
406 "Create a new Rect object.");
407
408 DocCtorStrName(
409 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
410 "Create a new Rect object from Points representing two corners.",
411 RectPP);
412
413 DocCtorStrName(
414 wxRect(const wxPoint& pos, const wxSize& size),
415 "Create a new Rect from a position and size.",
416 RectPS);
417
d14a1e28
RD
418 ~wxRect();
419
420 int GetX() const;
421 void SetX(int x);
422
423 int GetY();
424 void SetY(int y);
425
426 int GetWidth() const;
427 void SetWidth(int w);
428
429 int GetHeight() const;
430 void SetHeight(int h);
431
432 wxPoint GetPosition() const;
433 void SetPosition( const wxPoint &p );
434
435 wxSize GetSize() const;
436 void SetSize( const wxSize &s );
437
3f0ff538
RD
438 wxPoint GetTopLeft() const;
439 void SetTopLeft(const wxPoint &p);
440 wxPoint GetBottomRight() const;
441 void SetBottomRight(const wxPoint &p);
442
443// wxPoint GetLeftTop() const;
444// void SetLeftTop(const wxPoint &p);
445// wxPoint GetRightBottom() const;
446// void SetRightBottom(const wxPoint &p);
447
d14a1e28
RD
448 int GetLeft() const;
449 int GetTop() const;
450 int GetBottom() const;
451 int GetRight() const;
452
453 void SetLeft(int left);
454 void SetRight(int right);
455 void SetTop(int top);
456 void SetBottom(int bottom);
457
dd9f7fea
RD
458 %pythoncode {
459 position = property(GetPosition, SetPosition)
460 size = property(GetSize, SetSize)
461 left = property(GetLeft, SetLeft)
462 right = property(GetRight, SetRight)
463 top = property(GetTop, SetTop)
464 bottom = property(GetBottom, SetBottom)
465 }
466
467 DocDeclStr(
468 wxRect&, Inflate(wxCoord dx, wxCoord dy),
469 "Increase the rectangle size by dx in x direction and dy in y direction. Both\n"
470 "(or one of) parameters may be negative to decrease the rectangle size.");
471
472 DocDeclStr(
473 wxRect&, Deflate(wxCoord dx, wxCoord dy),
474 "Decrease the rectangle size by dx in x direction and dy in y direction. Both\n"
475 "(or one of) parameters may be negative to increase the rectngle size. This\n"
476 "method is the opposite of Inflate.");
477
478 DocDeclStrName(
479 void, Offset(wxCoord dx, wxCoord dy),
480 "Moves the rectangle by the specified offset. If dx is positive, the rectangle\n"
481 "is moved to the right, if dy is positive, it is moved to the bottom, otherwise\n"
482 "it is moved to the left or top respectively.",
483 OffsetXY);
484
485 DocDeclStr(
486 void, Offset(const wxPoint& pt),
487 "Same as OffsetXY but uses dx,dy from Point");
488
489 DocDeclStr(
490 wxRect&, Intersect(const wxRect& rect),
491 "Return the intersectsion of this rectangle and rect.");
d14a1e28 492
dd9f7fea
RD
493 DocDeclStr(
494 wxRect, operator+(const wxRect& rect) const,
495 "Add the properties of rect to this rectangle and return the result.");
d14a1e28 496
dd9f7fea
RD
497 DocDeclStr(
498 wxRect&, operator+=(const wxRect& rect),
499 "Add the properties of rect to this rectangle, updating this rectangle.");
d14a1e28 500
dd9f7fea
RD
501 DocDeclStr(
502 bool, operator==(const wxRect& rect) const,
503 "Test for equality.");
d14a1e28 504
dd9f7fea
RD
505 DocDeclStr(
506 bool, operator!=(const wxRect& rect) const,
507 "Test for inequality.");
d14a1e28 508
dd9f7fea
RD
509
510 DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.");
d14a1e28
RD
511 %name(InsideXY)bool Inside(int x, int y) const;
512 bool Inside(const wxPoint& pt) const;
513
dd9f7fea
RD
514 DocDeclStr(
515 bool, Intersects(const wxRect& rect) const,
516 "Returns True if the rectangles have a non empty intersection.");
d14a1e28 517
dd9f7fea 518
d14a1e28
RD
519 int x, y, width, height;
520
521
522 %extend {
dd9f7fea
RD
523 DocStr(Set, "Set all rectangle properties.");
524 void Set(int x=0, int y=0, int width=0, int height=0) {
d14a1e28
RD
525 self->x = x;
526 self->y = y;
527 self->width = width;
528 self->height = height;
529 }
530
dd9f7fea
RD
531 DocAStr(Get,
532 "Get() -> (x,y,width,height)",
533 "Return the rectangle properties as a tuple.");
534 PyObject* Get() {
d14a1e28
RD
535 wxPyBeginBlockThreads();
536 PyObject* tup = PyTuple_New(4);
537 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
538 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
539 PyTuple_SET_ITEM(tup, 2, PyInt_FromLong(self->width));
540 PyTuple_SET_ITEM(tup, 3, PyInt_FromLong(self->height));
541 wxPyEndBlockThreads();
542 return tup;
543 }
544 }
545
546 %pythoncode {
dd9f7fea
RD
547 asTuple = Get
548 def __str__(self): return str(self.Get())
549 def __repr__(self): return 'wx.Rect'+str(self.Get())
550 def __len__(self): return len(self.Get())
551 def __getitem__(self, index): return self.Get()[index]
d14a1e28
RD
552 def __setitem__(self, index, val):
553 if index == 0: self.x = val
554 elif index == 1: self.y = val
555 elif index == 2: self.width = val
556 elif index == 3: self.height = val
557 else: raise IndexError
dd9f7fea 558 def __nonzero__(self): return self.Get() != (0,0,0,0)
02376d73
RD
559 __safe_for_unpickling__ = True
560 def __reduce__(self): return (wx.Rect, self.Get())
d14a1e28
RD
561 }
562};
563
564
dd9f7fea
RD
565DocAStr(wxIntersectRect,
566 "IntersectRect(Rect r1, Rect r2) -> Rect",
567 "Calculate and return the intersection of r1 and r2.");
d14a1e28
RD
568%inline %{
569 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
570 wxRegion reg1(*r1);
571 wxRegion reg2(*r2);
572 wxRect dest(0,0,0,0);
573 PyObject* obj;
574
575 reg1.Intersect(reg2);
576 dest = reg1.GetBox();
577
578 if (dest != wxRect(0,0,0,0)) {
579 wxPyBeginBlockThreads();
580 wxRect* newRect = new wxRect(dest);
dd9f7fea 581 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), True);
d14a1e28
RD
582 wxPyEndBlockThreads();
583 return obj;
584 }
585 Py_INCREF(Py_None);
586 return Py_None;
587 }
588%}
589
590//---------------------------------------------------------------------------
591%newgroup
94d33c49 592
d14a1e28 593
dd9f7fea
RD
594DocStr(wxPoint2D,
595 "wx.Point2Ds represent a point or a vector in a 2d coordinate system with floating point values.");
d14a1e28
RD
596
597class wxPoint2D
598{
dd9f7fea
RD
599public:
600 DocStr(wxPoint2D, "Create a w.Point2D object.");
d14a1e28
RD
601 wxPoint2D( double x=0.0 , double y=0.0 );
602 %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
603 %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
604
dd9f7fea
RD
605 DocDeclAStr(
606 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
607 "GetFloor() -> (x,y)",
608 "Convert to integer");
609
610 DocDeclAStr(
611 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
612 "GetRounded() -> (x,y)",
613 "Convert to integer");
d14a1e28
RD
614
615 double GetVectorLength() const;
616 double GetVectorAngle() const ;
617 void SetVectorLength( double length );
618 void SetVectorAngle( double degrees );
dd9f7fea 619
d14a1e28
RD
620 // LinkError: void SetPolarCoordinates( double angle , double length );
621 // LinkError: void Normalize();
622 %pythoncode {
623 def SetPolarCoordinates(self, angle, length):
624 self.SetVectorLength(length)
625 self.SetVectorAngle(angle)
626 def Normalize(self):
627 self.SetVectorLength(1.0)
628 }
629
630 double GetDistance( const wxPoint2D &pt ) const;
631 double GetDistanceSquare( const wxPoint2D &pt ) const;
632 double GetDotProduct( const wxPoint2D &vec ) const;
633 double GetCrossProduct( const wxPoint2D &vec ) const;
634
dd9f7fea
RD
635 DocDeclStr(
636 wxPoint2D, operator-(),
637 "the reflection of this point");
d14a1e28
RD
638
639 wxPoint2D& operator+=(const wxPoint2D& pt);
640 wxPoint2D& operator-=(const wxPoint2D& pt);
641
642 wxPoint2D& operator*=(const wxPoint2D& pt);
643 wxPoint2D& operator/=(const wxPoint2D& pt);
644
dd9f7fea
RD
645 DocDeclStr(
646 bool, operator==(const wxPoint2D& pt) const,
647 "Test for equality");
648
649 DocDeclStr(
650 bool, operator!=(const wxPoint2D& pt) const,
651 "Test for inequality");
d14a1e28 652
d14a1e28
RD
653 %name(x)double m_x;
654 %name(y)double m_y;
655
656 %extend {
657 void Set( double x=0 , double y=0 ) {
658 self->m_x = x;
659 self->m_y = y;
660 }
dd9f7fea
RD
661
662 DocAStr(Get,
663 "Get() -> (x,y)",
664 "Return x and y properties as a tuple.");
665 PyObject* Get() {
d14a1e28
RD
666 wxPyBeginBlockThreads();
667 PyObject* tup = PyTuple_New(2);
668 PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
669 PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
670 wxPyEndBlockThreads();
671 return tup;
672 }
673 }
674
675 %pythoncode {
dd9f7fea
RD
676 asTuple = Get
677 def __str__(self): return str(self.Get())
678 def __repr__(self): return 'wx.Point2D'+str(self.Get())
679 def __len__(self): return len(self.Get())
680 def __getitem__(self, index): return self.Get()[index]
d14a1e28 681 def __setitem__(self, index, val):
dd9f7fea
RD
682 if index == 0: self.x = val
683 elif index == 1: self.y = val
d14a1e28 684 else: raise IndexError
dd9f7fea 685 def __nonzero__(self): return self.Get() != (0.0, 0.0)
02376d73
RD
686 __safe_for_unpickling__ = True
687 def __reduce__(self): return (wx.Point2D, self.Get())
d14a1e28
RD
688 }
689};
690
691
692//---------------------------------------------------------------------------
693
694%immutable;
695const wxPoint wxDefaultPosition;
696const wxSize wxDefaultSize;
697%mutable;
698
699//---------------------------------------------------------------------------