]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_gdicmn.i
fixes for compilation with wxUSE_XXX==0 and some other minor fixes (patch 1569904)
[wxWidgets.git] / wxPython / src / _gdicmn.i
index b4652a72bc4b100ef846d0fcd2f70a6b94c9e865..61f99c065f5cd52f82ba8ae3eeb0a745b8c0f5f9 100644 (file)
@@ -113,8 +113,8 @@ enum wxStockCursor
 
 DocStr( wxSize,
 "wx.Size is a useful data structure used to represent the size of
 
 DocStr( wxSize,
 "wx.Size is a useful data structure used to represent the size of
-something.  It simply contians integer width and height
-proprtites.  In most places in wxPython where a wx.Size is
+something.  It simply contains integer width and height
+properties.  In most places in wxPython where a wx.Size is
 expected a (width, height) tuple can be used instead.", "");
 
 class wxSize
 expected a (width, height) tuple can be used instead.", "");
 
 class wxSize
@@ -130,19 +130,33 @@ public:
 
     ~wxSize();
 
 
     ~wxSize();
 
-// None/NULL is now handled properly by the typemap, so these are not needed.
-//     %extend {
-//         bool __eq__(const wxSize* other) { return other ? (*self == *other) : false; }
-//         bool __ne__(const wxSize* other) { return other ? (*self != *other) : true;  }
-//     }
-
-    DocDeclStr(
-        bool, operator==(const wxSize& sz),
-        "Test for equality of wx.Size objects.", "");
+    
+    %extend {
+        KeepGIL(__eq__);
+        DocStr(__eq__, "Test for equality of wx.Size objects.", "");
+        bool __eq__(PyObject* other) {
+            wxSize  temp, *obj = &temp;
+            if ( other == Py_None ) return false;
+            if ( ! wxSize_helper(other, &obj) ) {
+                PyErr_Clear();
+                return false;
+            }
+            return self->operator==(*obj);
+        }
 
 
-    DocDeclStr(
-        bool, operator!=(const wxSize& sz),
-        "Test for inequality.", "");
+        
+        KeepGIL(__ne__);
+        DocStr(__ne__, "Test for inequality of wx.Size objects.", "");
+        bool __ne__(PyObject* other) {
+            wxSize  temp, *obj = &temp;
+            if ( other == Py_None ) return true;
+            if ( ! wxSize_helper(other, &obj)) {
+                PyErr_Clear();
+                return true;
+            }
+            return self->operator!=(*obj);
+        }
+    }
 
     DocDeclStr(
         wxSize, operator+(const wxSize& sz),
 
     DocDeclStr(
         wxSize, operator+(const wxSize& sz),
@@ -162,6 +176,26 @@ than the corresponding dimensions of the size.", "");
         "Decrements this object so that both of its dimensions are not greater
 than the corresponding dimensions of the size.", "");
 
         "Decrements this object so that both of its dimensions are not greater
 than the corresponding dimensions of the size.", "");
 
+
+    DocDeclStr(
+        void , IncBy(int dx, int dy),
+        "", "");
+    
+
+    DocDeclStr(
+        void , DecBy(int dx, int dy),
+        "", "");
+    
+// TODO: handle these overloads too?    
+//     void IncBy(const wxSize& sz);
+//     void IncBy(int d);
+//     void DecBy(const wxSize& sz);
+//     void DecBy(int d);
+    
+    DocDeclStr(
+        void , Scale(float xscale, float yscale),
+        "Scales the dimensions of this object by the given factors.", "");
+
     DocDeclStr(
         void, Set(int w, int h),
         "Set both width and height.", "");
     DocDeclStr(
         void, Set(int w, int h),
         "Set both width and height.", "");
@@ -191,7 +225,7 @@ of this object (i.e. equal to -1) with those of the other.", "");
                "Get() -> (width,height)",
                "Returns the width and height properties as a tuple.", "");
         PyObject* Get() {
                "Get() -> (width,height)",
                "Returns the width and height properties as a tuple.", "");
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
@@ -235,13 +269,32 @@ public:
     
     ~wxRealPoint();
 
     
     ~wxRealPoint();
 
-    DocDeclStr(
-        bool, operator==(const wxRealPoint& pt),
-        "Test for equality of wx.RealPoint objects.", "");
+    %extend {
+        KeepGIL(__eq__);
+        DocStr(__eq__, "Test for equality of wx.RealPoint objects.", "");
+        bool __eq__(PyObject* other) {
+            wxRealPoint  temp, *obj = &temp;
+            if ( other == Py_None ) return false;
+            if ( ! wxRealPoint_helper(other, &obj) ) {
+                PyErr_Clear();
+                return false;
+            }
+            return self->operator==(*obj);
+        }
 
 
-    DocDeclStr(
-        bool, operator!=(const wxRealPoint& pt),
-        "Test for inequality of wx.RealPoint objects.", "");
+        
+        KeepGIL(__ne__);
+        DocStr(__ne__, "Test for inequality of wx.RealPoint objects.", "");
+        bool __ne__(PyObject* other) {
+            wxRealPoint  temp, *obj = &temp;
+            if ( other == Py_None ) return true;
+            if ( ! wxRealPoint_helper(other, &obj)) {
+                PyErr_Clear();
+                return true;
+            }
+            return self->operator!=(*obj);
+        }
+    }
 
     
     DocDeclStr(
 
     
     DocDeclStr(
@@ -264,7 +317,7 @@ public:
                "Get() -> (x,y)",
                "Return the x and y properties as a tuple. ", "");
         PyObject* Get() {
                "Get() -> (x,y)",
                "Return the x and y properties as a tuple. ", "");
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
             PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->x));
             PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->y));
