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