1 // -*- mode: C++; indent-tabs-mode: nil; -*-
15 inline Rect(void) : _x1(0), _y1(0), _x2(0), _y2(0) { }
16 inline Rect(int __x, int __y, unsigned int __w, unsigned int __h)
17 : _x1(__x), _y1(__y), _x2(__w + __x - 1), _y2(__h + __y - 1) { }
18 inline explicit Rect(const XRectangle& xrect)
19 : _x1(xrect.x), _y1(xrect.y), _x2(xrect.width + xrect.x - 1),
20 _y2(xrect.height + xrect.y - 1) { }
22 inline int left(void) const { return _x1; }
23 inline int top(void) const { return _y1; }
24 inline int right(void) const { return _x2; }
25 inline int bottom(void) const { return _y2; }
27 inline int x(void) const { return _x1; }
28 inline int y(void) const { return _y1; }
31 void setPos(int __x, int __y);
33 inline unsigned int width(void) const { return _x2 - _x1 + 1; }
34 inline unsigned int height(void) const { return _y2 - _y1 + 1; }
35 void setWidth(unsigned int __w);
36 void setHeight(unsigned int __h);
37 void setSize(unsigned int __w, unsigned int __h);
39 void setRect(int __x, int __y, unsigned int __w, unsigned int __h);
41 void setCoords(int __l, int __t, int __r, int __b);
43 inline bool operator==(const Rect &a)
44 { return _x1 == a._x1 && _y1 == a._y1 && _x2 == a._x2 && _y2 == a._y2; }
45 inline bool operator!=(const Rect &a) { return ! operator==(a); }
47 Rect operator|(const Rect &a) const;
48 Rect operator&(const Rect &a) const;
49 inline Rect &operator|=(const Rect &a) { *this = *this | a; return *this; }
50 inline Rect &operator&=(const Rect &a) { *this = *this & a; return *this; }
52 inline bool valid(void) const { return _x2 > _x1 && _y2 > _y1; }
54 bool intersects(const Rect &a) const;
55 bool contains(int __x, int __y) const;
56 bool contains(const Rect &a) const;
59 int _x1, _y1, _x2, _y2;
62 typedef std::vector<Rect> RectList;