@@ -311,14 +364,32 @@ public:
     ~wxPoint();
 
     
     ~wxPoint();
 
     
-    DocDeclStr(
-        bool, operator==(const wxPoint& pt),
-        "Test for equality of wx.Point objects.", "");
-
-    DocDeclStr(
-        bool, operator!=(const wxPoint& pt),
-        "Test for inequality of wx.Point objects.", "");
+    %extend {
+        KeepGIL(__eq__);
+        DocStr(__eq__, "Test for equality of wx.Point objects.", "");
+        bool __eq__(PyObject* other) {
+            wxPoint  temp, *obj = &temp;
+            if ( other == Py_None ) return false;
+            if ( ! wxPoint_helper(other, &obj) ) {
+                PyErr_Clear();
+                return false;
+            }
+            return self->operator==(*obj);
+        }
 
 
+        
+        KeepGIL(__ne__);
+        DocStr(__ne__, "Test for inequality of wx.Point objects.", "");
+        bool __ne__(PyObject* other) {
+            wxPoint  temp, *obj = &temp;
+            if ( other == Py_None ) return true;
+            if ( ! wxPoint_helper(other, &obj)) {
+                PyErr_Clear();
+                return true;
+            }
+            return self->operator!=(*obj);
+        }
+    }
 
 
 //     %nokwargs operator+;
 
 
 //     %nokwargs operator+;
@@ -377,7 +448,7 @@ public:
                "Get() -> (x,y)",
                "Return the x and y properties as a tuple. ", "");
         PyObject* Get() {
                "Get() -> (x,y)",
                "Return the x and y properties as a tuple. ", "");
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
@@ -453,15 +524,26 @@ public:
     wxSize GetSize() const;
     void SetSize( const wxSize &s );
 
     wxSize GetSize() const;
     void SetSize( const wxSize &s );
 
+    bool IsEmpty() const;
+    
     wxPoint GetTopLeft() const;
     void SetTopLeft(const wxPoint &p);
     wxPoint GetBottomRight() const;
     void SetBottomRight(const wxPoint &p);
 
     wxPoint GetTopLeft() const;
     void SetTopLeft(const wxPoint &p);
     wxPoint GetBottomRight() const;
     void SetBottomRight(const wxPoint &p);
 
