Go to the documentation of this file.
26 #include "../stdext/types.h"
40 TRect() : x1(0), y1(0), x2(-1), y2(-1) { }
43 TRect(
const TRect<T>& other) : x1(other.x1), y1(other.y1), x2(other.x2), y2(other.y2) { }
48 bool isNull()
const {
return x2 == x1 - 1 && y2 == y1 - 1; }
49 bool isEmpty()
const {
return x1 > x2 || y1 > y2; }
50 bool isValid()
const {
return x1 <= x2 && y1 <= y2; }
52 T
left()
const {
return x1; }
53 T
top()
const {
return y1; }
58 T
x()
const {
return x1; }
59 T
y()
const {
return y1; }
69 T
width()
const {
return x2 - x1 + 1; }
70 T
height()
const {
return y2 - y1 + 1; }
72 void reset() { x1 = y1 = 0; x2 = y2 = -1; }
73 void clear() { x2 = x1 - 1; y2 = y1 - 1; }
96 void expand(T add) { x1 -= add; y1 -= add; x2 += add; y2 += add; }
102 void move(T
x, T
y) { x2 +=
x - x1; y2 +=
y - y1; x1 =
x; y1 =
y; }
104 void moveLeft(T pos) { x2 += (pos - x1); x1 = pos; }
105 void moveTop(T pos) { y2 += (pos - y1); y1 = pos; }
151 if(p.
x <= l || p.
x >= r)
154 if(p.
x < l || p.
x > r)
166 if(p.
y <= t || p.
y >= b)
169 if(p.
y < t || p.
y > b)
194 if(r.x2 - r.x1 + 1 < 0)
199 if(l1 > r2 || l2 > r1)
211 if(r.y2 - r.y1 + 1 < 0)
216 if(t1 > b2 || t2 > b1)
224 tmp.x1 = std::min<T>(x1, r.x1);
225 tmp.x2 = std::max<T>(x2, r.x2);
226 tmp.y1 = std::min<T>(y1, r.y1);
227 tmp.y2 = std::max<T>(y2, r.y2);
246 if(r.x2 - r.x1 + 1 < 0)
260 if(r.y2 - r.y1 + 1 < 0)
266 tmp.x1 = std::max<int>(l1, l2);
267 tmp.x2 = std::min<int>(r1, r2);
268 tmp.y1 = std::max<int>(t1, t2);
269 tmp.y2 = std::min<int>(b1, b2);
309 bool operator==(
const TRect<T>& other)
const {
return (x1 == other.x1 && y1 == other.y1 && x2 == other.x2 && y2 == other.y2); }
310 bool operator!=(
const TRect<T>& other)
const {
return (x1 != other.x1 || y1 != other.y1 || x2 != other.x2 || y2 != other.y2); }
325 out << rect.
left() <<
" " << rect.
top() <<
" " << rect.
width() <<
" " << rect.
height();
333 in >> x >> y >> w >> h;
bool contains(const TPoint< T > &p, bool insideOnly=false) const
TPoint< T > bottomLeft() const
void resize(const TSize< T > &size)
void moveHorizontalCenter(T x)
void moveTopLeft(const TPoint< T > &p)
TRect(const TPoint< T > &topLeft, int width, int height)
void move(const TPoint< T > &p)
TPoint< T > centerLeft() const
TPoint< T > centerRight() const
void moveCenterLeft(const TPoint< T > &p)
void moveBottomRight(const TPoint< T > &p)
void bind(const TRect< T > &r)
void alignIn(const TRect< T > &r, Fw::AlignmentFlag align)
void moveBottomCenter(const TPoint< T > &p)
bool operator==(const TRect< T > &other) const
TPoint< T > topRight() const
void moveTopCenter(const TPoint< T > &p)
std::ostream & operator<<(std::ostream &out, const TRect< T > &rect)
TRect< T > translated(int x, int y) const
void setBottomLeft(const TPoint< T > &p)
TPoint< T > topLeft() const
TRect(const TPoint< T > &topLeft, const TSize< T > &size)
TRect< T > translated(const TPoint< T > &p) const
void setTopLeft(const TPoint< T > &p)
void expand(T top, T right, T bottom, T left)
T horizontalCenter() const
void setCoords(int left, int top, int right, int bottom)
TRect< T > united(const TRect< T > &r) const
bool operator!=(const TRect< T > &other) const
TRect< T > & operator|=(const TRect< T > &other)
TRect< T > & operator&=(const TRect< T > &other)
TRect(const TPoint< T > &topLeft, const TPoint< T > &bottomRight)
TRect< T > expanded(T add) const
void moveCenter(const TPoint< T > &p)
TRect(T x, T y, T width, T height)
void translate(const TPoint< T > &p)
void resize(T width, T height)
void moveVerticalCenter(T y)
void setSize(const TSize< T > &size)
std::istream & operator>>(std::istream &in, TRect< T > &rect)
bool intersects(const TRect< T > &r) const
TRect(const TRect< T > &other)
TRect(T x, T y, const TSize< T > &size)
TRect< T > intersection(const TRect< T > &r) const
void moveCenterRight(const TPoint< T > &p)
TRect< T > & operator=(const TRect< T > &other)
TPoint< T > bottomRight() const
bool contains(const TRect< T > &r, bool insideOnly=false) const
void setRect(T x, T y, T width, T height)
TPoint< T > center() const
void setTopRight(const TPoint< T > &p)
void moveBottomLeft(const TPoint< T > &p)
TPoint< T > bottomCenter() const
TPoint< T > topCenter() const
void moveTopRight(const TPoint< T > &p)
void setBottomRight(const TPoint< T > &p)