NXWidgets: NXWidgets::CRect Class Reference

NXWidgets 1.19

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
NXWidgets::CRect Class Reference

`#include <crect.hxx>`

## Public Member Functions
| CRect (void)
| CRect (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height)
| CRect (FAR const nxgl_rect_s *rect)
| CRect (const CRect &rect)
nxgl_coord_t | getX (void) const
nxgl_coord_t | getY (void) const
nxgl_coord_t | getWidth (void) const
void | getSize (struct nxgl_size_s &size) const
nxgl_coord_t | getHeight (void) const
void | getNxRect (FAR struct nxgl_rect_s *rect) const
void | setX (nxgl_coord_t x)
void | setY (nxgl_coord_t y)
void | setWidth (nxgl_coord_t width)
void | setHeight (nxgl_coord_t height)
void | setNxRect (FAR const struct nxgl_rect_s *rect)
void | setX2 (nxgl_coord_t x2)
void | setY2 (nxgl_coord_t y2)
nxgl_coord_t | getX2 (void) const
nxgl_coord_t | getY2 (void) const
void | offset (nxgl_coord_t dx, nxgl_coord_t dy)
bool | hasDimensions (void) const
void | getIntersect (const CRect &rect, CRect &dest) const
void | getAddition (const CRect &rect, CRect &dest) const
void | clipToIntersect (const CRect &rect)
void | expandToInclude (const CRect &rect)
bool | intersects (const CRect &rect) const
bool | contains (nxgl_coord_t x, nxgl_coord_t y) const
void | copyTo (CRect &dest) const
CRect | operator & (const CRect &rect)
CRect | operator+ (const CRect &rect)

## Static Public Member Functions
static CRect | fromCoordinates (nxgl_coord_t x1, nxgl_coord_t y1, nxgl_coord_t x2, nxgl_coord_t y2)

## Public Attributes
struct nxgl_point_s | m_pos
struct nxgl_size_s | m_size

## Detailed Description

Class describing a rectangle.

Definition at line 101 of file crect.hxx.

## Constructor & Destructor Documentation

## ◆ CRect() [1/4]

CRect::CRect | ( | void |  | ) |

Constructor.

Definition at line 95 of file crect.cxx.

## ◆ CRect() [2/4]

CRect::CRect | ( | nxgl_coord_t | x,
|  | nxgl_coord_t | y,
|  | nxgl_coord_t | width,
|  | nxgl_coord_t | height
| ) |  |

Constructor.

Parameters

  x | The x coordinate of the rect.
  y | The y coordinate of the rect.
  width | The width of the rect.
  height | The height of the rect.

Definition at line 112 of file crect.cxx.

## ◆ CRect() [3/4]

CRect::CRect | ( | FAR const nxgl_rect_s * | rect | ) |

Constructor.

Parameters

  rect | Pointer to an NX rectangle

Definition at line 126 of file crect.cxx.

## ◆ CRect() [4/4]

CRect::CRect | ( | const CRect & | rect | ) |

Copy constructor.

Parameters

  rect | CRect to copy.

Definition at line 137 of file crect.cxx.

## Member Function Documentation

## ◆ clipToIntersect()

void CRect::clipToIntersect | ( | const CRect & | rect | ) |

Clips this rect to the region that intersects the supplied rect.

Parameters

  rect | CRect to intersect.

Definition at line 282 of file crect.cxx.

## ◆ contains()

bool CRect::contains | ( | nxgl_coord_t | x,
|  | nxgl_coord_t | y
| ) |  | const

Check if the rect contains the supplied point.

Parameters

  x | X coordinate of the point.
  y | Y coordinate of the point.

Returns
  True if the rect contains the point; false if not.

Definition at line 334 of file crect.cxx.

## ◆ copyTo()

void CRect::copyTo | ( | CRect & | dest | ) | const

Copy the properties of this rect to the destination rect.

Parameters

  dest | Destination rect to copy to.

Definition at line 346 of file crect.cxx.

## ◆ expandToInclude()

void CRect::expandToInclude | ( | const CRect & | rect | ) |

Expands this rect so that it includes the area described by the supplied rect.

Parameters

  rect | CRect to include.

Definition at line 300 of file crect.cxx.

## ◆ fromCoordinates()

static CRect NXWidgets::CRect::fromCoordinates | ( | nxgl_coord_t | x1,
|  | nxgl_coord_t | y1,
|  | nxgl_coord_t | x2,
|  | nxgl_coord_t | y2
| ) |  |
| static

Create a rect object from the supplied coordinates.

Parameters

  x1 | The x coordinate of the rect's top-left corner.
  y1 | The y coordinate of the rect's top-left corner.
  x2 | The x coordinate of the rect's bottom-right corner.
  y2 | The y coordinate of the rect's bottom-right corner.

Returns
  A new rect.

## ◆ getAddition()

void CRect::getAddition | ( | const CRect & | rect,
|  | CRect & | dest
| ) |  | const

Populates dest with a rectangle representating the smallest rectangle that contains this rectangle and rect.

Parameters

  rect | The rectangle to add to this.
  dest | The destination rectangle.

Definition at line 262 of file crect.cxx.

## ◆ getHeight()

nxgl_coord_t NXWidgets::CRect::getHeight | ( | void |  | ) | const
| inline

Get the rectangle's height.

Returns
  The rectangle's height.

Definition at line 204 of file crect.hxx.

## ◆ getIntersect()

void CRect::getIntersect | ( | const CRect & | rect,
|  | CRect & | dest
| ) |  | const

Populates dest with a rectangle representating the intersection of this rectangle and rect.

Parameters

  rect | The rectangle to intersect with this.
  dest | The destination rectangle.

Definition at line 241 of file crect.cxx.

## ◆ getNxRect()

