The KRect class defines a rectangle in the plane using integer precision. More...
#include <krect.h>
Public Member Functions | |
KPoint & | BottomRight () |
Returns the bottom-right point of KRect. | |
const KPoint & | BottomRight () const |
KPoint | CenterPoint () const |
Returns the centerpoint of KRect. | |
void | CopyRect (const KRect &rect) |
Copies the dimensions of a source rectangle to KRect. | |
void | CopyRect (const KRect *rect) |
Copies the dimensions of a source rectangle to KRect. | |
void | DeflateRect (const KRect &rect) |
Decreases the width and height of KRect. | |
void | DeflateRect (const KSize &size) |
Decreases the width and height of KRect. | |
void | DeflateRect (int l, int t, int r, int b) |
Decreases the width and height of KRect. | |
void | DeflateRect (int x, int y) |
Decreases the width and height of KRect. | |
bool | EqualRect (const KRect &cr) const |
Determines whether KRect is equal to the given rectangle. | |
bool | EqualRect (const KRect *cr) const |
Determines whether KRect is equal to the given rectangle. | |
int | Height () const |
Calculates the height of KRect. | |
void | InflateRect (const KRect &rect) |
Increases the width and height of KRect. | |
void | InflateRect (const KSize &size) |
Increases the width and height of KRect. | |
void | InflateRect (int l, int t, int r, int b) |
Increases the width and height of KRect. | |
void | InflateRect (int x, int y) |
Increases the width and height of KRect. | |
bool | IntersectRect (const KRect &rect1, const KRect &rect2) |
Sets KRect equal to the intersection of two rectangles. | |
bool | IntersectRect (const KRect *rect1, const KRect *rect2) |
Sets KRect equal to the intersection of two rectangles. | |
bool | IsRectEmpty () const |
Determines whether KRect is empty. KRect is empty if the width and/or height are 0. | |
bool | IsRectNull () const |
Determines whether the top, bottom, left, and right member variables are all equal to 0. | |
KRect () | |
KRect (const CRect &cr) | |
KRect (const KPoint &cp, const KSize &cs) | |
KRect (const KPoint &topLeft, const KPoint &bottomRight) | |
KRect (const KRect &rect) | |
KRect (const QRect &qr) | |
KRect (int l, int t, int r, int b) | |
KRect (KRect &&rect) noexcept | |
void | MoveToX (int x) |
Moves KRect to the specified x-coordinate. | |
void | MoveToXY (const KPoint &point) noexcept |
Moves KRect to the specified x- and y-coordinates. | |
void | MoveToXY (int x, int y) noexcept |
Moves KRect to the specified x- and y-coordinates. | |
void | MoveToY (int y) |
Moves KRect to the specified y-coordinate. | |
void | NormalizeRect () |
Standardizes the height and width of KRect. | |
void | OffsetRect (const KPoint &point) |
Moves KRect by the specified offsets. | |
void | OffsetRect (const KSize &size) |
Moves KRect by the specified offsets. | |
void | OffsetRect (int x, int y) |
Moves KRect by the specified offsets. | |
operator CRect () const | |
operator QRect () const | |
void | operator&= (const KRect &rect) |
Sets Krect equal to the intersection of Krect and a rectangle. | |
void | operator+= (const KPoint &point) |
Adds the specified offsets to Krect. | |
void | operator+= (const KRect &rect) |
Inflates Krect. | |
void | operator+= (const KSize &size) |
Adds the specified offsets to Krect. | |
void | operator-= (const KPoint &point) |
Subtracts the specified offsets from Krect. | |
void | operator-= (const KRect &rect) |
Deflates Krect. | |
void | operator-= (const KSize &size) |
Subtracts the specified offsets from Krect. | |
KRect & | operator= (const CRect &rect) |
KRect & | operator= (const KRect &rect) |
KRect & | operator= (const QRect &rect) |
KRect & | operator= (KRect &&rect) noexcept |
void | operator|= (const KRect &rect) |
Sets Krect equal to the union of Krect and a rectangle. | |
bool | PtInRect (const KPoint &point) const |
Determines whether the specified point lies within KRect. | |
void | SetRect (int left, int top, int right, int bottom) |
Sets the dimensions of KRect. | |
void | SetRectEmpty () |
Sets KRect to an empty rectangle (all coordinates equal to 0). | |
KSize | Size () const |
Calculates the size of KRect. | |
bool | SubtractRect (const KRect &rectSrc1, const KRect &rectSrc2) |
Subtracts one rectangle from another. | |
bool | SubtractRect (const KRect *rectSrc1, const KRect *rectSrc2) |
Subtracts one rectangle from another. | |
void | swap (KRect &rect) noexcept |
CRect | toCRect () const |
KPoint & | TopLeft () |
Returns the top-left point of KRect. | |
const KPoint & | TopLeft () const |
Returns the top-left point of KRect. | |
QRect | toQRect () const |
void | UnionRect (const KRect &rectSrc1, const KRect &rectSrc2) |
Sets KRect equal to the union of two rectangles. | |
void | UnionRect (const KRect *rectSrc1, const KRect *rectSrc2) |
Sets KRect equal to the union of two rectangles. | |
int | Width () const |
Calculates the width of KRect. | |
~KRect ()=default | |
Public Attributes | |
int & | bottom = m_bottomRight.y |
int & | left = m_topLeft.x |
int & | right = m_bottomRight.x |
int & | top = m_topLeft.y |
Related Symbols | |
(Note that these are not member symbols.) | |
bool | operator!= (const KRect &lhs, const KRect &rhs) noexcept |
Checks for inequality between 2 rects. | |
KRect | operator& (const KRect &lhs, const KRect &rhs) |
Creates the intersection of KRect and a rectangle and returns the resulting KRect . | |
KRect | operator+ (const KRect &lhs, const KPoint &rhs) |
Returns a KRect offset by a KPoint. | |
KRect | operator+ (const KRect &lhs, const KRect &rhs) |
Inflates KRect and returns the resulting KRect. | |
KRect | operator+ (const KRect &lhs, const KSize &rhs) |
Returns a KRect offset by a KSize. | |
KRect | operator- (const KRect &lhs, const KPoint &rhs) |
Subtracts the given offsets from Krect. | |
KRect | operator- (const KRect &lhs, const KRect &rhs) |
Deflates KRect and returns the resulting KRect. | |
KRect | operator- (const KRect &lhs, const KSize &rhs) |
Subtracts the given offsets from KRect. | |
bool | operator== (const KRect &lhs, const KRect &rhs) noexcept |
Checks for equality between 2 rects. | |
KRect | operator| (const KRect &lhs, const KRect &rhs) |
Creates the union of KRect and a rectangle and returns the resulting KRect. | |
The KRect class defines a rectangle in the plane using integer precision.
This class can replace CRect with the same API, and is compatible with both CRect and QRect.
KRect::KRect | ( | ) |
|
explicit |
|
default |
KRect::KRect | ( | const KRect & | rect | ) |
|
noexcept |
KRect::KRect | ( | const QRect & | qr | ) |
|
explicit |
const KPoint & KRect::BottomRight | ( | ) | const |
void KRect::DeflateRect | ( | int | l, |
int | t, | ||
int | r, | ||
int | b ) |
Decreases the width and height of KRect.
void KRect::DeflateRect | ( | int | x, |
int | y ) |
Decreases the width and height of KRect.
bool KRect::EqualRect | ( | const KRect & | cr | ) | const |
Determines whether KRect is equal to the given rectangle.
bool KRect::EqualRect | ( | const KRect * | cr | ) | const |
Determines whether KRect is equal to the given rectangle.
int KRect::Height | ( | ) | const |
Calculates the height of KRect.
void KRect::InflateRect | ( | int | l, |
int | t, | ||
int | r, | ||
int | b ) |
Increases the width and height of KRect.
void KRect::InflateRect | ( | int | x, |
int | y ) |
Increases the width and height of KRect.
Sets KRect equal to the intersection of two rectangles.
Sets KRect equal to the intersection of two rectangles.
bool KRect::IsRectEmpty | ( | ) | const |
bool KRect::IsRectNull | ( | ) | const |
Determines whether the top, bottom, left, and right member variables are all equal to 0.
void KRect::MoveToX | ( | int | x | ) |
Moves KRect to the specified x-coordinate.
|
noexcept |
Moves KRect to the specified x- and y-coordinates.
|
noexcept |
Moves KRect to the specified x- and y-coordinates.
void KRect::MoveToY | ( | int | y | ) |
Moves KRect to the specified y-coordinate.
void KRect::NormalizeRect | ( | ) |
Standardizes the height and width of KRect.
void KRect::OffsetRect | ( | int | x, |
int | y ) |
Moves KRect by the specified offsets.
KRect::operator CRect | ( | ) | const |
KRect::operator QRect | ( | ) | const |
void KRect::operator&= | ( | const KRect & | rect | ) |
Sets Krect equal to the intersection of Krect and a rectangle.
void KRect::operator+= | ( | const KPoint & | point | ) |
Adds the specified offsets to Krect.
void KRect::operator+= | ( | const KRect & | rect | ) |
Inflates Krect.
void KRect::operator+= | ( | const KSize & | size | ) |
Adds the specified offsets to Krect.
void KRect::operator-= | ( | const KPoint & | point | ) |
Subtracts the specified offsets from Krect.
void KRect::operator-= | ( | const KRect & | rect | ) |
Deflates Krect.
void KRect::operator-= | ( | const KSize & | size | ) |
Subtracts the specified offsets from Krect.
KRect & KRect::operator= | ( | const CRect & | rect | ) |
KRect & KRect::operator= | ( | const QRect & | rect | ) |
void KRect::operator|= | ( | const KRect & | rect | ) |
Sets Krect equal to the union of Krect and a rectangle.
bool KRect::PtInRect | ( | const KPoint & | point | ) | const |
Determines whether the specified point lies within KRect.
void KRect::SetRect | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom ) |
Sets the dimensions of KRect.
void KRect::SetRectEmpty | ( | ) |
Sets KRect to an empty rectangle (all coordinates equal to 0).
Subtracts one rectangle from another.
Subtracts one rectangle from another.
|
noexcept |
CRect KRect::toCRect | ( | ) | const |
QRect KRect::toQRect | ( | ) | const |
Sets KRect equal to the union of two rectangles.
Sets KRect equal to the union of two rectangles.
int KRect::Width | ( | ) | const |
Calculates the width of KRect.
Checks for inequality between 2 rects.
Subtracts the given offsets from Krect.
Subtracts the given offsets from KRect.
Checks for equality between 2 rects.
int& KRect::bottom = m_bottomRight.y |
int& KRect::left = m_topLeft.x |
int& KRect::right = m_bottomRight.x |
int& KRect::top = m_topLeft.y |