+    wxPoint GetTopRight() const;
+    void SetTopRight(const wxPoint &p);
+    wxPoint GetBottomLeft() const;
+    void SetBottomLeft(const wxPoint &p);
+    
 //    wxPoint GetLeftTop() const;
 //    void SetLeftTop(const wxPoint &p);
 //    wxPoint GetRightBottom() const;
 //    void SetRightBottom(const wxPoint &p);
 //    wxPoint GetLeftTop() const;
 //    void SetLeftTop(const wxPoint &p);
 //    wxPoint GetRightBottom() const;
 //    void SetRightBottom(const wxPoint &p);
+//    wxPoint GetRightTop() const;
+//    void SetRightTop(const wxPoint &p);
+//    wxPoint GetLeftBottom() const;
+//    void SetLeftBottom(const wxPoint &p);
 
     int GetLeft()   const;
     int GetTop()    const;
 
     int GetLeft()   const;
     int GetTop()    const;
@@ -482,6 +564,7 @@ public:
         bottom = property(GetBottom, SetBottom)
     }
 
         bottom = property(GetBottom, SetBottom)
     }
 
+
     DocDeclStr(
         wxRect&, Inflate(wxCoord dx, wxCoord dy),
         "Increases the size of the rectangle.
     DocDeclStr(
         wxRect&, Inflate(wxCoord dx, wxCoord dy),
         "Increases the size of the rectangle.
@@ -524,12 +607,21 @@ that means:
 :see: `Deflate`
 ");
 
 :see: `Deflate`
 ");
 
+    // There are also these versions...
+    //wxRect& Inflate(const wxSize& d);
+    //wxRect& Inflate(wxCoord d);
+
+    
     DocDeclStr(
         wxRect&, Deflate(wxCoord dx, wxCoord dy),
         "Decrease the rectangle size. This method is the opposite of `Inflate`
 in that Deflate(a,b) is equivalent to Inflate(-a,-b).  Please refer to
 `Inflate` for a full description.", "");
 
     DocDeclStr(
         wxRect&, Deflate(wxCoord dx, wxCoord dy),
         "Decrease the rectangle size. This method is the opposite of `Inflate`
 in that Deflate(a,b) is equivalent to Inflate(-a,-b).  Please refer to
 `Inflate` for a full description.", "");
 
+    // There are also these versions...
+    //wxRect& Deflate(const wxSize& d) { return Inflate(-d.x, -d.y); }
+    //wxRect& Deflate(wxCoord d) { return Inflate(-d); }
+
     DocDeclStrName(
         void, Offset(wxCoord dx, wxCoord dy),
         "Moves the rectangle by the specified offset. If dx is positive, the
     DocDeclStrName(
         void, Offset(wxCoord dx, wxCoord dy),
         "Moves the rectangle by the specified offset. If dx is positive, the
@@ -539,7 +631,7 @@ bottom, otherwise it is moved to the left or top respectively.", "",
     
     DocDeclStr(
         void, Offset(const wxPoint& pt),
     
     DocDeclStr(
         void, Offset(const wxPoint& pt),
-        "Same as OffsetXY but uses dx,dy from Point", "");
+        "Same as `OffsetXY` but uses dx,dy from Point", "");
 
     DocDeclStr(
         wxRect, Intersect(const wxRect& rect),
 
     DocDeclStr(
         wxRect, Intersect(const wxRect& rect),
@@ -558,23 +650,59 @@ bottom, otherwise it is moved to the left or top respectively.", "",
         wxRect&, operator+=(const wxRect& rect),
         "Add the properties of rect to this rectangle, updating this rectangle.", "");
 
         wxRect&, operator+=(const wxRect& rect),
         "Add the properties of rect to this rectangle, updating this rectangle.", "");
 
-    DocDeclStr(
-        bool, operator==(const wxRect& rect) const,
-        "Test for equality.", "");
+    %extend {
+        KeepGIL(__eq__);
+        DocStr(__eq__, "Test for equality of wx.Rect objects.", "");
+        bool __eq__(PyObject* other) {
+            wxRect  temp, *obj = &temp;
+            if ( other == Py_None ) return false;
+            if ( ! wxRect_helper(other, &obj) ) {
+                PyErr_Clear();
+                return false;
+            }
+            return self->operator==(*obj);
+        }
 
 
-    DocDeclStr(
-        bool, operator!=(const wxRect& rect) const,
-        "Test for inequality.", "");
+        
+        KeepGIL(__ne__);
+        DocStr(__ne__, "Test for inequality of wx.Rect objects.", "");
+        bool __ne__(PyObject* other) {
+            wxRect  temp, *obj = &temp;
+            if ( other == Py_None ) return true;
+            if ( ! wxRect_helper(other, &obj)) {
+                PyErr_Clear();
+                return true;
+            }
+            return self->operator!=(*obj);
+        }
+    }
 
     
 
     
-    DocStr( Inside, "Return True if the point is (not strcitly) inside the rect.", "");
-    %Rename(InsideXY, bool, Inside(int x, int y) const);
-    bool Inside(const wxPoint& pt) const;
+    DocStr( Contains, "Return True if the point is inside the rect.", "");
+    %Rename(ContainsXY, bool, Contains(int x, int y) const);
+    bool Contains(const wxPoint& pt) const;
 
 
+    DocDeclStrName(
+        bool, Contains(const wxRect& rect) const,
+        "Returns ``True`` if the given rectangle is completely inside this
+rectangle or touches its boundary.", "",
+        ContainsRect);
+    %pythoncode {
+        Inside = wx._deprecated(Contains, "Use `Contains` instead.")
+        InsideXY = wx._deprecated(ContainsXY, "Use `ContainsXY` instead.")
+        InsideRect = wx._deprecated(ContainsRect, "Use `ContainsRect` instead.")
+    }
+    
     DocDeclStr(    
         bool, Intersects(const wxRect& rect) const,
         "Returns True if the rectangles have a non empty intersection.", "");
 
     DocDeclStr(    
         bool, Intersects(const wxRect& rect) const,
         "Returns True if the rectangles have a non empty intersection.", "");
 
+    DocDeclStr(
+        wxRect, CenterIn(const wxRect& r, int dir = wxBOTH),
+        "Center this rectangle within the one passed to the method, which is
+usually, but not necessarily, the larger one.", "");
+    %pythoncode { CentreIn = CenterIn }
+    
     
     int x, y, width, height;
 
     
     int x, y, width, height;
 
@@ -592,7 +720,7 @@ bottom, otherwise it is moved to the left or top respectively.", "",
                "Get() -> (x,y,width,height)",
                "Return the rectangle properties as a tuple.", "");
         PyObject* Get() {
                "Get() -> (x,y,width,height)",
                "Return the rectangle properties as a tuple.", "");
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(4);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
             PyObject* tup = PyTuple_New(4);
             PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->x));
             PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y));
@@ -619,6 +747,24 @@ bottom, otherwise it is moved to the left or top respectively.", "",
     __safe_for_unpickling__ = True
     def __reduce__(self):                return (wx.Rect, self.Get())
     }
     __safe_for_unpickling__ = True
     def __reduce__(self):                return (wx.Rect, self.Get())
     }
+
+    
+    %property(Bottom, GetBottom, SetBottom, doc="See `GetBottom` and `SetBottom`");
+    %property(BottomRight, GetBottomRight, SetBottomRight, doc="See `GetBottomRight` and `SetBottomRight`");
+    %property(BottomLeft, GetBottomLeft, SetBottomLeft, doc="See `GetBottomLeft` and `SetBottomLeft`");
+    %property(Height, GetHeight, SetHeight, doc="See `GetHeight` and `SetHeight`");
+    %property(Left, GetLeft, SetLeft, doc="See `GetLeft` and `SetLeft`");
+    %property(Position, GetPosition, SetPosition, doc="See `GetPosition` and `SetPosition`");
+    %property(Right, GetRight, SetRight, doc="See `GetRight` and `SetRight`");
+    %property(Size, GetSize, SetSize, doc="See `GetSize` and `SetSize`");
+    %property(Top, GetTop, SetTop, doc="See `GetTop` and `SetTop`");
+    %property(TopLeft, GetTopLeft, SetTopLeft, doc="See `GetTopLeft` and `SetTopLeft`");
+    %property(TopRight, GetTopRight, SetTopRight, doc="See `GetTopRight` and `SetTopRight`");
+    %property(Width, GetWidth, SetWidth, doc="See `GetWidth` and `SetWidth`");
+    %property(X, GetX, SetX, doc="See `GetX` and `SetX`");
+    %property(Y, GetY, SetY, doc="See `GetY` and `SetY`");
+
+    %property(Empty, IsEmpty, doc="See `IsEmpty`");
 };
 
 
 };
 
 
