diff -r bd89f58e8623 -r 19dab6a68886 src/misc/rect.hpp --- a/src/misc/rect.hpp Mon Feb 19 20:37:33 2007 +0000 +++ b/src/misc/rect.hpp Tue Feb 27 13:26:47 2007 +0000 @@ -36,6 +36,11 @@ return *this; } + bool operator ==(const PointRaw &other) const + { + return PointRaw::x == other.x && PointRaw::y == other.y; + } + PointT operator -() const { return PointT(-PointRaw::x, -PointRaw::y); @@ -77,6 +82,16 @@ DoMove(-offset); return *this; } + + PointT operator *(T coef) const + { + return PointT(PointRaw::x * coef, PointRaw::y * coef); + } + + PointT operator /(T coef) const + { + return PointT(PointRaw::x / coef, PointRaw::y / coef); + } }; @@ -136,6 +151,16 @@ return bottom_right; } + PointT Size() const + { + return (bottom_right - top_left + PointT(1, 1)); + } + + PointT CenterPt() const + { + return (top_left + bottom_right) / 2; + } + void SetLeft(T val) { top_left.x = val; @@ -176,6 +201,11 @@ bottom_right = pt; } + void SetSize(const PointRaw &pt) + { + bottom_right = top_left + pt - PointT(1, 1); + } + bool PtInRect(const PointRaw &pt) const { return (top_left.x <= pt.x && pt.x <= bottom_right.x && top_left.y <= pt.y && pt.y <= bottom_right.y);