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 expected a
-(width,height) tuple can be used instead.", "");
+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
{
public:
- %name(width) int x;
- %name(height)int y;
+ %Rename(width, int, x);
+ %Rename(height,int, y);
%pythoncode { x = width; y = height }
DocCtorStr(
~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),
"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));
~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(
"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));
~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+;
"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));
wxRect(const wxPoint& pos, const wxSize& size),
"Create a new Rect from a position and size.", "",
RectPS);
-
+
+ DocCtorStrName(
+ wxRect(const wxSize& size),
+ "Create a new Rect from a size only.", "",
+ RectS);
+
~wxRect();
int GetX() const;
wxSize GetSize() const;
void SetSize( const wxSize &s );
+ bool IsEmpty() const;
+
wxPoint GetTopLeft() const;
void SetTopLeft(const wxPoint &p);
wxPoint GetBottomRight() const;
DocDeclStr(
wxRect&, Inflate(wxCoord dx, wxCoord dy),
- "Increase the rectangle size by dx in x direction and dy in y
-direction. Both or one of) parameters may be negative to decrease the
-rectangle size.", "");
+ "Increases the size of the rectangle.
+
+The left border is moved farther left and the right border is moved
+farther right by ``dx``. The upper border is moved farther up and the
+bottom border is moved farther down by ``dy``. (Note the the width and
+height of the rectangle thus change by ``2*dx`` and ``2*dy``,
+respectively.) If one or both of ``dx`` and ``dy`` are negative, the
+opposite happens: the rectangle size decreases in the respective
+direction.
+
+The change is made to the rectangle inplace, if instead you need a
+copy that is inflated, preserving the original then make the copy
+first::
+
+ copy = wx.Rect(*original)
+ copy.Inflate(10,15)
+
+", "
+Inflating and deflating behaves *naturally*. Defined more precisely,
+that means:
+
+ * Real inflates (that is, ``dx`` and/or ``dy`` >= 0) are not
+ constrained. Thus inflating a rectangle can cause its upper left
+ corner to move into the negative numbers. (The versions prior to
+ 2.5.4 forced the top left coordinate to not fall below (0, 0),
+ which implied a forced move of the rectangle.)
+
+ * Deflates are clamped to not reduce the width or height of the
+ rectangle below zero. In such cases, the top-left corner is
+ nonetheless handled properly. For example, a rectangle at (10,
+ 10) with size (20, 40) that is inflated by (-15, -15) will
+ become located at (20, 25) at size (0, 10). Finally, observe
+ that the width and height are treated independently. In the
+ above example, the width is reduced by 20, whereas the height is
+ reduced by the full 30 (rather than also stopping at 20, when
+ the width reached zero).
+
+:see: `Deflate`
+");
DocDeclStr(
wxRect&, Deflate(wxCoord dx, wxCoord dy),
- "Decrease the rectangle size by dx in x direction and dy in y
-direction. Both or one of) parameters may be negative to increase the
-rectngle size. This method is the opposite of Inflate.", "");
+ "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.", "");
DocDeclStrName(
void, Offset(wxCoord dx, wxCoord dy),
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),
- "Return the intersectsion of this rectangle and rect.", "");
+ wxRect, Intersect(const wxRect& rect),
+ "Returns the intersectsion of this rectangle and rect.", "");
+ DocDeclStr(
+ wxRect , Union(const wxRect& rect),
+ "Returns the union of this rectangle and rect.", "");
+
+
DocDeclStr(
wxRect, operator+(const wxRect& rect) const,
"Add the properties of rect to this rectangle and return the result.", "");
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.", "");
- %name(InsideXY)bool Inside(int x, int y) const;
+ %Rename(InsideXY, bool, Inside(int x, int y) const);
bool Inside(const wxPoint& pt) const;
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;
"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));
};
+MustHaveApp(wxIntersectRect);
+
DocAStr(wxIntersectRect,
"IntersectRect(Rect r1, Rect r2) -> Rect",
"Calculate and return the intersection of r1 and r2.", "");
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);
+ obj = wxPyConstructObject((void*)newRect, wxT("wxRect"), true);
wxPyEndBlockThreads(blocked);
return obj;
}
public:
DocStr(wxPoint2D, "Create a w.Point2D object.", "");
wxPoint2D( double x=0.0 , double y=0.0 );
- %name(Point2DCopy) wxPoint2D( const wxPoint2D &pt );
- %name(Point2DFromPoint) wxPoint2D( const wxPoint &pt );
+ %RenameCtor(Point2DCopy, wxPoint2D( const wxPoint2D &pt ));
+ %RenameCtor(Point2DFromPoint, wxPoint2D( const wxPoint &pt ));
DocDeclAStr(
void, GetFloor( int *OUTPUT , int *OUTPUT ) const,
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);
+ }
+ }
- %name(x)double m_x;
- %name(y)double m_y;
+ %Rename(x, double, m_x);
+ %Rename(y, double, m_y);
%extend {
void Set( double x=0 , double y=0 ) {
"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));