KWin::Rect Class
The Rect type represents a rectangle with integer coordinates. More...
| Header: | #include <core/rect.h> |
| CMake: | find_package(KWin REQUIRED)target_link_libraries(mytarget PRIVATE KWin::kwin) |
Properties
Public Functions
| Rect() | |
| Rect(Qt::Initialization) | |
| Rect(const QRect &rect) | |
| Rect(const QPoint &topLeft, const QPoint &bottomRight) | |
| Rect(const QPoint &topLeft, const QSize &size) | |
| Rect(int x, int y, int width, int height) | |
| void | adjust(int x1, int y1, int x2, int y2) |
| KWin::Rect | adjusted(int x1, int y1, int x2, int y2) const |
| int | bottom() const |
| QPoint | bottomLeft() const |
| QPoint | bottomRight() const |
| QPoint | center() const |
| bool | contains(const KWin::Rect &rect) const |
| bool | contains(const QPoint &point) const |
| bool | contains(int x, int y) const |
| void | getCoords(int *x1, int *y1, int *x2, int *y2) const |
| void | getRect(int *x, int *y, int *width, int *height) const |
| KWin::Rect | grownBy(const QMargins &margins) const |
| int | height() const |
| KWin::Rect | intersected(const KWin::Rect &other) const |
| bool | intersects(const KWin::Rect &other) const |
| bool | isEmpty() const |
| bool | isNull() const |
| bool | isValid() const |
| int | left() const |
| KWin::Rect | marginsAdded(const QMargins &margins) const |
| KWin::Rect | marginsRemoved(const QMargins &margins) const |
| void | moveBottom(int bottom) |
| void | moveBottomLeft(const QPoint &point) |
| void | moveBottomRight(const QPoint &point) |
| void | moveCenter(const QPoint &point) |
| void | moveLeft(int left) |
| void | moveRight(int right) |
| void | moveTo(const QPoint &point) |
| void | moveTo(int x, int y) |
| void | moveTop(int top) |
| void | moveTopLeft(const QPoint &point) |
| void | moveTopRight(const QPoint &point) |
| int | right() const |
| KWin::RectF | scaled(qreal scale) const |
| KWin::RectF | scaled(qreal xScale, qreal yScale) const |
| void | setBottom(int bottom) |
| void | setBottomLeft(const QPoint &point) |
| void | setBottomRight(const QPoint &point) |
| void | setCoords(int x1, int y1, int x2, int y2) |
| void | setHeight(int height) |
| void | setLeft(int left) |
| void | setRect(int x, int y, int width, int height) |
| void | setRight(int right) |
| void | setSize(const QSize &size) |
| void | setTop(int top) |
| void | setTopLeft(const QPoint &point) |
| void | setTopRight(const QPoint &point) |
| void | setWidth(int width) |
| void | setX(int x) |
| void | setY(int y) |
| KWin::Rect | shrunkBy(const QMargins &margins) const |
| QSize | size() const |
| int | top() const |
| QPoint | topLeft() const |
| QPoint | topRight() const |
| void | translate(const QPoint &offset) |
| void | translate(int dx, int dy) |
| KWin::Rect | translated(const QPoint &offset) const |
| KWin::Rect | translated(int dx, int dy) const |
| KWin::Rect | transposed() const |
| KWin::Rect | united(const KWin::Rect &other) const |
| int | width() const |
| int | x() const |
| int | y() const |
| operator QRect() const | |
| KWin::Rect | operator&(const KWin::Rect &other) const |
| KWin::Rect & | operator&=(const KWin::Rect &other) |
| KWin::Rect & | operator+=(const QMargins &margins) |
| KWin::Rect & | operator-=(const QMargins &margins) |
| bool | operator==(const KWin::Rect &other) const |
| KWin::Rect | operator|(const KWin::Rect &other) const |
| KWin::Rect & | operator|=(const KWin::Rect &other) |
Detailed Description
Property Documentation
height : int
The height of the rectangle
Access functions:
width : int
The width of the rectangle
Access functions:
x : int
The x coordinate of the top left corner
Access functions:
y : int
The y coordinate of the top left corner
Access functions:
Member Function Documentation
[constexpr noexcept] Rect::Rect()
Constructs an empty rectangle.
See also setRect().
[explicit constexpr noexcept] Rect::Rect(Qt::Initialization)
Constructs an uninitialized Rect.
[constexpr noexcept] Rect::Rect(const QRect &rect)
Constructs a Rect from the given QRect rect.
[constexpr noexcept] Rect::Rect(const QPoint &topLeft, const QPoint &bottomRight)
Constructs a rectangle with the specified topLeft and bottomRight corners.
[constexpr noexcept] Rect::Rect(const QPoint &topLeft, const QSize &size)
Constructs a rectangle with the specified topLeft position and size.
[constexpr noexcept] Rect::Rect(int x, int y, int width, int height)
Constructs a rectangle with the specified coordinates (x, and y), and the size (width, and height).
[constexpr noexcept] void Rect::adjust(int x1, int y1, int x2, int y2)
Adds x1, y1, x2, and y2 to the left, top, right, and bottom edge coordinates, respectively. This may change the size of the rectangle.
This function is provided for compatibility reasons with QRect.
Prefer using grownBy() or shrunkBy().
See also adjusted(), grownBy(), and shrunkBy().
[constexpr noexcept] KWin::Rect Rect::adjusted(int x1, int y1, int x2, int y2) const
Returns a copy of this rectangle with x1, y1, x2, and y2 added to its left, top, right, and bottom edge coordinates, respectively. This may change the size of the rectangle.
This function is provided for compatibility reasons with QRect.
Prefer using grownBy() or shrunkBy().
See also adjust(), grownBy(), and shrunkBy().
[constexpr noexcept] int Rect::bottom() const
Returns the bottom edge coordinate. This equivalent to y() + height().
See also setBottom() and moveBottom().
[constexpr noexcept] QPoint Rect::bottomLeft() const
Returns the bottom-left corner of the rectangle.
See also setBottomLeft() and moveBottomLeft().
[constexpr noexcept] QPoint Rect::bottomRight() const
Returns the bottom-right corner of the rectangle.
See also setBottomRight() and moveBottomRight().
[constexpr noexcept] QPoint Rect::center() const
Returns the center point of the rectangle.
See also moveCenter().
[constexpr noexcept] bool Rect::contains(const KWin::Rect &rect) const
Returns true if the specified rect is inside this rectangle; otherwise returns false. If the rectangle is empty, this function returns false.
[constexpr noexcept] bool Rect::contains(const QPoint &point) const
Returns true if the specified point is inside this rectangle; otherwise returns false. If the rectangle is empty, this function returns false.
The left and top edges are considered to be inside the rectangle, while the right and bottom edges are not. In other words, this checks left() <= point.x() < right(), and top() <= point.y() < bottom().
[constexpr noexcept] bool Rect::contains(int x, int y) const
This is an overloaded function.
[constexpr] void Rect::getCoords(int *x1, int *y1, int *x2, int *y2) const
Writes the rectangle's top-left corner position to x1 and y1, and its bottom-right corner position to x2 and y2.
This function is provided for compatibility reasons with QRect.
See also setCoords().
[constexpr] void Rect::getRect(int *x, int *y, int *width, int *height) const
Writes the rectangle's top-left corner position to x and y, and its size to width and height.
This function is provided for compatibility reasons with QRect.
See also setRect().
[constexpr noexcept] KWin::Rect Rect::grownBy(const QMargins &margins) const
Returns a copy of this rectangle grown by the given margins.
See also shrunkBy().
[constexpr noexcept] int Rect::height() const
Returns the height of the rectangle.
Note: Getter function for property height.
See also setHeight().
[constexpr noexcept] KWin::Rect Rect::intersected(const KWin::Rect &other) const
Returns the intersection of this rectangle and the given other rectangle. If the rectangles don't intersect, an empty rectangle will be returned.
See also intersects().
[constexpr noexcept] bool Rect::intersects(const KWin::Rect &other) const
Returns true if this rectangle and the given other rectangle intersect; otherwise returns false.
See also intersected().
[constexpr noexcept] bool Rect::isEmpty() const
Returns true if the rectangle is empty; otherwise returns false. An empty rectangle has left() >= right() or top() >= bottom() or both.
See also isNull() and isValid().
[constexpr noexcept] bool Rect::isNull() const
Returns true if the rectangle is empty; otherwise returns false. An empty rectangle has left() >= right() or top() >= bottom() or both.
This function is provided for compatibility reasons with QRect. It is identical to isEmpty(). Prefer using isEmpty().
See also isEmpty() and isValid().
[constexpr noexcept] bool Rect::isValid() const
Returns true if the rectangle is empty; otherwise returns false. An empty rectangle has left() >= right() or top() >= bottom() or both.
This function is provided for compatibility reasons with QRect. It is identical to isEmpty(). Prefer using isEmpty().
See also isEmpty() and isNull().
[constexpr noexcept] int Rect::left() const
Returns the left edge coordinate. Equivalent to x().
See also x(), setLeft(), and moveLeft().
[constexpr noexcept] KWin::Rect Rect::marginsAdded(const QMargins &margins) const
Returns a copy of this rectangle grown by the given margins. Equivalent to grownBy().
This function is provided for compatibility reasons with QRect.
See also shrunkBy() and marginsRemoved().
[constexpr noexcept] KWin::Rect Rect::marginsRemoved(const QMargins &margins) const
Returns a copy of this rectangle shrunk by the given margins. Equivalent to shrunkBy().
This function is provided for compatibility reasons with QRect.
See also grownBy() and marginsAdded().
[constexpr noexcept] void Rect::moveBottom(int bottom)
Moves the rectangle vertically so its bottom edge is left at the specified position bottom. The size of the rectangle won't be changed.
See also bottom() and setBottom().
[constexpr noexcept] void Rect::moveBottomLeft(const QPoint &point)
Moves the rectangle so its bottom-left corner is left at the specified position point. The size of the rectangle won't be changed.
See also bottomLeft() and setBottomLeft().
[constexpr noexcept] void Rect::moveBottomRight(const QPoint &point)
Moves the rectangle so its bottom-right corner is left at the specified position point. The size of the rectangle won't be changed.
See also bottomRight() and setBottomRight().
[constexpr noexcept] void Rect::moveCenter(const QPoint &point)
Moves the rectangle so its center point is at the specified position point. This does not change the size of the rectangle.
See also center().
[constexpr noexcept] void Rect::moveLeft(int left)
Moves the rectangle horizontally so its left edge is left at the specified position left. The size of the rectangle won't be changed.
See also left() and setLeft().
[constexpr noexcept] void Rect::moveRight(int right)
Moves the rectangle horizontally so its right edge is left at the specified position right. The size of the rectangle won't be changed.
See also right() and setRight().
[constexpr noexcept] void Rect::moveTo(const QPoint &point)
Moves the top-left corner of the rectangle to the specified point. Equivalent to moveTopLeft().
See also moveTopLeft().
[constexpr noexcept] void Rect::moveTo(int x, int y)
This is an overloaded function.
[constexpr noexcept] void Rect::moveTop(int top)
Moves the rectangle vertically so its top edge is left at the specified position top. The size of the rectangle won't be changed.
[constexpr noexcept] void Rect::moveTopLeft(const QPoint &point)
Moves the rectangle so its top-left corner is left at the specified position point. The size of the rectangle won't be changed.
See also topLeft() and setTopLeft().
[constexpr noexcept] void Rect::moveTopRight(const QPoint &point)
Moves the rectangle so its top-right corner is left at the specified position point. The size of the rectangle won't be changed.
See also topRight() and setTopRight().
[constexpr noexcept] int Rect::right() const
Returns the right edge coordinate. This equivalent to x() + width().
See also setRight() and moveRight().
[constexpr noexcept] KWin::RectF Rect::scaled(qreal scale) const
Returns a copy of this rectangle with its x and y coordinates scaled by the given scale factor.
[constexpr noexcept] KWin::RectF Rect::scaled(qreal xScale, qreal yScale) const
Returns a copy of this rectangle with its x coordinates scaled by the given xScale factor and the y coordinates scaled by the yScale factor.
[constexpr noexcept] void Rect::setBottom(int bottom)
Sets the bottom edge coordinate to bottom. This may change the height of the rectangle.
See also bottom() and moveBottom().
[constexpr noexcept] void Rect::setBottomLeft(const QPoint &point)
Sets the bottom-left corner coordinates to point. This may change the width and the height of the rectangle.
See also bottomLeft() and moveBottomLeft().
[constexpr noexcept] void Rect::setBottomRight(const QPoint &point)
Sets the bottom-right corner coordinates to point. This may change the width and the height of the rectangle.
See also bottomRight() and moveBottomRight().
[constexpr noexcept] void Rect::setCoords(int x1, int y1, int x2, int y2)
Sets the rectangle's top-left corner position to (x1, and y1), and its bottom-right corner position to (x2, and y2).
This function is provided for compatibility reasons with QRect.
See also getCoords().
[constexpr noexcept] void Rect::setHeight(int height)
Sets the height of the rectangle to height.
Note: Setter function for property height.
See also height().
[constexpr noexcept] void Rect::setLeft(int left)
Sets the left edge coordinate to left. This may change the width of the rectangle.
See also left(), moveLeft(), and setX().
[constexpr noexcept] void Rect::setRect(int x, int y, int width, int height)
Sets the rectangle's top-left corner position to (x, and y), and its size to (width, and height).
This function is provided for compatibility reasons with QRect.
See also getRect().
[constexpr noexcept] void Rect::setRight(int right)
Sets the right edge coordinate to right. This may change the width of the rectangle.
See also right() and moveRight().
[constexpr noexcept] void Rect::setSize(const QSize &size)
Sets the size of the rectangle to size.
See also size().
[constexpr noexcept] void Rect::setTop(int top)
Sets the top edge coordinate to top. This may change the height of the rectangle.
See also top(), moveTop(), and setY().
[constexpr noexcept] void Rect::setTopLeft(const QPoint &point)
Sets the top-left corner coordinates to point. This may change the width and the height of the rectangle.
See also topLeft() and moveTopLeft().
[constexpr noexcept] void Rect::setTopRight(const QPoint &point)
Sets the top-right corner coordinates to point. This may change the width and the height of the rectangle.
See also topRight() and moveTopRight().
[constexpr noexcept] void Rect::setWidth(int width)
Sets the width of the rectangle to width.
Note: Setter function for property width.
See also width().
[constexpr noexcept] void Rect::setX(int x)
Sets the left edge coordinate to x. This may change the width of the rectangle. Equivalent to setLeft().
Note: Setter function for property x.
[constexpr noexcept] void Rect::setY(int y)
Sets the top edge coordinate to y. This may change the height of the rectangle. Equivalent to setTop().
Note: Setter function for property y.
[constexpr noexcept] KWin::Rect Rect::shrunkBy(const QMargins &margins) const
Returns a copy of this rectangle shrunk by the given margins.
See also grownBy().
[constexpr noexcept] QSize Rect::size() const
Returns the size of the rectangle.
See also setSize().
[constexpr noexcept] int Rect::top() const
Returns the top edge coordinate. Equivalent to y().
See also y(), setTop(), and moveTop().
[constexpr noexcept] QPoint Rect::topLeft() const
Returns the top-left corner of the rectangle.
See also setTopLeft() and moveTopLeft().
[constexpr noexcept] QPoint Rect::topRight() const
Returns the top-right corner of the rectangle.
See also setTopRight() and moveTopRight().
[constexpr noexcept] void Rect::translate(const QPoint &offset)
Moves the rectangle by adding the given offset to the rectangle coordinates. The size will be left unchanged.
[constexpr noexcept] void Rect::translate(int dx, int dy)
This is an overloaded function.
[constexpr noexcept] KWin::Rect Rect::translated(const QPoint &offset) const
Returns a copy of this rectangle with the given offset added to its coordinates. The size will be left unchanged.
[constexpr noexcept] KWin::Rect Rect::translated(int dx, int dy) const
This is an overloaded function.
[constexpr noexcept] KWin::Rect Rect::transposed() const
Returns a copy of this rectangle that has its width and height swapped.
[constexpr noexcept] KWin::Rect Rect::united(const KWin::Rect &other) const
Returns the bounding rectangle of this rectangle and the given other rectangle.
[constexpr noexcept] int Rect::width() const
Returns the width of the rectangle.
Note: Getter function for property width.
See also setWidth().
[constexpr noexcept] int Rect::x() const
Returns the left edge coordinate. Equivalent to left().
Note: Getter function for property x.
[constexpr noexcept] int Rect::y() const
Returns the top edge coordinate. Equivalent to top().
Note: Getter function for property y.
[constexpr noexcept] Rect::operator QRect() const
Implicitly converts this rectangle to QRect.
[constexpr noexcept] KWin::Rect Rect::operator&(const KWin::Rect &other) const
Returns the intersection of this rectangle and the given other rectangle. Equivalent to intersected().
See also intersected().
[constexpr noexcept] KWin::Rect &Rect::operator&=(const KWin::Rect &other)
Intersects this rectangle with the given other rectangle.
See also intersected() and operator&().
[constexpr noexcept] KWin::Rect &Rect::operator+=(const QMargins &margins)
Grows this rectangle by the given margins.
See also grownBy().
[constexpr noexcept] KWin::Rect &Rect::operator-=(const QMargins &margins)
Shrinks this rectangle by the given margins.
See also shrunkBy().
[constexpr noexcept] bool Rect::operator==(const KWin::Rect &other) const
Returns true if this rectangle and the other rectangle are equal; otherwise returns false.
[constexpr noexcept] KWin::Rect Rect::operator|(const KWin::Rect &other) const
Returns the bounding rectangle of this rectangle and the given other rectangle. Equivalent to united().
See also united().
[constexpr noexcept] KWin::Rect &Rect::operator|=(const KWin::Rect &other)
Unites this rectangle with the given other rectangle.