1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface for common GDI stuff and misc classes
7 // Created: 13-Sept-2003
9 // Copyright: (c) 2003 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
20 // Turn off the aquisition of the Global Interpreter Lock for the classes and
21 // functions in this file
27 wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility!
32 wxBITMAP_TYPE_XBM_DATA,
34 wxBITMAP_TYPE_XPM_DATA,
45 wxBITMAP_TYPE_MACCURSOR,
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,
61 wxBITMAP_TYPE_ANY = 50
67 wxCURSOR_NONE, // should be 0
77 wxCURSOR_MIDDLE_BUTTON,
83 wxCURSOR_QUESTION_ARROW,
84 wxCURSOR_RIGHT_BUTTON,
94 wxCURSOR_DEFAULT, // standard X11 cursor
95 wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow
98 // // Not yet implemented for Windows
99 // wxCURSOR_CROSS_REVERSE,
100 // wxCURSOR_DOUBLE_ARROW,
101 // wxCURSOR_BASED_ARROW_UP,
102 // wxCURSOR_BASED_ARROW_DOWN,
112 #define wxCURSOR_COPY_ARROW wxCURSOR_ARROW
116 //---------------------------------------------------------------------------
120 "wx.Size is a useful data structure used to represent the size of
121 something. It simply contains integer width and height
122 properties. In most places in wxPython where a wx.Size is
123 expected a (width, height) tuple can be used instead.", "");
128 %Rename(width, int, x);
129 %Rename(height,int, y);
130 %pythoncode { x = width; y = height }
133 wxSize(int w=0, int h=0),
134 "Creates a size object.", "");
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) ) {
149 return self->operator==(*obj);
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)) {
162 return self->operator!=(*obj);
167 wxSize, operator+(const wxSize& sz),
168 "Add sz's proprties to this and return the result.", "");
171 wxSize, operator-(const wxSize& sz),
172 "Subtract sz's properties from this and return the result.", "");
175 void, IncTo(const wxSize& sz),
176 "Increments this object so that both of its dimensions are not less
177 than the corresponding dimensions of the size.", "");
180 void, DecTo(const wxSize& sz),
181 "Decrements this object so that both of its dimensions are not greater
182 than the corresponding dimensions of the size.", "");
186 void , IncBy(int dx, int dy),
191 void , DecBy(int dx, int dy),
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);
201 void , Scale(float xscale, float yscale),
202 "Scales the dimensions of this object by the given factors.", "");
205 void, Set(int w, int h),
206 "Set both width and height.", "");
208 void SetWidth(int w);
209 void SetHeight(int h);
210 int GetWidth() const;
211 int GetHeight() const;
215 bool , IsFullySpecified() const,
216 "Returns True if both components of the size are non-default values.", "");
220 void , SetDefaults(const wxSize& size),
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.", "");
230 "Get() -> (width,height)",
231 "Returns the width and height properties as a tuple.", "");
233 //wxPyBlock_t blocked = wxPyBeginBlockThreads();
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));
237 //wxPyEndBlockThreads(blocked);
242 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
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]
247 def __setitem__(self, index, val):
248 if index == 0: self.width = val
249 elif index == 1: self.height = val
250 else: raise IndexError
251 def __nonzero__(self): return self.Get() != (0,0)
252 __safe_for_unpickling__ = True
253 def __reduce__(self): return (wx.Size, self.Get())
258 //---------------------------------------------------------------------------
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.", "");
272 wxRealPoint(double x=0.0, double y=0.0),
273 "Create a wx.RealPoint object", "");
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) ) {
287 return self->operator==(*obj);
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)) {
300 return self->operator!=(*obj);
306 wxRealPoint, operator+(const wxRealPoint& pt),
307 "Add pt's proprties to this and return the result.", "");
310 wxRealPoint, operator-(const wxRealPoint& pt),
311 "Subtract pt's proprties from this and return the result", "");
315 DocStr(Set, "Set both the x and y properties", "");
316 void Set(double x, double y) {
323 "Return the x and y properties as a tuple. ", "");
325 //wxPyBlock_t blocked = wxPyBeginBlockThreads();
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));
329 //PyEndBlockThreads(blocked);
335 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
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]
340 def __setitem__(self, index, val):
341 if index == 0: self.x = val
342 elif index == 1: self.y = val
343 else: raise IndexError
344 def __nonzero__(self): return self.Get() != (0.0, 0.0)
345 __safe_for_unpickling__ = True
346 def __reduce__(self): return (wx.RealPoint, self.Get())
351 //---------------------------------------------------------------------------
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.", "");
366 wxPoint(int x=0, int y=0),
367 "Create a wx.Point object", "");
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) ) {
382 return self->operator==(*obj);
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)) {
395 return self->operator!=(*obj);
400 // %nokwargs operator+;
401 // %nokwargs operator-;
402 // %nokwargs operator+=;
403 // %nokwargs operator-=;
406 wxPoint, operator+(const wxPoint& pt),
407 "Add pt's proprties to this and return the result.", "");
411 wxPoint, operator-(const wxPoint& pt),
412 "Subtract pt's proprties from this and return the result", "");
416 wxPoint&, operator+=(const wxPoint& pt),
417 "Add pt to this object.", "");
420 wxPoint&, operator-=(const wxPoint& pt),
421 "Subtract pt from this object.", "");
426 // wxPoint, operator+(const wxSize& sz),
427 // "Add sz to this Point and return the result.", "");
430 // wxPoint, operator-(const wxSize& sz),
431 // "Subtract sz from this Point and return the result", "");
435 // wxPoint&, operator+=(const wxSize& sz),
436 // "Add sz to this object.", "");
439 // wxPoint&, operator-=(const wxSize& sz),
440 // "Subtract sz from this object.", "");
446 DocStr(Set, "Set both the x and y properties", "");
447 void Set(long x, long y) {
454 "Return the x and y properties as a tuple. ", "");
456 //wxPyBlock_t blocked = wxPyBeginBlockThreads();
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));
460 //wxPyEndBlockThreads(blocked);
466 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
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]
471 def __setitem__(self, index, val):
472 if index == 0: self.x = val
473 elif index == 1: self.y = val
474 else: raise IndexError
475 def __nonzero__(self): return self.Get() != (0,0)
476 __safe_for_unpickling__ = True
477 def __reduce__(self): return (wx.Point, self.Get())
481 //---------------------------------------------------------------------------
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.", "");
494 wxRect(int x=0, int y=0, int width=0, int height=0),
495 "Create a new Rect object.", "");
498 wxRect(const wxPoint& topLeft, const wxPoint& bottomRight),
499 "Create a new Rect object from Points representing two corners.", "",
503 wxRect(const wxPoint& pos, const wxSize& size),
504 "Create a new Rect from a position and size.", "",
508 wxRect(const wxSize& size),
509 "Create a new Rect from a size only.", "",
520 int GetWidth() const;
521 void SetWidth(int w);
523 int GetHeight() const;
524 void SetHeight(int h);
526 wxPoint GetPosition() const;
527 void SetPosition( const wxPoint &p );
529 wxSize GetSize() const;
530 void SetSize( const wxSize &s );
532 bool IsEmpty() const;
534 wxPoint GetTopLeft() const;
535 void SetTopLeft(const wxPoint &p);
536 wxPoint GetBottomRight() const;
537 void SetBottomRight(const wxPoint &p);
539 wxPoint GetTopRight() const;
540 void SetTopRight(const wxPoint &p);
541 wxPoint GetBottomLeft() const;
542 void SetBottomLeft(const wxPoint &p);
544 // wxPoint GetLeftTop() const;
545 // void SetLeftTop(const wxPoint &p);
546 // wxPoint GetRightBottom() const;
547 // void SetRightBottom(const wxPoint &p);
548 // wxPoint GetRightTop() const;
549 // void SetRightTop(const wxPoint &p);
550 // wxPoint GetLeftBottom() const;
551 // void SetLeftBottom(const wxPoint &p);
555 int GetBottom() const;
556 int GetRight() const;
558 void SetLeft(int left);
559 void SetRight(int right);
560 void SetTop(int top);
561 void SetBottom(int bottom);
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)
574 wxRect&, Inflate(wxCoord dx, wxCoord dy),
575 "Increases the size of the rectangle.
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
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
589 copy = wx.Rect(*original)
593 Inflating and deflating behaves *naturally*. Defined more precisely,
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.)
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).
615 // There are also these versions...
616 //wxRect& Inflate(const wxSize& d);
617 //wxRect& Inflate(wxCoord d);
621 wxRect&, Deflate(wxCoord dx, wxCoord dy),
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.", "");
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); }
631 void, Offset(wxCoord dx, wxCoord dy),
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.", "",
638 void, Offset(const wxPoint& pt),
639 "Same as `OffsetXY` but uses dx,dy from Point", "");
642 wxRect, Intersect(const wxRect& rect),
643 "Returns the intersectsion of this rectangle and rect.", "");
646 wxRect , Union(const wxRect& rect),
647 "Returns the union of this rectangle and rect.", "");
651 wxRect, operator+(const wxRect& rect) const,
652 "Add the properties of rect to this rectangle and return the result.", "");
655 wxRect&, operator+=(const wxRect& rect),
656 "Add the properties of rect to this rectangle, updating this rectangle.", "");
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) ) {
668 return self->operator==(*obj);
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)) {
681 return self->operator!=(*obj);
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;
691 bool, Contains(const wxRect& rect) const,
692 "Returns ``True`` if the given rectangle is completely inside this
693 rectangle or touches its boundary.", "",
697 %#Inside = wx._deprecated(Contains, "Use `Contains` instead.")
698 %#InsideXY = wx._deprecated(ContainsXY, "Use `ContainsXY` instead.")
699 %#InsideRect = wx._deprecated(ContainsRect, "Use `ContainsRect` instead.")
701 InsideXY = ContainsXY
702 InsideRect = ContainsRect
706 bool, Intersects(const wxRect& rect) const,
707 "Returns True if the rectangles have a non empty intersection.", "");
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 }
716 int x, y, width, height;
720 DocStr(Set, "Set all rectangle properties.", "");
721 void Set(int x=0, int y=0, int width=0, int height=0) {
725 self->height = height;
729 "Get() -> (x,y,width,height)",
730 "Return the rectangle properties as a tuple.", "");
732 //wxPyBlock_t blocked = wxPyBeginBlockThreads();
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));
738 //wxPyEndBlockThreads(blocked);
744 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
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]
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
755 def __nonzero__(self): return self.Get() != (0,0,0,0)
756 __safe_for_unpickling__ = True
757 def __reduce__(self): return (wx.Rect, self.Get())
761 %property(Bottom, GetBottom, SetBottom, doc="See `GetBottom` and `SetBottom`");
762 %property(BottomRight, GetBottomRight, SetBottomRight, doc="See `GetBottomRight` and `SetBottomRight`");
763 %property(BottomLeft, GetBottomLeft, SetBottomLeft, doc="See `GetBottomLeft` and `SetBottomLeft`");
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`");
771 %property(TopRight, GetTopRight, SetTopRight, doc="See `GetTopRight` and `SetTopRight`");
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`");
776 %property(Empty, IsEmpty, doc="See `IsEmpty`");
780 MustHaveApp(wxIntersectRect);
782 DocAStr(wxIntersectRect,
783 "IntersectRect(Rect r1, Rect r2) -> Rect",
784 "Calculate and return the intersection of r1 and r2.", "");
786 PyObject* wxIntersectRect(wxRect* r1, wxRect* r2) {
789 wxRect dest(0,0,0,0);
792 reg1.Intersect(reg2);
793 dest = reg1.GetBox();
795 if (dest != wxRect(0,0,0,0)) {
796 //wxPyBlock_t blocked = wxPyBeginBlockThreads();
797 wxRect* newRect = new wxRect(dest);
798 obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
799 //wxPyEndBlockThreads(blocked);
807 //---------------------------------------------------------------------------
812 "wx.Point2Ds represent a point or a vector in a 2d coordinate system
813 with floating point values.", "");
818 DocStr(wxPoint2D, "Create a w.Point2D object.", "");
819 wxPoint2D( double x=0.0 , double y=0.0 );
820 %RenameCtor(Point2DCopy, wxPoint2D( const wxPoint2D &pt ));
821 %RenameCtor(Point2DFromPoint, wxPoint2D( const wxPoint &pt ));
826 void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
827 "GetFloor() -> (x,y)",
828 "Convert to integer", "");
831 void, GetRounded( int *OUTPUT , int *OUTPUT ) const,
832 "GetRounded() -> (x,y)",
833 "Convert to integer", "");
835 double GetVectorLength() const;
836 double GetVectorAngle() const ;
837 void SetVectorLength( double length );
838 void SetVectorAngle( double degrees );
840 // LinkError: void SetPolarCoordinates( double angle , double length );
841 // LinkError: void Normalize();
843 def SetPolarCoordinates(self, angle, length):
844 self.SetVectorLength(length)
845 self.SetVectorAngle(angle)
847 self.SetVectorLength(1.0)
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;
856 wxPoint2D, operator-(),
857 "the reflection of this point", "");
859 wxPoint2D& operator+=(const wxPoint2D& pt);
860 wxPoint2D& operator-=(const wxPoint2D& pt);
862 wxPoint2D& operator*=(const wxPoint2D& pt);
863 wxPoint2D& operator/=(const wxPoint2D& pt);
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) ) {
875 return self->operator==(*obj);
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)) {
888 return self->operator!=(*obj);
892 %Rename(x, double, m_x);
893 %Rename(y, double, m_y);
896 void Set( double x=0 , double y=0 ) {
903 "Return x and y properties as a tuple.", "");
905 //wxPyBlock_t blocked = wxPyBeginBlockThreads();
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));
909 //wxPyEndBlockThreads(blocked);
915 asTuple = wx._deprecated(Get, "asTuple is deprecated, use `Get` instead")
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]
920 def __setitem__(self, index, val):
921 if index == 0: self.x = val
922 elif index == 1: self.y = val
923 else: raise IndexError
924 def __nonzero__(self): return self.Get() != (0.0, 0.0)
925 __safe_for_unpickling__ = True
926 def __reduce__(self): return (wx.Point2D, self.Get())
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`");
937 //---------------------------------------------------------------------------
952 "wx.Rect2D is a rectangle, with position and size, in a 2D coordinate system
953 with floating point component values.", "");
958 wxRect2D(wxDouble x=0.0, wxDouble y=0.0, wxDouble w=0.0, wxDouble h=0.0);
962 wxPoint2D GetPosition();
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
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 );
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;
1005 void Inset( wxDouble x , wxDouble y );
1006 void Inset( wxDouble left , wxDouble top ,wxDouble right , wxDouble bottom );
1007 void Offset( const wxPoint2D &pt );
1009 void ConstrainTo( const wxRect2D &rect );
1011 wxPoint2D Interpolate( wxInt32 widthfactor , wxInt32 heightfactor );
1013 //static void Intersect( const wxRect2D &src1 , const wxRect2D &src2 , wxRect2D *dest );
1015 void Intersect( const wxRect2D &otherRect );
1016 wxRect2D CreateIntersection( const wxRect2D &otherRect ) const;
1017 bool Intersects( const wxRect2D &rect ) const;
1019 // static void Union( const wxRect2D &src1 , const wxRect2D &src2 , wxRect2D *dest );
1021 void Union( const wxRect2D &otherRect );
1022 //void Union( const wxPoint2D &pt );
1024 wxRect2D CreateUnion( const wxRect2D &otherRect ) const;
1027 void Scale( wxDouble f );
1028 void Scale( int num , int denum );
1030 //wxRect2D& operator = (const wxRect2D& rect);
1031 //bool operator == (const wxRect2D& rect) const;
1032 //bool operator != (const wxRect2D& rect) const;
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) ) {
1044 return self->operator==(*obj);
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)) {
1057 return self->operator!=(*obj);
1062 %Rename(x, wxDouble , m_x);
1063 %Rename(y, wxDouble , m_y);
1064 %Rename(width, wxDouble , m_width);
1065 %Rename(height, wxDouble , m_height);
1068 void Set( wxDouble x=0 , wxDouble y=0, wxDouble width=0, wxDouble height=0 ) {
1071 self->m_width = width;
1072 self->m_height = height;
1076 "Get() -> (x,y, width, height)",
1077 "Return x, y, width and height y properties as a tuple.", "");
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);
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())
1108 //---------------------------------------------------------------------------
1111 const wxPoint wxDefaultPosition;
1112 const wxSize wxDefaultSize;
1115 //---------------------------------------------------------------------------
1117 // Turn GIL acquisition back on.