@@ -638,7 +784,7 @@ DocAStr(wxIntersectRect,
         dest = reg1.GetBox();
 
         if (dest != wxRect(0,0,0,0)) {
         dest = reg1.GetBox();
 
         if (dest != wxRect(0,0,0,0)) {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             wxRect* newRect = new wxRect(dest);
             obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
             wxPyEndBlockThreads(blocked);
             wxRect* newRect = new wxRect(dest);
             obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
             wxPyEndBlockThreads(blocked);
@@ -705,13 +851,32 @@ public:
     wxPoint2D& operator*=(const wxPoint2D& pt);
     wxPoint2D& operator/=(const wxPoint2D& pt);
 
     wxPoint2D& operator*=(const wxPoint2D& pt);
     wxPoint2D& operator/=(const wxPoint2D& pt);
 
-    DocDeclStr(
-        bool, operator==(const wxPoint2D& pt) const,
-        "Test for equality", "");
-    
-    DocDeclStr(
-        bool, operator!=(const wxPoint2D& pt) const,
-        "Test for inequality", "");
+    %extend {
+        KeepGIL(__eq__);
+        DocStr(__eq__, "Test for equality of wx.Point2D objects.", "");
+        bool __eq__(PyObject* other) {
+            wxPoint2D  temp, *obj = &temp;
+            if ( other == Py_None ) return false;
+            if ( ! wxPoint2D_helper(other, &obj) ) {
+                PyErr_Clear();
+                return false;
+            }
+            return self->operator==(*obj);
+        }
+
+        
+        KeepGIL(__ne__);
+        DocStr(__ne__, "Test for inequality of wx.Point2D objects.", "");
+        bool __ne__(PyObject* other) {
+            wxPoint2D  temp, *obj = &temp;
+            if ( other == Py_None ) return true;
+            if ( ! wxPoint2D_helper(other, &obj)) {
+                PyErr_Clear();
+                return true;
+            }
+            return self->operator!=(*obj);
+        }
+    }
 
     %Rename(x, double,  m_x);
     %Rename(y, double,  m_y);
 
     %Rename(x, double,  m_x);
     %Rename(y, double,  m_y);
@@ -726,7 +891,7 @@ public:
                "Get() -> (x,y)",
                "Return x and y properties as a tuple.", "");               
         PyObject* Get() {
                "Get() -> (x,y)",
                "Return x and y properties as a tuple.", "");               
         PyObject* Get() {
-            bool blocked = wxPyBeginBlockThreads();
+            wxPyBlock_t blocked = wxPyBeginBlockThreads();
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
             PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
             PyObject* tup = PyTuple_New(2);
             PyTuple_SET_ITEM(tup, 0, PyFloat_FromDouble(self->m_x));
             PyTuple_SET_ITEM(tup, 1, PyFloat_FromDouble(self->m_y));
@@ -749,6 +914,12 @@ public:
     __safe_for_unpickling__ = True
     def __reduce__(self):                return (wx.Point2D, self.Get())
     }
     __safe_for_unpickling__ = True
     def __reduce__(self):                return (wx.Point2D, self.Get())
     }
+
+    %property(Floor, GetFloor, doc="See `GetFloor`");
+    %property(Rounded, GetRounded, doc="See `GetRounded`");
+    %property(VectorAngle, GetVectorAngle, SetVectorAngle, doc="See `GetVectorAngle` and `SetVectorAngle`");
+    %property(VectorLength, GetVectorLength, SetVectorLength, doc="See `GetVectorLength` and `SetVectorLength`");
+    
 };
 
 
 };