- long GetWidth() const { return width; }
- void SetWidth(long w) { width = w; }
-
- long GetHeight() const { return height; }
- void SetHeight(long h) { height = h; }
-
- wxPoint GetPosition() { return wxPoint(x, y); }
- wxSize GetSize() { return wxSize(width, height); }
-
- long GetLeft() const { return x; }
- long GetTop() const { return y; }
- long GetBottom() const { return y + height; }
- long GetRight() const { return x + width; }
-
- wxRect& operator = (const wxRect& rect);
- bool operator == (const wxRect& rect);
- bool operator != (const wxRect& rect);
+ // default copy ctor and assignment operators ok
+
+ int GetX() const { return x; }
+ void SetX(int xx) { x = xx; }
+
+ int GetY() const { return y; }
+ void SetY(int yy) { y = yy; }
+
+ int GetWidth() const { return width; }
+ void SetWidth(int w) { width = w; }
+
+ int GetHeight() const { return height; }
+ void SetHeight(int h) { height = h; }
+
+ wxPoint GetPosition() const { return wxPoint(x, y); }
+ wxSize GetSize() const { return wxSize(width, height); }
+
+ int GetLeft() const { return x; }
+ int GetTop() const { return y; }
+ int GetBottom() const { return y + height - 1; }
+ int GetRight() const { return x + width - 1; }
+
+ void SetLeft(int left) { x = left; }
+ void SetRight(int right) { width = right - x + 1; }
+ void SetTop(int top) { y = top; }
+ void SetBottom(int bottom) { height = bottom - y + 1; }
+
+ // operations with rect
+ wxRect& Inflate(wxCoord dx, wxCoord dy);
+ wxRect& Inflate(wxCoord d) { return Inflate(d, d); }
+ wxRect Inflate(wxCoord dx, wxCoord dy) const
+ {
+ wxRect r = *this;
+ r.Inflate(dx, dy);
+ return r;
+ }
+
+ wxRect& Deflate(wxCoord dx, wxCoord dy) { return Inflate(-dx, -dy); }
+ wxRect& Deflate(wxCoord d) { return Inflate(-d); }
+ wxRect Deflate(wxCoord dx, wxCoord dy) const
+ {
+ wxRect r = *this;
+ r.Deflate(dx, dy);
+ return r;
+ }
+
+ void Offset(wxCoord dx, wxCoord dy) { x += dx; y += dy; }
+ void Offset(const wxPoint& pt) { Offset(pt.x, pt.y); }
+
+ wxRect& Intersect(const wxRect& rect);
+ wxRect Intersect(const wxRect& rect) const
+ {
+ wxRect r = *this;
+ r.Intersect(rect);
+ return r;
+ }
+
+ wxRect operator+(const wxRect& rect) const;
+ wxRect& operator+=(const wxRect& rect);
+
+ // compare rectangles
+ bool operator==(const wxRect& rect) const;
+ bool operator!=(const wxRect& rect) const { return !(*this == rect); }
+
+ // return TRUE if the point is (not strcitly) inside the rect
+ bool Inside(int x, int y) const;
+ bool Inside(const wxPoint& pt) const { return Inside(pt.x, pt.y); }
+
+ // return TRUE if the rectangles have a non empty intersection
+ bool Intersects(const wxRect& rect) const;