49 #error qrect.h must be included before any header file that defines topLeft
61 QRect() { x1 = y1 = 0; x2 = y2 = -1; }
77 QT3_SUPPORT
int &rLeft() {
return x1; }
78 QT3_SUPPORT
int &rTop() {
return y1; }
79 QT3_SUPPORT
int &rRight() {
return x2; }
80 QT3_SUPPORT
int &rBottom() {
return y2; }
82 QT3_SUPPORT QRect normalize()
const {
return normalized(); }
87 void setLeft(
int pos);
89 void setRight(
int pos);
90 void setBottom(
int pos);
94 void setTopLeft(
const QPoint &
p);
95 void setBottomRight(
const QPoint &
p);
96 void setTopRight(
const QPoint &
p);
97 void setBottomLeft(
const QPoint &
p);
100 QPoint bottomRight()
const;
102 QPoint bottomLeft()
const;
105 void moveLeft(
int pos);
106 void moveTop(
int pos);
107 void moveRight(
int pos);
108 void moveBottom(
int pos);
109 void moveTopLeft(
const QPoint &
p);
110 void moveBottomRight(
const QPoint &
p);
111 void moveTopRight(
const QPoint &
p);
112 void moveBottomLeft(
const QPoint &
p);
113 void moveCenter(
const QPoint &
p);
115 inline void translate(
int dx,
int dy);
116 inline void translate(
const QPoint &
p);
117 inline QRect translated(
int dx,
int dy)
const;
118 inline QRect translated(
const QPoint &
p)
const;
120 void moveTo(
int x,
int t);
124 QT3_SUPPORT
void moveBy(
int dx,
int dy) { translate(dx, dy); }
125 QT3_SUPPORT
void moveBy(
const QPoint &
p) { translate(p); }
128 void setRect(
int x,
int y,
int w,
int h);
129 inline void getRect(
int *
x,
int *
y,
int *
w,
int *
h)
const;
131 void setCoords(
int x1,
int y1,
int x2,
int y2);
133 QT3_SUPPORT
void addCoords(
int x1,
int y1,
int x2,
int y2);
135 inline void getCoords(
int *x1,
int *y1,
int *x2,
int *y2)
const;
137 inline void adjust(
int x1,
int y1,
int x2,
int y2);
138 inline QRect adjusted(
int x1,
int y1,
int x2,
int y2)
const;
143 void setWidth(
int w);
144 void setHeight(
int h);
145 void setSize(
const QSize &
s);
149 QRect& operator|=(
const QRect &
r);
150 QRect& operator&=(
const QRect &
r);
152 bool contains(
const QPoint &
p,
bool proper=
false)
const;
153 bool contains(
int x,
int y)
const;
154 bool contains(
int x,
int y,
bool proper)
const;
155 bool contains(
const QRect &
r,
bool proper =
false)
const;
156 QRect unite(
const QRect &
r)
const;
157 QRect united(
const QRect &other)
const;
158 QRect intersect(
const QRect &
r)
const;
159 QRect intersected(
const QRect &other)
const;
160 bool intersects(
const QRect &
r)
const;
162 friend Q_CORE_EXPORT_INLINE
bool operator==(
const QRect &,
const QRect &);
163 friend Q_CORE_EXPORT_INLINE
bool operator!=(
const QRect &,
const QRect &);
166 inline QT3_SUPPORT
void rect(
int *
x,
int *
y,
int *
w,
int *
h)
const { getRect(x, y, w, h); }
167 inline QT3_SUPPORT
void coords(
int *ax1,
int *ay1,
int *ax2,
int *ay2)
const
168 { getCoords(ax1, ay1, ax2, ay2); }
172 #if defined(Q_WS_X11)
173 friend void qt_setCoords(QRect *
r,
int xp1,
int yp1,
int xp2,
int yp2);
176 #if defined(Q_OS_MAC)
198 #ifndef QT_NO_DATASTREAM
211 x2 = (aleft + awidth - 1);
212 y2 = (atop + aheight - 1);
219 x2 = abottomRight.
x();
220 y2 = abottomRight.
y();
227 x2 = (x1+asize.
width() - 1);
228 y2 = (y1+asize.
height() - 1);
232 {
return x2 == x1 - 1 && y2 == y1 - 1; }
235 {
return x1 > x2 || y1 > y2; }
238 {
return x1 <= x2 && y1 <= y2; }
271 { x1 = p.
x(); y1 = p.
y(); }
274 { x2 = p.
x(); y2 = p.
y(); }
277 { x2 = p.
x(); y1 = p.
y(); }
280 { x1 = p.
x(); y2 = p.
y(); }
289 {
return QPoint(x1, y1); }
292 {
return QPoint(x2, y2); }
295 {
return QPoint(x2, y1); }
298 {
return QPoint(x1, y2); }
301 {
return QPoint((x1+x2)/2, (y1+y2)/2); }
304 {
return x2 - x1 + 1; }
307 {
return y2 - y1 + 1; }
351 { x2 += (pos - x1); x1 = pos; }
354 { y2 += (pos - y1); y1 = pos; }
425 inline void QRect::addCoords(
int dx1,
int dy1,
int dx2,
int dy2)
427 adjust(dx1, dy1, dx2, dy2);
443 { x2 = (x1 + w - 1); }
446 { y2 = (y1 + h - 1); }
450 x2 = (s.
width() + x1 - 1);
451 y2 = (s.
height() + y1 - 1);
498 return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2;
503 return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2;
506 #ifndef QT_NO_DEBUG_STREAM
521 bool isEmpty()
const;
522 bool isValid()
const;
525 inline qreal
left()
const {
return xp; }
526 inline qreal
top()
const {
return yp; }
527 inline qreal
right()
const {
return xp +
w; }
528 inline qreal
bottom()
const {
return yp +
h; }
530 inline qreal
x()
const;
531 inline qreal
y()
const;
532 inline void setLeft(qreal pos);
533 inline void setTop(qreal pos);
534 inline void setRight(qreal pos);
535 inline void setBottom(qreal pos);
536 inline void setX(qreal pos) { setLeft(pos); }
537 inline void setY(qreal pos) { setTop(pos); }
546 void setBottomRight(
const QPointF &
p);
548 void setBottomLeft(
const QPointF &
p);
550 void moveLeft(qreal pos);
551 void moveTop(qreal pos);
552 void moveRight(qreal pos);
553 void moveBottom(qreal pos);
555 void moveBottomRight(
const QPointF &
p);
556 void moveTopRight(
const QPointF &
p);
557 void moveBottomLeft(
const QPointF &
p);
560 void translate(qreal
dx, qreal
dy);
566 void moveTo(qreal
x, qreal
t);
569 void setRect(qreal
x, qreal
y, qreal
w, qreal
h);
570 void getRect(qreal *
x, qreal *
y, qreal *
w, qreal *
h)
const;
572 void setCoords(qreal x1, qreal y1, qreal x2, qreal y2);
573 void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2)
const;
575 inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2);
576 inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2)
const;
581 void setWidth(qreal
w);
582 void setHeight(qreal
h);
590 bool contains(
const QPointF &
p)
const;
591 bool contains(qreal
x, qreal
y)
const;
592 bool contains(
const QRectF &
r)
const;
597 bool intersects(
const QRectF &
r)
const;
602 QRect toRect()
const;
603 QRect toAlignedRect()
const;
620 #ifndef QT_NO_DATASTREAM
630 : xp(aleft), yp(atop),
w(awidth),
h(aheight)
646 w = abottomRight.
x() - xp;
647 h = abottomRight.
y() - yp;
656 {
return w == 0. &&
h == 0.; }
659 {
return w <= 0. ||
h <= 0.; }
662 {
return w > 0. &&
h > 0.; }
674 inline void QRectF::setTop(qreal pos) { qreal diff = pos - yp; yp += diff;
h -= diff; }
741 {
return QRectF(xp + dx, yp + dy,
w,
h); }
744 {
return QRectF(xp + p.
x(), yp + p.
y(),
w,
h); }
779 { xp += xp1; yp += yp1;
w += xp2 - xp1;
h += yp2 - yp1; }
782 {
return QRectF(xp + xp1, yp + yp1,
w + xp2 - xp1,
h + yp2 - yp1); }
847 return QRect(qRound(xp), qRound(yp), qRound(
w), qRound(
h));
850 #ifndef QT_NO_DEBUG_STREAM
GLdouble GLdouble GLdouble r
void setCoords(qreal x1, qreal y1, qreal x2, qreal y2)
void setRect(int x, int y, int w, int h)
void setTopRight(const QPoint &p)
void adjust(qreal x1, qreal y1, qreal x2, qreal y2)
QRect adjusted(int x1, int y1, int x2, int y2) const
QPoint bottomLeft() const
void moveTopRight(const QPointF &p)
void moveBottomRight(const QPointF &p)
void setBottom(qreal pos)
QRectF intersect(const QRectF &r) const
QRectF unite(const QRectF &r) const
void translate(int dx, int dy)
void moveCenter(const QPointF &p)
void translate(qreal dx, qreal dy)
QRect unite(const QRect &r) const
QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const
QRect intersected(const QRect &other) const
void setTopLeft(const QPointF &p)
void setBottomRight(const QPoint &p)
QRect & operator&=(const QRect &r)
void getCoords(int *x1, int *y1, int *x2, int *y2) const
QPointF bottomRight() const
void moveTo(int x, int t)
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void moveRight(qreal pos)
void moveBottom(qreal pos)
void setSize(const QSizeF &s)
Q_CORE_EXPORT QBitArray operator&(const QBitArray &, const QBitArray &)
QRectF translated(qreal dx, qreal dy) const
Q_CORE_EXPORT QDataStream & operator<<(QDataStream &, const QRect &)
#define QT_BEGIN_NAMESPACE
QPointF bottomLeft() const
QRect & operator|=(const QRect &r)
void setBottomLeft(const QPoint &p)
QPoint bottomRight() const
void setRect(qreal x, qreal y, qreal w, qreal h)
void moveTopRight(const QPoint &p)
GLenum GLsizei GLsizei height
void setTopRight(const QPointF &p)
void moveTo(qreal x, qreal t)
void getRect(int *x, int *y, int *w, int *h) const
void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
QRect intersect(const QRect &r) const
void setBottomLeft(const QPointF &p)
Q_CORE_EXPORT_INLINE bool operator==(const QRect &, const QRect &)
void setTopLeft(const QPoint &p)
QRectF united(const QRectF &other) const
int int int int int int h
GLint GLenum GLboolean normalized
void moveTopLeft(const QPointF &p)
void adjust(int x1, int y1, int x2, int y2)
bool qFuzzyCompare(const QMatrix &m1, const QMatrix &m2)
void moveBottomLeft(const QPointF &p)
Q_CORE_EXPORT_INLINE bool operator!=(const QRect &, const QRect &)
void moveTopLeft(const QPoint &p)
void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const
bool contains(const QPointF &p) const
void moveBottomRight(const QPoint &p)
QRectF & operator&=(const QRectF &r)
bool contains(const QPoint &p, bool proper=false) const
Q_CORE_EXPORT QBitArray operator|(const QBitArray &, const QBitArray &)
GLubyte GLubyte GLubyte GLubyte w
QRectF intersected(const QRectF &other) const
QRectF & operator|=(const QRectF &r)
Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE)
QRect translated(int dx, int dy) const
QRect united(const QRect &other) const
void setBottomRight(const QPointF &p)
void moveBottomLeft(const QPoint &p)
void setSize(const QSize &s)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &, QRect &)
void setCoords(int x1, int y1, int x2, int y2)