| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qrect.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 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 http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | #include "qrect.h" | - | ||||||||||||
| 35 | #include "qdatastream.h" | - | ||||||||||||
| 36 | #include "qmath.h" | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | #include <private/qdebug_p.h> | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | /*! | - | ||||||||||||
| 43 | \class QRect | - | ||||||||||||
| 44 | \inmodule QtCore | - | ||||||||||||
| 45 | \ingroup painting | - | ||||||||||||
| 46 | \reentrant | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | \brief The QRect class defines a rectangle in the plane using | - | ||||||||||||
| 49 | integer precision. | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | A rectangle is normally expressed as an upper-left corner and a | - | ||||||||||||
| 52 | size. The size (width and height) of a QRect is always equivalent | - | ||||||||||||
| 53 | to the mathematical rectangle that forms the basis for its | - | ||||||||||||
| 54 | rendering. | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | A QRect can be constructed with a set of left, top, width and | - | ||||||||||||
| 57 | height integers, or from a QPoint and a QSize. The following code | - | ||||||||||||
| 58 | creates two identical rectangles. | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | \snippet code/src_corelib_tools_qrect.cpp 0 | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | There is a third constructor that creates a QRect using the | - | ||||||||||||
| 63 | top-left and bottom-right coordinates, but we recommend that you | - | ||||||||||||
| 64 | avoid using it. The rationale is that for historical reasons the | - | ||||||||||||
| 65 | values returned by the bottom() and right() functions deviate from | - | ||||||||||||
| 66 | the true bottom-right corner of the rectangle. | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | The QRect class provides a collection of functions that return the | - | ||||||||||||
| 69 | various rectangle coordinates, and enable manipulation of | - | ||||||||||||
| 70 | these. QRect also provide functions to move the rectangle relative | - | ||||||||||||
| 71 | to the various coordinates. In addition there is a moveTo() | - | ||||||||||||
| 72 | function that moves the rectangle, leaving its top left corner at | - | ||||||||||||
| 73 | the given coordinates. Alternatively, the translate() function | - | ||||||||||||
| 74 | moves the rectangle the given offset relative to the current | - | ||||||||||||
| 75 | position, and the translated() function returns a translated copy | - | ||||||||||||
| 76 | of this rectangle. | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | The size() function returns the rectange's dimensions as a | - | ||||||||||||
| 79 | QSize. The dimensions can also be retrieved separately using the | - | ||||||||||||
| 80 | width() and height() functions. To manipulate the dimensions use | - | ||||||||||||
| 81 | the setSize(), setWidth() or setHeight() functions. Alternatively, | - | ||||||||||||
| 82 | the size can be changed by applying either of the functions | - | ||||||||||||
| 83 | setting the rectangle coordinates, for example, setBottom() or | - | ||||||||||||
| 84 | setRight(). | - | ||||||||||||
| 85 | - | |||||||||||||
| 86 | The contains() function tells whether a given point is inside the | - | ||||||||||||
| 87 | rectangle or not, and the intersects() function returns \c true if | - | ||||||||||||
| 88 | this rectangle intersects with a given rectangle. The QRect class | - | ||||||||||||
| 89 | also provides the intersected() function which returns the | - | ||||||||||||
| 90 | intersection rectangle, and the united() function which returns the | - | ||||||||||||
| 91 | rectangle that encloses the given rectangle and this: | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | \table | - | ||||||||||||
| 94 | \row | - | ||||||||||||
| 95 | \li \inlineimage qrect-intersect.png | - | ||||||||||||
| 96 | \li \inlineimage qrect-unite.png | - | ||||||||||||
| 97 | \row | - | ||||||||||||
| 98 | \li intersected() | - | ||||||||||||
| 99 | \li united() | - | ||||||||||||
| 100 | \endtable | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | The isEmpty() function returns \c true if left() > right() or top() > | - | ||||||||||||
| 103 | bottom(). Note that an empty rectangle is not valid: The isValid() | - | ||||||||||||
| 104 | function returns \c true if left() <= right() \e and top() <= | - | ||||||||||||
| 105 | bottom(). A null rectangle (isNull() == true) on the other hand, | - | ||||||||||||
| 106 | has both width and height set to 0. | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | Note that due to the way QRect and QRectF are defined, an | - | ||||||||||||
| 109 | empty QRect is defined in essentially the same way as QRectF. | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | Finally, QRect objects can be streamed as well as compared. | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | \tableofcontents | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | \section1 Rendering | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | When using an \l {QPainter::Antialiasing}{anti-aliased} painter, | - | ||||||||||||
| 118 | the boundary line of a QRect will be rendered symmetrically on | - | ||||||||||||
| 119 | both sides of the mathematical rectangle's boundary line. But when | - | ||||||||||||
| 120 | using an aliased painter (the default) other rules apply. | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | Then, when rendering with a one pixel wide pen the QRect's boundary | - | ||||||||||||
| 123 | line will be rendered to the right and below the mathematical | - | ||||||||||||
| 124 | rectangle's boundary line. | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | When rendering with a two pixels wide pen the boundary line will | - | ||||||||||||
| 127 | be split in the middle by the mathematical rectangle. This will be | - | ||||||||||||
| 128 | the case whenever the pen is set to an even number of pixels, | - | ||||||||||||
| 129 | while rendering with a pen with an odd number of pixels, the spare | - | ||||||||||||
| 130 | pixel will be rendered to the right and below the mathematical | - | ||||||||||||
| 131 | rectangle as in the one pixel case. | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | \table | - | ||||||||||||
| 134 | \row | - | ||||||||||||
| 135 | \li \inlineimage qrect-diagram-zero.png | - | ||||||||||||
| 136 | \li \inlineimage qrect-diagram-one.png | - | ||||||||||||
| 137 | \row | - | ||||||||||||
| 138 | \li Logical representation | - | ||||||||||||
| 139 | \li One pixel wide pen | - | ||||||||||||
| 140 | \row | - | ||||||||||||
| 141 | \li \inlineimage qrect-diagram-two.png | - | ||||||||||||
| 142 | \li \inlineimage qrect-diagram-three.png | - | ||||||||||||
| 143 | \row | - | ||||||||||||
| 144 | \li Two pixel wide pen | - | ||||||||||||
| 145 | \li Three pixel wide pen | - | ||||||||||||
| 146 | \endtable | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | \section1 Coordinates | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | The QRect class provides a collection of functions that return the | - | ||||||||||||
| 151 | various rectangle coordinates, and enable manipulation of | - | ||||||||||||
| 152 | these. QRect also provide functions to move the rectangle relative | - | ||||||||||||
| 153 | to the various coordinates. | - | ||||||||||||
| 154 | - | |||||||||||||
| 155 | For example the left(), setLeft() and moveLeft() functions as an | - | ||||||||||||
| 156 | example: left() returns the x-coordinate of the rectangle's left | - | ||||||||||||
| 157 | edge, setLeft() sets the left edge of the rectangle to the given x | - | ||||||||||||
| 158 | coordinate (it may change the width, but will never change the | - | ||||||||||||
| 159 | rectangle's right edge) and moveLeft() moves the entire rectangle | - | ||||||||||||
| 160 | horizontally, leaving the rectangle's left edge at the given x | - | ||||||||||||
| 161 | coordinate and its size unchanged. | - | ||||||||||||
| 162 | - | |||||||||||||
| 163 | \image qrect-coordinates.png | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | Note that for historical reasons the values returned by the | - | ||||||||||||
| 166 | bottom() and right() functions deviate from the true bottom-right | - | ||||||||||||
| 167 | corner of the rectangle: The right() function returns \e { left() | - | ||||||||||||
| 168 | + width() - 1} and the bottom() function returns \e {top() + | - | ||||||||||||
| 169 | height() - 1}. The same is the case for the point returned by the | - | ||||||||||||
| 170 | bottomRight() convenience function. In addition, the x and y | - | ||||||||||||
| 171 | coordinate of the topRight() and bottomLeft() functions, | - | ||||||||||||
| 172 | respectively, contain the same deviation from the true right and | - | ||||||||||||
| 173 | bottom edges. | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | We recommend that you use x() + width() and y() + height() to find | - | ||||||||||||
| 176 | the true bottom-right corner, and avoid right() and | - | ||||||||||||
| 177 | bottom(). Another solution is to use QRectF: The QRectF class | - | ||||||||||||
| 178 | defines a rectangle in the plane using floating point accuracy for | - | ||||||||||||
| 179 | coordinates, and the QRectF::right() and QRectF::bottom() | - | ||||||||||||
| 180 | functions \e do return the right and bottom coordinates. | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | It is also possible to add offsets to this rectangle's coordinates | - | ||||||||||||
| 183 | using the adjust() function, as well as retrieve a new rectangle | - | ||||||||||||
| 184 | based on adjustments of the original one using the adjusted() | - | ||||||||||||
| 185 | function. If either of the width and height is negative, use the | - | ||||||||||||
| 186 | normalized() function to retrieve a rectangle where the corners | - | ||||||||||||
| 187 | are swapped. | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | In addition, QRect provides the getCoords() function which extracts | - | ||||||||||||
| 190 | the position of the rectangle's top-left and bottom-right corner, | - | ||||||||||||
| 191 | and the getRect() function which extracts the rectangle's top-left | - | ||||||||||||
| 192 | corner, width and height. Use the setCoords() and setRect() | - | ||||||||||||
| 193 | function to manipulate the rectangle's coordinates and dimensions | - | ||||||||||||
| 194 | in one go. | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | \section1 Constraints | - | ||||||||||||
| 197 | - | |||||||||||||
| 198 | QRect is limited to the minimum and maximum values for the \c int type. | - | ||||||||||||
| 199 | Operations on a QRect that could potentially result in values outside this | - | ||||||||||||
| 200 | range will result in undefined behavior. | - | ||||||||||||
| 201 | - | |||||||||||||
| 202 | \sa QRectF, QRegion | - | ||||||||||||
| 203 | */ | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | /***************************************************************************** | - | ||||||||||||
| 206 | QRect member functions | - | ||||||||||||
| 207 | *****************************************************************************/ | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | /*! | - | ||||||||||||
| 210 | \fn QRect::QRect() | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | Constructs a null rectangle. | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | \sa isNull() | - | ||||||||||||
| 215 | */ | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | /*! | - | ||||||||||||
| 218 | \fn QRect::QRect(const QPoint &topLeft, const QPoint &bottomRight) | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | Constructs a rectangle with the given \a topLeft and \a bottomRight corners. | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | \sa setTopLeft(), setBottomRight() | - | ||||||||||||
| 223 | */ | - | ||||||||||||
| 224 | - | |||||||||||||
| 225 | - | |||||||||||||
| 226 | /*! | - | ||||||||||||
| 227 | \fn QRect::QRect(const QPoint &topLeft, const QSize &size) | - | ||||||||||||
| 228 | - | |||||||||||||
| 229 | Constructs a rectangle with the given \a topLeft corner and the | - | ||||||||||||
| 230 | given \a size. | - | ||||||||||||
| 231 | - | |||||||||||||
| 232 | \sa setTopLeft(), setSize() | - | ||||||||||||
| 233 | */ | - | ||||||||||||
| 234 | - | |||||||||||||
| 235 | - | |||||||||||||
| 236 | /*! | - | ||||||||||||
| 237 | \fn QRect::QRect(int x, int y, int width, int height) | - | ||||||||||||
| 238 | - | |||||||||||||
| 239 | Constructs a rectangle with (\a x, \a y) as its top-left corner | - | ||||||||||||
| 240 | and the given \a width and \a height. | - | ||||||||||||
| 241 | - | |||||||||||||
| 242 | \sa setRect() | - | ||||||||||||
| 243 | */ | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | - | |||||||||||||
| 246 | /*! | - | ||||||||||||
| 247 | \fn bool QRect::isNull() const | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | Returns \c true if the rectangle is a null rectangle, otherwise | - | ||||||||||||
| 250 | returns \c false. | - | ||||||||||||
| 251 | - | |||||||||||||
| 252 | A null rectangle has both the width and the height set to 0 (i.e., | - | ||||||||||||
| 253 | right() == left() - 1 and bottom() == top() - 1). A null rectangle | - | ||||||||||||
| 254 | is also empty, and hence is not valid. | - | ||||||||||||
| 255 | - | |||||||||||||
| 256 | \sa isEmpty(), isValid() | - | ||||||||||||
| 257 | */ | - | ||||||||||||
| 258 | - | |||||||||||||
| 259 | /*! | - | ||||||||||||
| 260 | \fn bool QRect::isEmpty() const | - | ||||||||||||
| 261 | - | |||||||||||||
| 262 | Returns \c true if the rectangle is empty, otherwise returns \c false. | - | ||||||||||||
| 263 | - | |||||||||||||
| 264 | An empty rectangle has a left() > right() or top() > bottom(). An | - | ||||||||||||
| 265 | empty rectangle is not valid (i.e., isEmpty() == !isValid()). | - | ||||||||||||
| 266 | - | |||||||||||||
| 267 | Use the normalized() function to retrieve a rectangle where the | - | ||||||||||||
| 268 | corners are swapped. | - | ||||||||||||
| 269 | - | |||||||||||||
| 270 | \sa isNull(), isValid(), normalized() | - | ||||||||||||
| 271 | */ | - | ||||||||||||
| 272 | - | |||||||||||||
| 273 | /*! | - | ||||||||||||
| 274 | \fn bool QRect::isValid() const | - | ||||||||||||
| 275 | - | |||||||||||||
| 276 | Returns \c true if the rectangle is valid, otherwise returns \c false. | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | A valid rectangle has a left() <= right() and top() <= | - | ||||||||||||
| 279 | bottom(). Note that non-trivial operations like intersections are | - | ||||||||||||
| 280 | not defined for invalid rectangles. A valid rectangle is not empty | - | ||||||||||||
| 281 | (i.e., isValid() == !isEmpty()). | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | \sa isNull(), isEmpty(), normalized() | - | ||||||||||||
| 284 | */ | - | ||||||||||||
| 285 | - | |||||||||||||
| 286 | - | |||||||||||||
| 287 | /*! | - | ||||||||||||
| 288 | Returns a normalized rectangle; i.e., a rectangle that has a | - | ||||||||||||
| 289 | non-negative width and height. | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | If width() < 0 the function swaps the left and right corners, and | - | ||||||||||||
| 292 | it swaps the top and bottom corners if height() < 0. | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | \sa isValid(), isEmpty() | - | ||||||||||||
| 295 | */ | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | QRect QRect::normalized() const Q_DECL_NOTHROW | - | ||||||||||||
| 298 | { | - | ||||||||||||
| 299 | QRect r; | - | ||||||||||||
| 300 | if (x2 < x1 - 1) { // swap bad x values
| 1040-52857 | ||||||||||||
| 301 | r.x1 = x2; | - | ||||||||||||
| 302 | r.x2 = x1; | - | ||||||||||||
| 303 | } else { executed 1040 times by 10 tests: end of blockExecuted by:
| 1040 | ||||||||||||
| 304 | r.x1 = x1; | - | ||||||||||||
| 305 | r.x2 = x2; | - | ||||||||||||
| 306 | } executed 52857 times by 83 tests: end of blockExecuted by:
| 52857 | ||||||||||||
| 307 | if (y2 < y1 - 1) { // swap bad y values
| 479-53418 | ||||||||||||
| 308 | r.y1 = y2; | - | ||||||||||||
| 309 | r.y2 = y1; | - | ||||||||||||
| 310 | } else { executed 479 times by 8 tests: end of blockExecuted by:
| 479 | ||||||||||||
| 311 | r.y1 = y1; | - | ||||||||||||
| 312 | r.y2 = y2; | - | ||||||||||||
| 313 | } executed 53418 times by 83 tests: end of blockExecuted by:
| 53418 | ||||||||||||
| 314 | return r; executed 53897 times by 83 tests: return r;Executed by:
| 53897 | ||||||||||||
| 315 | } | - | ||||||||||||
| 316 | - | |||||||||||||
| 317 | - | |||||||||||||
| 318 | /*! | - | ||||||||||||
| 319 | \fn int QRect::left() const | - | ||||||||||||
| 320 | - | |||||||||||||
| 321 | Returns the x-coordinate of the rectangle's left edge. Equivalent | - | ||||||||||||
| 322 | to x(). | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | \sa setLeft(), topLeft(), bottomLeft() | - | ||||||||||||
| 325 | */ | - | ||||||||||||
| 326 | - | |||||||||||||
| 327 | /*! | - | ||||||||||||
| 328 | \fn int QRect::top() const | - | ||||||||||||
| 329 | - | |||||||||||||
| 330 | Returns the y-coordinate of the rectangle's top edge. | - | ||||||||||||
| 331 | Equivalent to y(). | - | ||||||||||||
| 332 | - | |||||||||||||
| 333 | \sa setTop(), topLeft(), topRight() | - | ||||||||||||
| 334 | */ | - | ||||||||||||
| 335 | - | |||||||||||||
| 336 | /*! | - | ||||||||||||
| 337 | \fn int QRect::right() const | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | Returns the x-coordinate of the rectangle's right edge. | - | ||||||||||||
| 340 | - | |||||||||||||
| 341 | Note that for historical reasons this function returns left() + | - | ||||||||||||
| 342 | width() - 1; use x() + width() to retrieve the true x-coordinate. | - | ||||||||||||
| 343 | - | |||||||||||||
| 344 | \sa setRight(), topRight(), bottomRight() | - | ||||||||||||
| 345 | */ | - | ||||||||||||
| 346 | - | |||||||||||||
| 347 | /*! | - | ||||||||||||
| 348 | \fn int QRect::bottom() const | - | ||||||||||||
| 349 | - | |||||||||||||
| 350 | Returns the y-coordinate of the rectangle's bottom edge. | - | ||||||||||||
| 351 | - | |||||||||||||
| 352 | Note that for historical reasons this function returns top() + | - | ||||||||||||
| 353 | height() - 1; use y() + height() to retrieve the true y-coordinate. | - | ||||||||||||
| 354 | - | |||||||||||||
| 355 | \sa setBottom(), bottomLeft(), bottomRight() | - | ||||||||||||
| 356 | */ | - | ||||||||||||
| 357 | - | |||||||||||||
| 358 | /*! | - | ||||||||||||
| 359 | \fn int QRect::x() const | - | ||||||||||||
| 360 | - | |||||||||||||
| 361 | Returns the x-coordinate of the rectangle's left edge. Equivalent to left(). | - | ||||||||||||
| 362 | - | |||||||||||||
| 363 | \sa setX(), y(), topLeft() | - | ||||||||||||
| 364 | */ | - | ||||||||||||
| 365 | - | |||||||||||||
| 366 | /*! | - | ||||||||||||
| 367 | \fn int QRect::y() const | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | Returns the y-coordinate of the rectangle's top edge. Equivalent to top(). | - | ||||||||||||
| 370 | - | |||||||||||||
| 371 | \sa setY(), x(), topLeft() | - | ||||||||||||
| 372 | */ | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | /*! | - | ||||||||||||
| 375 | \fn void QRect::setLeft(int x) | - | ||||||||||||
| 376 | - | |||||||||||||
| 377 | Sets the left edge of the rectangle to the given \a x | - | ||||||||||||
| 378 | coordinate. May change the width, but will never change the right | - | ||||||||||||
| 379 | edge of the rectangle. | - | ||||||||||||
| 380 | - | |||||||||||||
| 381 | Equivalent to setX(). | - | ||||||||||||
| 382 | - | |||||||||||||
| 383 | \sa left(), moveLeft() | - | ||||||||||||
| 384 | */ | - | ||||||||||||
| 385 | - | |||||||||||||
| 386 | /*! | - | ||||||||||||
| 387 | \fn void QRect::setTop(int y) | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | Sets the top edge of the rectangle to the given \a y | - | ||||||||||||
| 390 | coordinate. May change the height, but will never change the | - | ||||||||||||
| 391 | bottom edge of the rectangle. | - | ||||||||||||
| 392 | - | |||||||||||||
| 393 | Equivalent to setY(). | - | ||||||||||||
| 394 | - | |||||||||||||
| 395 | \sa top(), moveTop() | - | ||||||||||||
| 396 | */ | - | ||||||||||||
| 397 | - | |||||||||||||
| 398 | /*! | - | ||||||||||||
| 399 | \fn void QRect::setRight(int x) | - | ||||||||||||
| 400 | - | |||||||||||||
| 401 | Sets the right edge of the rectangle to the given \a x | - | ||||||||||||
| 402 | coordinate. May change the width, but will never change the left | - | ||||||||||||
| 403 | edge of the rectangle. | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | \sa right(), moveRight() | - | ||||||||||||
| 406 | */ | - | ||||||||||||
| 407 | - | |||||||||||||
| 408 | /*! | - | ||||||||||||
| 409 | \fn void QRect::setBottom(int y) | - | ||||||||||||
| 410 | - | |||||||||||||
| 411 | Sets the bottom edge of the rectangle to the given \a y | - | ||||||||||||
| 412 | coordinate. May change the height, but will never change the top | - | ||||||||||||
| 413 | edge of the rectangle. | - | ||||||||||||
| 414 | - | |||||||||||||
| 415 | \sa bottom(), moveBottom(), | - | ||||||||||||
| 416 | */ | - | ||||||||||||
| 417 | - | |||||||||||||
| 418 | /*! | - | ||||||||||||
| 419 | \fn void QRect::setX(int x) | - | ||||||||||||
| 420 | - | |||||||||||||
| 421 | Sets the left edge of the rectangle to the given \a x | - | ||||||||||||
| 422 | coordinate. May change the width, but will never change the right | - | ||||||||||||
| 423 | edge of the rectangle. | - | ||||||||||||
| 424 | - | |||||||||||||
| 425 | Equivalent to setLeft(). | - | ||||||||||||
| 426 | - | |||||||||||||
| 427 | \sa x(), setY(), setTopLeft() | - | ||||||||||||
| 428 | */ | - | ||||||||||||
| 429 | - | |||||||||||||
| 430 | /*! | - | ||||||||||||
| 431 | \fn void QRect::setY(int y) | - | ||||||||||||
| 432 | - | |||||||||||||
| 433 | Sets the top edge of the rectangle to the given \a y | - | ||||||||||||
| 434 | coordinate. May change the height, but will never change the | - | ||||||||||||
| 435 | bottom edge of the rectangle. | - | ||||||||||||
| 436 | - | |||||||||||||
| 437 | Equivalent to setTop(). | - | ||||||||||||
| 438 | - | |||||||||||||
| 439 | \sa y(), setX(), setTopLeft() | - | ||||||||||||
| 440 | */ | - | ||||||||||||
| 441 | - | |||||||||||||
| 442 | /*! | - | ||||||||||||
| 443 | \fn void QRect::setTopLeft(const QPoint &position) | - | ||||||||||||
| 444 | - | |||||||||||||
| 445 | Set the top-left corner of the rectangle to the given \a | - | ||||||||||||
| 446 | position. May change the size, but will never change the | - | ||||||||||||
| 447 | bottom-right corner of the rectangle. | - | ||||||||||||
| 448 | - | |||||||||||||
| 449 | \sa topLeft(), moveTopLeft() | - | ||||||||||||
| 450 | */ | - | ||||||||||||
| 451 | - | |||||||||||||
| 452 | /*! | - | ||||||||||||
| 453 | \fn void QRect::setBottomRight(const QPoint &position) | - | ||||||||||||
| 454 | - | |||||||||||||
| 455 | Set the bottom-right corner of the rectangle to the given \a | - | ||||||||||||
| 456 | position. May change the size, but will never change the | - | ||||||||||||
| 457 | top-left corner of the rectangle. | - | ||||||||||||
| 458 | - | |||||||||||||
| 459 | \sa bottomRight(), moveBottomRight() | - | ||||||||||||
| 460 | */ | - | ||||||||||||
| 461 | - | |||||||||||||
| 462 | /*! | - | ||||||||||||
| 463 | \fn void QRect::setTopRight(const QPoint &position) | - | ||||||||||||
| 464 | - | |||||||||||||
| 465 | Set the top-right corner of the rectangle to the given \a | - | ||||||||||||
| 466 | position. May change the size, but will never change the | - | ||||||||||||
| 467 | bottom-left corner of the rectangle. | - | ||||||||||||
| 468 | - | |||||||||||||
| 469 | \sa topRight(), moveTopRight() | - | ||||||||||||
| 470 | */ | - | ||||||||||||
| 471 | - | |||||||||||||
| 472 | /*! | - | ||||||||||||
| 473 | \fn void QRect::setBottomLeft(const QPoint &position) | - | ||||||||||||
| 474 | - | |||||||||||||
| 475 | Set the bottom-left corner of the rectangle to the given \a | - | ||||||||||||
| 476 | position. May change the size, but will never change the | - | ||||||||||||
| 477 | top-right corner of the rectangle. | - | ||||||||||||
| 478 | - | |||||||||||||
| 479 | \sa bottomLeft(), moveBottomLeft() | - | ||||||||||||
| 480 | */ | - | ||||||||||||
| 481 | - | |||||||||||||
| 482 | /*! | - | ||||||||||||
| 483 | \fn QPoint QRect::topLeft() const | - | ||||||||||||
| 484 | - | |||||||||||||
| 485 | Returns the position of the rectangle's top-left corner. | - | ||||||||||||
| 486 | - | |||||||||||||
| 487 | \sa setTopLeft(), top(), left() | - | ||||||||||||
| 488 | */ | - | ||||||||||||
| 489 | - | |||||||||||||
| 490 | /*! | - | ||||||||||||
| 491 | \fn QPoint QRect::bottomRight() const | - | ||||||||||||
| 492 | - | |||||||||||||
| 493 | Returns the position of the rectangle's bottom-right corner. | - | ||||||||||||
| 494 | - | |||||||||||||
| 495 | Note that for historical reasons this function returns | - | ||||||||||||
| 496 | QPoint(left() + width() -1, top() + height() - 1). | - | ||||||||||||
| 497 | - | |||||||||||||
| 498 | \sa setBottomRight(), bottom(), right() | - | ||||||||||||
| 499 | */ | - | ||||||||||||
| 500 | - | |||||||||||||
| 501 | /*! | - | ||||||||||||
| 502 | \fn QPoint QRect::topRight() const | - | ||||||||||||
| 503 | - | |||||||||||||
| 504 | Returns the position of the rectangle's top-right corner. | - | ||||||||||||
| 505 | - | |||||||||||||
| 506 | Note that for historical reasons this function returns | - | ||||||||||||
| 507 | QPoint(left() + width() -1, top()). | - | ||||||||||||
| 508 | - | |||||||||||||
| 509 | \sa setTopRight(), top(), right() | - | ||||||||||||
| 510 | */ | - | ||||||||||||
| 511 | - | |||||||||||||
| 512 | /*! | - | ||||||||||||
| 513 | \fn QPoint QRect::bottomLeft() const | - | ||||||||||||
| 514 | - | |||||||||||||
| 515 | Returns the position of the rectangle's bottom-left corner. Note | - | ||||||||||||
| 516 | that for historical reasons this function returns QPoint(left(), | - | ||||||||||||
| 517 | top() + height() - 1). | - | ||||||||||||
| 518 | - | |||||||||||||
| 519 | \sa setBottomLeft(), bottom(), left() | - | ||||||||||||
| 520 | */ | - | ||||||||||||
| 521 | - | |||||||||||||
| 522 | /*! | - | ||||||||||||
| 523 | \fn QPoint QRect::center() const | - | ||||||||||||
| 524 | - | |||||||||||||
| 525 | Returns the center point of the rectangle. | - | ||||||||||||
| 526 | - | |||||||||||||
| 527 | \sa moveCenter() | - | ||||||||||||
| 528 | */ | - | ||||||||||||
| 529 | - | |||||||||||||
| 530 | - | |||||||||||||
| 531 | /*! | - | ||||||||||||
| 532 | \fn void QRect::getRect(int *x, int *y, int *width, int *height) const | - | ||||||||||||
| 533 | - | |||||||||||||
| 534 | Extracts the position of the rectangle's top-left corner to *\a x | - | ||||||||||||
| 535 | and *\a y, and its dimensions to *\a width and *\a height. | - | ||||||||||||
| 536 | - | |||||||||||||
| 537 | \sa setRect(), getCoords() | - | ||||||||||||
| 538 | */ | - | ||||||||||||
| 539 | - | |||||||||||||
| 540 | - | |||||||||||||
| 541 | /*! | - | ||||||||||||
| 542 | \fn void QRect::getCoords(int *x1, int *y1, int *x2, int *y2) const | - | ||||||||||||
| 543 | - | |||||||||||||
| 544 | Extracts the position of the rectangle's top-left corner to *\a x1 | - | ||||||||||||
| 545 | and *\a y1, and the position of the bottom-right corner to *\a x2 | - | ||||||||||||
| 546 | and *\a y2. | - | ||||||||||||
| 547 | - | |||||||||||||
| 548 | \sa setCoords(), getRect() | - | ||||||||||||
| 549 | */ | - | ||||||||||||
| 550 | - | |||||||||||||
| 551 | /*! | - | ||||||||||||
| 552 | \fn void QRect::moveLeft(int x) | - | ||||||||||||
| 553 | - | |||||||||||||
| 554 | Moves the rectangle horizontally, leaving the rectangle's left | - | ||||||||||||
| 555 | edge at the given \a x coordinate. The rectangle's size is | - | ||||||||||||
| 556 | unchanged. | - | ||||||||||||
| 557 | - | |||||||||||||
| 558 | \sa left(), setLeft(), moveRight() | - | ||||||||||||
| 559 | */ | - | ||||||||||||
| 560 | - | |||||||||||||
| 561 | /*! | - | ||||||||||||
| 562 | \fn void QRect::moveTop(int y) | - | ||||||||||||
| 563 | - | |||||||||||||
| 564 | Moves the rectangle vertically, leaving the rectangle's top edge | - | ||||||||||||
| 565 | at the given \a y coordinate. The rectangle's size is unchanged. | - | ||||||||||||
| 566 | - | |||||||||||||
| 567 | \sa top(), setTop(), moveBottom() | - | ||||||||||||
| 568 | */ | - | ||||||||||||
| 569 | - | |||||||||||||
| 570 | - | |||||||||||||
| 571 | /*! | - | ||||||||||||
| 572 | \fn void QRect::moveRight(int x) | - | ||||||||||||
| 573 | - | |||||||||||||
| 574 | Moves the rectangle horizontally, leaving the rectangle's right | - | ||||||||||||
| 575 | edge at the given \a x coordinate. The rectangle's size is | - | ||||||||||||
| 576 | unchanged. | - | ||||||||||||
| 577 | - | |||||||||||||
| 578 | \sa right(), setRight(), moveLeft() | - | ||||||||||||
| 579 | */ | - | ||||||||||||
| 580 | - | |||||||||||||
| 581 | - | |||||||||||||
| 582 | /*! | - | ||||||||||||
| 583 | \fn void QRect::moveBottom(int y) | - | ||||||||||||
| 584 | - | |||||||||||||
| 585 | Moves the rectangle vertically, leaving the rectangle's bottom | - | ||||||||||||
| 586 | edge at the given \a y coordinate. The rectangle's size is | - | ||||||||||||
| 587 | unchanged. | - | ||||||||||||
| 588 | - | |||||||||||||
| 589 | \sa bottom(), setBottom(), moveTop() | - | ||||||||||||
| 590 | */ | - | ||||||||||||
| 591 | - | |||||||||||||
| 592 | - | |||||||||||||
| 593 | /*! | - | ||||||||||||
| 594 | \fn void QRect::moveTopLeft(const QPoint &position) | - | ||||||||||||
| 595 | - | |||||||||||||
| 596 | Moves the rectangle, leaving the top-left corner at the given \a | - | ||||||||||||
| 597 | position. The rectangle's size is unchanged. | - | ||||||||||||
| 598 | - | |||||||||||||
| 599 | \sa setTopLeft(), moveTop(), moveLeft() | - | ||||||||||||
| 600 | */ | - | ||||||||||||
| 601 | - | |||||||||||||
| 602 | - | |||||||||||||
| 603 | /*! | - | ||||||||||||
| 604 | \fn void QRect::moveBottomRight(const QPoint &position) | - | ||||||||||||
| 605 | - | |||||||||||||
| 606 | Moves the rectangle, leaving the bottom-right corner at the given | - | ||||||||||||
| 607 | \a position. The rectangle's size is unchanged. | - | ||||||||||||
| 608 | - | |||||||||||||
| 609 | \sa setBottomRight(), moveRight(), moveBottom() | - | ||||||||||||
| 610 | */ | - | ||||||||||||
| 611 | - | |||||||||||||
| 612 | - | |||||||||||||
| 613 | /*! | - | ||||||||||||
| 614 | \fn void QRect::moveTopRight(const QPoint &position) | - | ||||||||||||
| 615 | - | |||||||||||||
| 616 | Moves the rectangle, leaving the top-right corner at the given \a | - | ||||||||||||
| 617 | position. The rectangle's size is unchanged. | - | ||||||||||||
| 618 | - | |||||||||||||
| 619 | \sa setTopRight(), moveTop(), moveRight() | - | ||||||||||||
| 620 | */ | - | ||||||||||||
| 621 | - | |||||||||||||
| 622 | - | |||||||||||||
| 623 | /*! | - | ||||||||||||
| 624 | \fn void QRect::moveBottomLeft(const QPoint &position) | - | ||||||||||||
| 625 | - | |||||||||||||
| 626 | Moves the rectangle, leaving the bottom-left corner at the given | - | ||||||||||||
| 627 | \a position. The rectangle's size is unchanged. | - | ||||||||||||
| 628 | - | |||||||||||||
| 629 | \sa setBottomLeft(), moveBottom(), moveLeft() | - | ||||||||||||
| 630 | */ | - | ||||||||||||
| 631 | - | |||||||||||||
| 632 | - | |||||||||||||
| 633 | /*! | - | ||||||||||||
| 634 | \fn void QRect::moveCenter(const QPoint &position) | - | ||||||||||||
| 635 | - | |||||||||||||
| 636 | Moves the rectangle, leaving the center point at the given \a | - | ||||||||||||
| 637 | position. The rectangle's size is unchanged. | - | ||||||||||||
| 638 | - | |||||||||||||
| 639 | \sa center() | - | ||||||||||||
| 640 | */ | - | ||||||||||||
| 641 | - | |||||||||||||
| 642 | /*! | - | ||||||||||||
| 643 | \fn void QRect::moveTo(int x, int y) | - | ||||||||||||
| 644 | - | |||||||||||||
| 645 | Moves the rectangle, leaving the top-left corner at the given | - | ||||||||||||
| 646 | position (\a x, \a y). The rectangle's size is unchanged. | - | ||||||||||||
| 647 | - | |||||||||||||
| 648 | \sa translate(), moveTopLeft() | - | ||||||||||||
| 649 | */ | - | ||||||||||||
| 650 | - | |||||||||||||
| 651 | /*! | - | ||||||||||||
| 652 | \fn void QRect::moveTo(const QPoint &position) | - | ||||||||||||
| 653 | - | |||||||||||||
| 654 | Moves the rectangle, leaving the top-left corner at the given \a | - | ||||||||||||
| 655 | position. | - | ||||||||||||
| 656 | */ | - | ||||||||||||
| 657 | - | |||||||||||||
| 658 | /*! | - | ||||||||||||
| 659 | \fn void QRect::translate(int dx, int dy) | - | ||||||||||||
| 660 | - | |||||||||||||
| 661 | Moves the rectangle \a dx along the x axis and \a dy along the y | - | ||||||||||||
| 662 | axis, relative to the current position. Positive values move the | - | ||||||||||||
| 663 | rectangle to the right and down. | - | ||||||||||||
| 664 | - | |||||||||||||
| 665 | \sa moveTopLeft(), moveTo(), translated() | - | ||||||||||||
| 666 | */ | - | ||||||||||||
| 667 | - | |||||||||||||
| 668 | - | |||||||||||||
| 669 | /*! | - | ||||||||||||
| 670 | \fn void QRect::translate(const QPoint &offset) | - | ||||||||||||
| 671 | \overload | - | ||||||||||||
| 672 | - | |||||||||||||
| 673 | Moves the rectangle \a{offset}.\l{QPoint::x()}{x()} along the x | - | ||||||||||||
| 674 | axis and \a{offset}.\l{QPoint::y()}{y()} along the y axis, | - | ||||||||||||
| 675 | relative to the current position. | - | ||||||||||||
| 676 | */ | - | ||||||||||||
| 677 | - | |||||||||||||
| 678 | - | |||||||||||||
| 679 | /*! | - | ||||||||||||
| 680 | \fn QRect QRect::translated(int dx, int dy) const | - | ||||||||||||
| 681 | - | |||||||||||||
| 682 | Returns a copy of the rectangle that is translated \a dx along the | - | ||||||||||||
| 683 | x axis and \a dy along the y axis, relative to the current | - | ||||||||||||
| 684 | position. Positive values move the rectangle to the right and | - | ||||||||||||
| 685 | down. | - | ||||||||||||
| 686 | - | |||||||||||||
| 687 | \sa translate() | - | ||||||||||||
| 688 | - | |||||||||||||
| 689 | */ | - | ||||||||||||
| 690 | - | |||||||||||||
| 691 | - | |||||||||||||
| 692 | /*! | - | ||||||||||||
| 693 | \fn QRect QRect::translated(const QPoint &offset) const | - | ||||||||||||
| 694 | - | |||||||||||||
| 695 | \overload | - | ||||||||||||
| 696 | - | |||||||||||||
| 697 | Returns a copy of the rectangle that is translated | - | ||||||||||||
| 698 | \a{offset}.\l{QPoint::x()}{x()} along the x axis and | - | ||||||||||||
| 699 | \a{offset}.\l{QPoint::y()}{y()} along the y axis, relative to the | - | ||||||||||||
| 700 | current position. | - | ||||||||||||
| 701 | */ | - | ||||||||||||
| 702 | - | |||||||||||||
| 703 | - | |||||||||||||
| 704 | /*! | - | ||||||||||||
| 705 | \fn void QRect::setRect(int x, int y, int width, int height) | - | ||||||||||||
| 706 | - | |||||||||||||
| 707 | Sets the coordinates of the rectangle's top-left corner to (\a{x}, | - | ||||||||||||
| 708 | \a{y}), and its size to the given \a width and \a height. | - | ||||||||||||
| 709 | - | |||||||||||||
| 710 | \sa getRect(), setCoords() | - | ||||||||||||
| 711 | */ | - | ||||||||||||
| 712 | - | |||||||||||||
| 713 | - | |||||||||||||
| 714 | /*! | - | ||||||||||||
| 715 | \fn void QRect::setCoords(int x1, int y1, int x2, int y2) | - | ||||||||||||
| 716 | - | |||||||||||||
| 717 | Sets the coordinates of the rectangle's top-left corner to (\a x1, | - | ||||||||||||
| 718 | \a y1), and the coordinates of its bottom-right corner to (\a x2, | - | ||||||||||||
| 719 | \a y2). | - | ||||||||||||
| 720 | - | |||||||||||||
| 721 | \sa getCoords(), setRect() | - | ||||||||||||
| 722 | */ | - | ||||||||||||
| 723 | - | |||||||||||||
| 724 | - | |||||||||||||
| 725 | /*! \fn QRect QRect::adjusted(int dx1, int dy1, int dx2, int dy2) const | - | ||||||||||||
| 726 | - | |||||||||||||
| 727 | Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2 | - | ||||||||||||
| 728 | added respectively to the existing coordinates of this rectangle. | - | ||||||||||||
| 729 | - | |||||||||||||
| 730 | \sa adjust() | - | ||||||||||||
| 731 | */ | - | ||||||||||||
| 732 | - | |||||||||||||
| 733 | /*! \fn void QRect::adjust(int dx1, int dy1, int dx2, int dy2) | - | ||||||||||||
| 734 | - | |||||||||||||
| 735 | Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the | - | ||||||||||||
| 736 | existing coordinates of the rectangle. | - | ||||||||||||
| 737 | - | |||||||||||||
| 738 | \sa adjusted(), setRect() | - | ||||||||||||
| 739 | */ | - | ||||||||||||
| 740 | - | |||||||||||||
| 741 | /*! | - | ||||||||||||
| 742 | \fn QSize QRect::size() const | - | ||||||||||||
| 743 | - | |||||||||||||
| 744 | Returns the size of the rectangle. | - | ||||||||||||
| 745 | - | |||||||||||||
| 746 | \sa setSize(), width(), height() | - | ||||||||||||
| 747 | */ | - | ||||||||||||
| 748 | - | |||||||||||||
| 749 | /*! | - | ||||||||||||
| 750 | \fn int QRect::width() const | - | ||||||||||||
| 751 | - | |||||||||||||
| 752 | Returns the width of the rectangle. | - | ||||||||||||
| 753 | - | |||||||||||||
| 754 | \sa setWidth(), height(), size() | - | ||||||||||||
| 755 | */ | - | ||||||||||||
| 756 | - | |||||||||||||
| 757 | /*! | - | ||||||||||||
| 758 | \fn int QRect::height() const | - | ||||||||||||
| 759 | - | |||||||||||||
| 760 | Returns the height of the rectangle. | - | ||||||||||||
| 761 | - | |||||||||||||
| 762 | \sa setHeight(), width(), size() | - | ||||||||||||
| 763 | */ | - | ||||||||||||
| 764 | - | |||||||||||||
| 765 | /*! | - | ||||||||||||
| 766 | \fn void QRect::setWidth(int width) | - | ||||||||||||
| 767 | - | |||||||||||||
| 768 | Sets the width of the rectangle to the given \a width. The right | - | ||||||||||||
| 769 | edge is changed, but not the left one. | - | ||||||||||||
| 770 | - | |||||||||||||
| 771 | \sa width(), setSize() | - | ||||||||||||
| 772 | */ | - | ||||||||||||
| 773 | - | |||||||||||||
| 774 | - | |||||||||||||
| 775 | /*! | - | ||||||||||||
| 776 | \fn void QRect::setHeight(int height) | - | ||||||||||||
| 777 | - | |||||||||||||
| 778 | Sets the height of the rectangle to the given \a height. The bottom | - | ||||||||||||
| 779 | edge is changed, but not the top one. | - | ||||||||||||
| 780 | - | |||||||||||||
| 781 | \sa height(), setSize() | - | ||||||||||||
| 782 | */ | - | ||||||||||||
| 783 | - | |||||||||||||
| 784 | - | |||||||||||||
| 785 | /*! | - | ||||||||||||
| 786 | \fn void QRect::setSize(const QSize &size) | - | ||||||||||||
| 787 | - | |||||||||||||
| 788 | Sets the size of the rectangle to the given \a size. The top-left | - | ||||||||||||
| 789 | corner is not moved. | - | ||||||||||||
| 790 | - | |||||||||||||
| 791 | \sa size(), setWidth(), setHeight() | - | ||||||||||||
| 792 | */ | - | ||||||||||||
| 793 | - | |||||||||||||
| 794 | - | |||||||||||||
| 795 | /*! | - | ||||||||||||
| 796 | \fn bool QRect::contains(const QPoint &point, bool proper) const | - | ||||||||||||
| 797 | - | |||||||||||||
| 798 | Returns \c true if the given \a point is inside or on the edge of | - | ||||||||||||
| 799 | the rectangle, otherwise returns \c false. If \a proper is true, this | - | ||||||||||||
| 800 | function only returns \c true if the given \a point is \e inside the | - | ||||||||||||
| 801 | rectangle (i.e., not on the edge). | - | ||||||||||||
| 802 | - | |||||||||||||
| 803 | \sa intersects() | - | ||||||||||||
| 804 | */ | - | ||||||||||||
| 805 | - | |||||||||||||
| 806 | bool QRect::contains(const QPoint &p, bool proper) const Q_DECL_NOTHROW | - | ||||||||||||
| 807 | { | - | ||||||||||||
| 808 | int l, r; | - | ||||||||||||
| 809 | if (x2 < x1 - 1) {
| 24-4967617 | ||||||||||||
| 810 | l = x2; | - | ||||||||||||
| 811 | r = x1; | - | ||||||||||||
| 812 | } else { executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||
| 813 | l = x1; | - | ||||||||||||
| 814 | r = x2; | - | ||||||||||||
| 815 | } executed 4967617 times by 132 tests: end of blockExecuted by:
| 4967617 | ||||||||||||
| 816 | if (proper) {
| 27-4967614 | ||||||||||||
| 817 | if (p.x() <= l || p.x() >= r)
| 7-20 | ||||||||||||
| 818 | return false; executed 18 times by 1 test: return false;Executed by:
| 18 | ||||||||||||
| 819 | } else { executed 9 times by 1 test: end of blockExecuted by:
| 9 | ||||||||||||
| 820 | if (p.x() < l || p.x() > r)
| 182345-4785269 | ||||||||||||
| 821 | return false; executed 1497288 times by 63 tests: return false;Executed by:
| 1497288 | ||||||||||||
| 822 | } executed 3470326 times by 132 tests: end of blockExecuted by:
| 3470326 | ||||||||||||
| 823 | int t, b; | - | ||||||||||||
| 824 | if (y2 < y1 - 1) {
| 14-3470321 | ||||||||||||
| 825 | t = y2; | - | ||||||||||||
| 826 | b = y1; | - | ||||||||||||
| 827 | } else { executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||
| 828 | t = y1; | - | ||||||||||||
| 829 | b = y2; | - | ||||||||||||
| 830 | } executed 3470321 times by 132 tests: end of blockExecuted by:
| 3470321 | ||||||||||||
| 831 | if (proper) {
| 9-3470326 | ||||||||||||
| 832 | if (p.y() <= t || p.y() >= b)
| 0-6 | ||||||||||||
| 833 | return false; executed 3 times by 1 test: return false;Executed by:
| 3 | ||||||||||||
| 834 | } else { executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||
| 835 | if (p.y() < t || p.y() > b)
| 256174-3214152 | ||||||||||||
| 836 | return false; executed 3172159 times by 51 tests: return false;Executed by:
| 3172159 | ||||||||||||
| 837 | } executed 298167 times by 132 tests: end of blockExecuted by:
| 298167 | ||||||||||||
| 838 | return true; executed 298173 times by 132 tests: return true;Executed by:
| 298173 | ||||||||||||
| 839 | } | - | ||||||||||||
| 840 | - | |||||||||||||
| 841 | - | |||||||||||||
| 842 | /*! | - | ||||||||||||
| 843 | \fn bool QRect::contains(int x, int y, bool proper) const | - | ||||||||||||
| 844 | \overload | - | ||||||||||||
| 845 | - | |||||||||||||
| 846 | Returns \c true if the point (\a x, \a y) is inside or on the edge of | - | ||||||||||||
| 847 | the rectangle, otherwise returns \c false. If \a proper is true, this | - | ||||||||||||
| 848 | function only returns \c true if the point is entirely inside the | - | ||||||||||||
| 849 | rectangle(not on the edge). | - | ||||||||||||
| 850 | */ | - | ||||||||||||
| 851 | - | |||||||||||||
| 852 | /*! | - | ||||||||||||
| 853 | \fn bool QRect::contains(int x, int y) const | - | ||||||||||||
| 854 | \overload | - | ||||||||||||
| 855 | - | |||||||||||||
| 856 | Returns \c true if the point (\a x, \a y) is inside this rectangle, | - | ||||||||||||
| 857 | otherwise returns \c false. | - | ||||||||||||
| 858 | */ | - | ||||||||||||
| 859 | - | |||||||||||||
| 860 | /*! | - | ||||||||||||
| 861 | \fn bool QRect::contains(const QRect &rectangle, bool proper) const | - | ||||||||||||
| 862 | \overload | - | ||||||||||||
| 863 | - | |||||||||||||
| 864 | Returns \c true if the given \a rectangle is inside this rectangle. | - | ||||||||||||
| 865 | otherwise returns \c false. If \a proper is true, this function only | - | ||||||||||||
| 866 | returns \c true if the \a rectangle is entirely inside this | - | ||||||||||||
| 867 | rectangle (not on the edge). | - | ||||||||||||
| 868 | */ | - | ||||||||||||
| 869 | - | |||||||||||||
| 870 | bool QRect::contains(const QRect &r, bool proper) const Q_DECL_NOTHROW | - | ||||||||||||
| 871 | { | - | ||||||||||||
| 872 | if (isNull() || r.isNull())
| 2-9153 | ||||||||||||
| 873 | return false; executed 7 times by 3 tests: return false;Executed by:
| 7 | ||||||||||||
| 874 | - | |||||||||||||
| 875 | int l1 = x1; | - | ||||||||||||
| 876 | int r1 = x1; | - | ||||||||||||
| 877 | if (x2 - x1 + 1 < 0)
| 4-9144 | ||||||||||||
| 878 | l1 = x2; executed 4 times by 1 test: l1 = x2;Executed by:
| 4 | ||||||||||||
| 879 | else | - | ||||||||||||
| 880 | r1 = x2; executed 9144 times by 33 tests: r1 = x2;Executed by:
| 9144 | ||||||||||||
| 881 | - | |||||||||||||
| 882 | int l2 = r.x1; | - | ||||||||||||
| 883 | int r2 = r.x1; | - | ||||||||||||
| 884 | if (r.x2 - r.x1 + 1 < 0)
| 4-9144 | ||||||||||||
| 885 | l2 = r.x2; executed 4 times by 1 test: l2 = r.x2;Executed by:
| 4 | ||||||||||||
| 886 | else | - | ||||||||||||
| 887 | r2 = r.x2; executed 9144 times by 33 tests: r2 = r.x2;Executed by:
| 9144 | ||||||||||||
| 888 | - | |||||||||||||
| 889 | if (proper) {
| 0-9148 | ||||||||||||
| 890 | if (l2 <= l1 || r2 >= r1)
| 0 | ||||||||||||
| 891 | return false; never executed: return false; | 0 | ||||||||||||
| 892 | } else { never executed: end of block | 0 | ||||||||||||
| 893 | if (l2 < l1 || r2 > r1)
| 152-8996 | ||||||||||||
| 894 | return false; executed 2013 times by 14 tests: return false;Executed by:
| 2013 | ||||||||||||
| 895 | } executed 7135 times by 32 tests: end of blockExecuted by:
| 7135 | ||||||||||||
| 896 | - | |||||||||||||
| 897 | int t1 = y1; | - | ||||||||||||
| 898 | int b1 = y1; | - | ||||||||||||
| 899 | if (y2 - y1 + 1 < 0)
| 2-7133 | ||||||||||||
| 900 | t1 = y2; executed 2 times by 1 test: t1 = y2;Executed by:
| 2 | ||||||||||||
| 901 | else | - | ||||||||||||
| 902 | b1 = y2; executed 7133 times by 32 tests: b1 = y2;Executed by:
| 7133 | ||||||||||||
| 903 | - | |||||||||||||
| 904 | int t2 = r.y1; | - | ||||||||||||
| 905 | int b2 = r.y1; | - | ||||||||||||
| 906 | if (r.y2 - r.y1 + 1 < 0)
| 2-7133 | ||||||||||||
| 907 | t2 = r.y2; executed 2 times by 1 test: t2 = r.y2;Executed by:
| 2 | ||||||||||||
| 908 | else | - | ||||||||||||
| 909 | b2 = r.y2; executed 7133 times by 32 tests: b2 = r.y2;Executed by:
| 7133 | ||||||||||||
| 910 | - | |||||||||||||
| 911 | if (proper) {
| 0-7135 | ||||||||||||
| 912 | if (t2 <= t1 || b2 >= b1)
| 0 | ||||||||||||
| 913 | return false; never executed: return false; | 0 | ||||||||||||
| 914 | } else { never executed: end of block | 0 | ||||||||||||
| 915 | if (t2 < t1 || b2 > b1)
| 89-7046 | ||||||||||||
| 916 | return false; executed 1223 times by 11 tests: return false;Executed by:
| 1223 | ||||||||||||
| 917 | } executed 5912 times by 31 tests: end of blockExecuted by:
| 5912 | ||||||||||||
| 918 | - | |||||||||||||
| 919 | return true; executed 5912 times by 31 tests: return true;Executed by:
| 5912 | ||||||||||||
| 920 | } | - | ||||||||||||
| 921 | - | |||||||||||||
| 922 | /*! | - | ||||||||||||
| 923 | \fn QRect& QRect::operator|=(const QRect &rectangle) | - | ||||||||||||
| 924 | - | |||||||||||||
| 925 | Unites this rectangle with the given \a rectangle. | - | ||||||||||||
| 926 | - | |||||||||||||
| 927 | \sa united(), operator|() | - | ||||||||||||
| 928 | */ | - | ||||||||||||
| 929 | - | |||||||||||||
| 930 | /*! | - | ||||||||||||
| 931 | \fn QRect& QRect::operator&=(const QRect &rectangle) | - | ||||||||||||
| 932 | - | |||||||||||||
| 933 | Intersects this rectangle with the given \a rectangle. | - | ||||||||||||
| 934 | - | |||||||||||||
| 935 | \sa intersected(), operator&() | - | ||||||||||||
| 936 | */ | - | ||||||||||||
| 937 | - | |||||||||||||
| 938 | - | |||||||||||||
| 939 | /*! | - | ||||||||||||
| 940 | \fn QRect QRect::operator|(const QRect &rectangle) const | - | ||||||||||||
| 941 | - | |||||||||||||
| 942 | Returns the bounding rectangle of this rectangle and the given \a | - | ||||||||||||
| 943 | rectangle. | - | ||||||||||||
| 944 | - | |||||||||||||
| 945 | \sa operator|=(), united() | - | ||||||||||||
| 946 | */ | - | ||||||||||||
| 947 | - | |||||||||||||
| 948 | QRect QRect::operator|(const QRect &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 949 | { | - | ||||||||||||
| 950 | if (isNull())
| 1577-357161 | ||||||||||||
| 951 | return r; executed 1577 times by 60 tests: return r;Executed by:
| 1577 | ||||||||||||
| 952 | if (r.isNull())
| 170630-186531 | ||||||||||||
| 953 | return *this; executed 170630 times by 27 tests: return *this;Executed by:
| 170630 | ||||||||||||
| 954 | - | |||||||||||||
| 955 | int l1 = x1; | - | ||||||||||||
| 956 | int r1 = x1; | - | ||||||||||||
| 957 | if (x2 - x1 + 1 < 0)
| 17-186514 | ||||||||||||
| 958 | l1 = x2; executed 17 times by 5 tests: l1 = x2;Executed by:
| 17 | ||||||||||||
| 959 | else | - | ||||||||||||
| 960 | r1 = x2; executed 186514 times by 45 tests: r1 = x2;Executed by:
| 186514 | ||||||||||||
| 961 | - | |||||||||||||
| 962 | int l2 = r.x1; | - | ||||||||||||
| 963 | int r2 = r.x1; | - | ||||||||||||
| 964 | if (r.x2 - r.x1 + 1 < 0)
| 77-186454 | ||||||||||||
| 965 | l2 = r.x2; executed 77 times by 4 tests: l2 = r.x2;Executed by:
| 77 | ||||||||||||
| 966 | else | - | ||||||||||||
| 967 | r2 = r.x2; executed 186454 times by 45 tests: r2 = r.x2;Executed by:
| 186454 | ||||||||||||
| 968 | - | |||||||||||||
| 969 | int t1 = y1; | - | ||||||||||||
| 970 | int b1 = y1; | - | ||||||||||||
| 971 | if (y2 - y1 + 1 < 0)
| 4-186527 | ||||||||||||
| 972 | t1 = y2; executed 4 times by 1 test: t1 = y2;Executed by:
| 4 | ||||||||||||
| 973 | else | - | ||||||||||||
| 974 | b1 = y2; executed 186527 times by 45 tests: b1 = y2;Executed by:
| 186527 | ||||||||||||
| 975 | - | |||||||||||||
| 976 | int t2 = r.y1; | - | ||||||||||||
| 977 | int b2 = r.y1; | - | ||||||||||||
| 978 | if (r.y2 - r.y1 + 1 < 0)
| 4-186527 | ||||||||||||
| 979 | t2 = r.y2; executed 4 times by 1 test: t2 = r.y2;Executed by:
| 4 | ||||||||||||
| 980 | else | - | ||||||||||||
| 981 | b2 = r.y2; executed 186527 times by 45 tests: b2 = r.y2;Executed by:
| 186527 | ||||||||||||
| 982 | - | |||||||||||||
| 983 | QRect tmp; | - | ||||||||||||
| 984 | tmp.x1 = qMin(l1, l2); | - | ||||||||||||
| 985 | tmp.x2 = qMax(r1, r2); | - | ||||||||||||
| 986 | tmp.y1 = qMin(t1, t2); | - | ||||||||||||
| 987 | tmp.y2 = qMax(b1, b2); | - | ||||||||||||
| 988 | return tmp; executed 186531 times by 45 tests: return tmp;Executed by:
| 186531 | ||||||||||||
| 989 | } | - | ||||||||||||
| 990 | - | |||||||||||||
| 991 | /*! | - | ||||||||||||
| 992 | \fn QRect QRect::unite(const QRect &rectangle) const | - | ||||||||||||
| 993 | \obsolete | - | ||||||||||||
| 994 | - | |||||||||||||
| 995 | Use united(\a rectangle) instead. | - | ||||||||||||
| 996 | */ | - | ||||||||||||
| 997 | - | |||||||||||||
| 998 | /*! | - | ||||||||||||
| 999 | \fn QRect QRect::united(const QRect &rectangle) const | - | ||||||||||||
| 1000 | \since 4.2 | - | ||||||||||||
| 1001 | - | |||||||||||||
| 1002 | Returns the bounding rectangle of this rectangle and the given \a rectangle. | - | ||||||||||||
| 1003 | - | |||||||||||||
| 1004 | \image qrect-unite.png | - | ||||||||||||
| 1005 | - | |||||||||||||
| 1006 | \sa intersected() | - | ||||||||||||
| 1007 | */ | - | ||||||||||||
| 1008 | - | |||||||||||||
| 1009 | - | |||||||||||||
| 1010 | /*! | - | ||||||||||||
| 1011 | \fn QRect QRect::operator&(const QRect &rectangle) const | - | ||||||||||||
| 1012 | - | |||||||||||||
| 1013 | Returns the intersection of this rectangle and the given \a | - | ||||||||||||
| 1014 | rectangle. Returns an empty rectangle if there is no intersection. | - | ||||||||||||
| 1015 | - | |||||||||||||
| 1016 | \sa operator&=(), intersected() | - | ||||||||||||
| 1017 | */ | - | ||||||||||||
| 1018 | - | |||||||||||||
| 1019 | QRect QRect::operator&(const QRect &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 1020 | { | - | ||||||||||||
| 1021 | if (isNull() || r.isNull())
| 422-537364 | ||||||||||||
| 1022 | return QRect(); executed 1073 times by 33 tests: return QRect();Executed by:
| 1073 | ||||||||||||
| 1023 | - | |||||||||||||
| 1024 | int l1 = x1; | - | ||||||||||||
| 1025 | int r1 = x1; | - | ||||||||||||
| 1026 | if (x2 - x1 + 1 < 0)
| 10-536932 | ||||||||||||
| 1027 | l1 = x2; executed 10 times by 2 tests: l1 = x2;Executed by:
| 10 | ||||||||||||
| 1028 | else | - | ||||||||||||
| 1029 | r1 = x2; executed 536932 times by 127 tests: r1 = x2;Executed by:
| 536932 | ||||||||||||
| 1030 | - | |||||||||||||
| 1031 | int l2 = r.x1; | - | ||||||||||||
| 1032 | int r2 = r.x1; | - | ||||||||||||
| 1033 | if (r.x2 - r.x1 + 1 < 0)
| 4-536938 | ||||||||||||
| 1034 | l2 = r.x2; executed 4 times by 1 test: l2 = r.x2;Executed by:
| 4 | ||||||||||||
| 1035 | else | - | ||||||||||||
| 1036 | r2 = r.x2; executed 536938 times by 127 tests: r2 = r.x2;Executed by:
| 536938 | ||||||||||||
| 1037 | - | |||||||||||||
| 1038 | if (l1 > r2 || l2 > r1)
| 4407-529242 | ||||||||||||
| 1039 | return QRect(); executed 12107 times by 35 tests: return QRect();Executed by:
| 12107 | ||||||||||||
| 1040 | - | |||||||||||||
| 1041 | int t1 = y1; | - | ||||||||||||
| 1042 | int b1 = y1; | - | ||||||||||||
| 1043 | if (y2 - y1 + 1 < 0)
| 21-524814 | ||||||||||||
| 1044 | t1 = y2; executed 21 times by 2 tests: t1 = y2;Executed by:
| 21 | ||||||||||||
| 1045 | else | - | ||||||||||||
| 1046 | b1 = y2; executed 524814 times by 127 tests: b1 = y2;Executed by:
| 524814 | ||||||||||||
| 1047 | - | |||||||||||||
| 1048 | int t2 = r.y1; | - | ||||||||||||
| 1049 | int b2 = r.y1; | - | ||||||||||||
| 1050 | if (r.y2 - r.y1 + 1 < 0)
| 3-524832 | ||||||||||||
| 1051 | t2 = r.y2; executed 3 times by 1 test: t2 = r.y2;Executed by:
| 3 | ||||||||||||
| 1052 | else | - | ||||||||||||
| 1053 | b2 = r.y2; executed 524832 times by 127 tests: b2 = r.y2;Executed by:
| 524832 | ||||||||||||
| 1054 | - | |||||||||||||
| 1055 | if (t1 > b2 || t2 > b1)
| 737-521970 | ||||||||||||
| 1056 | return QRect(); executed 3602 times by 38 tests: return QRect();Executed by:
| 3602 | ||||||||||||
| 1057 | - | |||||||||||||
| 1058 | QRect tmp; | - | ||||||||||||
| 1059 | tmp.x1 = qMax(l1, l2); | - | ||||||||||||
| 1060 | tmp.x2 = qMin(r1, r2); | - | ||||||||||||
| 1061 | tmp.y1 = qMax(t1, t2); | - | ||||||||||||
| 1062 | tmp.y2 = qMin(b1, b2); | - | ||||||||||||
| 1063 | return tmp; executed 521233 times by 127 tests: return tmp;Executed by:
| 521233 | ||||||||||||
| 1064 | } | - | ||||||||||||
| 1065 | - | |||||||||||||
| 1066 | /*! | - | ||||||||||||
| 1067 | \fn QRect QRect::intersect(const QRect &rectangle) const | - | ||||||||||||
| 1068 | \obsolete | - | ||||||||||||
| 1069 | - | |||||||||||||
| 1070 | Use intersected(\a rectangle) instead. | - | ||||||||||||
| 1071 | */ | - | ||||||||||||
| 1072 | - | |||||||||||||
| 1073 | /*! | - | ||||||||||||
| 1074 | \fn QRect QRect::intersected(const QRect &rectangle) const | - | ||||||||||||
| 1075 | \since 4.2 | - | ||||||||||||
| 1076 | - | |||||||||||||
| 1077 | Returns the intersection of this rectangle and the given \a | - | ||||||||||||
| 1078 | rectangle. Note that \c{r.intersected(s)} is equivalent to \c{r & s}. | - | ||||||||||||
| 1079 | - | |||||||||||||
| 1080 | \image qrect-intersect.png | - | ||||||||||||
| 1081 | - | |||||||||||||
| 1082 | \sa intersects(), united(), operator&=() | - | ||||||||||||
| 1083 | */ | - | ||||||||||||
| 1084 | - | |||||||||||||
| 1085 | /*! | - | ||||||||||||
| 1086 | \fn bool QRect::intersects(const QRect &rectangle) const | - | ||||||||||||
| 1087 | - | |||||||||||||
| 1088 | Returns \c true if this rectangle intersects with the given \a | - | ||||||||||||
| 1089 | rectangle (i.e., there is at least one pixel that is within both | - | ||||||||||||
| 1090 | rectangles), otherwise returns \c false. | - | ||||||||||||
| 1091 | - | |||||||||||||
| 1092 | The intersection rectangle can be retrieved using the intersected() | - | ||||||||||||
| 1093 | function. | - | ||||||||||||
| 1094 | - | |||||||||||||
| 1095 | \sa contains() | - | ||||||||||||
| 1096 | */ | - | ||||||||||||
| 1097 | - | |||||||||||||
| 1098 | bool QRect::intersects(const QRect &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 1099 | { | - | ||||||||||||
| 1100 | if (isNull() || r.isNull())
| 108-44804 | ||||||||||||
| 1101 | return false; executed 808 times by 22 tests: return false;Executed by:
| 808 | ||||||||||||
| 1102 | - | |||||||||||||
| 1103 | int l1 = x1; | - | ||||||||||||
| 1104 | int r1 = x1; | - | ||||||||||||
| 1105 | if (x2 - x1 + 1 < 0)
| 4-44100 | ||||||||||||
| 1106 | l1 = x2; executed 4 times by 1 test: l1 = x2;Executed by:
| 4 | ||||||||||||
| 1107 | else | - | ||||||||||||
| 1108 | r1 = x2; executed 44100 times by 70 tests: r1 = x2;Executed by:
| 44100 | ||||||||||||
| 1109 | - | |||||||||||||
| 1110 | int l2 = r.x1; | - | ||||||||||||
| 1111 | int r2 = r.x1; | - | ||||||||||||
| 1112 | if (r.x2 - r.x1 + 1 < 0)
| 11-44093 | ||||||||||||
| 1113 | l2 = r.x2; executed 11 times by 4 tests: l2 = r.x2;Executed by:
| 11 | ||||||||||||
| 1114 | else | - | ||||||||||||
| 1115 | r2 = r.x2; executed 44093 times by 70 tests: r2 = r.x2;Executed by:
| 44093 | ||||||||||||
| 1116 | - | |||||||||||||
| 1117 | if (l1 > r2 || l2 > r1)
| 287-43817 | ||||||||||||
| 1118 | return false; executed 905 times by 16 tests: return false;Executed by:
| 905 | ||||||||||||
| 1119 | - | |||||||||||||
| 1120 | int t1 = y1; | - | ||||||||||||
| 1121 | int b1 = y1; | - | ||||||||||||
| 1122 | if (y2 - y1 + 1 < 0)
| 3-43196 | ||||||||||||
| 1123 | t1 = y2; executed 3 times by 1 test: t1 = y2;Executed by:
| 3 | ||||||||||||
| 1124 | else | - | ||||||||||||
| 1125 | b1 = y2; executed 43196 times by 69 tests: b1 = y2;Executed by:
| 43196 | ||||||||||||
| 1126 | - | |||||||||||||
| 1127 | int t2 = r.y1; | - | ||||||||||||
| 1128 | int b2 = r.y1; | - | ||||||||||||
| 1129 | if (r.y2 - r.y1 + 1 < 0)
| 8-43191 | ||||||||||||
| 1130 | t2 = r.y2; executed 8 times by 3 tests: t2 = r.y2;Executed by:
| 8 | ||||||||||||
| 1131 | else | - | ||||||||||||
| 1132 | b2 = r.y2; executed 43191 times by 69 tests: b2 = r.y2;Executed by:
| 43191 | ||||||||||||
| 1133 | - | |||||||||||||
| 1134 | if (t1 > b2 || t2 > b1)
| 247-42601 | ||||||||||||
| 1135 | return false; executed 845 times by 14 tests: return false;Executed by:
| 845 | ||||||||||||
| 1136 | - | |||||||||||||
| 1137 | return true; executed 42354 times by 66 tests: return true;Executed by:
| 42354 | ||||||||||||
| 1138 | } | - | ||||||||||||
| 1139 | - | |||||||||||||
| 1140 | /*! | - | ||||||||||||
| 1141 | \fn bool operator==(const QRect &r1, const QRect &r2) | - | ||||||||||||
| 1142 | \relates QRect | - | ||||||||||||
| 1143 | - | |||||||||||||
| 1144 | Returns \c true if the rectangles \a r1 and \a r2 are equal, | - | ||||||||||||
| 1145 | otherwise returns \c false. | - | ||||||||||||
| 1146 | */ | - | ||||||||||||
| 1147 | - | |||||||||||||
| 1148 | - | |||||||||||||
| 1149 | /*! | - | ||||||||||||
| 1150 | \fn bool operator!=(const QRect &r1, const QRect &r2) | - | ||||||||||||
| 1151 | \relates QRect | - | ||||||||||||
| 1152 | - | |||||||||||||
| 1153 | Returns \c true if the rectangles \a r1 and \a r2 are different, otherwise | - | ||||||||||||
| 1154 | returns \c false. | - | ||||||||||||
| 1155 | */ | - | ||||||||||||
| 1156 | - | |||||||||||||
| 1157 | /*! | - | ||||||||||||
| 1158 | \fn QRect operator+(const QRect &rectangle, const QMargins &margins) | - | ||||||||||||
| 1159 | \relates QRect | - | ||||||||||||
| 1160 | - | |||||||||||||
| 1161 | Returns the \a rectangle grown by the \a margins. | - | ||||||||||||
| 1162 | - | |||||||||||||
| 1163 | \since 5.1 | - | ||||||||||||
| 1164 | */ | - | ||||||||||||
| 1165 | - | |||||||||||||
| 1166 | /*! | - | ||||||||||||
| 1167 | \fn QRect operator+(const QMargins &margins, const QRect &rectangle) | - | ||||||||||||
| 1168 | \relates QRect | - | ||||||||||||
| 1169 | \overload | - | ||||||||||||
| 1170 | - | |||||||||||||
| 1171 | Returns the \a rectangle grown by the \a margins. | - | ||||||||||||
| 1172 | - | |||||||||||||
| 1173 | \since 5.1 | - | ||||||||||||
| 1174 | */ | - | ||||||||||||
| 1175 | - | |||||||||||||
| 1176 | /*! | - | ||||||||||||
| 1177 | \fn QRect operator-(const QRect &lhs, const QMargins &rhs) | - | ||||||||||||
| 1178 | \relates QRect | - | ||||||||||||
| 1179 | - | |||||||||||||
| 1180 | Returns the \a lhs rectangle shrunken by the \a rhs margins. | - | ||||||||||||
| 1181 | - | |||||||||||||
| 1182 | \since 5.3 | - | ||||||||||||
| 1183 | */ | - | ||||||||||||
| 1184 | - | |||||||||||||
| 1185 | /*! | - | ||||||||||||
| 1186 | \fn QRect QRect::marginsAdded(const QMargins &margins) const | - | ||||||||||||
| 1187 | - | |||||||||||||
| 1188 | Returns a rectangle grown by the \a margins. | - | ||||||||||||
| 1189 | - | |||||||||||||
| 1190 | \sa operator+=(), marginsRemoved(), operator-=() | - | ||||||||||||
| 1191 | - | |||||||||||||
| 1192 | \since 5.1 | - | ||||||||||||
| 1193 | */ | - | ||||||||||||
| 1194 | - | |||||||||||||
| 1195 | /*! | - | ||||||||||||
| 1196 | \fn QRect QRect::operator+=(const QMargins &margins) | - | ||||||||||||
| 1197 | - | |||||||||||||
| 1198 | Adds the \a margins to the rectangle, growing it. | - | ||||||||||||
| 1199 | - | |||||||||||||
| 1200 | \sa marginsAdded(), marginsRemoved(), operator-=() | - | ||||||||||||
| 1201 | - | |||||||||||||
| 1202 | \since 5.1 | - | ||||||||||||
| 1203 | */ | - | ||||||||||||
| 1204 | - | |||||||||||||
| 1205 | /*! | - | ||||||||||||
| 1206 | \fn QRect QRect::marginsRemoved(const QMargins &margins) const | - | ||||||||||||
| 1207 | - | |||||||||||||
| 1208 | Removes the \a margins from the rectangle, shrinking it. | - | ||||||||||||
| 1209 | - | |||||||||||||
| 1210 | \sa marginsAdded(), operator+=(), operator-=() | - | ||||||||||||
| 1211 | - | |||||||||||||
| 1212 | \since 5.1 | - | ||||||||||||
| 1213 | */ | - | ||||||||||||
| 1214 | - | |||||||||||||
| 1215 | /*! | - | ||||||||||||
| 1216 | \fn QRect QRect::operator -=(const QMargins &margins) | - | ||||||||||||
| 1217 | - | |||||||||||||
| 1218 | Returns a rectangle shrunk by the \a margins. | - | ||||||||||||
| 1219 | - | |||||||||||||
| 1220 | \sa marginsRemoved(), operator+=(), marginsAdded() | - | ||||||||||||
| 1221 | - | |||||||||||||
| 1222 | \since 5.1 | - | ||||||||||||
| 1223 | */ | - | ||||||||||||
| 1224 | - | |||||||||||||
| 1225 | - | |||||||||||||
| 1226 | /***************************************************************************** | - | ||||||||||||
| 1227 | QRect stream functions | - | ||||||||||||
| 1228 | *****************************************************************************/ | - | ||||||||||||
| 1229 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||
| 1230 | /*! | - | ||||||||||||
| 1231 | \fn QDataStream &operator<<(QDataStream &stream, const QRect &rectangle) | - | ||||||||||||
| 1232 | \relates QRect | - | ||||||||||||
| 1233 | - | |||||||||||||
| 1234 | Writes the given \a rectangle to the given \a stream, and returns | - | ||||||||||||
| 1235 | a reference to the stream. | - | ||||||||||||
| 1236 | - | |||||||||||||
| 1237 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 1238 | */ | - | ||||||||||||
| 1239 | - | |||||||||||||
| 1240 | QDataStream &operator<<(QDataStream &s, const QRect &r) | - | ||||||||||||
| 1241 | { | - | ||||||||||||
| 1242 | if (s.version() == 1)
| 0-2668 | ||||||||||||
| 1243 | s << (qint16)r.left() << (qint16)r.top() never executed: s << (qint16)r.left() << (qint16)r.top() << (qint16)r.right() << (qint16)r.bottom(); | 0 | ||||||||||||
| 1244 | << (qint16)r.right() << (qint16)r.bottom(); never executed: s << (qint16)r.left() << (qint16)r.top() << (qint16)r.right() << (qint16)r.bottom(); | 0 | ||||||||||||
| 1245 | else | - | ||||||||||||
| 1246 | s << (qint32)r.left() << (qint32)r.top() executed 2668 times by 8 tests: s << (qint32)r.left() << (qint32)r.top() << (qint32)r.right() << (qint32)r.bottom();Executed by:
| 2668 | ||||||||||||
| 1247 | << (qint32)r.right() << (qint32)r.bottom(); executed 2668 times by 8 tests: s << (qint32)r.left() << (qint32)r.top() << (qint32)r.right() << (qint32)r.bottom();Executed by:
| 2668 | ||||||||||||
| 1248 | return s; executed 2668 times by 8 tests: return s;Executed by:
| 2668 | ||||||||||||
| 1249 | } | - | ||||||||||||
| 1250 | - | |||||||||||||
| 1251 | /*! | - | ||||||||||||
| 1252 | \fn QDataStream &operator>>(QDataStream &stream, QRect &rectangle) | - | ||||||||||||
| 1253 | \relates QRect | - | ||||||||||||
| 1254 | - | |||||||||||||
| 1255 | Reads a rectangle from the given \a stream into the given \a | - | ||||||||||||
| 1256 | rectangle, and returns a reference to the stream. | - | ||||||||||||
| 1257 | - | |||||||||||||
| 1258 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 1259 | */ | - | ||||||||||||
| 1260 | - | |||||||||||||
| 1261 | QDataStream &operator>>(QDataStream &s, QRect &r) | - | ||||||||||||
| 1262 | { | - | ||||||||||||
| 1263 | if (s.version() == 1) {
| 0-2669 | ||||||||||||
| 1264 | qint16 x1, y1, x2, y2; | - | ||||||||||||
| 1265 | s >> x1; s >> y1; s >> x2; s >> y2; | - | ||||||||||||
| 1266 | r.setCoords(x1, y1, x2, y2); | - | ||||||||||||
| 1267 | } never executed: end of block | 0 | ||||||||||||
| 1268 | else { | - | ||||||||||||
| 1269 | qint32 x1, y1, x2, y2; | - | ||||||||||||
| 1270 | s >> x1; s >> y1; s >> x2; s >> y2; | - | ||||||||||||
| 1271 | r.setCoords(x1, y1, x2, y2); | - | ||||||||||||
| 1272 | } executed 2669 times by 8 tests: end of blockExecuted by:
| 2669 | ||||||||||||
| 1273 | return s; executed 2669 times by 8 tests: return s;Executed by:
| 2669 | ||||||||||||
| 1274 | } | - | ||||||||||||
| 1275 | - | |||||||||||||
| 1276 | #endif // QT_NO_DATASTREAM | - | ||||||||||||
| 1277 | - | |||||||||||||
| 1278 | - | |||||||||||||
| 1279 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 1280 | QDebug operator<<(QDebug dbg, const QRect &r) | - | ||||||||||||
| 1281 | { | - | ||||||||||||
| 1282 | QDebugStateSaver saver(dbg); | - | ||||||||||||
| 1283 | dbg.nospace(); | - | ||||||||||||
| 1284 | dbg << "QRect" << '('; | - | ||||||||||||
| 1285 | QtDebugUtils::formatQRect(dbg, r); | - | ||||||||||||
| 1286 | dbg << ')'; | - | ||||||||||||
| 1287 | return dbg; executed 24 times by 5 tests: return dbg;Executed by:
| 24 | ||||||||||||
| 1288 | } | - | ||||||||||||
| 1289 | #endif | - | ||||||||||||
| 1290 | - | |||||||||||||
| 1291 | /*! | - | ||||||||||||
| 1292 | \class QRectF | - | ||||||||||||
| 1293 | \inmodule QtCore | - | ||||||||||||
| 1294 | \ingroup painting | - | ||||||||||||
| 1295 | \reentrant | - | ||||||||||||
| 1296 | - | |||||||||||||
| 1297 | \brief The QRectF class defines a rectangle in the plane using floating | - | ||||||||||||
| 1298 | point precision. | - | ||||||||||||
| 1299 | - | |||||||||||||
| 1300 | A rectangle is normally expressed as an upper-left corner and a | - | ||||||||||||
| 1301 | size. The size (width and height) of a QRectF is always equivalent | - | ||||||||||||
| 1302 | to the mathematical rectangle that forms the basis for its | - | ||||||||||||
| 1303 | rendering. | - | ||||||||||||
| 1304 | - | |||||||||||||
| 1305 | A QRectF can be constructed with a set of left, top, width and | - | ||||||||||||
| 1306 | height integers, or from a QPoint and a QSize. The following code | - | ||||||||||||
| 1307 | creates two identical rectangles. | - | ||||||||||||
| 1308 | - | |||||||||||||
| 1309 | \snippet code/src_corelib_tools_qrect.cpp 1 | - | ||||||||||||
| 1310 | - | |||||||||||||
| 1311 | There is also a third constructor creating a QRectF from a QRect, | - | ||||||||||||
| 1312 | and a corresponding toRect() function that returns a QRect object | - | ||||||||||||
| 1313 | based on the values of this rectangle (note that the coordinates | - | ||||||||||||
| 1314 | in the returned rectangle are rounded to the nearest integer). | - | ||||||||||||
| 1315 | - | |||||||||||||
| 1316 | The QRectF class provides a collection of functions that return | - | ||||||||||||
| 1317 | the various rectangle coordinates, and enable manipulation of | - | ||||||||||||
| 1318 | these. QRectF also provide functions to move the rectangle | - | ||||||||||||
| 1319 | relative to the various coordinates. In addition there is a | - | ||||||||||||
| 1320 | moveTo() function that moves the rectangle, leaving its top left | - | ||||||||||||
| 1321 | corner at the given coordinates. Alternatively, the translate() | - | ||||||||||||
| 1322 | function moves the rectangle the given offset relative to the | - | ||||||||||||
| 1323 | current position, and the translated() function returns a | - | ||||||||||||
| 1324 | translated copy of this rectangle. | - | ||||||||||||
| 1325 | - | |||||||||||||
| 1326 | The size() function returns the rectange's dimensions as a | - | ||||||||||||
| 1327 | QSize. The dimensions can also be retrieved separately using the | - | ||||||||||||
| 1328 | width() and height() functions. To manipulate the dimensions use | - | ||||||||||||
| 1329 | the setSize(), setWidth() or setHeight() functions. Alternatively, | - | ||||||||||||
| 1330 | the size can be changed by applying either of the functions | - | ||||||||||||
| 1331 | setting the rectangle coordinates, for example, setBottom() or | - | ||||||||||||
| 1332 | setRight(). | - | ||||||||||||
| 1333 | - | |||||||||||||
| 1334 | The contains() function tells whether a given point is inside the | - | ||||||||||||
| 1335 | rectangle or not, and the intersects() function returns \c true if | - | ||||||||||||
| 1336 | this rectangle intersects with a given rectangle (otherwise | - | ||||||||||||
| 1337 | false). The QRectF class also provides the intersected() function | - | ||||||||||||
| 1338 | which returns the intersection rectangle, and the united() function | - | ||||||||||||
| 1339 | which returns the rectangle that encloses the given rectangle and | - | ||||||||||||
| 1340 | this: | - | ||||||||||||
| 1341 | - | |||||||||||||
| 1342 | \table | - | ||||||||||||
| 1343 | \row | - | ||||||||||||
| 1344 | \li \inlineimage qrect-intersect.png | - | ||||||||||||
| 1345 | \li \inlineimage qrect-unite.png | - | ||||||||||||
| 1346 | \row | - | ||||||||||||
| 1347 | \li intersected() | - | ||||||||||||
| 1348 | \li united() | - | ||||||||||||
| 1349 | \endtable | - | ||||||||||||
| 1350 | - | |||||||||||||
| 1351 | The isEmpty() function returns \c true if the rectangle's width or | - | ||||||||||||
| 1352 | height is less than, or equal to, 0. Note that an empty rectangle | - | ||||||||||||
| 1353 | is not valid: The isValid() function returns \c true if both width | - | ||||||||||||
| 1354 | and height is larger than 0. A null rectangle (isNull() == true) | - | ||||||||||||
| 1355 | on the other hand, has both width and height set to 0. | - | ||||||||||||
| 1356 | - | |||||||||||||
| 1357 | Note that due to the way QRect and QRectF are defined, an | - | ||||||||||||
| 1358 | empty QRectF is defined in essentially the same way as QRect. | - | ||||||||||||
| 1359 | - | |||||||||||||
| 1360 | Finally, QRectF objects can be streamed as well as compared. | - | ||||||||||||
| 1361 | - | |||||||||||||
| 1362 | \tableofcontents | - | ||||||||||||
| 1363 | - | |||||||||||||
| 1364 | \section1 Rendering | - | ||||||||||||
| 1365 | - | |||||||||||||
| 1366 | When using an \l {QPainter::Antialiasing}{anti-aliased} painter, | - | ||||||||||||
| 1367 | the boundary line of a QRectF will be rendered symmetrically on both | - | ||||||||||||
| 1368 | sides of the mathematical rectangle's boundary line. But when | - | ||||||||||||
| 1369 | using an aliased painter (the default) other rules apply. | - | ||||||||||||
| 1370 | - | |||||||||||||
| 1371 | Then, when rendering with a one pixel wide pen the QRectF's boundary | - | ||||||||||||
| 1372 | line will be rendered to the right and below the mathematical | - | ||||||||||||
| 1373 | rectangle's boundary line. | - | ||||||||||||
| 1374 | - | |||||||||||||
| 1375 | When rendering with a two pixels wide pen the boundary line will | - | ||||||||||||
| 1376 | be split in the middle by the mathematical rectangle. This will be | - | ||||||||||||
| 1377 | the case whenever the pen is set to an even number of pixels, | - | ||||||||||||
| 1378 | while rendering with a pen with an odd number of pixels, the spare | - | ||||||||||||
| 1379 | pixel will be rendered to the right and below the mathematical | - | ||||||||||||
| 1380 | rectangle as in the one pixel case. | - | ||||||||||||
| 1381 | - | |||||||||||||
| 1382 | \table | - | ||||||||||||
| 1383 | \row | - | ||||||||||||
| 1384 | \li \inlineimage qrect-diagram-zero.png | - | ||||||||||||
| 1385 | \li \inlineimage qrectf-diagram-one.png | - | ||||||||||||
| 1386 | \row | - | ||||||||||||
| 1387 | \li Logical representation | - | ||||||||||||
| 1388 | \li One pixel wide pen | - | ||||||||||||
| 1389 | \row | - | ||||||||||||
| 1390 | \li \inlineimage qrectf-diagram-two.png | - | ||||||||||||
| 1391 | \li \inlineimage qrectf-diagram-three.png | - | ||||||||||||
| 1392 | \row | - | ||||||||||||
| 1393 | \li Two pixel wide pen | - | ||||||||||||
| 1394 | \li Three pixel wide pen | - | ||||||||||||
| 1395 | \endtable | - | ||||||||||||
| 1396 | - | |||||||||||||
| 1397 | \section1 Coordinates | - | ||||||||||||
| 1398 | - | |||||||||||||
| 1399 | The QRectF class provides a collection of functions that return | - | ||||||||||||
| 1400 | the various rectangle coordinates, and enable manipulation of | - | ||||||||||||
| 1401 | these. QRectF also provide functions to move the rectangle | - | ||||||||||||
| 1402 | relative to the various coordinates. | - | ||||||||||||
| 1403 | - | |||||||||||||
| 1404 | For example: the bottom(), setBottom() and moveBottom() functions: | - | ||||||||||||
| 1405 | bottom() returns the y-coordinate of the rectangle's bottom edge, | - | ||||||||||||
| 1406 | setBottom() sets the bottom edge of the rectangle to the given y | - | ||||||||||||
| 1407 | coordinate (it may change the height, but will never change the | - | ||||||||||||
| 1408 | rectangle's top edge) and moveBottom() moves the entire rectangle | - | ||||||||||||
| 1409 | vertically, leaving the rectangle's bottom edge at the given y | - | ||||||||||||
| 1410 | coordinate and its size unchanged. | - | ||||||||||||
| 1411 | - | |||||||||||||
| 1412 | \image qrectf-coordinates.png | - | ||||||||||||
| 1413 | - | |||||||||||||
| 1414 | It is also possible to add offsets to this rectangle's coordinates | - | ||||||||||||
| 1415 | using the adjust() function, as well as retrieve a new rectangle | - | ||||||||||||
| 1416 | based on adjustments of the original one using the adjusted() | - | ||||||||||||
| 1417 | function. If either of the width and height is negative, use the | - | ||||||||||||
| 1418 | normalized() function to retrieve a rectangle where the corners | - | ||||||||||||
| 1419 | are swapped. | - | ||||||||||||
| 1420 | - | |||||||||||||
| 1421 | In addition, QRectF provides the getCoords() function which extracts | - | ||||||||||||
| 1422 | the position of the rectangle's top-left and bottom-right corner, | - | ||||||||||||
| 1423 | and the getRect() function which extracts the rectangle's top-left | - | ||||||||||||
| 1424 | corner, width and height. Use the setCoords() and setRect() | - | ||||||||||||
| 1425 | function to manipulate the rectangle's coordinates and dimensions | - | ||||||||||||
| 1426 | in one go. | - | ||||||||||||
| 1427 | - | |||||||||||||
| 1428 | \sa QRect, QRegion | - | ||||||||||||
| 1429 | */ | - | ||||||||||||
| 1430 | - | |||||||||||||
| 1431 | /***************************************************************************** | - | ||||||||||||
| 1432 | QRectF member functions | - | ||||||||||||
| 1433 | *****************************************************************************/ | - | ||||||||||||
| 1434 | - | |||||||||||||
| 1435 | /*! | - | ||||||||||||
| 1436 | \fn QRectF::QRectF() | - | ||||||||||||
| 1437 | - | |||||||||||||
| 1438 | Constructs a null rectangle. | - | ||||||||||||
| 1439 | - | |||||||||||||
| 1440 | \sa isNull() | - | ||||||||||||
| 1441 | */ | - | ||||||||||||
| 1442 | - | |||||||||||||
| 1443 | /*! | - | ||||||||||||
| 1444 | \fn QRectF::QRectF(const QPointF &topLeft, const QSizeF &size) | - | ||||||||||||
| 1445 | - | |||||||||||||
| 1446 | Constructs a rectangle with the given \a topLeft corner and the given \a size. | - | ||||||||||||
| 1447 | - | |||||||||||||
| 1448 | \sa setTopLeft(), setSize() | - | ||||||||||||
| 1449 | */ | - | ||||||||||||
| 1450 | - | |||||||||||||
| 1451 | /*! | - | ||||||||||||
| 1452 | \fn QRectF::QRectF(const QPointF &topLeft, const QPointF &bottomRight) | - | ||||||||||||
| 1453 | \since 4.3 | - | ||||||||||||
| 1454 | - | |||||||||||||
| 1455 | Constructs a rectangle with the given \a topLeft and \a bottomRight corners. | - | ||||||||||||
| 1456 | - | |||||||||||||
| 1457 | \sa setTopLeft(), setBottomRight() | - | ||||||||||||
| 1458 | */ | - | ||||||||||||
| 1459 | - | |||||||||||||
| 1460 | /*! | - | ||||||||||||
| 1461 | \fn QRectF::QRectF(qreal x, qreal y, qreal width, qreal height) | - | ||||||||||||
| 1462 | - | |||||||||||||
| 1463 | Constructs a rectangle with (\a x, \a y) as its top-left corner | - | ||||||||||||
| 1464 | and the given \a width and \a height. | - | ||||||||||||
| 1465 | - | |||||||||||||
| 1466 | \sa setRect() | - | ||||||||||||
| 1467 | */ | - | ||||||||||||
| 1468 | - | |||||||||||||
| 1469 | /*! | - | ||||||||||||
| 1470 | \fn QRectF::QRectF(const QRect &rectangle) | - | ||||||||||||
| 1471 | - | |||||||||||||
| 1472 | Constructs a QRectF rectangle from the given QRect \a rectangle. | - | ||||||||||||
| 1473 | - | |||||||||||||
| 1474 | \sa toRect() | - | ||||||||||||
| 1475 | */ | - | ||||||||||||
| 1476 | - | |||||||||||||
| 1477 | /*! | - | ||||||||||||
| 1478 | \fn bool QRectF::isNull() const | - | ||||||||||||
| 1479 | - | |||||||||||||
| 1480 | Returns \c true if the rectangle is a null rectangle, otherwise returns \c false. | - | ||||||||||||
| 1481 | - | |||||||||||||
| 1482 | A null rectangle has both the width and the height set to 0. A | - | ||||||||||||
| 1483 | null rectangle is also empty, and hence not valid. | - | ||||||||||||
| 1484 | - | |||||||||||||
| 1485 | \sa isEmpty(), isValid() | - | ||||||||||||
| 1486 | */ | - | ||||||||||||
| 1487 | - | |||||||||||||
| 1488 | /*! | - | ||||||||||||
| 1489 | \fn bool QRectF::isEmpty() const | - | ||||||||||||
| 1490 | - | |||||||||||||
| 1491 | Returns \c true if the rectangle is empty, otherwise returns \c false. | - | ||||||||||||
| 1492 | - | |||||||||||||
| 1493 | An empty rectangle has width() <= 0 or height() <= 0. An empty | - | ||||||||||||
| 1494 | rectangle is not valid (i.e., isEmpty() == !isValid()). | - | ||||||||||||
| 1495 | - | |||||||||||||
| 1496 | Use the normalized() function to retrieve a rectangle where the | - | ||||||||||||
| 1497 | corners are swapped. | - | ||||||||||||
| 1498 | - | |||||||||||||
| 1499 | \sa isNull(), isValid(), normalized() | - | ||||||||||||
| 1500 | */ | - | ||||||||||||
| 1501 | - | |||||||||||||
| 1502 | /*! | - | ||||||||||||
| 1503 | \fn bool QRectF::isValid() const | - | ||||||||||||
| 1504 | - | |||||||||||||
| 1505 | Returns \c true if the rectangle is valid, otherwise returns \c false. | - | ||||||||||||
| 1506 | - | |||||||||||||
| 1507 | A valid rectangle has a width() > 0 and height() > 0. Note that | - | ||||||||||||
| 1508 | non-trivial operations like intersections are not defined for | - | ||||||||||||
| 1509 | invalid rectangles. A valid rectangle is not empty (i.e., isValid() | - | ||||||||||||
| 1510 | == !isEmpty()). | - | ||||||||||||
| 1511 | - | |||||||||||||
| 1512 | \sa isNull(), isEmpty(), normalized() | - | ||||||||||||
| 1513 | */ | - | ||||||||||||
| 1514 | - | |||||||||||||
| 1515 | - | |||||||||||||
| 1516 | /*! | - | ||||||||||||
| 1517 | Returns a normalized rectangle; i.e., a rectangle that has a | - | ||||||||||||
| 1518 | non-negative width and height. | - | ||||||||||||
| 1519 | - | |||||||||||||
| 1520 | If width() < 0 the function swaps the left and right corners, and | - | ||||||||||||
| 1521 | it swaps the top and bottom corners if height() < 0. | - | ||||||||||||
| 1522 | - | |||||||||||||
| 1523 | \sa isValid(), isEmpty() | - | ||||||||||||
| 1524 | */ | - | ||||||||||||
| 1525 | - | |||||||||||||
| 1526 | QRectF QRectF::normalized() const Q_DECL_NOTHROW | - | ||||||||||||
| 1527 | { | - | ||||||||||||
| 1528 | QRectF r = *this; | - | ||||||||||||
| 1529 | if (r.w < 0) {
| 3-8411 | ||||||||||||
| 1530 | r.xp += r.w; | - | ||||||||||||
| 1531 | r.w = -r.w; | - | ||||||||||||
| 1532 | } executed 3 times by 2 tests: end of blockExecuted by:
| 3 | ||||||||||||
| 1533 | if (r.h < 0) {
| 2-8412 | ||||||||||||
| 1534 | r.yp += r.h; | - | ||||||||||||
| 1535 | r.h = -r.h; | - | ||||||||||||
| 1536 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 1537 | return r; executed 8414 times by 48 tests: return r;Executed by:
| 8414 | ||||||||||||
| 1538 | } | - | ||||||||||||
| 1539 | - | |||||||||||||
| 1540 | /*! | - | ||||||||||||
| 1541 | \fn qreal QRectF::x() const | - | ||||||||||||
| 1542 | - | |||||||||||||
| 1543 | Returns the x-coordinate of the rectangle's left edge. Equivalent | - | ||||||||||||
| 1544 | to left(). | - | ||||||||||||
| 1545 | - | |||||||||||||
| 1546 | - | |||||||||||||
| 1547 | \sa setX(), y(), topLeft() | - | ||||||||||||
| 1548 | */ | - | ||||||||||||
| 1549 | - | |||||||||||||
| 1550 | /*! | - | ||||||||||||
| 1551 | \fn qreal QRectF::y() const | - | ||||||||||||
| 1552 | - | |||||||||||||
| 1553 | Returns the y-coordinate of the rectangle's top edge. Equivalent | - | ||||||||||||
| 1554 | to top(). | - | ||||||||||||
| 1555 | - | |||||||||||||
| 1556 | \sa setY(), x(), topLeft() | - | ||||||||||||
| 1557 | */ | - | ||||||||||||
| 1558 | - | |||||||||||||
| 1559 | - | |||||||||||||
| 1560 | /*! | - | ||||||||||||
| 1561 | \fn void QRectF::setLeft(qreal x) | - | ||||||||||||
| 1562 | - | |||||||||||||
| 1563 | Sets the left edge of the rectangle to the given \a x | - | ||||||||||||
| 1564 | coordinate. May change the width, but will never change the right | - | ||||||||||||
| 1565 | edge of the rectangle. | - | ||||||||||||
| 1566 | - | |||||||||||||
| 1567 | Equivalent to setX(). | - | ||||||||||||
| 1568 | - | |||||||||||||
| 1569 | \sa left(), moveLeft() | - | ||||||||||||
| 1570 | */ | - | ||||||||||||
| 1571 | - | |||||||||||||
| 1572 | /*! | - | ||||||||||||
| 1573 | \fn void QRectF::setTop(qreal y) | - | ||||||||||||
| 1574 | - | |||||||||||||
| 1575 | Sets the top edge of the rectangle to the given \a y coordinate. May | - | ||||||||||||
| 1576 | change the height, but will never change the bottom edge of the | - | ||||||||||||
| 1577 | rectangle. | - | ||||||||||||
| 1578 | - | |||||||||||||
| 1579 | Equivalent to setY(). | - | ||||||||||||
| 1580 | - | |||||||||||||
| 1581 | \sa top(), moveTop() | - | ||||||||||||
| 1582 | */ | - | ||||||||||||
| 1583 | - | |||||||||||||
| 1584 | /*! | - | ||||||||||||
| 1585 | \fn void QRectF::setRight(qreal x) | - | ||||||||||||
| 1586 | - | |||||||||||||
| 1587 | Sets the right edge of the rectangle to the given \a x | - | ||||||||||||
| 1588 | coordinate. May change the width, but will never change the left | - | ||||||||||||
| 1589 | edge of the rectangle. | - | ||||||||||||
| 1590 | - | |||||||||||||
| 1591 | \sa right(), moveRight() | - | ||||||||||||
| 1592 | */ | - | ||||||||||||
| 1593 | - | |||||||||||||
| 1594 | /*! | - | ||||||||||||
| 1595 | \fn void QRectF::setBottom(qreal y) | - | ||||||||||||
| 1596 | - | |||||||||||||
| 1597 | Sets the bottom edge of the rectangle to the given \a y | - | ||||||||||||
| 1598 | coordinate. May change the height, but will never change the top | - | ||||||||||||
| 1599 | edge of the rectangle. | - | ||||||||||||
| 1600 | - | |||||||||||||
| 1601 | \sa bottom(), moveBottom() | - | ||||||||||||
| 1602 | */ | - | ||||||||||||
| 1603 | - | |||||||||||||
| 1604 | /*! | - | ||||||||||||
| 1605 | \fn void QRectF::setX(qreal x) | - | ||||||||||||
| 1606 | - | |||||||||||||
| 1607 | Sets the left edge of the rectangle to the given \a x | - | ||||||||||||
| 1608 | coordinate. May change the width, but will never change the right | - | ||||||||||||
| 1609 | edge of the rectangle. | - | ||||||||||||
| 1610 | - | |||||||||||||
| 1611 | Equivalent to setLeft(). | - | ||||||||||||
| 1612 | - | |||||||||||||
| 1613 | \sa x(), setY(), setTopLeft() | - | ||||||||||||
| 1614 | */ | - | ||||||||||||
| 1615 | - | |||||||||||||
| 1616 | /*! | - | ||||||||||||
| 1617 | \fn void QRectF::setY(qreal y) | - | ||||||||||||
| 1618 | - | |||||||||||||
| 1619 | Sets the top edge of the rectangle to the given \a y | - | ||||||||||||
| 1620 | coordinate. May change the height, but will never change the | - | ||||||||||||
| 1621 | bottom edge of the rectangle. | - | ||||||||||||
| 1622 | - | |||||||||||||
| 1623 | Equivalent to setTop(). | - | ||||||||||||
| 1624 | - | |||||||||||||
| 1625 | \sa y(), setX(), setTopLeft() | - | ||||||||||||
| 1626 | */ | - | ||||||||||||
| 1627 | - | |||||||||||||
| 1628 | /*! | - | ||||||||||||
| 1629 | \fn void QRectF::setTopLeft(const QPointF &position) | - | ||||||||||||
| 1630 | - | |||||||||||||
| 1631 | Set the top-left corner of the rectangle to the given \a | - | ||||||||||||
| 1632 | position. May change the size, but will never change the | - | ||||||||||||
| 1633 | bottom-right corner of the rectangle. | - | ||||||||||||
| 1634 | - | |||||||||||||
| 1635 | \sa topLeft(), moveTopLeft() | - | ||||||||||||
| 1636 | */ | - | ||||||||||||
| 1637 | - | |||||||||||||
| 1638 | /*! | - | ||||||||||||
| 1639 | \fn void QRectF::setBottomRight(const QPointF &position) | - | ||||||||||||
| 1640 | - | |||||||||||||
| 1641 | Set the bottom-right corner of the rectangle to the given \a | - | ||||||||||||
| 1642 | position. May change the size, but will never change the | - | ||||||||||||
| 1643 | top-left corner of the rectangle. | - | ||||||||||||
| 1644 | - | |||||||||||||
| 1645 | \sa bottomRight(), moveBottomRight() | - | ||||||||||||
| 1646 | */ | - | ||||||||||||
| 1647 | - | |||||||||||||
| 1648 | /*! | - | ||||||||||||
| 1649 | \fn void QRectF::setTopRight(const QPointF &position) | - | ||||||||||||
| 1650 | - | |||||||||||||
| 1651 | Set the top-right corner of the rectangle to the given \a | - | ||||||||||||
| 1652 | position. May change the size, but will never change the | - | ||||||||||||
| 1653 | bottom-left corner of the rectangle. | - | ||||||||||||
| 1654 | - | |||||||||||||
| 1655 | \sa topRight(), moveTopRight() | - | ||||||||||||
| 1656 | */ | - | ||||||||||||
| 1657 | - | |||||||||||||
| 1658 | /*! | - | ||||||||||||
| 1659 | \fn void QRectF::setBottomLeft(const QPointF &position) | - | ||||||||||||
| 1660 | - | |||||||||||||
| 1661 | Set the bottom-left corner of the rectangle to the given \a | - | ||||||||||||
| 1662 | position. May change the size, but will never change the | - | ||||||||||||
| 1663 | top-right corner of the rectangle. | - | ||||||||||||
| 1664 | - | |||||||||||||
| 1665 | \sa bottomLeft(), moveBottomLeft() | - | ||||||||||||
| 1666 | */ | - | ||||||||||||
| 1667 | - | |||||||||||||
| 1668 | /*! | - | ||||||||||||
| 1669 | \fn QPointF QRectF::center() const | - | ||||||||||||
| 1670 | - | |||||||||||||
| 1671 | Returns the center point of the rectangle. | - | ||||||||||||
| 1672 | - | |||||||||||||
| 1673 | \sa moveCenter() | - | ||||||||||||
| 1674 | */ | - | ||||||||||||
| 1675 | - | |||||||||||||
| 1676 | - | |||||||||||||
| 1677 | /*! | - | ||||||||||||
| 1678 | \fn void QRectF::getRect(qreal *x, qreal *y, qreal *width, qreal *height) const | - | ||||||||||||
| 1679 | - | |||||||||||||
| 1680 | Extracts the position of the rectangle's top-left corner to *\a x and | - | ||||||||||||
| 1681 | *\a y, and its dimensions to *\a width and *\a height. | - | ||||||||||||
| 1682 | - | |||||||||||||
| 1683 | \sa setRect(), getCoords() | - | ||||||||||||
| 1684 | */ | - | ||||||||||||
| 1685 | - | |||||||||||||
| 1686 | - | |||||||||||||
| 1687 | /*! | - | ||||||||||||
| 1688 | \fn void QRectF::getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const | - | ||||||||||||
| 1689 | - | |||||||||||||
| 1690 | Extracts the position of the rectangle's top-left corner to *\a x1 | - | ||||||||||||
| 1691 | and *\a y1, and the position of the bottom-right corner to *\a x2 and | - | ||||||||||||
| 1692 | *\a y2. | - | ||||||||||||
| 1693 | - | |||||||||||||
| 1694 | \sa setCoords(), getRect() | - | ||||||||||||
| 1695 | */ | - | ||||||||||||
| 1696 | - | |||||||||||||
| 1697 | /*! | - | ||||||||||||
| 1698 | \fn void QRectF::moveLeft(qreal x) | - | ||||||||||||
| 1699 | - | |||||||||||||
| 1700 | Moves the rectangle horizontally, leaving the rectangle's left | - | ||||||||||||
| 1701 | edge at the given \a x coordinate. The rectangle's size is | - | ||||||||||||
| 1702 | unchanged. | - | ||||||||||||
| 1703 | - | |||||||||||||
| 1704 | \sa left(), setLeft(), moveRight() | - | ||||||||||||
| 1705 | */ | - | ||||||||||||
| 1706 | - | |||||||||||||
| 1707 | /*! | - | ||||||||||||
| 1708 | \fn void QRectF::moveTop(qreal y) | - | ||||||||||||
| 1709 | - | |||||||||||||
| 1710 | Moves the rectangle vertically, leaving the rectangle's top line | - | ||||||||||||
| 1711 | at the given \a y coordinate. The rectangle's size is unchanged. | - | ||||||||||||
| 1712 | - | |||||||||||||
| 1713 | \sa top(), setTop(), moveBottom() | - | ||||||||||||
| 1714 | */ | - | ||||||||||||
| 1715 | - | |||||||||||||
| 1716 | - | |||||||||||||
| 1717 | /*! | - | ||||||||||||
| 1718 | \fn void QRectF::moveRight(qreal x) | - | ||||||||||||
| 1719 | - | |||||||||||||
| 1720 | Moves the rectangle horizontally, leaving the rectangle's right | - | ||||||||||||
| 1721 | edge at the given \a x coordinate. The rectangle's size is | - | ||||||||||||
| 1722 | unchanged. | - | ||||||||||||
| 1723 | - | |||||||||||||
| 1724 | \sa right(), setRight(), moveLeft() | - | ||||||||||||
| 1725 | */ | - | ||||||||||||
| 1726 | - | |||||||||||||
| 1727 | - | |||||||||||||
| 1728 | /*! | - | ||||||||||||
| 1729 | \fn void QRectF::moveBottom(qreal y) | - | ||||||||||||
| 1730 | - | |||||||||||||
| 1731 | Moves the rectangle vertically, leaving the rectangle's bottom | - | ||||||||||||
| 1732 | edge at the given \a y coordinate. The rectangle's size is | - | ||||||||||||
| 1733 | unchanged. | - | ||||||||||||
| 1734 | - | |||||||||||||
| 1735 | \sa bottom(), setBottom(), moveTop() | - | ||||||||||||
| 1736 | */ | - | ||||||||||||
| 1737 | - | |||||||||||||
| 1738 | - | |||||||||||||
| 1739 | /*! | - | ||||||||||||
| 1740 | \fn void QRectF::moveTopLeft(const QPointF &position) | - | ||||||||||||
| 1741 | - | |||||||||||||
| 1742 | Moves the rectangle, leaving the top-left corner at the given \a | - | ||||||||||||
| 1743 | position. The rectangle's size is unchanged. | - | ||||||||||||
| 1744 | - | |||||||||||||
| 1745 | \sa setTopLeft(), moveTop(), moveLeft() | - | ||||||||||||
| 1746 | */ | - | ||||||||||||
| 1747 | - | |||||||||||||
| 1748 | - | |||||||||||||
| 1749 | /*! | - | ||||||||||||
| 1750 | \fn void QRectF::moveBottomRight(const QPointF &position) | - | ||||||||||||
| 1751 | - | |||||||||||||
| 1752 | Moves the rectangle, leaving the bottom-right corner at the given | - | ||||||||||||
| 1753 | \a position. The rectangle's size is unchanged. | - | ||||||||||||
| 1754 | - | |||||||||||||
| 1755 | \sa setBottomRight(), moveBottom(), moveRight() | - | ||||||||||||
| 1756 | */ | - | ||||||||||||
| 1757 | - | |||||||||||||
| 1758 | - | |||||||||||||
| 1759 | /*! | - | ||||||||||||
| 1760 | \fn void QRectF::moveTopRight(const QPointF &position) | - | ||||||||||||
| 1761 | - | |||||||||||||
| 1762 | Moves the rectangle, leaving the top-right corner at the given | - | ||||||||||||
| 1763 | \a position. The rectangle's size is unchanged. | - | ||||||||||||
| 1764 | - | |||||||||||||
| 1765 | \sa setTopRight(), moveTop(), moveRight() | - | ||||||||||||
| 1766 | */ | - | ||||||||||||
| 1767 | - | |||||||||||||
| 1768 | - | |||||||||||||
| 1769 | /*! | - | ||||||||||||
| 1770 | \fn void QRectF::moveBottomLeft(const QPointF &position) | - | ||||||||||||
| 1771 | - | |||||||||||||
| 1772 | Moves the rectangle, leaving the bottom-left corner at the given | - | ||||||||||||
| 1773 | \a position. The rectangle's size is unchanged. | - | ||||||||||||
| 1774 | - | |||||||||||||
| 1775 | \sa setBottomLeft(), moveBottom(), moveLeft() | - | ||||||||||||
| 1776 | */ | - | ||||||||||||
| 1777 | - | |||||||||||||
| 1778 | - | |||||||||||||
| 1779 | /*! | - | ||||||||||||
| 1780 | \fn void QRectF::moveTo(qreal x, qreal y) | - | ||||||||||||
| 1781 | - | |||||||||||||
| 1782 | Moves the rectangle, leaving the top-left corner at the given | - | ||||||||||||
| 1783 | position (\a x, \a y). The rectangle's size is unchanged. | - | ||||||||||||
| 1784 | - | |||||||||||||
| 1785 | \sa translate(), moveTopLeft() | - | ||||||||||||
| 1786 | */ | - | ||||||||||||
| 1787 | - | |||||||||||||
| 1788 | /*! | - | ||||||||||||
| 1789 | \fn void QRectF::moveTo(const QPointF &position) | - | ||||||||||||
| 1790 | \overload | - | ||||||||||||
| 1791 | - | |||||||||||||
| 1792 | Moves the rectangle, leaving the top-left corner at the given \a | - | ||||||||||||
| 1793 | position. | - | ||||||||||||
| 1794 | */ | - | ||||||||||||
| 1795 | - | |||||||||||||
| 1796 | /*! | - | ||||||||||||
| 1797 | \fn void QRectF::translate(qreal dx, qreal dy) | - | ||||||||||||
| 1798 | - | |||||||||||||
| 1799 | Moves the rectangle \a dx along the x-axis and \a dy along the y-axis, | - | ||||||||||||
| 1800 | relative to the current position. Positive values move the rectangle to the | - | ||||||||||||
| 1801 | right and downwards. | - | ||||||||||||
| 1802 | - | |||||||||||||
| 1803 | \sa moveTopLeft(), moveTo(), translated() | - | ||||||||||||
| 1804 | */ | - | ||||||||||||
| 1805 | - | |||||||||||||
| 1806 | - | |||||||||||||
| 1807 | /*! | - | ||||||||||||
| 1808 | \fn void QRectF::translate(const QPointF &offset) | - | ||||||||||||
| 1809 | \overload | - | ||||||||||||
| 1810 | - | |||||||||||||
| 1811 | Moves the rectangle \a{offset}.\l{QPointF::x()}{x()} along the x | - | ||||||||||||
| 1812 | axis and \a{offset}.\l{QPointF::y()}{y()} along the y axis, | - | ||||||||||||
| 1813 | relative to the current position. | - | ||||||||||||
| 1814 | */ | - | ||||||||||||
| 1815 | - | |||||||||||||
| 1816 | - | |||||||||||||
| 1817 | /*! | - | ||||||||||||
| 1818 | \fn QRectF QRectF::translated(qreal dx, qreal dy) const | - | ||||||||||||
| 1819 | - | |||||||||||||
| 1820 | Returns a copy of the rectangle that is translated \a dx along the | - | ||||||||||||
| 1821 | x axis and \a dy along the y axis, relative to the current | - | ||||||||||||
| 1822 | position. Positive values move the rectangle to the right and | - | ||||||||||||
| 1823 | down. | - | ||||||||||||
| 1824 | - | |||||||||||||
| 1825 | \sa translate() | - | ||||||||||||
| 1826 | */ | - | ||||||||||||
| 1827 | - | |||||||||||||
| 1828 | - | |||||||||||||
| 1829 | /*! | - | ||||||||||||
| 1830 | \fn QRectF QRectF::translated(const QPointF &offset) const | - | ||||||||||||
| 1831 | \overload | - | ||||||||||||
| 1832 | - | |||||||||||||
| 1833 | Returns a copy of the rectangle that is translated | - | ||||||||||||
| 1834 | \a{offset}.\l{QPointF::x()}{x()} along the x axis and | - | ||||||||||||
| 1835 | \a{offset}.\l{QPointF::y()}{y()} along the y axis, relative to the | - | ||||||||||||
| 1836 | current position. | - | ||||||||||||
| 1837 | */ | - | ||||||||||||
| 1838 | - | |||||||||||||
| 1839 | - | |||||||||||||
| 1840 | /*! | - | ||||||||||||
| 1841 | \fn void QRectF::setRect(qreal x, qreal y, qreal width, qreal height) | - | ||||||||||||
| 1842 | - | |||||||||||||
| 1843 | Sets the coordinates of the rectangle's top-left corner to (\a x, | - | ||||||||||||
| 1844 | \a y), and its size to the given \a width and \a height. | - | ||||||||||||
| 1845 | - | |||||||||||||
| 1846 | \sa getRect(), setCoords() | - | ||||||||||||
| 1847 | */ | - | ||||||||||||
| 1848 | - | |||||||||||||
| 1849 | - | |||||||||||||
| 1850 | /*! | - | ||||||||||||
| 1851 | \fn void QRectF::setCoords(qreal x1, qreal y1, qreal x2, qreal y2) | - | ||||||||||||
| 1852 | - | |||||||||||||
| 1853 | Sets the coordinates of the rectangle's top-left corner to (\a x1, | - | ||||||||||||
| 1854 | \a y1), and the coordinates of its bottom-right corner to (\a x2, | - | ||||||||||||
| 1855 | \a y2). | - | ||||||||||||
| 1856 | - | |||||||||||||
| 1857 | \sa getCoords(), setRect() | - | ||||||||||||
| 1858 | */ | - | ||||||||||||
| 1859 | - | |||||||||||||
| 1860 | /*! | - | ||||||||||||
| 1861 | \fn QRectF QRectF::adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const | - | ||||||||||||
| 1862 | - | |||||||||||||
| 1863 | Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2 | - | ||||||||||||
| 1864 | added respectively to the existing coordinates of this rectangle. | - | ||||||||||||
| 1865 | - | |||||||||||||
| 1866 | \sa adjust() | - | ||||||||||||
| 1867 | */ | - | ||||||||||||
| 1868 | - | |||||||||||||
| 1869 | /*! \fn void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2) | - | ||||||||||||
| 1870 | - | |||||||||||||
| 1871 | Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the | - | ||||||||||||
| 1872 | existing coordinates of the rectangle. | - | ||||||||||||
| 1873 | - | |||||||||||||
| 1874 | \sa adjusted(), setRect() | - | ||||||||||||
| 1875 | */ | - | ||||||||||||
| 1876 | /*! | - | ||||||||||||
| 1877 | \fn QSizeF QRectF::size() const | - | ||||||||||||
| 1878 | - | |||||||||||||
| 1879 | Returns the size of the rectangle. | - | ||||||||||||
| 1880 | - | |||||||||||||
| 1881 | \sa setSize(), width(), height() | - | ||||||||||||
| 1882 | */ | - | ||||||||||||
| 1883 | - | |||||||||||||
| 1884 | /*! | - | ||||||||||||
| 1885 | \fn qreal QRectF::width() const | - | ||||||||||||
| 1886 | - | |||||||||||||
| 1887 | Returns the width of the rectangle. | - | ||||||||||||
| 1888 | - | |||||||||||||
| 1889 | \sa setWidth(), height(), size() | - | ||||||||||||
| 1890 | */ | - | ||||||||||||
| 1891 | - | |||||||||||||
| 1892 | /*! | - | ||||||||||||
| 1893 | \fn qreal QRectF::height() const | - | ||||||||||||
| 1894 | - | |||||||||||||
| 1895 | Returns the height of the rectangle. | - | ||||||||||||
| 1896 | - | |||||||||||||
| 1897 | \sa setHeight(), width(), size() | - | ||||||||||||
| 1898 | */ | - | ||||||||||||
| 1899 | - | |||||||||||||
| 1900 | /*! | - | ||||||||||||
| 1901 | \fn void QRectF::setWidth(qreal width) | - | ||||||||||||
| 1902 | - | |||||||||||||
| 1903 | Sets the width of the rectangle to the given \a width. The right | - | ||||||||||||
| 1904 | edge is changed, but not the left one. | - | ||||||||||||
| 1905 | - | |||||||||||||
| 1906 | \sa width(), setSize() | - | ||||||||||||
| 1907 | */ | - | ||||||||||||
| 1908 | - | |||||||||||||
| 1909 | - | |||||||||||||
| 1910 | /*! | - | ||||||||||||
| 1911 | \fn void QRectF::setHeight(qreal height) | - | ||||||||||||
| 1912 | - | |||||||||||||
| 1913 | Sets the height of the rectangle to the given \a height. The bottom | - | ||||||||||||
| 1914 | edge is changed, but not the top one. | - | ||||||||||||
| 1915 | - | |||||||||||||
| 1916 | \sa height(), setSize() | - | ||||||||||||
| 1917 | */ | - | ||||||||||||
| 1918 | - | |||||||||||||
| 1919 | - | |||||||||||||
| 1920 | /*! | - | ||||||||||||
| 1921 | \fn void QRectF::setSize(const QSizeF &size) | - | ||||||||||||
| 1922 | - | |||||||||||||
| 1923 | Sets the size of the rectangle to the given \a size. The top-left | - | ||||||||||||
| 1924 | corner is not moved. | - | ||||||||||||
| 1925 | - | |||||||||||||
| 1926 | \sa size(), setWidth(), setHeight() | - | ||||||||||||
| 1927 | */ | - | ||||||||||||
| 1928 | - | |||||||||||||
| 1929 | - | |||||||||||||
| 1930 | /*! | - | ||||||||||||
| 1931 | \fn bool QRectF::contains(const QPointF &point) const | - | ||||||||||||
| 1932 | - | |||||||||||||
| 1933 | Returns \c true if the given \a point is inside or on the edge of the | - | ||||||||||||
| 1934 | rectangle; otherwise returns \c false. | - | ||||||||||||
| 1935 | - | |||||||||||||
| 1936 | \sa intersects() | - | ||||||||||||
| 1937 | */ | - | ||||||||||||
| 1938 | - | |||||||||||||
| 1939 | bool QRectF::contains(const QPointF &p) const Q_DECL_NOTHROW | - | ||||||||||||
| 1940 | { | - | ||||||||||||
| 1941 | qreal l = xp; | - | ||||||||||||
| 1942 | qreal r = xp; | - | ||||||||||||
| 1943 | if (w < 0)
| 12-125980 | ||||||||||||
| 1944 | l += w; executed 12 times by 1 test: l += w;Executed by:
| 12 | ||||||||||||
| 1945 | else | - | ||||||||||||
| 1946 | r += w; executed 125980 times by 65 tests: r += w;Executed by:
| 125980 | ||||||||||||
| 1947 | if (l == r) // null rect
| 6-125986 | ||||||||||||
| 1948 | return false; executed 6 times by 4 tests: return false;Executed by:
| 6 | ||||||||||||
| 1949 | - | |||||||||||||
| 1950 | if (p.x() < l || p.x() > r)
| 14974-111012 | ||||||||||||
| 1951 | return false; executed 30174 times by 23 tests: return false;Executed by:
| 30174 | ||||||||||||
| 1952 | - | |||||||||||||
| 1953 | qreal t = yp; | - | ||||||||||||
| 1954 | qreal b = yp; | - | ||||||||||||
| 1955 | if (h < 0)
| 12-95800 | ||||||||||||
| 1956 | t += h; executed 12 times by 1 test: t += h;Executed by:
| 12 | ||||||||||||
| 1957 | else | - | ||||||||||||
| 1958 | b += h; executed 95800 times by 62 tests: b += h;Executed by:
| 95800 | ||||||||||||
| 1959 | if (t == b) // null rect
| 1-95811 | ||||||||||||
| 1960 | return false; executed 1 time by 1 test: return false;Executed by:
| 1 | ||||||||||||
| 1961 | - | |||||||||||||
| 1962 | if (p.y() < t || p.y() > b)
| 7758-88053 | ||||||||||||
| 1963 | return false; executed 15683 times by 17 tests: return false;Executed by:
| 15683 | ||||||||||||
| 1964 | - | |||||||||||||
| 1965 | return true; executed 80128 times by 61 tests: return true;Executed by:
| 80128 | ||||||||||||
| 1966 | } | - | ||||||||||||
| 1967 | - | |||||||||||||
| 1968 | - | |||||||||||||
| 1969 | /*! | - | ||||||||||||
| 1970 | \fn bool QRectF::contains(qreal x, qreal y) const | - | ||||||||||||
| 1971 | \overload | - | ||||||||||||
| 1972 | - | |||||||||||||
| 1973 | Returns \c true if the point (\a x, \a y) is inside or on the edge of | - | ||||||||||||
| 1974 | the rectangle; otherwise returns \c false. | - | ||||||||||||
| 1975 | */ | - | ||||||||||||
| 1976 | - | |||||||||||||
| 1977 | /*! | - | ||||||||||||
| 1978 | \fn bool QRectF::contains(const QRectF &rectangle) const | - | ||||||||||||
| 1979 | \overload | - | ||||||||||||
| 1980 | - | |||||||||||||
| 1981 | Returns \c true if the given \a rectangle is inside this rectangle; | - | ||||||||||||
| 1982 | otherwise returns \c false. | - | ||||||||||||
| 1983 | */ | - | ||||||||||||
| 1984 | - | |||||||||||||
| 1985 | bool QRectF::contains(const QRectF &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 1986 | { | - | ||||||||||||
| 1987 | qreal l1 = xp; | - | ||||||||||||
| 1988 | qreal r1 = xp; | - | ||||||||||||
| 1989 | if (w < 0)
| 4-13954 | ||||||||||||
| 1990 | l1 += w; executed 4 times by 1 test: l1 += w;Executed by:
| 4 | ||||||||||||
| 1991 | else | - | ||||||||||||
| 1992 | r1 += w; executed 13954 times by 81 tests: r1 += w;Executed by:
| 13954 | ||||||||||||
| 1993 | if (l1 == r1) // null rect
| 10-13948 | ||||||||||||
| 1994 | return false; executed 10 times by 2 tests: return false;Executed by:
| 10 | ||||||||||||
| 1995 | - | |||||||||||||
| 1996 | qreal l2 = r.xp; | - | ||||||||||||
| 1997 | qreal r2 = r.xp; | - | ||||||||||||
| 1998 | if (r.w < 0)
| 4-13944 | ||||||||||||
| 1999 | l2 += r.w; executed 4 times by 1 test: l2 += r.w;Executed by:
| 4 | ||||||||||||
| 2000 | else | - | ||||||||||||
| 2001 | r2 += r.w; executed 13944 times by 81 tests: r2 += r.w;Executed by:
| 13944 | ||||||||||||
| 2002 | if (l2 == r2) // null rect
| 4-13944 | ||||||||||||
| 2003 | return false; executed 4 times by 3 tests: return false;Executed by:
| 4 | ||||||||||||
| 2004 | - | |||||||||||||
| 2005 | if (l2 < l1 || r2 > r1)
| 302-13168 | ||||||||||||
| 2006 | return false; executed 1078 times by 35 tests: return false;Executed by:
| 1078 | ||||||||||||
| 2007 | - | |||||||||||||
| 2008 | qreal t1 = yp; | - | ||||||||||||
| 2009 | qreal b1 = yp; | - | ||||||||||||
| 2010 | if (h < 0)
| 2-12864 | ||||||||||||
| 2011 | t1 += h; executed 2 times by 1 test: t1 += h;Executed by:
| 2 | ||||||||||||
| 2012 | else | - | ||||||||||||
| 2013 | b1 += h; executed 12864 times by 81 tests: b1 += h;Executed by:
| 12864 | ||||||||||||
| 2014 | if (t1 == b1) // null rect
| 0-12866 | ||||||||||||
| 2015 | return false; never executed: return false; | 0 | ||||||||||||
| 2016 | - | |||||||||||||
| 2017 | qreal t2 = r.yp; | - | ||||||||||||
| 2018 | qreal b2 = r.yp; | - | ||||||||||||
| 2019 | if (r.h < 0)
| 2-12864 | ||||||||||||
| 2020 | t2 += r.h; executed 2 times by 1 test: t2 += r.h;Executed by:
| 2 | ||||||||||||
| 2021 | else | - | ||||||||||||
| 2022 | b2 += r.h; executed 12864 times by 81 tests: b2 += r.h;Executed by:
| 12864 | ||||||||||||
| 2023 | if (t2 == b2) // null rect
| 0-12866 | ||||||||||||
| 2024 | return false; never executed: return false; | 0 | ||||||||||||
| 2025 | - | |||||||||||||
| 2026 | if (t2 < t1 || b2 > b1)
| 114-12662 | ||||||||||||
| 2027 | return false; executed 318 times by 10 tests: return false;Executed by:
| 318 | ||||||||||||
| 2028 | - | |||||||||||||
| 2029 | return true; executed 12548 times by 81 tests: return true;Executed by:
| 12548 | ||||||||||||
| 2030 | } | - | ||||||||||||
| 2031 | - | |||||||||||||
| 2032 | /*! | - | ||||||||||||
| 2033 | \fn qreal QRectF::left() const | - | ||||||||||||
| 2034 | - | |||||||||||||
| 2035 | Returns the x-coordinate of the rectangle's left edge. Equivalent | - | ||||||||||||
| 2036 | to x(). | - | ||||||||||||
| 2037 | - | |||||||||||||
| 2038 | \sa setLeft(), topLeft(), bottomLeft() | - | ||||||||||||
| 2039 | */ | - | ||||||||||||
| 2040 | - | |||||||||||||
| 2041 | /*! | - | ||||||||||||
| 2042 | \fn qreal QRectF::top() const | - | ||||||||||||
| 2043 | - | |||||||||||||
| 2044 | Returns the y-coordinate of the rectangle's top edge. Equivalent | - | ||||||||||||
| 2045 | to y(). | - | ||||||||||||
| 2046 | - | |||||||||||||
| 2047 | \sa setTop(), topLeft(), topRight() | - | ||||||||||||
| 2048 | */ | - | ||||||||||||
| 2049 | - | |||||||||||||
| 2050 | /*! | - | ||||||||||||
| 2051 | \fn qreal QRectF::right() const | - | ||||||||||||
| 2052 | - | |||||||||||||
| 2053 | Returns the x-coordinate of the rectangle's right edge. | - | ||||||||||||
| 2054 | - | |||||||||||||
| 2055 | \sa setRight(), topRight(), bottomRight() | - | ||||||||||||
| 2056 | */ | - | ||||||||||||
| 2057 | - | |||||||||||||
| 2058 | /*! | - | ||||||||||||
| 2059 | \fn qreal QRectF::bottom() const | - | ||||||||||||
| 2060 | - | |||||||||||||
| 2061 | Returns the y-coordinate of the rectangle's bottom edge. | - | ||||||||||||
| 2062 | - | |||||||||||||
| 2063 | \sa setBottom(), bottomLeft(), bottomRight() | - | ||||||||||||
| 2064 | */ | - | ||||||||||||
| 2065 | - | |||||||||||||
| 2066 | /*! | - | ||||||||||||
| 2067 | \fn QPointF QRectF::topLeft() const | - | ||||||||||||
| 2068 | - | |||||||||||||
| 2069 | Returns the position of the rectangle's top-left corner. | - | ||||||||||||
| 2070 | - | |||||||||||||
| 2071 | \sa setTopLeft(), top(), left() | - | ||||||||||||
| 2072 | */ | - | ||||||||||||
| 2073 | - | |||||||||||||
| 2074 | /*! | - | ||||||||||||
| 2075 | \fn QPointF QRectF::bottomRight() const | - | ||||||||||||
| 2076 | - | |||||||||||||
| 2077 | Returns the position of the rectangle's bottom-right corner. | - | ||||||||||||
| 2078 | - | |||||||||||||
| 2079 | \sa setBottomRight(), bottom(), right() | - | ||||||||||||
| 2080 | */ | - | ||||||||||||
| 2081 | - | |||||||||||||
| 2082 | /*! | - | ||||||||||||
| 2083 | \fn QPointF QRectF::topRight() const | - | ||||||||||||
| 2084 | - | |||||||||||||
| 2085 | Returns the position of the rectangle's top-right corner. | - | ||||||||||||
| 2086 | - | |||||||||||||
| 2087 | \sa setTopRight(), top(), right() | - | ||||||||||||
| 2088 | */ | - | ||||||||||||
| 2089 | - | |||||||||||||
| 2090 | /*! | - | ||||||||||||
| 2091 | \fn QPointF QRectF::bottomLeft() const | - | ||||||||||||
| 2092 | - | |||||||||||||
| 2093 | Returns the position of the rectangle's bottom-left corner. | - | ||||||||||||
| 2094 | - | |||||||||||||
| 2095 | \sa setBottomLeft(), bottom(), left() | - | ||||||||||||
| 2096 | */ | - | ||||||||||||
| 2097 | - | |||||||||||||
| 2098 | /*! | - | ||||||||||||
| 2099 | \fn QRectF& QRectF::operator|=(const QRectF &rectangle) | - | ||||||||||||
| 2100 | - | |||||||||||||
| 2101 | Unites this rectangle with the given \a rectangle. | - | ||||||||||||
| 2102 | - | |||||||||||||
| 2103 | \sa united(), operator|() | - | ||||||||||||
| 2104 | */ | - | ||||||||||||
| 2105 | - | |||||||||||||
| 2106 | /*! | - | ||||||||||||
| 2107 | \fn QRectF& QRectF::operator&=(const QRectF &rectangle) | - | ||||||||||||
| 2108 | - | |||||||||||||
| 2109 | Intersects this rectangle with the given \a rectangle. | - | ||||||||||||
| 2110 | - | |||||||||||||
| 2111 | \sa intersected(), operator|=() | - | ||||||||||||
| 2112 | */ | - | ||||||||||||
| 2113 | - | |||||||||||||
| 2114 | - | |||||||||||||
| 2115 | /*! | - | ||||||||||||
| 2116 | \fn QRectF QRectF::operator|(const QRectF &rectangle) const | - | ||||||||||||
| 2117 | - | |||||||||||||
| 2118 | Returns the bounding rectangle of this rectangle and the given \a rectangle. | - | ||||||||||||
| 2119 | - | |||||||||||||
| 2120 | \sa united(), operator|=() | - | ||||||||||||
| 2121 | */ | - | ||||||||||||
| 2122 | - | |||||||||||||
| 2123 | QRectF QRectF::operator|(const QRectF &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 2124 | { | - | ||||||||||||
| 2125 | if (isNull())
| 4071-26303 | ||||||||||||
| 2126 | return r; executed 4071 times by 26 tests: return r;Executed by:
| 4071 | ||||||||||||
| 2127 | if (r.isNull())
| 222-26081 | ||||||||||||
| 2128 | return *this; executed 222 times by 8 tests: return *this;Executed by:
| 222 | ||||||||||||
| 2129 | - | |||||||||||||
| 2130 | qreal left = xp; | - | ||||||||||||
| 2131 | qreal right = xp; | - | ||||||||||||
| 2132 | if (w < 0)
| 4-26077 | ||||||||||||
| 2133 | left += w; executed 4 times by 1 test: left += w;Executed by:
| 4 | ||||||||||||
| 2134 | else | - | ||||||||||||
| 2135 | right += w; executed 26077 times by 33 tests: right += w;Executed by:
| 26077 | ||||||||||||
| 2136 | - | |||||||||||||
| 2137 | if (r.w < 0) {
| 4-26077 | ||||||||||||
| 2138 | left = qMin(left, r.xp + r.w); | - | ||||||||||||
| 2139 | right = qMax(right, r.xp); | - | ||||||||||||
| 2140 | } else { executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||
| 2141 | left = qMin(left, r.xp); | - | ||||||||||||
| 2142 | right = qMax(right, r.xp + r.w); | - | ||||||||||||
| 2143 | } executed 26077 times by 33 tests: end of blockExecuted by:
| 26077 | ||||||||||||
| 2144 | - | |||||||||||||
| 2145 | qreal top = yp; | - | ||||||||||||
| 2146 | qreal bottom = yp; | - | ||||||||||||
| 2147 | if (h < 0)
| 4-26077 | ||||||||||||
| 2148 | top += h; executed 4 times by 1 test: top += h;Executed by:
| 4 | ||||||||||||
| 2149 | else | - | ||||||||||||
| 2150 | bottom += h; executed 26077 times by 33 tests: bottom += h;Executed by:
| 26077 | ||||||||||||
| 2151 | - | |||||||||||||
| 2152 | if (r.h < 0) {
| 4-26077 | ||||||||||||
| 2153 | top = qMin(top, r.yp + r.h); | - | ||||||||||||
| 2154 | bottom = qMax(bottom, r.yp); | - | ||||||||||||
| 2155 | } else { executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||
| 2156 | top = qMin(top, r.yp); | - | ||||||||||||
| 2157 | bottom = qMax(bottom, r.yp + r.h); | - | ||||||||||||
| 2158 | } executed 26077 times by 33 tests: end of blockExecuted by:
| 26077 | ||||||||||||
| 2159 | - | |||||||||||||
| 2160 | return QRectF(left, top, right - left, bottom - top); executed 26081 times by 33 tests: return QRectF(left, top, right - left, bottom - top);Executed by:
| 26081 | ||||||||||||
| 2161 | } | - | ||||||||||||
| 2162 | - | |||||||||||||
| 2163 | /*! | - | ||||||||||||
| 2164 | \fn QRectF QRectF::unite(const QRectF &rectangle) const | - | ||||||||||||
| 2165 | \obsolete | - | ||||||||||||
| 2166 | - | |||||||||||||
| 2167 | Use united(\a rectangle) instead. | - | ||||||||||||
| 2168 | */ | - | ||||||||||||
| 2169 | - | |||||||||||||
| 2170 | /*! | - | ||||||||||||
| 2171 | \fn QRectF QRectF::united(const QRectF &rectangle) const | - | ||||||||||||
| 2172 | \since 4.2 | - | ||||||||||||
| 2173 | - | |||||||||||||
| 2174 | Returns the bounding rectangle of this rectangle and the given \a | - | ||||||||||||
| 2175 | rectangle. | - | ||||||||||||
| 2176 | - | |||||||||||||
| 2177 | \image qrect-unite.png | - | ||||||||||||
| 2178 | - | |||||||||||||
| 2179 | \sa intersected() | - | ||||||||||||
| 2180 | */ | - | ||||||||||||
| 2181 | - | |||||||||||||
| 2182 | - | |||||||||||||
| 2183 | /*! | - | ||||||||||||
| 2184 | \fn QRectF QRectF::operator &(const QRectF &rectangle) const | - | ||||||||||||
| 2185 | - | |||||||||||||
| 2186 | Returns the intersection of this rectangle and the given \a | - | ||||||||||||
| 2187 | rectangle. Returns an empty rectangle if there is no intersection. | - | ||||||||||||
| 2188 | - | |||||||||||||
| 2189 | \sa operator&=(), intersected() | - | ||||||||||||
| 2190 | */ | - | ||||||||||||
| 2191 | - | |||||||||||||
| 2192 | QRectF QRectF::operator&(const QRectF &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 2193 | { | - | ||||||||||||
| 2194 | qreal l1 = xp; | - | ||||||||||||
| 2195 | qreal r1 = xp; | - | ||||||||||||
| 2196 | if (w < 0)
| 8-7806 | ||||||||||||
| 2197 | l1 += w; executed 8 times by 1 test: l1 += w;Executed by:
| 8 | ||||||||||||
| 2198 | else | - | ||||||||||||
| 2199 | r1 += w; executed 7806 times by 46 tests: r1 += w;Executed by:
| 7806 | ||||||||||||
| 2200 | if (l1 == r1) // null rect
| 38-7776 | ||||||||||||
| 2201 | return QRectF(); executed 38 times by 3 tests: return QRectF();Executed by:
| 38 | ||||||||||||
| 2202 | - | |||||||||||||
| 2203 | qreal l2 = r.xp; | - | ||||||||||||
| 2204 | qreal r2 = r.xp; | - | ||||||||||||
| 2205 | if (r.w < 0)
| 4-7772 | ||||||||||||
| 2206 | l2 += r.w; executed 4 times by 1 test: l2 += r.w;Executed by:
| 4 | ||||||||||||
| 2207 | else | - | ||||||||||||
| 2208 | r2 += r.w; executed 7772 times by 46 tests: r2 += r.w;Executed by:
| 7772 | ||||||||||||
| 2209 | if (l2 == r2) // null rect
| 6-7770 | ||||||||||||
| 2210 | return QRectF(); executed 6 times by 3 tests: return QRectF();Executed by:
| 6 | ||||||||||||
| 2211 | - | |||||||||||||
| 2212 | if (l1 >= r2 || l2 >= r1)
| 6-7764 | ||||||||||||
| 2213 | return QRectF(); executed 31 times by 5 tests: return QRectF();Executed by:
| 31 | ||||||||||||
| 2214 | - | |||||||||||||
| 2215 | qreal t1 = yp; | - | ||||||||||||
| 2216 | qreal b1 = yp; | - | ||||||||||||
| 2217 | if (h < 0)
| 3-7736 | ||||||||||||
| 2218 | t1 += h; executed 3 times by 1 test: t1 += h;Executed by:
| 3 | ||||||||||||
| 2219 | else | - | ||||||||||||
| 2220 | b1 += h; executed 7736 times by 45 tests: b1 += h;Executed by:
| 7736 | ||||||||||||
| 2221 | if (t1 == b1) // null rect
| 0-7739 | ||||||||||||
| 2222 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||
| 2223 | - | |||||||||||||
| 2224 | qreal t2 = r.yp; | - | ||||||||||||
| 2225 | qreal b2 = r.yp; | - | ||||||||||||
| 2226 | if (r.h < 0)
| 3-7736 | ||||||||||||
| 2227 | t2 += r.h; executed 3 times by 1 test: t2 += r.h;Executed by:
| 3 | ||||||||||||
| 2228 | else | - | ||||||||||||
| 2229 | b2 += r.h; executed 7736 times by 45 tests: b2 += r.h;Executed by:
| 7736 | ||||||||||||
| 2230 | if (t2 == b2) // null rect
| 0-7739 | ||||||||||||
| 2231 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||
| 2232 | - | |||||||||||||
| 2233 | if (t1 >= b2 || t2 >= b1)
| 8-6132 | ||||||||||||
| 2234 | return QRectF(); executed 1615 times by 7 tests: return QRectF();Executed by:
| 1615 | ||||||||||||
| 2235 | - | |||||||||||||
| 2236 | QRectF tmp; | - | ||||||||||||
| 2237 | tmp.xp = qMax(l1, l2); | - | ||||||||||||
| 2238 | tmp.yp = qMax(t1, t2); | - | ||||||||||||
| 2239 | tmp.w = qMin(r1, r2) - tmp.xp; | - | ||||||||||||
| 2240 | tmp.h = qMin(b1, b2) - tmp.yp; | - | ||||||||||||
| 2241 | return tmp; executed 6124 times by 45 tests: return tmp;Executed by:
| 6124 | ||||||||||||
| 2242 | } | - | ||||||||||||
| 2243 | - | |||||||||||||
| 2244 | /*! | - | ||||||||||||
| 2245 | \fn QRectF QRectF::intersect(const QRectF &rectangle) const | - | ||||||||||||
| 2246 | \obsolete | - | ||||||||||||
| 2247 | - | |||||||||||||
| 2248 | Use intersected(\a rectangle) instead. | - | ||||||||||||
| 2249 | */ | - | ||||||||||||
| 2250 | - | |||||||||||||
| 2251 | /*! | - | ||||||||||||
| 2252 | \fn QRectF QRectF::intersected(const QRectF &rectangle) const | - | ||||||||||||
| 2253 | \since 4.2 | - | ||||||||||||
| 2254 | - | |||||||||||||
| 2255 | Returns the intersection of this rectangle and the given \a | - | ||||||||||||
| 2256 | rectangle. Note that \c {r.intersected(s)} is equivalent to \c | - | ||||||||||||
| 2257 | {r & s}. | - | ||||||||||||
| 2258 | - | |||||||||||||
| 2259 | \image qrect-intersect.png | - | ||||||||||||
| 2260 | - | |||||||||||||
| 2261 | \sa intersects(), united(), operator&=() | - | ||||||||||||
| 2262 | */ | - | ||||||||||||
| 2263 | - | |||||||||||||
| 2264 | /*! | - | ||||||||||||
| 2265 | \fn bool QRectF::intersects(const QRectF &rectangle) const | - | ||||||||||||
| 2266 | - | |||||||||||||
| 2267 | Returns \c true if this rectangle intersects with the given \a | - | ||||||||||||
| 2268 | rectangle (i.e. there is a non-empty area of overlap between | - | ||||||||||||
| 2269 | them), otherwise returns \c false. | - | ||||||||||||
| 2270 | - | |||||||||||||
| 2271 | The intersection rectangle can be retrieved using the intersected() | - | ||||||||||||
| 2272 | function. | - | ||||||||||||
| 2273 | - | |||||||||||||
| 2274 | \sa contains() | - | ||||||||||||
| 2275 | */ | - | ||||||||||||
| 2276 | - | |||||||||||||
| 2277 | bool QRectF::intersects(const QRectF &r) const Q_DECL_NOTHROW | - | ||||||||||||
| 2278 | { | - | ||||||||||||
| 2279 | qreal l1 = xp; | - | ||||||||||||
| 2280 | qreal r1 = xp; | - | ||||||||||||
| 2281 | if (w < 0)
| 4-1467739 | ||||||||||||
| 2282 | l1 += w; executed 4 times by 1 test: l1 += w;Executed by:
| 4 | ||||||||||||
| 2283 | else | - | ||||||||||||
| 2284 | r1 += w; executed 1467739 times by 35 tests: r1 += w;Executed by:
| 1467739 | ||||||||||||
| 2285 | if (l1 == r1) // null rect
| 114-1467629 | ||||||||||||
| 2286 | return false; executed 114 times by 3 tests: return false;Executed by:
| 114 | ||||||||||||
| 2287 | - | |||||||||||||
| 2288 | qreal l2 = r.xp; | - | ||||||||||||
| 2289 | qreal r2 = r.xp; | - | ||||||||||||
| 2290 | if (r.w < 0)
| 5-1467624 | ||||||||||||
| 2291 | l2 += r.w; executed 5 times by 2 tests: l2 += r.w;Executed by:
| 5 | ||||||||||||
| 2292 | else | - | ||||||||||||
| 2293 | r2 += r.w; executed 1467624 times by 35 tests: r2 += r.w;Executed by:
| 1467624 | ||||||||||||
| 2294 | if (l2 == r2) // null rect
| 2-1467627 | ||||||||||||
| 2295 | return false; executed 2 times by 2 tests: return false;Executed by:
| 2 | ||||||||||||
| 2296 | - | |||||||||||||
| 2297 | if (l1 >= r2 || l2 >= r1)
| 72663-767576 | ||||||||||||
| 2298 | return false; executed 1394964 times by 11 tests: return false;Executed by:
| 1394964 | ||||||||||||
| 2299 | - | |||||||||||||
| 2300 | qreal t1 = yp; | - | ||||||||||||
| 2301 | qreal b1 = yp; | - | ||||||||||||
| 2302 | if (h < 0)
| 3-72660 | ||||||||||||
| 2303 | t1 += h; executed 3 times by 1 test: t1 += h;Executed by:
| 3 | ||||||||||||
| 2304 | else | - | ||||||||||||
| 2305 | b1 += h; executed 72660 times by 35 tests: b1 += h;Executed by:
| 72660 | ||||||||||||
| 2306 | if (t1 == b1) // null rect
| 0-72663 | ||||||||||||
| 2307 | return false; never executed: return false; | 0 | ||||||||||||
| 2308 | - | |||||||||||||
| 2309 | qreal t2 = r.yp; | - | ||||||||||||
| 2310 | qreal b2 = r.yp; | - | ||||||||||||
| 2311 | if (r.h < 0)
| 4-72659 | ||||||||||||
| 2312 | t2 += r.h; executed 4 times by 2 tests: t2 += r.h;Executed by:
| 4 | ||||||||||||
| 2313 | else | - | ||||||||||||
| 2314 | b2 += r.h; executed 72659 times by 35 tests: b2 += r.h;Executed by:
| 72659 | ||||||||||||
| 2315 | if (t2 == b2) // null rect
| 0-72663 | ||||||||||||
| 2316 | return false; never executed: return false; | 0 | ||||||||||||
| 2317 | - | |||||||||||||
| 2318 | if (t1 >= b2 || t2 >= b1)
| 10258-44722 | ||||||||||||
| 2319 | return false; executed 62405 times by 12 tests: return false;Executed by:
| 62405 | ||||||||||||
| 2320 | - | |||||||||||||
| 2321 | return true; executed 10258 times by 35 tests: return true;Executed by:
| 10258 | ||||||||||||
| 2322 | } | - | ||||||||||||
| 2323 | - | |||||||||||||
| 2324 | /*! | - | ||||||||||||
| 2325 | \fn QRect QRectF::toRect() const | - | ||||||||||||
| 2326 | - | |||||||||||||
| 2327 | Returns a QRect based on the values of this rectangle. Note that the | - | ||||||||||||
| 2328 | coordinates in the returned rectangle are rounded to the nearest integer. | - | ||||||||||||
| 2329 | - | |||||||||||||
| 2330 | \sa QRectF(), toAlignedRect() | - | ||||||||||||
| 2331 | */ | - | ||||||||||||
| 2332 | - | |||||||||||||
| 2333 | /*! | - | ||||||||||||
| 2334 | \fn QRect QRectF::toAlignedRect() const | - | ||||||||||||
| 2335 | \since 4.3 | - | ||||||||||||
| 2336 | - | |||||||||||||
| 2337 | Returns a QRect based on the values of this rectangle that is the | - | ||||||||||||
| 2338 | smallest possible integer rectangle that completely contains this | - | ||||||||||||
| 2339 | rectangle. | - | ||||||||||||
| 2340 | - | |||||||||||||
| 2341 | \sa toRect() | - | ||||||||||||
| 2342 | */ | - | ||||||||||||
| 2343 | - | |||||||||||||
| 2344 | QRect QRectF::toAlignedRect() const Q_DECL_NOTHROW | - | ||||||||||||
| 2345 | { | - | ||||||||||||
| 2346 | int xmin = int(qFloor(xp)); | - | ||||||||||||
| 2347 | int xmax = int(qCeil(xp + w)); | - | ||||||||||||
| 2348 | int ymin = int(qFloor(yp)); | - | ||||||||||||
| 2349 | int ymax = int(qCeil(yp + h)); | - | ||||||||||||
| 2350 | return QRect(xmin, ymin, xmax - xmin, ymax - ymin); executed 50550 times by 107 tests: return QRect(xmin, ymin, xmax - xmin, ymax - ymin);Executed by:
| 50550 | ||||||||||||
| 2351 | } | - | ||||||||||||
| 2352 | - | |||||||||||||
| 2353 | /*! | - | ||||||||||||
| 2354 | \fn void QRectF::moveCenter(const QPointF &position) | - | ||||||||||||
| 2355 | - | |||||||||||||
| 2356 | Moves the rectangle, leaving the center point at the given \a | - | ||||||||||||
| 2357 | position. The rectangle's size is unchanged. | - | ||||||||||||
| 2358 | - | |||||||||||||
| 2359 | \sa center() | - | ||||||||||||
| 2360 | */ | - | ||||||||||||
| 2361 | - | |||||||||||||
| 2362 | /*! | - | ||||||||||||
| 2363 | \fn bool operator==(const QRectF &r1, const QRectF &r2) | - | ||||||||||||
| 2364 | \relates QRectF | - | ||||||||||||
| 2365 | - | |||||||||||||
| 2366 | Returns \c true if the rectangles \a r1 and \a r2 are equal, | - | ||||||||||||
| 2367 | otherwise returns \c false. | - | ||||||||||||
| 2368 | */ | - | ||||||||||||
| 2369 | - | |||||||||||||
| 2370 | - | |||||||||||||
| 2371 | /*! | - | ||||||||||||
| 2372 | \fn bool operator!=(const QRectF &r1, const QRectF &r2) | - | ||||||||||||
| 2373 | \relates QRectF | - | ||||||||||||
| 2374 | - | |||||||||||||
| 2375 | Returns \c true if the rectangles \a r1 and \a r2 are different, otherwise | - | ||||||||||||
| 2376 | returns \c false. | - | ||||||||||||
| 2377 | */ | - | ||||||||||||
| 2378 | - | |||||||||||||
| 2379 | /*! | - | ||||||||||||
| 2380 | \fn QRectF operator+(const QRectF &lhs, const QMarginsF &rhs) | - | ||||||||||||
| 2381 | \relates QRectF | - | ||||||||||||
| 2382 | \since 5.3 | - | ||||||||||||
| 2383 | - | |||||||||||||
| 2384 | Returns the \a lhs rectangle grown by the \a rhs margins. | - | ||||||||||||
| 2385 | */ | - | ||||||||||||
| 2386 | - | |||||||||||||
| 2387 | /*! | - | ||||||||||||
| 2388 | \fn QRectF operator-(const QRectF &lhs, const QMarginsF &rhs) | - | ||||||||||||
| 2389 | \relates QRectF | - | ||||||||||||
| 2390 | \since 5.3 | - | ||||||||||||
| 2391 | - | |||||||||||||
| 2392 | Returns the \a lhs rectangle grown by the \a rhs margins. | - | ||||||||||||
| 2393 | */ | - | ||||||||||||
| 2394 | - | |||||||||||||
| 2395 | /*! | - | ||||||||||||
| 2396 | \fn QRectF operator+(const QMarginsF &lhs, const QRectF &rhs) | - | ||||||||||||
| 2397 | \relates QRectF | - | ||||||||||||
| 2398 | \overload | - | ||||||||||||
| 2399 | \since 5.3 | - | ||||||||||||
| 2400 | - | |||||||||||||
| 2401 | Returns the \a lhs rectangle grown by the \a rhs margins. | - | ||||||||||||
| 2402 | */ | - | ||||||||||||
| 2403 | - | |||||||||||||
| 2404 | /*! | - | ||||||||||||
| 2405 | \fn QRectF QRectF::marginsAdded(const QMarginsF &margins) const | - | ||||||||||||
| 2406 | \since 5.3 | - | ||||||||||||
| 2407 | - | |||||||||||||
| 2408 | Returns a rectangle grown by the \a margins. | - | ||||||||||||
| 2409 | - | |||||||||||||
| 2410 | \sa operator+=(), marginsRemoved(), operator-=() | - | ||||||||||||
| 2411 | */ | - | ||||||||||||
| 2412 | - | |||||||||||||
| 2413 | /*! | - | ||||||||||||
| 2414 | \fn QRectF QRectF::marginsRemoved(const QMarginsF &margins) const | - | ||||||||||||
| 2415 | \since 5.3 | - | ||||||||||||
| 2416 | - | |||||||||||||
| 2417 | Removes the \a margins from the rectangle, shrinking it. | - | ||||||||||||
| 2418 | - | |||||||||||||
| 2419 | \sa marginsAdded(), operator+=(), operator-=() | - | ||||||||||||
| 2420 | */ | - | ||||||||||||
| 2421 | - | |||||||||||||
| 2422 | /*! | - | ||||||||||||
| 2423 | \fn QRectF QRectF::operator+=(const QMarginsF &margins) | - | ||||||||||||
| 2424 | \since 5.3 | - | ||||||||||||
| 2425 | - | |||||||||||||
| 2426 | Adds the \a margins to the rectangle, growing it. | - | ||||||||||||
| 2427 | - | |||||||||||||
| 2428 | \sa marginsAdded(), marginsRemoved(), operator-=() | - | ||||||||||||
| 2429 | */ | - | ||||||||||||
| 2430 | - | |||||||||||||
| 2431 | /*! | - | ||||||||||||
| 2432 | \fn QRectF QRectF::operator-=(const QMarginsF &margins) | - | ||||||||||||
| 2433 | \since 5.3 | - | ||||||||||||
| 2434 | - | |||||||||||||
| 2435 | Returns a rectangle shrunk by the \a margins. | - | ||||||||||||
| 2436 | - | |||||||||||||
| 2437 | \sa marginsRemoved(), operator+=(), marginsAdded() | - | ||||||||||||
| 2438 | */ | - | ||||||||||||
| 2439 | - | |||||||||||||
| 2440 | /***************************************************************************** | - | ||||||||||||
| 2441 | QRectF stream functions | - | ||||||||||||
| 2442 | *****************************************************************************/ | - | ||||||||||||
| 2443 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||
| 2444 | /*! | - | ||||||||||||
| 2445 | \fn QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle) | - | ||||||||||||
| 2446 | - | |||||||||||||
| 2447 | \relates QRectF | - | ||||||||||||
| 2448 | - | |||||||||||||
| 2449 | Writes the \a rectangle to the \a stream, and returns a reference to the | - | ||||||||||||
| 2450 | stream. | - | ||||||||||||
| 2451 | - | |||||||||||||
| 2452 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 2453 | */ | - | ||||||||||||
| 2454 | - | |||||||||||||
| 2455 | QDataStream &operator<<(QDataStream &s, const QRectF &r) | - | ||||||||||||
| 2456 | { | - | ||||||||||||
| 2457 | s << double(r.x()) << double(r.y()) << double(r.width()) << double(r.height()); | - | ||||||||||||
| 2458 | return s; executed 72 times by 3 tests: return s;Executed by:
| 72 | ||||||||||||
| 2459 | } | - | ||||||||||||
| 2460 | - | |||||||||||||
| 2461 | /*! | - | ||||||||||||
| 2462 | \fn QDataStream &operator>>(QDataStream &stream, QRectF &rectangle) | - | ||||||||||||
| 2463 | - | |||||||||||||
| 2464 | \relates QRectF | - | ||||||||||||
| 2465 | - | |||||||||||||
| 2466 | Reads a \a rectangle from the \a stream, and returns a reference to the | - | ||||||||||||
| 2467 | stream. | - | ||||||||||||
| 2468 | - | |||||||||||||
| 2469 | \sa {Serializing Qt Data Types} | - | ||||||||||||
| 2470 | */ | - | ||||||||||||
| 2471 | - | |||||||||||||
| 2472 | QDataStream &operator>>(QDataStream &s, QRectF &r) | - | ||||||||||||
| 2473 | { | - | ||||||||||||
| 2474 | double x, y, w, h; | - | ||||||||||||
| 2475 | s >> x; | - | ||||||||||||
| 2476 | s >> y; | - | ||||||||||||
| 2477 | s >> w; | - | ||||||||||||
| 2478 | s >> h; | - | ||||||||||||
| 2479 | r.setRect(qreal(x), qreal(y), qreal(w), qreal(h)); | - | ||||||||||||
| 2480 | return s; executed 75 times by 3 tests: return s;Executed by:
| 75 | ||||||||||||
| 2481 | } | - | ||||||||||||
| 2482 | - | |||||||||||||
| 2483 | #endif // QT_NO_DATASTREAM | - | ||||||||||||
| 2484 | - | |||||||||||||
| 2485 | - | |||||||||||||
| 2486 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 2487 | QDebug operator<<(QDebug dbg, const QRectF &r) | - | ||||||||||||
| 2488 | { | - | ||||||||||||
| 2489 | QDebugStateSaver saver(dbg); | - | ||||||||||||
| 2490 | dbg.nospace(); | - | ||||||||||||
| 2491 | dbg << "QRectF" << '('; | - | ||||||||||||
| 2492 | QtDebugUtils::formatQRect(dbg, r); | - | ||||||||||||
| 2493 | dbg << ')'; | - | ||||||||||||
| 2494 | return dbg; executed 40 times by 4 tests: return dbg;Executed by:
| 40 | ||||||||||||
| 2495 | } | - | ||||||||||||
| 2496 | #endif | - | ||||||||||||
| 2497 | - | |||||||||||||
| 2498 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |