00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QRECT_H
00043 #define QRECT_H
00044
00045 #include <QtCore/qsize.h>
00046 #include <QtCore/qpoint.h>
00047
00048 #ifdef topLeft
00049 #error qrect.h must be included before any header file that defines topLeft
00050 #endif
00051
00052 QT_BEGIN_HEADER
00053
00054 QT_BEGIN_NAMESPACE
00055
00056 QT_MODULE(Core)
00057
00058 class Q_CORE_EXPORT QRect
00059 {
00060 public:
00061 QRect() { x1 = y1 = 0; x2 = y2 = -1; }
00062 QRect(const QPoint &topleft, const QPoint &bottomright);
00063 QRect(const QPoint &topleft, const QSize &size);
00064 QRect(int left, int top, int width, int height);
00065
00066 bool isNull() const;
00067 bool isEmpty() const;
00068 bool isValid() const;
00069
00070 int left() const;
00071 int top() const;
00072 int right() const;
00073 int bottom() const;
00074 QRect normalized() const;
00075
00076 #ifdef QT3_SUPPORT
00077 QT3_SUPPORT int &rLeft() { return x1; }
00078 QT3_SUPPORT int &rTop() { return y1; }
00079 QT3_SUPPORT int &rRight() { return x2; }
00080 QT3_SUPPORT int &rBottom() { return y2; }
00081
00082 QT3_SUPPORT QRect normalize() const { return normalized(); }
00083 #endif
00084
00085 int x() const;
00086 int y() const;
00087 void setLeft(int pos);
00088 void setTop(int pos);
00089 void setRight(int pos);
00090 void setBottom(int pos);
00091 void setX(int x);
00092 void setY(int y);
00093
00094 void setTopLeft(const QPoint &p);
00095 void setBottomRight(const QPoint &p);
00096 void setTopRight(const QPoint &p);
00097 void setBottomLeft(const QPoint &p);
00098
00099 QPoint topLeft() const;
00100 QPoint bottomRight() const;
00101 QPoint topRight() const;
00102 QPoint bottomLeft() const;
00103 QPoint center() const;
00104
00105 void moveLeft(int pos);
00106 void moveTop(int pos);
00107 void moveRight(int pos);
00108 void moveBottom(int pos);
00109 void moveTopLeft(const QPoint &p);
00110 void moveBottomRight(const QPoint &p);
00111 void moveTopRight(const QPoint &p);
00112 void moveBottomLeft(const QPoint &p);
00113 void moveCenter(const QPoint &p);
00114
00115 inline void translate(int dx, int dy);
00116 inline void translate(const QPoint &p);
00117 inline QRect translated(int dx, int dy) const;
00118 inline QRect translated(const QPoint &p) const;
00119
00120 void moveTo(int x, int t);
00121 void moveTo(const QPoint &p);
00122
00123 #ifdef QT3_SUPPORT
00124 QT3_SUPPORT void moveBy(int dx, int dy) { translate(dx, dy); }
00125 QT3_SUPPORT void moveBy(const QPoint &p) { translate(p); }
00126 #endif
00127
00128 void setRect(int x, int y, int w, int h);
00129 inline void getRect(int *x, int *y, int *w, int *h) const;
00130
00131 void setCoords(int x1, int y1, int x2, int y2);
00132 #ifdef QT3_SUPPORT
00133 QT3_SUPPORT void addCoords(int x1, int y1, int x2, int y2);
00134 #endif
00135 inline void getCoords(int *x1, int *y1, int *x2, int *y2) const;
00136
00137 inline void adjust(int x1, int y1, int x2, int y2);
00138 inline QRect adjusted(int x1, int y1, int x2, int y2) const;
00139
00140 QSize size() const;
00141 int width() const;
00142 int height() const;
00143 void setWidth(int w);
00144 void setHeight(int h);
00145 void setSize(const QSize &s);
00146
00147 QRect operator|(const QRect &r) const;
00148 QRect operator&(const QRect &r) const;
00149 QRect& operator|=(const QRect &r);
00150 QRect& operator&=(const QRect &r);
00151
00152 bool contains(const QPoint &p, bool proper=false) const;
00153 bool contains(int x, int y) const;
00154 bool contains(int x, int y, bool proper) const;
00155 bool contains(const QRect &r, bool proper = false) const;
00156 QRect unite(const QRect &r) const;
00157 QRect united(const QRect &other) const;
00158 QRect intersect(const QRect &r) const;
00159 QRect intersected(const QRect &other) const;
00160 bool intersects(const QRect &r) const;
00161
00162 friend Q_CORE_EXPORT_INLINE bool operator==(const QRect &, const QRect &);
00163 friend Q_CORE_EXPORT_INLINE bool operator!=(const QRect &, const QRect &);
00164
00165 #ifdef QT3_SUPPORT
00166 inline QT3_SUPPORT void rect(int *x, int *y, int *w, int *h) const { getRect(x, y, w, h); }
00167 inline QT3_SUPPORT void coords(int *ax1, int *ay1, int *ax2, int *ay2) const
00168 { getCoords(ax1, ay1, ax2, ay2); }
00169 #endif
00170
00171 private:
00172 #if defined(Q_WS_X11)
00173 friend void qt_setCoords(QRect *r, int xp1, int yp1, int xp2, int yp2);
00174 #endif
00175
00176 #if defined(Q_OS_MAC)
00177 int y1;
00178 int x1;
00179 int y2;
00180 int x2;
00181 #else
00182 int x1;
00183 int y1;
00184 int x2;
00185 int y2;
00186 #endif
00187
00188 };
00189 Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE);
00190
00191 Q_CORE_EXPORT_INLINE bool operator==(const QRect &, const QRect &);
00192 Q_CORE_EXPORT_INLINE bool operator!=(const QRect &, const QRect &);
00193
00194
00195
00196
00197
00198 #ifndef QT_NO_DATASTREAM
00199 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QRect &);
00200 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRect &);
00201 #endif
00202
00203
00204
00205
00206
00207 inline QRect::QRect(int aleft, int atop, int awidth, int aheight)
00208 {
00209 x1 = aleft;
00210 y1 = atop;
00211 x2 = (aleft + awidth - 1);
00212 y2 = (atop + aheight - 1);
00213 }
00214
00215 inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight)
00216 {
00217 x1 = atopLeft.x();
00218 y1 = atopLeft.y();
00219 x2 = abottomRight.x();
00220 y2 = abottomRight.y();
00221 }
00222
00223 inline QRect::QRect(const QPoint &atopLeft, const QSize &asize)
00224 {
00225 x1 = atopLeft.x();
00226 y1 = atopLeft.y();
00227 x2 = (x1+asize.width() - 1);
00228 y2 = (y1+asize.height() - 1);
00229 }
00230
00231 inline bool QRect::isNull() const
00232 { return x2 == x1 - 1 && y2 == y1 - 1; }
00233
00234 inline bool QRect::isEmpty() const
00235 { return x1 > x2 || y1 > y2; }
00236
00237 inline bool QRect::isValid() const
00238 { return x1 <= x2 && y1 <= y2; }
00239
00240 inline int QRect::left() const
00241 { return x1; }
00242
00243 inline int QRect::top() const
00244 { return y1; }
00245
00246 inline int QRect::right() const
00247 { return x2; }
00248
00249 inline int QRect::bottom() const
00250 { return y2; }
00251
00252 inline int QRect::x() const
00253 { return x1; }
00254
00255 inline int QRect::y() const
00256 { return y1; }
00257
00258 inline void QRect::setLeft(int pos)
00259 { x1 = pos; }
00260
00261 inline void QRect::setTop(int pos)
00262 { y1 = pos; }
00263
00264 inline void QRect::setRight(int pos)
00265 { x2 = pos; }
00266
00267 inline void QRect::setBottom(int pos)
00268 { y2 = pos; }
00269
00270 inline void QRect::setTopLeft(const QPoint &p)
00271 { x1 = p.x(); y1 = p.y(); }
00272
00273 inline void QRect::setBottomRight(const QPoint &p)
00274 { x2 = p.x(); y2 = p.y(); }
00275
00276 inline void QRect::setTopRight(const QPoint &p)
00277 { x2 = p.x(); y1 = p.y(); }
00278
00279 inline void QRect::setBottomLeft(const QPoint &p)
00280 { x1 = p.x(); y2 = p.y(); }
00281
00282 inline void QRect::setX(int ax)
00283 { x1 = ax; }
00284
00285 inline void QRect::setY(int ay)
00286 { y1 = ay; }
00287
00288 inline QPoint QRect::topLeft() const
00289 { return QPoint(x1, y1); }
00290
00291 inline QPoint QRect::bottomRight() const
00292 { return QPoint(x2, y2); }
00293
00294 inline QPoint QRect::topRight() const
00295 { return QPoint(x2, y1); }
00296
00297 inline QPoint QRect::bottomLeft() const
00298 { return QPoint(x1, y2); }
00299
00300 inline QPoint QRect::center() const
00301 { return QPoint((x1+x2)/2, (y1+y2)/2); }
00302
00303 inline int QRect::width() const
00304 { return x2 - x1 + 1; }
00305
00306 inline int QRect::height() const
00307 { return y2 - y1 + 1; }
00308
00309 inline QSize QRect::size() const
00310 { return QSize(width(), height()); }
00311
00312 inline void QRect::translate(int dx, int dy)
00313 {
00314 x1 += dx;
00315 y1 += dy;
00316 x2 += dx;
00317 y2 += dy;
00318 }
00319
00320 inline void QRect::translate(const QPoint &p)
00321 {
00322 x1 += p.x();
00323 y1 += p.y();
00324 x2 += p.x();
00325 y2 += p.y();
00326 }
00327
00328 inline QRect QRect::translated(int dx, int dy) const
00329 { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); }
00330
00331 inline QRect QRect::translated(const QPoint &p) const
00332 { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); }
00333
00334 inline void QRect::moveTo(int ax, int ay)
00335 {
00336 x2 += ax - x1;
00337 y2 += ay - y1;
00338 x1 = ax;
00339 y1 = ay;
00340 }
00341
00342 inline void QRect::moveTo(const QPoint &p)
00343 {
00344 x2 += p.x() - x1;
00345 y2 += p.y() - y1;
00346 x1 = p.x();
00347 y1 = p.y();
00348 }
00349
00350 inline void QRect::moveLeft(int pos)
00351 { x2 += (pos - x1); x1 = pos; }
00352
00353 inline void QRect::moveTop(int pos)
00354 { y2 += (pos - y1); y1 = pos; }
00355
00356 inline void QRect::moveRight(int pos)
00357 {
00358 x1 += (pos - x2);
00359 x2 = pos;
00360 }
00361
00362 inline void QRect::moveBottom(int pos)
00363 {
00364 y1 += (pos - y2);
00365 y2 = pos;
00366 }
00367
00368 inline void QRect::moveTopLeft(const QPoint &p)
00369 {
00370 moveLeft(p.x());
00371 moveTop(p.y());
00372 }
00373
00374 inline void QRect::moveBottomRight(const QPoint &p)
00375 {
00376 moveRight(p.x());
00377 moveBottom(p.y());
00378 }
00379
00380 inline void QRect::moveTopRight(const QPoint &p)
00381 {
00382 moveRight(p.x());
00383 moveTop(p.y());
00384 }
00385
00386 inline void QRect::moveBottomLeft(const QPoint &p)
00387 {
00388 moveLeft(p.x());
00389 moveBottom(p.y());
00390 }
00391
00392 inline void QRect::getRect(int *ax, int *ay, int *aw, int *ah) const
00393 {
00394 *ax = x1;
00395 *ay = y1;
00396 *aw = x2 - x1 + 1;
00397 *ah = y2 - y1 + 1;
00398 }
00399
00400 inline void QRect::setRect(int ax, int ay, int aw, int ah)
00401 {
00402 x1 = ax;
00403 y1 = ay;
00404 x2 = (ax + aw - 1);
00405 y2 = (ay + ah - 1);
00406 }
00407
00408 inline void QRect::getCoords(int *xp1, int *yp1, int *xp2, int *yp2) const
00409 {
00410 *xp1 = x1;
00411 *yp1 = y1;
00412 *xp2 = x2;
00413 *yp2 = y2;
00414 }
00415
00416 inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2)
00417 {
00418 x1 = xp1;
00419 y1 = yp1;
00420 x2 = xp2;
00421 y2 = yp2;
00422 }
00423
00424 #ifdef QT3_SUPPORT
00425 inline void QRect::addCoords(int dx1, int dy1, int dx2, int dy2)
00426 {
00427 adjust(dx1, dy1, dx2, dy2);
00428 }
00429 #endif
00430
00431 inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const
00432 { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); }
00433
00434 inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2)
00435 {
00436 x1 += dx1;
00437 y1 += dy1;
00438 x2 += dx2;
00439 y2 += dy2;
00440 }
00441
00442 inline void QRect::setWidth(int w)
00443 { x2 = (x1 + w - 1); }
00444
00445 inline void QRect::setHeight(int h)
00446 { y2 = (y1 + h - 1); }
00447
00448 inline void QRect::setSize(const QSize &s)
00449 {
00450 x2 = (s.width() + x1 - 1);
00451 y2 = (s.height() + y1 - 1);
00452 }
00453
00454 inline bool QRect::contains(int ax, int ay, bool aproper) const
00455 {
00456 return contains(QPoint(ax, ay), aproper);
00457 }
00458
00459 inline bool QRect::contains(int ax, int ay) const
00460 {
00461 return contains(QPoint(ax, ay), false);
00462 }
00463
00464 inline QRect& QRect::operator|=(const QRect &r)
00465 {
00466 *this = *this | r;
00467 return *this;
00468 }
00469
00470 inline QRect& QRect::operator&=(const QRect &r)
00471 {
00472 *this = *this & r;
00473 return *this;
00474 }
00475
00476 inline QRect QRect::intersect(const QRect &r) const
00477 {
00478 return *this & r;
00479 }
00480
00481 inline QRect QRect::intersected(const QRect &other) const
00482 {
00483 return intersect(other);
00484 }
00485
00486 inline QRect QRect::unite(const QRect &r) const
00487 {
00488 return *this | r;
00489 }
00490
00491 inline QRect QRect::united(const QRect &r) const
00492 {
00493 return unite(r);
00494 }
00495
00496 inline bool operator==(const QRect &r1, const QRect &r2)
00497 {
00498 return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2;
00499 }
00500
00501 inline bool operator!=(const QRect &r1, const QRect &r2)
00502 {
00503 return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2;
00504 }
00505
00506 #ifndef QT_NO_DEBUG_STREAM
00507 Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &);
00508 #endif
00509
00510
00511 class Q_CORE_EXPORT QRectF
00512 {
00513 public:
00514 QRectF() { xp = yp = 0.; w = h = 0.; }
00515 QRectF(const QPointF &topleft, const QSizeF &size);
00516 QRectF(const QPointF &topleft, const QPointF &bottomRight);
00517 QRectF(qreal left, qreal top, qreal width, qreal height);
00518 QRectF(const QRect &rect);
00519
00520 bool isNull() const;
00521 bool isEmpty() const;
00522 bool isValid() const;
00523 QRectF normalized() const;
00524
00525 inline qreal left() const { return xp; }
00526 inline qreal top() const { return yp; }
00527 inline qreal right() const { return xp + w; }
00528 inline qreal bottom() const { return yp + h; }
00529
00530 inline qreal x() const;
00531 inline qreal y() const;
00532 inline void setLeft(qreal pos);
00533 inline void setTop(qreal pos);
00534 inline void setRight(qreal pos);
00535 inline void setBottom(qreal pos);
00536 inline void setX(qreal pos) { setLeft(pos); }
00537 inline void setY(qreal pos) { setTop(pos); }
00538
00539 inline QPointF topLeft() const { return QPointF(xp, yp); }
00540 inline QPointF bottomRight() const { return QPointF(xp+w, yp+h); }
00541 inline QPointF topRight() const { return QPointF(xp+w, yp); }
00542 inline QPointF bottomLeft() const { return QPointF(xp, yp+h); }
00543 inline QPointF center() const;
00544
00545 void setTopLeft(const QPointF &p);
00546 void setBottomRight(const QPointF &p);
00547 void setTopRight(const QPointF &p);
00548 void setBottomLeft(const QPointF &p);
00549
00550 void moveLeft(qreal pos);
00551 void moveTop(qreal pos);
00552 void moveRight(qreal pos);
00553 void moveBottom(qreal pos);
00554 void moveTopLeft(const QPointF &p);
00555 void moveBottomRight(const QPointF &p);
00556 void moveTopRight(const QPointF &p);
00557 void moveBottomLeft(const QPointF &p);
00558 void moveCenter(const QPointF &p);
00559
00560 void translate(qreal dx, qreal dy);
00561 void translate(const QPointF &p);
00562
00563 QRectF translated(qreal dx, qreal dy) const;
00564 QRectF translated(const QPointF &p) const;
00565
00566 void moveTo(qreal x, qreal t);
00567 void moveTo(const QPointF &p);
00568
00569 void setRect(qreal x, qreal y, qreal w, qreal h);
00570 void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const;
00571
00572 void setCoords(qreal x1, qreal y1, qreal x2, qreal y2);
00573 void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
00574
00575 inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2);
00576 inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const;
00577
00578 QSizeF size() const;
00579 qreal width() const;
00580 qreal height() const;
00581 void setWidth(qreal w);
00582 void setHeight(qreal h);
00583 void setSize(const QSizeF &s);
00584
00585 QRectF operator|(const QRectF &r) const;
00586 QRectF operator&(const QRectF &r) const;
00587 QRectF& operator|=(const QRectF &r);
00588 QRectF& operator&=(const QRectF &r);
00589
00590 bool contains(const QPointF &p) const;
00591 bool contains(qreal x, qreal y) const;
00592 bool contains(const QRectF &r) const;
00593 QRectF unite(const QRectF &r) const;
00594 QRectF united(const QRectF &other) const;
00595 QRectF intersect(const QRectF &r) const;
00596 QRectF intersected(const QRectF &other) const;
00597 bool intersects(const QRectF &r) const;
00598
00599 friend Q_CORE_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &);
00600 friend Q_CORE_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &);
00601
00602 QRect toRect() const;
00603 QRect toAlignedRect() const;
00604
00605 private:
00606 qreal xp;
00607 qreal yp;
00608 qreal w;
00609 qreal h;
00610 };
00611 Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE);
00612
00613 Q_CORE_EXPORT_INLINE bool operator==(const QRectF &, const QRectF &);
00614 Q_CORE_EXPORT_INLINE bool operator!=(const QRectF &, const QRectF &);
00615
00616
00617
00618
00619
00620 #ifndef QT_NO_DATASTREAM
00621 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QRectF &);
00622 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRectF &);
00623 #endif
00624
00625
00626
00627
00628
00629 inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight)
00630 : xp(aleft), yp(atop), w(awidth), h(aheight)
00631 {
00632 }
00633
00634 inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize)
00635 {
00636 xp = atopLeft.x();
00637 yp = atopLeft.y();
00638 w = asize.width();
00639 h = asize.height();
00640 }
00641
00642 inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight)
00643 {
00644 xp = atopLeft.x();
00645 yp = atopLeft.y();
00646 w = abottomRight.x() - xp;
00647 h = abottomRight.y() - yp;
00648 }
00649
00650 inline QRectF::QRectF(const QRect &r)
00651 : xp(r.x()), yp(r.y()), w(r.width()), h(r.height())
00652 {
00653 }
00654
00655 inline bool QRectF::isNull() const
00656 { return w == 0. && h == 0.; }
00657
00658 inline bool QRectF::isEmpty() const
00659 { return w <= 0. || h <= 0.; }
00660
00661 inline bool QRectF::isValid() const
00662 { return w > 0. && h > 0.; }
00663
00664 inline qreal QRectF::x() const
00665 { return xp; }
00666
00667 inline qreal QRectF::y() const
00668 { return yp; }
00669
00670 inline void QRectF::setLeft(qreal pos) { qreal diff = pos - xp; xp += diff; w -= diff; }
00671
00672 inline void QRectF::setRight(qreal pos) { w = pos - xp; }
00673
00674 inline void QRectF::setTop(qreal pos) { qreal diff = pos - yp; yp += diff; h -= diff; }
00675
00676 inline void QRectF::setBottom(qreal pos) { h = pos - yp; }
00677
00678 inline void QRectF::setTopLeft(const QPointF &p) { setLeft(p.x()); setTop(p.y()); }
00679
00680 inline void QRectF::setTopRight(const QPointF &p) { setRight(p.x()); setTop(p.y()); }
00681
00682 inline void QRectF::setBottomLeft(const QPointF &p) { setLeft(p.x()); setBottom(p.y()); }
00683
00684 inline void QRectF::setBottomRight(const QPointF &p) { setRight(p.x()); setBottom(p.y()); }
00685
00686 inline QPointF QRectF::center() const
00687 { return QPointF(xp + w/2, yp + h/2); }
00688
00689 inline void QRectF::moveLeft(qreal pos) { xp = pos; }
00690
00691 inline void QRectF::moveTop(qreal pos) { yp = pos; }
00692
00693 inline void QRectF::moveRight(qreal pos) { xp = pos - w; }
00694
00695 inline void QRectF::moveBottom(qreal pos) { yp = pos - h; }
00696
00697 inline void QRectF::moveTopLeft(const QPointF &p) { moveLeft(p.x()); moveTop(p.y()); }
00698
00699 inline void QRectF::moveTopRight(const QPointF &p) { moveRight(p.x()); moveTop(p.y()); }
00700
00701 inline void QRectF::moveBottomLeft(const QPointF &p) { moveLeft(p.x()); moveBottom(p.y()); }
00702
00703 inline void QRectF::moveBottomRight(const QPointF &p) { moveRight(p.x()); moveBottom(p.y()); }
00704
00705 inline void QRectF::moveCenter(const QPointF &p) { xp = p.x() - w/2; yp = p.y() - h/2; }
00706
00707 inline qreal QRectF::width() const
00708 { return w; }
00709
00710 inline qreal QRectF::height() const
00711 { return h; }
00712
00713 inline QSizeF QRectF::size() const
00714 { return QSizeF(w, h); }
00715
00716 inline void QRectF::translate(qreal dx, qreal dy)
00717 {
00718 xp += dx;
00719 yp += dy;
00720 }
00721
00722 inline void QRectF::translate(const QPointF &p)
00723 {
00724 xp += p.x();
00725 yp += p.y();
00726 }
00727
00728 inline void QRectF::moveTo(qreal ax, qreal ay)
00729 {
00730 xp = ax;
00731 yp = ay;
00732 }
00733
00734 inline void QRectF::moveTo(const QPointF &p)
00735 {
00736 xp = p.x();
00737 yp = p.y();
00738 }
00739
00740 inline QRectF QRectF::translated(qreal dx, qreal dy) const
00741 { return QRectF(xp + dx, yp + dy, w, h); }
00742
00743 inline QRectF QRectF::translated(const QPointF &p) const
00744 { return QRectF(xp + p.x(), yp + p.y(), w, h); }
00745
00746 inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const
00747 {
00748 *ax = this->xp;
00749 *ay = this->yp;
00750 *aaw = this->w;
00751 *aah = this->h;
00752 }
00753
00754 inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah)
00755 {
00756 this->xp = ax;
00757 this->yp = ay;
00758 this->w = aaw;
00759 this->h = aah;
00760 }
00761
00762 inline void QRectF::getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const
00763 {
00764 *xp1 = xp;
00765 *yp1 = yp;
00766 *xp2 = xp + w;
00767 *yp2 = yp + h;
00768 }
00769
00770 inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2)
00771 {
00772 xp = xp1;
00773 yp = yp1;
00774 w = xp2 - xp1;
00775 h = yp2 - yp1;
00776 }
00777
00778 inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2)
00779 { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; }
00780
00781 inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const
00782 { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); }
00783
00784 inline void QRectF::setWidth(qreal aw)
00785 { this->w = aw; }
00786
00787 inline void QRectF::setHeight(qreal ah)
00788 { this->h = ah; }
00789
00790 inline void QRectF::setSize(const QSizeF &s)
00791 {
00792 w = s.width();
00793 h = s.height();
00794 }
00795
00796 inline bool QRectF::contains(qreal ax, qreal ay) const
00797 {
00798 return contains(QPointF(ax, ay));
00799 }
00800
00801 inline QRectF& QRectF::operator|=(const QRectF &r)
00802 {
00803 *this = *this | r;
00804 return *this;
00805 }
00806
00807 inline QRectF& QRectF::operator&=(const QRectF &r)
00808 {
00809 *this = *this & r;
00810 return *this;
00811 }
00812
00813 inline QRectF QRectF::intersect(const QRectF &r) const
00814 {
00815 return *this & r;
00816 }
00817
00818 inline QRectF QRectF::intersected(const QRectF &r) const
00819 {
00820 return intersect(r);
00821 }
00822
00823 inline QRectF QRectF::unite(const QRectF &r) const
00824 {
00825 return *this | r;
00826 }
00827
00828 inline QRectF QRectF::united(const QRectF &r) const
00829 {
00830 return unite(r);
00831 }
00832
00833 inline bool operator==(const QRectF &r1, const QRectF &r2)
00834 {
00835 return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp)
00836 && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h);
00837 }
00838
00839 inline bool operator!=(const QRectF &r1, const QRectF &r2)
00840 {
00841 return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp)
00842 || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h);
00843 }
00844
00845 inline QRect QRectF::toRect() const
00846 {
00847 return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));
00848 }
00849
00850 #ifndef QT_NO_DEBUG_STREAM
00851 Q_CORE_EXPORT QDebug operator<<(QDebug, const QRectF &);
00852 #endif
00853
00854 QT_END_NAMESPACE
00855
00856 QT_END_HEADER
00857
00858 #endif // QRECT_H