| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
|---|
| 4 | ** Contact: https://www.qt.io/licensing/ | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial License Usage | 
|---|
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
|---|
| 11 | ** accordance with the commercial license agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
|---|
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
|---|
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
|---|
| 16 | ** | 
|---|
| 17 | ** GNU Lesser General Public License Usage | 
|---|
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 19 | ** General Public License version 3 as published by the Free Software | 
|---|
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
|---|
| 21 | ** packaging of this file. Please review the following information to | 
|---|
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
|---|
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
|---|
| 24 | ** | 
|---|
| 25 | ** GNU General Public License Usage | 
|---|
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
|---|
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
|---|
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
|---|
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
|---|
| 31 | ** included in the packaging of this file. Please review the following | 
|---|
| 32 | ** information to ensure the GNU General Public License requirements will | 
|---|
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
|---|
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** $QT_END_LICENSE$ | 
|---|
| 37 | ** | 
|---|
| 38 | ****************************************************************************/ | 
|---|
| 39 |  | 
|---|
| 40 | #ifndef QRECT_H | 
|---|
| 41 | #define QRECT_H | 
|---|
| 42 |  | 
|---|
| 43 | #include <QtCore/qmargins.h> | 
|---|
| 44 | #include <QtCore/qsize.h> | 
|---|
| 45 | #include <QtCore/qpoint.h> | 
|---|
| 46 |  | 
|---|
| 47 | #ifdef topLeft | 
|---|
| 48 | #error qrect.h must be included before any header file that defines topLeft | 
|---|
| 49 | #endif | 
|---|
| 50 |  | 
|---|
| 51 | #if defined(Q_OS_DARWIN) || defined(Q_QDOC) | 
|---|
| 52 | struct CGRect; | 
|---|
| 53 | #endif | 
|---|
| 54 |  | 
|---|
| 55 | QT_BEGIN_NAMESPACE | 
|---|
| 56 |  | 
|---|
| 57 | class Q_CORE_EXPORT QRect | 
|---|
| 58 | { | 
|---|
| 59 | public: | 
|---|
| 60 | Q_DECL_CONSTEXPR QRect() noexcept : x1(0), y1(0), x2(-1), y2(-1) {} | 
|---|
| 61 | Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QPoint &bottomright) noexcept; | 
|---|
| 62 | Q_DECL_CONSTEXPR QRect(const QPoint &topleft, const QSize &size) noexcept; | 
|---|
| 63 | Q_DECL_CONSTEXPR QRect(int left, int top, int width, int height) noexcept; | 
|---|
| 64 |  | 
|---|
| 65 | Q_DECL_CONSTEXPR inline bool isNull() const noexcept; | 
|---|
| 66 | Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; | 
|---|
| 67 | Q_DECL_CONSTEXPR inline bool isValid() const noexcept; | 
|---|
| 68 |  | 
|---|
| 69 | Q_DECL_CONSTEXPR inline int left() const noexcept; | 
|---|
| 70 | Q_DECL_CONSTEXPR inline int top() const noexcept; | 
|---|
| 71 | Q_DECL_CONSTEXPR inline int right() const noexcept; | 
|---|
| 72 | Q_DECL_CONSTEXPR inline int bottom() const noexcept; | 
|---|
| 73 | Q_REQUIRED_RESULT QRect normalized() const noexcept; | 
|---|
| 74 |  | 
|---|
| 75 | Q_DECL_CONSTEXPR inline int x() const noexcept; | 
|---|
| 76 | Q_DECL_CONSTEXPR inline int y() const noexcept; | 
|---|
| 77 | Q_DECL_RELAXED_CONSTEXPR inline void setLeft(int pos) noexcept; | 
|---|
| 78 | Q_DECL_RELAXED_CONSTEXPR inline void setTop(int pos) noexcept; | 
|---|
| 79 | Q_DECL_RELAXED_CONSTEXPR inline void setRight(int pos) noexcept; | 
|---|
| 80 | Q_DECL_RELAXED_CONSTEXPR inline void setBottom(int pos) noexcept; | 
|---|
| 81 | Q_DECL_RELAXED_CONSTEXPR inline void setX(int x) noexcept; | 
|---|
| 82 | Q_DECL_RELAXED_CONSTEXPR inline void setY(int y) noexcept; | 
|---|
| 83 |  | 
|---|
| 84 | Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPoint &p) noexcept; | 
|---|
| 85 | Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPoint &p) noexcept; | 
|---|
| 86 | Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPoint &p) noexcept; | 
|---|
| 87 | Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPoint &p) noexcept; | 
|---|
| 88 |  | 
|---|
| 89 | Q_DECL_CONSTEXPR inline QPoint topLeft() const noexcept; | 
|---|
| 90 | Q_DECL_CONSTEXPR inline QPoint bottomRight() const noexcept; | 
|---|
| 91 | Q_DECL_CONSTEXPR inline QPoint topRight() const noexcept; | 
|---|
| 92 | Q_DECL_CONSTEXPR inline QPoint bottomLeft() const noexcept; | 
|---|
| 93 | Q_DECL_CONSTEXPR inline QPoint center() const noexcept; | 
|---|
| 94 |  | 
|---|
| 95 | Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(int pos) noexcept; | 
|---|
| 96 | Q_DECL_RELAXED_CONSTEXPR inline void moveTop(int pos) noexcept; | 
|---|
| 97 | Q_DECL_RELAXED_CONSTEXPR inline void moveRight(int pos) noexcept; | 
|---|
| 98 | Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(int pos) noexcept; | 
|---|
| 99 | Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPoint &p) noexcept; | 
|---|
| 100 | Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPoint &p) noexcept; | 
|---|
| 101 | Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPoint &p) noexcept; | 
|---|
| 102 | Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPoint &p) noexcept; | 
|---|
| 103 | Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPoint &p) noexcept; | 
|---|
| 104 |  | 
|---|
| 105 | Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) noexcept; | 
|---|
| 106 | Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) noexcept; | 
|---|
| 107 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const noexcept; | 
|---|
| 108 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const noexcept; | 
|---|
| 109 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const noexcept; | 
|---|
| 110 |  | 
|---|
| 111 | Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) noexcept; | 
|---|
| 112 | Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) noexcept; | 
|---|
| 113 |  | 
|---|
| 114 | Q_DECL_RELAXED_CONSTEXPR inline void setRect(int x, int y, int w, int h) noexcept; | 
|---|
| 115 | Q_DECL_RELAXED_CONSTEXPR inline void getRect(int *x, int *y, int *w, int *h) const; | 
|---|
| 116 |  | 
|---|
| 117 | Q_DECL_RELAXED_CONSTEXPR inline void setCoords(int x1, int y1, int x2, int y2) noexcept; | 
|---|
| 118 | Q_DECL_RELAXED_CONSTEXPR inline void getCoords(int *x1, int *y1, int *x2, int *y2) const; | 
|---|
| 119 |  | 
|---|
| 120 | Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) noexcept; | 
|---|
| 121 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const noexcept; | 
|---|
| 122 |  | 
|---|
| 123 | Q_DECL_CONSTEXPR inline QSize size() const noexcept; | 
|---|
| 124 | Q_DECL_CONSTEXPR inline int width() const noexcept; | 
|---|
| 125 | Q_DECL_CONSTEXPR inline int height() const noexcept; | 
|---|
| 126 | Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) noexcept; | 
|---|
| 127 | Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) noexcept; | 
|---|
| 128 | Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSize &s) noexcept; | 
|---|
| 129 |  | 
|---|
| 130 | QRect operator|(const QRect &r) const noexcept; | 
|---|
| 131 | QRect operator&(const QRect &r) const noexcept; | 
|---|
| 132 | inline QRect& operator|=(const QRect &r) noexcept; | 
|---|
| 133 | inline QRect& operator&=(const QRect &r) noexcept; | 
|---|
| 134 |  | 
|---|
| 135 | bool contains(const QRect &r, bool proper = false) const noexcept; | 
|---|
| 136 | bool contains(const QPoint &p, bool proper=false) const noexcept; | 
|---|
| 137 | inline bool contains(int x, int y) const noexcept; | 
|---|
| 138 | inline bool contains(int x, int y, bool proper) const noexcept; | 
|---|
| 139 | Q_REQUIRED_RESULT inline QRect united(const QRect &other) const noexcept; | 
|---|
| 140 | Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const noexcept; | 
|---|
| 141 | bool intersects(const QRect &r) const noexcept; | 
|---|
| 142 |  | 
|---|
| 143 | Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const noexcept; | 
|---|
| 144 | Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const noexcept; | 
|---|
| 145 | Q_DECL_RELAXED_CONSTEXPR inline QRect &operator+=(const QMargins &margins) noexcept; | 
|---|
| 146 | Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) noexcept; | 
|---|
| 147 |  | 
|---|
| 148 | #if QT_DEPRECATED_SINCE(5, 0) | 
|---|
| 149 | Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const noexcept { return united(r); } | 
|---|
| 150 | Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const noexcept { return intersected(r); } | 
|---|
| 151 | #endif | 
|---|
| 152 |  | 
|---|
| 153 | friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) noexcept; | 
|---|
| 154 | friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) noexcept; | 
|---|
| 155 |  | 
|---|
| 156 | #if defined(Q_OS_DARWIN) || defined(Q_QDOC) | 
|---|
| 157 | Q_REQUIRED_RESULT CGRect toCGRect() const noexcept; | 
|---|
| 158 | #endif | 
|---|
| 159 |  | 
|---|
| 160 | private: | 
|---|
| 161 | int x1; | 
|---|
| 162 | int y1; | 
|---|
| 163 | int x2; | 
|---|
| 164 | int y2; | 
|---|
| 165 | }; | 
|---|
| 166 | Q_DECLARE_TYPEINFO(QRect, Q_MOVABLE_TYPE); | 
|---|
| 167 |  | 
|---|
| 168 | Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) noexcept; | 
|---|
| 169 | Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) noexcept; | 
|---|
| 170 |  | 
|---|
| 171 |  | 
|---|
| 172 | /***************************************************************************** | 
|---|
| 173 | QRect stream functions | 
|---|
| 174 | *****************************************************************************/ | 
|---|
| 175 | #ifndef QT_NO_DATASTREAM | 
|---|
| 176 | Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QRect &); | 
|---|
| 177 | Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRect &); | 
|---|
| 178 | #endif | 
|---|
| 179 |  | 
|---|
| 180 | /***************************************************************************** | 
|---|
| 181 | QRect inline member functions | 
|---|
| 182 | *****************************************************************************/ | 
|---|
| 183 |  | 
|---|
| 184 | Q_DECL_CONSTEXPR inline QRect::QRect(int aleft, int atop, int awidth, int aheight) noexcept | 
|---|
| 185 | : x1(aleft), y1(atop), x2(aleft + awidth - 1), y2(atop + aheight - 1) {} | 
|---|
| 186 |  | 
|---|
| 187 | Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QPoint &abottomRight) noexcept | 
|---|
| 188 | : x1(atopLeft.x()), y1(atopLeft.y()), x2(abottomRight.x()), y2(abottomRight.y()) {} | 
|---|
| 189 |  | 
|---|
| 190 | Q_DECL_CONSTEXPR inline QRect::QRect(const QPoint &atopLeft, const QSize &asize) noexcept | 
|---|
| 191 | : x1(atopLeft.x()), y1(atopLeft.y()), x2(atopLeft.x()+asize.width() - 1), y2(atopLeft.y()+asize.height() - 1) {} | 
|---|
| 192 |  | 
|---|
| 193 | Q_DECL_CONSTEXPR inline bool QRect::isNull() const noexcept | 
|---|
| 194 | { return x2 == x1 - 1 && y2 == y1 - 1; } | 
|---|
| 195 |  | 
|---|
| 196 | Q_DECL_CONSTEXPR inline bool QRect::isEmpty() const noexcept | 
|---|
| 197 | { return x1 > x2 || y1 > y2; } | 
|---|
| 198 |  | 
|---|
| 199 | Q_DECL_CONSTEXPR inline bool QRect::isValid() const noexcept | 
|---|
| 200 | { return x1 <= x2 && y1 <= y2; } | 
|---|
| 201 |  | 
|---|
| 202 | Q_DECL_CONSTEXPR inline int QRect::left() const noexcept | 
|---|
| 203 | { return x1; } | 
|---|
| 204 |  | 
|---|
| 205 | Q_DECL_CONSTEXPR inline int QRect::top() const noexcept | 
|---|
| 206 | { return y1; } | 
|---|
| 207 |  | 
|---|
| 208 | Q_DECL_CONSTEXPR inline int QRect::right() const noexcept | 
|---|
| 209 | { return x2; } | 
|---|
| 210 |  | 
|---|
| 211 | Q_DECL_CONSTEXPR inline int QRect::bottom() const noexcept | 
|---|
| 212 | { return y2; } | 
|---|
| 213 |  | 
|---|
| 214 | Q_DECL_CONSTEXPR inline int QRect::x() const noexcept | 
|---|
| 215 | { return x1; } | 
|---|
| 216 |  | 
|---|
| 217 | Q_DECL_CONSTEXPR inline int QRect::y() const noexcept | 
|---|
| 218 | { return y1; } | 
|---|
| 219 |  | 
|---|
| 220 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setLeft(int pos) noexcept | 
|---|
| 221 | { x1 = pos; } | 
|---|
| 222 |  | 
|---|
| 223 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTop(int pos) noexcept | 
|---|
| 224 | { y1 = pos; } | 
|---|
| 225 |  | 
|---|
| 226 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRight(int pos) noexcept | 
|---|
| 227 | { x2 = pos; } | 
|---|
| 228 |  | 
|---|
| 229 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottom(int pos) noexcept | 
|---|
| 230 | { y2 = pos; } | 
|---|
| 231 |  | 
|---|
| 232 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopLeft(const QPoint &p) noexcept | 
|---|
| 233 | { x1 = p.x(); y1 = p.y(); } | 
|---|
| 234 |  | 
|---|
| 235 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomRight(const QPoint &p) noexcept | 
|---|
| 236 | { x2 = p.x(); y2 = p.y(); } | 
|---|
| 237 |  | 
|---|
| 238 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setTopRight(const QPoint &p) noexcept | 
|---|
| 239 | { x2 = p.x(); y1 = p.y(); } | 
|---|
| 240 |  | 
|---|
| 241 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setBottomLeft(const QPoint &p) noexcept | 
|---|
| 242 | { x1 = p.x(); y2 = p.y(); } | 
|---|
| 243 |  | 
|---|
| 244 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setX(int ax) noexcept | 
|---|
| 245 | { x1 = ax; } | 
|---|
| 246 |  | 
|---|
| 247 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setY(int ay) noexcept | 
|---|
| 248 | { y1 = ay; } | 
|---|
| 249 |  | 
|---|
| 250 | Q_DECL_CONSTEXPR inline QPoint QRect::topLeft() const noexcept | 
|---|
| 251 | { return QPoint(x1, y1); } | 
|---|
| 252 |  | 
|---|
| 253 | Q_DECL_CONSTEXPR inline QPoint QRect::bottomRight() const noexcept | 
|---|
| 254 | { return QPoint(x2, y2); } | 
|---|
| 255 |  | 
|---|
| 256 | Q_DECL_CONSTEXPR inline QPoint QRect::topRight() const noexcept | 
|---|
| 257 | { return QPoint(x2, y1); } | 
|---|
| 258 |  | 
|---|
| 259 | Q_DECL_CONSTEXPR inline QPoint QRect::bottomLeft() const noexcept | 
|---|
| 260 | { return QPoint(x1, y2); } | 
|---|
| 261 |  | 
|---|
| 262 | Q_DECL_CONSTEXPR inline QPoint QRect::center() const noexcept | 
|---|
| 263 | { return QPoint(int((qint64(x1)+x2)/2), int((qint64(y1)+y2)/2)); } // cast avoids overflow on addition | 
|---|
| 264 |  | 
|---|
| 265 | Q_DECL_CONSTEXPR inline int QRect::width() const noexcept | 
|---|
| 266 | { return  x2 - x1 + 1; } | 
|---|
| 267 |  | 
|---|
| 268 | Q_DECL_CONSTEXPR inline int QRect::height() const noexcept | 
|---|
| 269 | { return  y2 - y1 + 1; } | 
|---|
| 270 |  | 
|---|
| 271 | Q_DECL_CONSTEXPR inline QSize QRect::size() const noexcept | 
|---|
| 272 | { return QSize(width(), height()); } | 
|---|
| 273 |  | 
|---|
| 274 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(int dx, int dy) noexcept | 
|---|
| 275 | { | 
|---|
| 276 | x1 += dx; | 
|---|
| 277 | y1 += dy; | 
|---|
| 278 | x2 += dx; | 
|---|
| 279 | y2 += dy; | 
|---|
| 280 | } | 
|---|
| 281 |  | 
|---|
| 282 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::translate(const QPoint &p) noexcept | 
|---|
| 283 | { | 
|---|
| 284 | x1 += p.x(); | 
|---|
| 285 | y1 += p.y(); | 
|---|
| 286 | x2 += p.x(); | 
|---|
| 287 | y2 += p.y(); | 
|---|
| 288 | } | 
|---|
| 289 |  | 
|---|
| 290 | Q_DECL_CONSTEXPR inline QRect QRect::translated(int dx, int dy) const noexcept | 
|---|
| 291 | { return QRect(QPoint(x1 + dx, y1 + dy), QPoint(x2 + dx, y2 + dy)); } | 
|---|
| 292 |  | 
|---|
| 293 | Q_DECL_CONSTEXPR inline QRect QRect::translated(const QPoint &p) const noexcept | 
|---|
| 294 | { return QRect(QPoint(x1 + p.x(), y1 + p.y()), QPoint(x2 + p.x(), y2 + p.y())); } | 
|---|
| 295 |  | 
|---|
| 296 | Q_DECL_CONSTEXPR inline QRect QRect::transposed() const noexcept | 
|---|
| 297 | { return QRect(topLeft(), size().transposed()); } | 
|---|
| 298 |  | 
|---|
| 299 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(int ax, int ay) noexcept | 
|---|
| 300 | { | 
|---|
| 301 | x2 += ax - x1; | 
|---|
| 302 | y2 += ay - y1; | 
|---|
| 303 | x1 = ax; | 
|---|
| 304 | y1 = ay; | 
|---|
| 305 | } | 
|---|
| 306 |  | 
|---|
| 307 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTo(const QPoint &p) noexcept | 
|---|
| 308 | { | 
|---|
| 309 | x2 += p.x() - x1; | 
|---|
| 310 | y2 += p.y() - y1; | 
|---|
| 311 | x1 = p.x(); | 
|---|
| 312 | y1 = p.y(); | 
|---|
| 313 | } | 
|---|
| 314 |  | 
|---|
| 315 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveLeft(int pos) noexcept | 
|---|
| 316 | { x2 += (pos - x1); x1 = pos; } | 
|---|
| 317 |  | 
|---|
| 318 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTop(int pos) noexcept | 
|---|
| 319 | { y2 += (pos - y1); y1 = pos; } | 
|---|
| 320 |  | 
|---|
| 321 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveRight(int pos) noexcept | 
|---|
| 322 | { | 
|---|
| 323 | x1 += (pos - x2); | 
|---|
| 324 | x2 = pos; | 
|---|
| 325 | } | 
|---|
| 326 |  | 
|---|
| 327 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottom(int pos) noexcept | 
|---|
| 328 | { | 
|---|
| 329 | y1 += (pos - y2); | 
|---|
| 330 | y2 = pos; | 
|---|
| 331 | } | 
|---|
| 332 |  | 
|---|
| 333 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopLeft(const QPoint &p) noexcept | 
|---|
| 334 | { | 
|---|
| 335 | moveLeft(p.x()); | 
|---|
| 336 | moveTop(p.y()); | 
|---|
| 337 | } | 
|---|
| 338 |  | 
|---|
| 339 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomRight(const QPoint &p) noexcept | 
|---|
| 340 | { | 
|---|
| 341 | moveRight(p.x()); | 
|---|
| 342 | moveBottom(p.y()); | 
|---|
| 343 | } | 
|---|
| 344 |  | 
|---|
| 345 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveTopRight(const QPoint &p) noexcept | 
|---|
| 346 | { | 
|---|
| 347 | moveRight(p.x()); | 
|---|
| 348 | moveTop(p.y()); | 
|---|
| 349 | } | 
|---|
| 350 |  | 
|---|
| 351 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveBottomLeft(const QPoint &p) noexcept | 
|---|
| 352 | { | 
|---|
| 353 | moveLeft(p.x()); | 
|---|
| 354 | moveBottom(p.y()); | 
|---|
| 355 | } | 
|---|
| 356 |  | 
|---|
| 357 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::moveCenter(const QPoint &p) noexcept | 
|---|
| 358 | { | 
|---|
| 359 | int w = x2 - x1; | 
|---|
| 360 | int h = y2 - y1; | 
|---|
| 361 | x1 = p.x() - w/2; | 
|---|
| 362 | y1 = p.y() - h/2; | 
|---|
| 363 | x2 = x1 + w; | 
|---|
| 364 | y2 = y1 + h; | 
|---|
| 365 | } | 
|---|
| 366 |  | 
|---|
| 367 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::getRect(int *ax, int *ay, int *aw, int *ah) const | 
|---|
| 368 | { | 
|---|
| 369 | *ax = x1; | 
|---|
| 370 | *ay = y1; | 
|---|
| 371 | *aw = x2 - x1 + 1; | 
|---|
| 372 | *ah = y2 - y1 + 1; | 
|---|
| 373 | } | 
|---|
| 374 |  | 
|---|
| 375 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setRect(int ax, int ay, int aw, int ah) noexcept | 
|---|
| 376 | { | 
|---|
| 377 | x1 = ax; | 
|---|
| 378 | y1 = ay; | 
|---|
| 379 | x2 = (ax + aw - 1); | 
|---|
| 380 | y2 = (ay + ah - 1); | 
|---|
| 381 | } | 
|---|
| 382 |  | 
|---|
| 383 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::getCoords(int *xp1, int *yp1, int *xp2, int *yp2) const | 
|---|
| 384 | { | 
|---|
| 385 | *xp1 = x1; | 
|---|
| 386 | *yp1 = y1; | 
|---|
| 387 | *xp2 = x2; | 
|---|
| 388 | *yp2 = y2; | 
|---|
| 389 | } | 
|---|
| 390 |  | 
|---|
| 391 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2) noexcept | 
|---|
| 392 | { | 
|---|
| 393 | x1 = xp1; | 
|---|
| 394 | y1 = yp1; | 
|---|
| 395 | x2 = xp2; | 
|---|
| 396 | y2 = yp2; | 
|---|
| 397 | } | 
|---|
| 398 |  | 
|---|
| 399 | Q_DECL_CONSTEXPR inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const noexcept | 
|---|
| 400 | { return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); } | 
|---|
| 401 |  | 
|---|
| 402 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::adjust(int dx1, int dy1, int dx2, int dy2) noexcept | 
|---|
| 403 | { | 
|---|
| 404 | x1 += dx1; | 
|---|
| 405 | y1 += dy1; | 
|---|
| 406 | x2 += dx2; | 
|---|
| 407 | y2 += dy2; | 
|---|
| 408 | } | 
|---|
| 409 |  | 
|---|
| 410 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setWidth(int w) noexcept | 
|---|
| 411 | { x2 = (x1 + w - 1); } | 
|---|
| 412 |  | 
|---|
| 413 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setHeight(int h) noexcept | 
|---|
| 414 | { y2 = (y1 + h - 1); } | 
|---|
| 415 |  | 
|---|
| 416 | Q_DECL_RELAXED_CONSTEXPR inline void QRect::setSize(const QSize &s) noexcept | 
|---|
| 417 | { | 
|---|
| 418 | x2 = (s.width()  + x1 - 1); | 
|---|
| 419 | y2 = (s.height() + y1 - 1); | 
|---|
| 420 | } | 
|---|
| 421 |  | 
|---|
| 422 | inline bool QRect::contains(int ax, int ay, bool aproper) const noexcept | 
|---|
| 423 | { | 
|---|
| 424 | return contains(QPoint(ax, ay), aproper); | 
|---|
| 425 | } | 
|---|
| 426 |  | 
|---|
| 427 | inline bool QRect::contains(int ax, int ay) const noexcept | 
|---|
| 428 | { | 
|---|
| 429 | return contains(QPoint(ax, ay), false); | 
|---|
| 430 | } | 
|---|
| 431 |  | 
|---|
| 432 | inline QRect& QRect::operator|=(const QRect &r) noexcept | 
|---|
| 433 | { | 
|---|
| 434 | *this = *this | r; | 
|---|
| 435 | return *this; | 
|---|
| 436 | } | 
|---|
| 437 |  | 
|---|
| 438 | inline QRect& QRect::operator&=(const QRect &r) noexcept | 
|---|
| 439 | { | 
|---|
| 440 | *this = *this & r; | 
|---|
| 441 | return *this; | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | inline QRect QRect::intersected(const QRect &other) const noexcept | 
|---|
| 445 | { | 
|---|
| 446 | return *this & other; | 
|---|
| 447 | } | 
|---|
| 448 |  | 
|---|
| 449 | inline QRect QRect::united(const QRect &r) const noexcept | 
|---|
| 450 | { | 
|---|
| 451 | return *this | r; | 
|---|
| 452 | } | 
|---|
| 453 |  | 
|---|
| 454 | Q_DECL_CONSTEXPR inline bool operator==(const QRect &r1, const QRect &r2) noexcept | 
|---|
| 455 | { | 
|---|
| 456 | return r1.x1==r2.x1 && r1.x2==r2.x2 && r1.y1==r2.y1 && r1.y2==r2.y2; | 
|---|
| 457 | } | 
|---|
| 458 |  | 
|---|
| 459 | Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) noexcept | 
|---|
| 460 | { | 
|---|
| 461 | return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; | 
|---|
| 462 | } | 
|---|
| 463 |  | 
|---|
| 464 | Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) noexcept | 
|---|
| 465 | { | 
|---|
| 466 | return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), | 
|---|
| 467 | QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 | Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) noexcept | 
|---|
| 471 | { | 
|---|
| 472 | return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), | 
|---|
| 473 | QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); | 
|---|
| 474 | } | 
|---|
| 475 |  | 
|---|
| 476 | Q_DECL_CONSTEXPR inline QRect operator-(const QRect &lhs, const QMargins &rhs) noexcept | 
|---|
| 477 | { | 
|---|
| 478 | return QRect(QPoint(lhs.left() + rhs.left(), lhs.top() + rhs.top()), | 
|---|
| 479 | QPoint(lhs.right() - rhs.right(), lhs.bottom() - rhs.bottom())); | 
|---|
| 480 | } | 
|---|
| 481 |  | 
|---|
| 482 | Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const noexcept | 
|---|
| 483 | { | 
|---|
| 484 | return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), | 
|---|
| 485 | QPoint(x2 + margins.right(), y2 + margins.bottom())); | 
|---|
| 486 | } | 
|---|
| 487 |  | 
|---|
| 488 | Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const noexcept | 
|---|
| 489 | { | 
|---|
| 490 | return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), | 
|---|
| 491 | QPoint(x2 - margins.right(), y2 - margins.bottom())); | 
|---|
| 492 | } | 
|---|
| 493 |  | 
|---|
| 494 | Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator+=(const QMargins &margins) noexcept | 
|---|
| 495 | { | 
|---|
| 496 | *this = marginsAdded(margins); | 
|---|
| 497 | return *this; | 
|---|
| 498 | } | 
|---|
| 499 |  | 
|---|
| 500 | Q_DECL_RELAXED_CONSTEXPR inline QRect &QRect::operator-=(const QMargins &margins) noexcept | 
|---|
| 501 | { | 
|---|
| 502 | *this = marginsRemoved(margins); | 
|---|
| 503 | return *this; | 
|---|
| 504 | } | 
|---|
| 505 |  | 
|---|
| 506 | #ifndef QT_NO_DEBUG_STREAM | 
|---|
| 507 | Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &); | 
|---|
| 508 | #endif | 
|---|
| 509 |  | 
|---|
| 510 |  | 
|---|
| 511 | class Q_CORE_EXPORT QRectF | 
|---|
| 512 | { | 
|---|
| 513 | public: | 
|---|
| 514 | Q_DECL_CONSTEXPR QRectF() noexcept : xp(0.), yp(0.), w(0.), h(0.) {} | 
|---|
| 515 | Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QSizeF &size) noexcept; | 
|---|
| 516 | Q_DECL_CONSTEXPR QRectF(const QPointF &topleft, const QPointF &bottomRight) noexcept; | 
|---|
| 517 | Q_DECL_CONSTEXPR QRectF(qreal left, qreal top, qreal width, qreal height) noexcept; | 
|---|
| 518 | Q_DECL_CONSTEXPR QRectF(const QRect &rect) noexcept; | 
|---|
| 519 |  | 
|---|
| 520 | Q_DECL_CONSTEXPR inline bool isNull() const noexcept; | 
|---|
| 521 | Q_DECL_CONSTEXPR inline bool isEmpty() const noexcept; | 
|---|
| 522 | Q_DECL_CONSTEXPR inline bool isValid() const noexcept; | 
|---|
| 523 | Q_REQUIRED_RESULT QRectF normalized() const noexcept; | 
|---|
| 524 |  | 
|---|
| 525 | Q_DECL_CONSTEXPR inline qreal left() const noexcept { return xp; } | 
|---|
| 526 | Q_DECL_CONSTEXPR inline qreal top() const noexcept { return yp; } | 
|---|
| 527 | Q_DECL_CONSTEXPR inline qreal right() const noexcept { return xp + w; } | 
|---|
| 528 | Q_DECL_CONSTEXPR inline qreal bottom() const noexcept { return yp + h; } | 
|---|
| 529 |  | 
|---|
| 530 | Q_DECL_CONSTEXPR inline qreal x() const noexcept; | 
|---|
| 531 | Q_DECL_CONSTEXPR inline qreal y() const noexcept; | 
|---|
| 532 | Q_DECL_RELAXED_CONSTEXPR inline void setLeft(qreal pos) noexcept; | 
|---|
| 533 | Q_DECL_RELAXED_CONSTEXPR inline void setTop(qreal pos) noexcept; | 
|---|
| 534 | Q_DECL_RELAXED_CONSTEXPR inline void setRight(qreal pos) noexcept; | 
|---|
| 535 | Q_DECL_RELAXED_CONSTEXPR inline void setBottom(qreal pos) noexcept; | 
|---|
| 536 | Q_DECL_RELAXED_CONSTEXPR inline void setX(qreal pos) noexcept { setLeft(pos); } | 
|---|
| 537 | Q_DECL_RELAXED_CONSTEXPR inline void setY(qreal pos) noexcept { setTop(pos); } | 
|---|
| 538 |  | 
|---|
| 539 | Q_DECL_CONSTEXPR inline QPointF topLeft() const noexcept { return QPointF(xp, yp); } | 
|---|
| 540 | Q_DECL_CONSTEXPR inline QPointF bottomRight() const noexcept { return QPointF(xp+w, yp+h); } | 
|---|
| 541 | Q_DECL_CONSTEXPR inline QPointF topRight() const noexcept { return QPointF(xp+w, yp); } | 
|---|
| 542 | Q_DECL_CONSTEXPR inline QPointF bottomLeft() const noexcept { return QPointF(xp, yp+h); } | 
|---|
| 543 | Q_DECL_CONSTEXPR inline QPointF center() const noexcept; | 
|---|
| 544 |  | 
|---|
| 545 | Q_DECL_RELAXED_CONSTEXPR inline void setTopLeft(const QPointF &p) noexcept; | 
|---|
| 546 | Q_DECL_RELAXED_CONSTEXPR inline void setBottomRight(const QPointF &p) noexcept; | 
|---|
| 547 | Q_DECL_RELAXED_CONSTEXPR inline void setTopRight(const QPointF &p) noexcept; | 
|---|
| 548 | Q_DECL_RELAXED_CONSTEXPR inline void setBottomLeft(const QPointF &p) noexcept; | 
|---|
| 549 |  | 
|---|
| 550 | Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(qreal pos) noexcept; | 
|---|
| 551 | Q_DECL_RELAXED_CONSTEXPR inline void moveTop(qreal pos) noexcept; | 
|---|
| 552 | Q_DECL_RELAXED_CONSTEXPR inline void moveRight(qreal pos) noexcept; | 
|---|
| 553 | Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(qreal pos) noexcept; | 
|---|
| 554 | Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPointF &p) noexcept; | 
|---|
| 555 | Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPointF &p) noexcept; | 
|---|
| 556 | Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPointF &p) noexcept; | 
|---|
| 557 | Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPointF &p) noexcept; | 
|---|
| 558 | Q_DECL_RELAXED_CONSTEXPR inline void moveCenter(const QPointF &p) noexcept; | 
|---|
| 559 |  | 
|---|
| 560 | Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) noexcept; | 
|---|
| 561 | Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) noexcept; | 
|---|
| 562 |  | 
|---|
| 563 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const noexcept; | 
|---|
| 564 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const noexcept; | 
|---|
| 565 |  | 
|---|
| 566 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const noexcept; | 
|---|
| 567 |  | 
|---|
| 568 | Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) noexcept; | 
|---|
| 569 | Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) noexcept; | 
|---|
| 570 |  | 
|---|
| 571 | Q_DECL_RELAXED_CONSTEXPR inline void setRect(qreal x, qreal y, qreal w, qreal h) noexcept; | 
|---|
| 572 | Q_DECL_RELAXED_CONSTEXPR inline void getRect(qreal *x, qreal *y, qreal *w, qreal *h) const; | 
|---|
| 573 |  | 
|---|
| 574 | Q_DECL_RELAXED_CONSTEXPR inline void setCoords(qreal x1, qreal y1, qreal x2, qreal y2) noexcept; | 
|---|
| 575 | Q_DECL_RELAXED_CONSTEXPR inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const; | 
|---|
| 576 |  | 
|---|
| 577 | Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) noexcept; | 
|---|
| 578 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept; | 
|---|
| 579 |  | 
|---|
| 580 | Q_DECL_CONSTEXPR inline QSizeF size() const noexcept; | 
|---|
| 581 | Q_DECL_CONSTEXPR inline qreal width() const noexcept; | 
|---|
| 582 | Q_DECL_CONSTEXPR inline qreal height() const noexcept; | 
|---|
| 583 | Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) noexcept; | 
|---|
| 584 | Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) noexcept; | 
|---|
| 585 | Q_DECL_RELAXED_CONSTEXPR inline void setSize(const QSizeF &s) noexcept; | 
|---|
| 586 |  | 
|---|
| 587 | QRectF operator|(const QRectF &r) const noexcept; | 
|---|
| 588 | QRectF operator&(const QRectF &r) const noexcept; | 
|---|
| 589 | inline QRectF& operator|=(const QRectF &r) noexcept; | 
|---|
| 590 | inline QRectF& operator&=(const QRectF &r) noexcept; | 
|---|
| 591 |  | 
|---|
| 592 | bool contains(const QRectF &r) const noexcept; | 
|---|
| 593 | bool contains(const QPointF &p) const noexcept; | 
|---|
| 594 | inline bool contains(qreal x, qreal y) const noexcept; | 
|---|
| 595 | Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const noexcept; | 
|---|
| 596 | Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const noexcept; | 
|---|
| 597 | bool intersects(const QRectF &r) const noexcept; | 
|---|
| 598 |  | 
|---|
| 599 | Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const noexcept; | 
|---|
| 600 | Q_DECL_CONSTEXPR inline QRectF marginsRemoved(const QMarginsF &margins) const noexcept; | 
|---|
| 601 | Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator+=(const QMarginsF &margins) noexcept; | 
|---|
| 602 | Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) noexcept; | 
|---|
| 603 |  | 
|---|
| 604 | #if QT_DEPRECATED_SINCE(5, 0) | 
|---|
| 605 | Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const noexcept { return united(r); } | 
|---|
| 606 | Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const noexcept { return intersected(r); } | 
|---|
| 607 | #endif | 
|---|
| 608 |  | 
|---|
| 609 | friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) noexcept; | 
|---|
| 610 | friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) noexcept; | 
|---|
| 611 |  | 
|---|
| 612 | Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const noexcept; | 
|---|
| 613 | Q_REQUIRED_RESULT QRect toAlignedRect() const noexcept; | 
|---|
| 614 |  | 
|---|
| 615 | #if defined(Q_OS_DARWIN) || defined(Q_QDOC) | 
|---|
| 616 | Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) noexcept; | 
|---|
| 617 | Q_REQUIRED_RESULT CGRect toCGRect() const noexcept; | 
|---|
| 618 | #endif | 
|---|
| 619 |  | 
|---|
| 620 | private: | 
|---|
| 621 | qreal xp; | 
|---|
| 622 | qreal yp; | 
|---|
| 623 | qreal w; | 
|---|
| 624 | qreal h; | 
|---|
| 625 | }; | 
|---|
| 626 | Q_DECLARE_TYPEINFO(QRectF, Q_MOVABLE_TYPE); | 
|---|
| 627 |  | 
|---|
| 628 | Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) noexcept; | 
|---|
| 629 | Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) noexcept; | 
|---|
| 630 |  | 
|---|
| 631 |  | 
|---|
| 632 | /***************************************************************************** | 
|---|
| 633 | QRectF stream functions | 
|---|
| 634 | *****************************************************************************/ | 
|---|
| 635 | #ifndef QT_NO_DATASTREAM | 
|---|
| 636 | Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QRectF &); | 
|---|
| 637 | Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QRectF &); | 
|---|
| 638 | #endif | 
|---|
| 639 |  | 
|---|
| 640 | /***************************************************************************** | 
|---|
| 641 | QRectF inline member functions | 
|---|
| 642 | *****************************************************************************/ | 
|---|
| 643 |  | 
|---|
| 644 | Q_DECL_CONSTEXPR inline QRectF::QRectF(qreal aleft, qreal atop, qreal awidth, qreal aheight) noexcept | 
|---|
| 645 | : xp(aleft), yp(atop), w(awidth), h(aheight) | 
|---|
| 646 | { | 
|---|
| 647 | } | 
|---|
| 648 |  | 
|---|
| 649 | Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QSizeF &asize) noexcept | 
|---|
| 650 | : xp(atopLeft.x()), yp(atopLeft.y()), w(asize.width()), h(asize.height()) | 
|---|
| 651 | { | 
|---|
| 652 | } | 
|---|
| 653 |  | 
|---|
| 654 |  | 
|---|
| 655 | Q_DECL_CONSTEXPR inline QRectF::QRectF(const QPointF &atopLeft, const QPointF &abottomRight) noexcept | 
|---|
| 656 | : xp(atopLeft.x()), yp(atopLeft.y()), w(abottomRight.x() - atopLeft.x()), h(abottomRight.y() - atopLeft.y()) | 
|---|
| 657 | { | 
|---|
| 658 | } | 
|---|
| 659 |  | 
|---|
| 660 | Q_DECL_CONSTEXPR inline QRectF::QRectF(const QRect &r) noexcept | 
|---|
| 661 | : xp(r.x()), yp(r.y()), w(r.width()), h(r.height()) | 
|---|
| 662 | { | 
|---|
| 663 | } | 
|---|
| 664 |  | 
|---|
| 665 | QT_WARNING_PUSH | 
|---|
| 666 | QT_WARNING_DISABLE_CLANG( "-Wfloat-equal") | 
|---|
| 667 | QT_WARNING_DISABLE_GCC( "-Wfloat-equal") | 
|---|
| 668 | QT_WARNING_DISABLE_INTEL(1572) | 
|---|
| 669 |  | 
|---|
| 670 | Q_DECL_CONSTEXPR inline bool QRectF::isNull() const noexcept | 
|---|
| 671 | { return w == 0. && h == 0.; } | 
|---|
| 672 |  | 
|---|
| 673 | Q_DECL_CONSTEXPR inline bool QRectF::isEmpty() const noexcept | 
|---|
| 674 | { return w <= 0. || h <= 0.; } | 
|---|
| 675 |  | 
|---|
| 676 | QT_WARNING_POP | 
|---|
| 677 |  | 
|---|
| 678 | Q_DECL_CONSTEXPR inline bool QRectF::isValid() const noexcept | 
|---|
| 679 | { return w > 0. && h > 0.; } | 
|---|
| 680 |  | 
|---|
| 681 | Q_DECL_CONSTEXPR inline qreal QRectF::x() const noexcept | 
|---|
| 682 | { return xp; } | 
|---|
| 683 |  | 
|---|
| 684 | Q_DECL_CONSTEXPR inline qreal QRectF::y() const noexcept | 
|---|
| 685 | { return yp; } | 
|---|
| 686 |  | 
|---|
| 687 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setLeft(qreal pos) noexcept | 
|---|
| 688 | { qreal diff = pos - xp; xp += diff; w -= diff; } | 
|---|
| 689 |  | 
|---|
| 690 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRight(qreal pos) noexcept | 
|---|
| 691 | { w = pos - xp; } | 
|---|
| 692 |  | 
|---|
| 693 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTop(qreal pos) noexcept | 
|---|
| 694 | { qreal diff = pos - yp; yp += diff; h -= diff; } | 
|---|
| 695 |  | 
|---|
| 696 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottom(qreal pos) noexcept | 
|---|
| 697 | { h = pos - yp; } | 
|---|
| 698 |  | 
|---|
| 699 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopLeft(const QPointF &p) noexcept | 
|---|
| 700 | { setLeft(p.x()); setTop(p.y()); } | 
|---|
| 701 |  | 
|---|
| 702 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setTopRight(const QPointF &p) noexcept | 
|---|
| 703 | { setRight(p.x()); setTop(p.y()); } | 
|---|
| 704 |  | 
|---|
| 705 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomLeft(const QPointF &p) noexcept | 
|---|
| 706 | { setLeft(p.x()); setBottom(p.y()); } | 
|---|
| 707 |  | 
|---|
| 708 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setBottomRight(const QPointF &p) noexcept | 
|---|
| 709 | { setRight(p.x()); setBottom(p.y()); } | 
|---|
| 710 |  | 
|---|
| 711 | Q_DECL_CONSTEXPR inline QPointF QRectF::center() const noexcept | 
|---|
| 712 | { return QPointF(xp + w/2, yp + h/2); } | 
|---|
| 713 |  | 
|---|
| 714 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveLeft(qreal pos) noexcept | 
|---|
| 715 | { xp = pos; } | 
|---|
| 716 |  | 
|---|
| 717 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTop(qreal pos) noexcept | 
|---|
| 718 | { yp = pos; } | 
|---|
| 719 |  | 
|---|
| 720 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveRight(qreal pos) noexcept | 
|---|
| 721 | { xp = pos - w; } | 
|---|
| 722 |  | 
|---|
| 723 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottom(qreal pos) noexcept | 
|---|
| 724 | { yp = pos - h; } | 
|---|
| 725 |  | 
|---|
| 726 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopLeft(const QPointF &p) noexcept | 
|---|
| 727 | { moveLeft(p.x()); moveTop(p.y()); } | 
|---|
| 728 |  | 
|---|
| 729 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTopRight(const QPointF &p) noexcept | 
|---|
| 730 | { moveRight(p.x()); moveTop(p.y()); } | 
|---|
| 731 |  | 
|---|
| 732 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomLeft(const QPointF &p) noexcept | 
|---|
| 733 | { moveLeft(p.x()); moveBottom(p.y()); } | 
|---|
| 734 |  | 
|---|
| 735 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveBottomRight(const QPointF &p) noexcept | 
|---|
| 736 | { moveRight(p.x()); moveBottom(p.y()); } | 
|---|
| 737 |  | 
|---|
| 738 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveCenter(const QPointF &p) noexcept | 
|---|
| 739 | { xp = p.x() - w/2; yp = p.y() - h/2; } | 
|---|
| 740 |  | 
|---|
| 741 | Q_DECL_CONSTEXPR inline qreal QRectF::width() const noexcept | 
|---|
| 742 | { return w; } | 
|---|
| 743 |  | 
|---|
| 744 | Q_DECL_CONSTEXPR inline qreal QRectF::height() const noexcept | 
|---|
| 745 | { return h; } | 
|---|
| 746 |  | 
|---|
| 747 | Q_DECL_CONSTEXPR inline QSizeF QRectF::size() const noexcept | 
|---|
| 748 | { return QSizeF(w, h); } | 
|---|
| 749 |  | 
|---|
| 750 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(qreal dx, qreal dy) noexcept | 
|---|
| 751 | { | 
|---|
| 752 | xp += dx; | 
|---|
| 753 | yp += dy; | 
|---|
| 754 | } | 
|---|
| 755 |  | 
|---|
| 756 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::translate(const QPointF &p) noexcept | 
|---|
| 757 | { | 
|---|
| 758 | xp += p.x(); | 
|---|
| 759 | yp += p.y(); | 
|---|
| 760 | } | 
|---|
| 761 |  | 
|---|
| 762 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(qreal ax, qreal ay) noexcept | 
|---|
| 763 | { | 
|---|
| 764 | xp = ax; | 
|---|
| 765 | yp = ay; | 
|---|
| 766 | } | 
|---|
| 767 |  | 
|---|
| 768 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::moveTo(const QPointF &p) noexcept | 
|---|
| 769 | { | 
|---|
| 770 | xp = p.x(); | 
|---|
| 771 | yp = p.y(); | 
|---|
| 772 | } | 
|---|
| 773 |  | 
|---|
| 774 | Q_DECL_CONSTEXPR inline QRectF QRectF::translated(qreal dx, qreal dy) const noexcept | 
|---|
| 775 | { return QRectF(xp + dx, yp + dy, w, h); } | 
|---|
| 776 |  | 
|---|
| 777 | Q_DECL_CONSTEXPR inline QRectF QRectF::translated(const QPointF &p) const noexcept | 
|---|
| 778 | { return QRectF(xp + p.x(), yp + p.y(), w, h); } | 
|---|
| 779 |  | 
|---|
| 780 | Q_DECL_CONSTEXPR inline QRectF QRectF::transposed() const noexcept | 
|---|
| 781 | { return QRectF(topLeft(), size().transposed()); } | 
|---|
| 782 |  | 
|---|
| 783 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getRect(qreal *ax, qreal *ay, qreal *aaw, qreal *aah) const | 
|---|
| 784 | { | 
|---|
| 785 | *ax = this->xp; | 
|---|
| 786 | *ay = this->yp; | 
|---|
| 787 | *aaw = this->w; | 
|---|
| 788 | *aah = this->h; | 
|---|
| 789 | } | 
|---|
| 790 |  | 
|---|
| 791 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setRect(qreal ax, qreal ay, qreal aaw, qreal aah) noexcept | 
|---|
| 792 | { | 
|---|
| 793 | this->xp = ax; | 
|---|
| 794 | this->yp = ay; | 
|---|
| 795 | this->w = aaw; | 
|---|
| 796 | this->h = aah; | 
|---|
| 797 | } | 
|---|
| 798 |  | 
|---|
| 799 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::getCoords(qreal *xp1, qreal *yp1, qreal *xp2, qreal *yp2) const | 
|---|
| 800 | { | 
|---|
| 801 | *xp1 = xp; | 
|---|
| 802 | *yp1 = yp; | 
|---|
| 803 | *xp2 = xp + w; | 
|---|
| 804 | *yp2 = yp + h; | 
|---|
| 805 | } | 
|---|
| 806 |  | 
|---|
| 807 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setCoords(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept | 
|---|
| 808 | { | 
|---|
| 809 | xp = xp1; | 
|---|
| 810 | yp = yp1; | 
|---|
| 811 | w = xp2 - xp1; | 
|---|
| 812 | h = yp2 - yp1; | 
|---|
| 813 | } | 
|---|
| 814 |  | 
|---|
| 815 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::adjust(qreal xp1, qreal yp1, qreal xp2, qreal yp2) noexcept | 
|---|
| 816 | { xp += xp1; yp += yp1; w += xp2 - xp1; h += yp2 - yp1; } | 
|---|
| 817 |  | 
|---|
| 818 | Q_DECL_CONSTEXPR inline QRectF QRectF::adjusted(qreal xp1, qreal yp1, qreal xp2, qreal yp2) const noexcept | 
|---|
| 819 | { return QRectF(xp + xp1, yp + yp1, w + xp2 - xp1, h + yp2 - yp1); } | 
|---|
| 820 |  | 
|---|
| 821 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setWidth(qreal aw) noexcept | 
|---|
| 822 | { this->w = aw; } | 
|---|
| 823 |  | 
|---|
| 824 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setHeight(qreal ah) noexcept | 
|---|
| 825 | { this->h = ah; } | 
|---|
| 826 |  | 
|---|
| 827 | Q_DECL_RELAXED_CONSTEXPR inline void QRectF::setSize(const QSizeF &s) noexcept | 
|---|
| 828 | { | 
|---|
| 829 | w = s.width(); | 
|---|
| 830 | h = s.height(); | 
|---|
| 831 | } | 
|---|
| 832 |  | 
|---|
| 833 | inline bool QRectF::contains(qreal ax, qreal ay) const noexcept | 
|---|
| 834 | { | 
|---|
| 835 | return contains(QPointF(ax, ay)); | 
|---|
| 836 | } | 
|---|
| 837 |  | 
|---|
| 838 | inline QRectF& QRectF::operator|=(const QRectF &r) noexcept | 
|---|
| 839 | { | 
|---|
| 840 | *this = *this | r; | 
|---|
| 841 | return *this; | 
|---|
| 842 | } | 
|---|
| 843 |  | 
|---|
| 844 | inline QRectF& QRectF::operator&=(const QRectF &r) noexcept | 
|---|
| 845 | { | 
|---|
| 846 | *this = *this & r; | 
|---|
| 847 | return *this; | 
|---|
| 848 | } | 
|---|
| 849 |  | 
|---|
| 850 | inline QRectF QRectF::intersected(const QRectF &r) const noexcept | 
|---|
| 851 | { | 
|---|
| 852 | return *this & r; | 
|---|
| 853 | } | 
|---|
| 854 |  | 
|---|
| 855 | inline QRectF QRectF::united(const QRectF &r) const noexcept | 
|---|
| 856 | { | 
|---|
| 857 | return *this | r; | 
|---|
| 858 | } | 
|---|
| 859 |  | 
|---|
| 860 | Q_DECL_CONSTEXPR inline bool operator==(const QRectF &r1, const QRectF &r2) noexcept | 
|---|
| 861 | { | 
|---|
| 862 | return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp) | 
|---|
| 863 | && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h); | 
|---|
| 864 | } | 
|---|
| 865 |  | 
|---|
| 866 | Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &r1, const QRectF &r2) noexcept | 
|---|
| 867 | { | 
|---|
| 868 | return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp) | 
|---|
| 869 | || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h); | 
|---|
| 870 | } | 
|---|
| 871 |  | 
|---|
| 872 | Q_DECL_CONSTEXPR inline QRect QRectF::toRect() const noexcept | 
|---|
| 873 | { | 
|---|
| 874 | return QRect(QPoint(qRound(xp), qRound(yp)), QPoint(qRound(xp + w) - 1, qRound(yp + h) - 1)); | 
|---|
| 875 | } | 
|---|
| 876 |  | 
|---|
| 877 | Q_DECL_CONSTEXPR inline QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) noexcept | 
|---|
| 878 | { | 
|---|
| 879 | return QRectF(QPointF(lhs.left() - rhs.left(), lhs.top() - rhs.top()), | 
|---|
| 880 | QSizeF(lhs.width() + rhs.left() + rhs.right(), lhs.height() + rhs.top() + rhs.bottom())); | 
|---|
| 881 | } | 
|---|
| 882 |  | 
|---|
| 883 | Q_DECL_CONSTEXPR inline QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) noexcept | 
|---|
| 884 | { | 
|---|
| 885 | return QRectF(QPointF(rhs.left() - lhs.left(), rhs.top() - lhs.top()), | 
|---|
| 886 | QSizeF(rhs.width() + lhs.left() + lhs.right(), rhs.height() + lhs.top() + lhs.bottom())); | 
|---|
| 887 | } | 
|---|
| 888 |  | 
|---|
| 889 | Q_DECL_CONSTEXPR inline QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) noexcept | 
|---|
| 890 | { | 
|---|
| 891 | return QRectF(QPointF(lhs.left() + rhs.left(), lhs.top() + rhs.top()), | 
|---|
| 892 | QSizeF(lhs.width() - rhs.left() - rhs.right(), lhs.height() - rhs.top() - rhs.bottom())); | 
|---|
| 893 | } | 
|---|
| 894 |  | 
|---|
| 895 | Q_DECL_CONSTEXPR inline QRectF QRectF::marginsAdded(const QMarginsF &margins) const noexcept | 
|---|
| 896 | { | 
|---|
| 897 | return QRectF(QPointF(xp - margins.left(), yp - margins.top()), | 
|---|
| 898 | QSizeF(w + margins.left() + margins.right(), h + margins.top() + margins.bottom())); | 
|---|
| 899 | } | 
|---|
| 900 |  | 
|---|
| 901 | Q_DECL_CONSTEXPR inline QRectF QRectF::marginsRemoved(const QMarginsF &margins) const noexcept | 
|---|
| 902 | { | 
|---|
| 903 | return QRectF(QPointF(xp + margins.left(), yp + margins.top()), | 
|---|
| 904 | QSizeF(w - margins.left() - margins.right(), h - margins.top() - margins.bottom())); | 
|---|
| 905 | } | 
|---|
| 906 |  | 
|---|
| 907 | Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator+=(const QMarginsF &margins) noexcept | 
|---|
| 908 | { | 
|---|
| 909 | *this = marginsAdded(margins); | 
|---|
| 910 | return *this; | 
|---|
| 911 | } | 
|---|
| 912 |  | 
|---|
| 913 | Q_DECL_RELAXED_CONSTEXPR inline QRectF &QRectF::operator-=(const QMarginsF &margins) noexcept | 
|---|
| 914 | { | 
|---|
| 915 | *this = marginsRemoved(margins); | 
|---|
| 916 | return *this; | 
|---|
| 917 | } | 
|---|
| 918 |  | 
|---|
| 919 | #ifndef QT_NO_DEBUG_STREAM | 
|---|
| 920 | Q_CORE_EXPORT QDebug operator<<(QDebug, const QRectF &); | 
|---|
| 921 | #endif | 
|---|
| 922 |  | 
|---|
| 923 | QT_END_NAMESPACE | 
|---|
| 924 |  | 
|---|
| 925 | #endif // QRECT_H | 
|---|
| 926 |  | 
|---|