void NXWidgets::CRect::getNxRect | ( | FAR struct nxgl_rect_s * | rect | ) | const
| inline

Get the NX rectangle representation

Parameters

  rect | Pointer to NX rectangle

Definition at line 215 of file crect.hxx.

## ◆ getSize()

void NXWidgets::CRect::getSize | ( | struct nxgl_size_s & | size | ) | const
| inline

Get the size of the rectangle

Returns
  The rectangle's size

Definition at line 192 of file crect.hxx.

## ◆ getWidth()

nxgl_coord_t NXWidgets::CRect::getWidth | ( | void |  | ) | const
| inline

Get the rectangle's width.

Returns
  The rectangle's width.

Definition at line 181 of file crect.hxx.

## ◆ getX()

nxgl_coord_t NXWidgets::CRect::getX | ( | void |  | ) | const
| inline

Get the rectangle's left x coordinate.

Returns
  The rectangle's x coordinate.

Definition at line 160 of file crect.hxx.

## ◆ getX2()

nxgl_coord_t NXWidgets::CRect::getX2 | ( | void |  | ) | const
| inline

Get the x coordinate of the rectangle's right side.

Returns
  The x coordinate of the rectangle's right side.

Definition at line 308 of file crect.hxx.

## ◆ getY()

nxgl_coord_t NXWidgets::CRect::getY | ( | void |  | ) | const
| inline

Get the rectangle's top y coordinate.

Returns
  The rectangle's y coordinate.

Definition at line 170 of file crect.hxx.

## ◆ getY2()

nxgl_coord_t NXWidgets::CRect::getY2 | ( | void |  | ) | const
| inline

Get the y coordinate of the rectangle's bottom side.

Returns
  The y coordinate of the rerectangle's bottom side.

Definition at line 319 of file crect.hxx.

## ◆ hasDimensions()

bool NXWidgets::CRect::hasDimensions | ( | void |  | ) | const
| inline

Determines if the rectangle has two dimensions; in other words, does it have both height and width? Negative width or height is considered not to be valid.

Returns
  True if the rect has height and width; false if not.

Definition at line 345 of file crect.hxx.

## ◆ intersects()

bool CRect::intersects | ( | const CRect & | rect | ) | const

Check if the supplied rect intersects this.

Parameters

  rect | CRect to check for intersection with this.

Returns
  True if the rect intersects this; false if not.

Definition at line 318 of file crect.cxx.

## ◆ offset()

void NXWidgets::CRect::offset | ( | nxgl_coord_t | dx,
|  | nxgl_coord_t | dy
| ) |  |
| inline

Offset the rectangle position by the specified dx, dy values.

Parameters

  dx | X offset value
  dy | Y offset value

Definition at line 331 of file crect.hxx.

## ◆ operator &()

CRect NXWidgets::CRect::operator& | ( | const CRect & | rect | ) |

Overloaded & operator. Returns the intersect of this rectangle and the rectangle passed as the "rect" argument".

Parameters

  rect | The rectangle to intersect with this.

## ◆ operator+()

CRect CRect::operator+ | ( | const CRect & | rect | ) |

Overloaded + operator. Returns the smallest rectangle that can contain this rectangle and the rectangle passed as the "rect" argument".

Parameters

  rect | The rectangle to add to this.

Definition at line 375 of file crect.cxx.

## ◆ setHeight()

void NXWidgets::CRect::setHeight | ( | nxgl_coord_t | height | ) |
| inline

Set the rect's height.

Parameters

  height | The new height.

Definition at line 261 of file crect.hxx.

## ◆ setNxRect()

void NXWidgets::CRect::setNxRect | ( | FAR const struct nxgl_rect_s * | rect | ) |
| inline

Get the NX rectangle representation

Parameters

  rect | Pointer to NX rectangle

Definition at line 272 of file crect.hxx.

## ◆ setWidth()

void NXWidgets::CRect::setWidth | ( | nxgl_coord_t | width | ) |
| inline

Set the rect's width.

Parameters

  width | The new width.

Definition at line 250 of file crect.hxx.

## ◆ setX()

void NXWidgets::CRect::setX | ( | nxgl_coord_t | x | ) |
| inline

Set the rectangle's left x coordinate.

Parameters

  x | The new x coordinate.

Definition at line 229 of file crect.hxx.

## ◆ setX2()

void CRect::setX2 | ( | nxgl_coord_t | x2 | ) |

Set the x coordinate of the rect's bottom-right corner. If x2 is less than the rect's current x coordinate the method automatically adjusts the coordinates so that the rect's width is never negative. Changing this property will change the width of the rect.

Parameters

  x2 | The x coordinate of the rect's bottom-right corner.

Definition at line 192 of file crect.cxx.

## ◆ setY()

void NXWidgets::CRect::setY | ( | nxgl_coord_t | y | ) |
| inline

Set the rectangle's top y coordinate.

Parameters

  y | The new y coordinate.

Definition at line 240 of file crect.hxx.

## ◆ setY2()

void CRect::setY2 | ( | nxgl_coord_t | y2 | ) |

Set the y coordinate of the rect's bottom-right corner. If y2 is less than the rect's current y coordinate the method automatically adjusts the coordinates so that the rect's height is never negative. Changing this property will change the height of the rect.

Parameters

  y2 | The y coordinate of the rect's bottom-right corner.

Definition at line 217 of file crect.cxx.

## Member Data Documentation

## ◆ m_pos

struct nxgl_point_s NXWidgets::CRect::m_pos

The position of the rectangle in the window

Definition at line 104 of file crect.hxx.

## ◆ m_size

struct nxgl_size_s NXWidgets::CRect::m_size

The size of the rectangle

Definition at line 105 of file crect.hxx.

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

- crect.hxx
- crect.cxx