Logo    
KDWinUtils
Helper library for MFC to Qt migration
Loading...
Searching...
No Matches
KRect Class Reference

The KRect class defines a rectangle in the plane using integer precision. More...

#include <krect.h>

Public Member Functions

KPointBottomRight ()
 Returns the bottom-right point of KRect.
 
const KPointBottomRight () 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.
 
KRectoperator= (const CRect &rect)
 
KRectoperator= (const KRect &rect)
 
KRectoperator= (const QRect &rect)
 
KRectoperator= (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
 
KPointTopLeft ()
 Returns the top-left point of KRect.
 
const KPointTopLeft () 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.
 

Detailed Description

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.

See also
https://learn.microsoft.com/en-us/cpp/atl-mfc-shared/reference/crect-class

Constructor & Destructor Documentation

◆ KRect() [1/8]

KRect::KRect ( )

◆ KRect() [2/8]

KRect::KRect ( int l,
int t,
int r,
int b )
explicit

◆ KRect() [3/8]

KRect::KRect ( const KPoint & cp,
const KSize & cs )
explicit

◆ KRect() [4/8]

KRect::KRect ( const KPoint & topLeft,
const KPoint & bottomRight )
explicit

◆ ~KRect()

KRect::~KRect ( )
default

◆ KRect() [5/8]

KRect::KRect ( const KRect & rect)

◆ KRect() [6/8]

KRect::KRect ( KRect && rect)
noexcept

◆ KRect() [7/8]

KRect::KRect ( const QRect & qr)

◆ KRect() [8/8]

KRect::KRect ( const CRect & cr)
explicit

Member Function Documentation

◆ BottomRight() [1/2]

KPoint & KRect::BottomRight ( )

Returns the bottom-right point of KRect.

◆ BottomRight() [2/2]

const KPoint & KRect::BottomRight ( ) const

◆ CenterPoint()

KPoint KRect::CenterPoint ( ) const

Returns the centerpoint of KRect.

◆ CopyRect() [1/2]

void KRect::CopyRect ( const KRect & rect)

Copies the dimensions of a source rectangle to KRect.

◆ CopyRect() [2/2]

void KRect::CopyRect ( const KRect * rect)

Copies the dimensions of a source rectangle to KRect.

◆ DeflateRect() [1/4]

void KRect::DeflateRect ( const KRect & rect)

Decreases the width and height of KRect.

◆ DeflateRect() [2/4]

void KRect::DeflateRect ( const KSize & size)

Decreases the width and height of KRect.

◆ DeflateRect() [3/4]

void KRect::DeflateRect ( int l,
int t,
int r,
int b )

Decreases the width and height of KRect.

◆ DeflateRect() [4/4]

void KRect::DeflateRect ( int x,
int y )

Decreases the width and height of KRect.

◆ EqualRect() [1/2]

bool KRect::EqualRect ( const KRect & cr) const

Determines whether KRect is equal to the given rectangle.

◆ EqualRect() [2/2]

bool KRect::EqualRect ( const KRect * cr) const

Determines whether KRect is equal to the given rectangle.

◆ Height()

int KRect::Height ( ) const

Calculates the height of KRect.

◆ InflateRect() [1/4]

void KRect::InflateRect ( const KRect & rect)

Increases the width and height of KRect.

◆ InflateRect() [2/4]

void KRect::InflateRect ( const KSize & size)

Increases the width and height of KRect.

◆ InflateRect() [3/4]

void KRect::InflateRect ( int l,
int t,
int r,
int b )

Increases the width and height of KRect.

◆ InflateRect() [4/4]

void KRect::InflateRect ( int x,
int y )

Increases the width and height of KRect.

◆ IntersectRect() [1/2]

bool KRect::IntersectRect ( const KRect & rect1,
const KRect & rect2 )

Sets KRect equal to the intersection of two rectangles.

◆ IntersectRect() [2/2]

bool KRect::IntersectRect ( const KRect * rect1,
const KRect * rect2 )

Sets KRect equal to the intersection of two rectangles.

◆ IsRectEmpty()

bool KRect::IsRectEmpty ( ) const

Determines whether KRect is empty. KRect is empty if the width and/or height are 0.

◆ IsRectNull()

bool KRect::IsRectNull ( ) const

Determines whether the top, bottom, left, and right member variables are all equal to 0.

◆ MoveToX()

void KRect::MoveToX ( int x)

Moves KRect to the specified x-coordinate.

◆ MoveToXY() [1/2]

void KRect::MoveToXY ( const KPoint & point)
noexcept

Moves KRect to the specified x- and y-coordinates.

◆ MoveToXY() [2/2]

void KRect::MoveToXY ( int x,
int y )
noexcept

Moves KRect to the specified x- and y-coordinates.

◆ MoveToY()

void KRect::MoveToY ( int y)

Moves KRect to the specified y-coordinate.

◆ NormalizeRect()

void KRect::NormalizeRect ( )

Standardizes the height and width of KRect.

◆ OffsetRect() [1/3]

void KRect::OffsetRect ( const KPoint & point)

Moves KRect by the specified offsets.

◆ OffsetRect() [2/3]

void KRect::OffsetRect ( const KSize & size)

Moves KRect by the specified offsets.

◆ OffsetRect() [3/3]

void KRect::OffsetRect ( int x,
int y )

Moves KRect by the specified offsets.

◆ operator CRect()

KRect::operator CRect ( ) const

◆ operator QRect()

KRect::operator QRect ( ) const

◆ operator&=()

void KRect::operator&= ( const KRect & rect)

Sets Krect equal to the intersection of Krect and a rectangle.

◆ operator+=() [1/3]

void KRect::operator+= ( const KPoint & point)

Adds the specified offsets to Krect.

◆ operator+=() [2/3]

void KRect::operator+= ( const KRect & rect)

Inflates Krect.

◆ operator+=() [3/3]

void KRect::operator+= ( const KSize & size)

Adds the specified offsets to Krect.

◆ operator-=() [1/3]

void KRect::operator-= ( const KPoint & point)

Subtracts the specified offsets from Krect.

◆ operator-=() [2/3]

void KRect::operator-= ( const KRect & rect)

Deflates Krect.

◆ operator-=() [3/3]

void KRect::operator-= ( const KSize & size)

Subtracts the specified offsets from Krect.

◆ operator=() [1/4]

KRect & KRect::operator= ( const CRect & rect)

◆ operator=() [2/4]

KRect & KRect::operator= ( const KRect & rect)

◆ operator=() [3/4]

KRect & KRect::operator= ( const QRect & rect)

◆ operator=() [4/4]

KRect & KRect::operator= ( KRect && rect)
noexcept

◆ operator|=()

void KRect::operator|= ( const KRect & rect)

Sets Krect equal to the union of Krect and a rectangle.

◆ PtInRect()

bool KRect::PtInRect ( const KPoint & point) const

Determines whether the specified point lies within KRect.

◆ SetRect()

void KRect::SetRect ( int left,
int top,
int right,
int bottom )

Sets the dimensions of KRect.

◆ SetRectEmpty()

void KRect::SetRectEmpty ( )

Sets KRect to an empty rectangle (all coordinates equal to 0).

◆ Size()

KSize KRect::Size ( ) const

Calculates the size of KRect.

◆ SubtractRect() [1/2]

bool KRect::SubtractRect ( const KRect & rectSrc1,
const KRect & rectSrc2 )

Subtracts one rectangle from another.

◆ SubtractRect() [2/2]

bool KRect::SubtractRect ( const KRect * rectSrc1,
const KRect * rectSrc2 )

Subtracts one rectangle from another.

◆ swap()

void KRect::swap ( KRect & rect)
noexcept

◆ toCRect()

CRect KRect::toCRect ( ) const

◆ TopLeft() [1/2]

KPoint & KRect::TopLeft ( )

Returns the top-left point of KRect.

◆ TopLeft() [2/2]

const KPoint & KRect::TopLeft ( ) const

Returns the top-left point of KRect.

◆ toQRect()

QRect KRect::toQRect ( ) const

◆ UnionRect() [1/2]

void KRect::UnionRect ( const KRect & rectSrc1,
const KRect & rectSrc2 )

Sets KRect equal to the union of two rectangles.

◆ UnionRect() [2/2]

void KRect::UnionRect ( const KRect * rectSrc1,
const KRect * rectSrc2 )

Sets KRect equal to the union of two rectangles.

◆ Width()

int KRect::Width ( ) const

Calculates the width of KRect.

Friends And Related Symbol Documentation

◆ operator!=()

bool operator!= ( const KRect & lhs,
const KRect & rhs )
related

Checks for inequality between 2 rects.

◆ operator&()

KRect operator& ( const KRect & lhs,
const KRect & rhs )
related

Creates the intersection of KRect and a rectangle and returns the resulting KRect .

◆ operator+() [1/3]

KRect operator+ ( const KRect & lhs,
const KPoint & rhs )
related

Returns a KRect offset by a KPoint.

◆ operator+() [2/3]

KRect operator+ ( const KRect & lhs,
const KRect & rhs )
related

Inflates KRect and returns the resulting KRect.

◆ operator+() [3/3]

KRect operator+ ( const KRect & lhs,
const KSize & rhs )
related

Returns a KRect offset by a KSize.

◆ operator-() [1/3]

KRect operator- ( const KRect & lhs,
const KPoint & rhs )
related

Subtracts the given offsets from Krect.

◆ operator-() [2/3]

KRect operator- ( const KRect & lhs,
const KRect & rhs )
related

Deflates KRect and returns the resulting KRect.

◆ operator-() [3/3]

KRect operator- ( const KRect & lhs,
const KSize & rhs )
related

Subtracts the given offsets from KRect.

◆ operator==()

bool operator== ( const KRect & lhs,
const KRect & rhs )
related

Checks for equality between 2 rects.

◆ operator|()

KRect operator| ( const KRect & lhs,
const KRect & rhs )
related

Creates the union of KRect and a rectangle and returns the resulting KRect.

Member Data Documentation

◆ bottom

int& KRect::bottom = m_bottomRight.y

◆ left

int& KRect::left = m_topLeft.x

◆ right

int& KRect::right = m_bottomRight.x

◆ top

int& KRect::top = m_topLeft.y

The documentation for this class was generated from the following file: