- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Exponent::MathTools::CRect Class Reference

List of all members.

## Detailed Description

Rectangle object.

Date:
  19/09/2004

Author:
  Paul Chana

Version:
  1.0.0 Initial version

  1.0.1 Added insert / offset functions

  1.0.2 Added scaling functions

  1.0.3 Added intersection functions

  1.0.4 Added union function

  1.0.5 Made the inline functions cross platform (

See also:
  FORCEINLINE)

Version:
  1.0.6 Added getCentral!Position functions

  1.0.7 Added dimension based functions, including c'tor

  1.0.8 Added from string conversion

Note:
  All contents of this source code are copyright 2005 Exp Digital Uk.
  This source file is covered by the licence conditions of the Infinity API. You should have recieved a copy
  with the source code. If you didnt, please refer to http://www.expdigital.co.uk All content is the Intellectual property of Exp Digital Uk.
  Certain sections of this code may come from other sources. They are credited where applicable.
  If you have comments, suggestions or bug reports please visit http://support.expdigital.co.uk

Id
  CRect.hpp,v 1.4 2007/02/08 21:06:44 paul Exp

Definition at line 42 of file CRect.hpp.

## Public Member Functions

- CRect (const CPoint &origin, const CDimension &dimension)
- CRect (const CRect &rect)
- CRect (const long left=0, const long top=0, const long width=0, const long height=0)
- RECT getAsRect ()
- long getBottom () const
- long getCentralXPosition () const
- long getCentralYPosition () const
- CDimension getDimension () const
- long getHeight () const
- long getLeft () const
- virtual void getObjectDescription (char *string, const long size) const
- CPoint getOrigin () const
- long getRight () const
- long getTop () const
- long getWidth () const
- void inset (const long amount)
- __forceinline bool isRectangleEmpty () const
- void offset (const CPoint &point)
- virtual CRect & operator= (const CRect &rect)
- virtual bool operator== (const CRect &rect)
- __forceinline bool pointIsInside (const CPoint &point) const
- __forceinline bool rectanglesIntersect (const CRect &other) const
- __forceinline bool rectIsInside (const CRect &rect) const
- void scale (const double amount)
- void setDimensions (const CDimension &dimension)
- void setFromRect (RECT &rect)
- void setHeight (const long height)
- void setLeft (const long left)
- void setOrigin (const CPoint &point)
- void setRect (const CPoint &origin, const CDimension &dimension)
- void setRect (const long left, const long top, const long width, const long height)
- void setTop (const long top)
- void setWidth (const long width)
- void unionWith (const CRect &rect)
- virtual ~CRect ()

## Static Public Member Functions

- static CRect convertFromString (const CString &string)
- static void getIntersectionArea (const CRect &rect1, const CRect &rect2, CRect &output)
- static CRect * getIntersectionArea (const CRect &rect1, const CRect &rect2)

## Protected Attributes

- long m_bottom
- long m_height
- long m_left
- long m_right
- long m_top
- long m_width

## Constructor & Destructor Documentation

Exponent::MathTools::CRect::CRect | ( | const long | left = `0`,
|  | const long | top = `0`,
|  | const long | width = `0`,
|  | const long | height = `0` |
| ) |  |  |

Construciton

Parameters:

  | left | The left position
  | top | The top position
  | width | The width of the rectangle
  | height | The height of the rectangle

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

Copy construction

Parameters:

  | rect | The rect to copy

Exponent::MathTools::CRect::CRect | ( | const CPoint & | origin,
|  | const CDimension & | dimension |
| ) |  |  |

Construction

Parameters:

  | origin | The origin of the control
  | dimension | The dimensions of the rect

virtual Exponent::MathTools::CRect::~CRect | ( |  | ) | `[virtual]`

Destruction

## Member Function Documentation

static CRect Exponent::MathTools::CRect::convertFromString | ( | const CString & | string | ) | `[static]`

Convert from comma delimited string

Parameters:

  | string | The string to convert

Return values:

  | CRect | The new CRect, is 0 size rect if error

RECT Exponent::MathTools::CRect::getAsRect | ( |  | ) |

Get as a windows RECT

Return values:

  | RECT | The widnows rect

long Exponent::MathTools::CRect::getBottom | ( |  | ) | const`[inline]`

Get the bottom

Return values:

  | long | The bottom

Definition at line 175 of file CRect.hpp.

References m_bottom.

Referenced by rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::getCentralXPosition | ( |  | ) | const

Get the central x position

Return values:

  | long | The central x position

long Exponent::MathTools::CRect::getCentralYPosition | ( |  | ) | const

Get the central y position

Return values:

  | long | The central y position

CDimension Exponent::MathTools::CRect::getDimension | ( |  | ) | const`[inline]`

Get the dimension as a point

Return values:

  | CDimension | The width and hight

Definition at line 199 of file CRect.hpp.

References m_height, and m_width.

long Exponent::MathTools::CRect::getHeight | ( |  | ) | const`[inline]`

Get the height

Return values:

  | long | The height

Definition at line 187 of file CRect.hpp.

References m_height.

static void Exponent::MathTools::CRect::getIntersectionArea | ( | const CRect & | rect1,
|  | const CRect & | rect2,
|  | CRect & | output |
| ) |  |  | `[static]`

Get the intersection area of two rectangles

Parameters:

  | rect1 | Rectangle 1
  | rect2 | Rectangle 2
  | output | The intersection area of the two rectangles

static CRect* Exponent::MathTools::CRect::getIntersectionArea | ( | const CRect & | rect1,
|  | const CRect & | rect2 |
| ) |  |  | `[static]`

Get the intersection area of two rectangles

Parameters:

  | rect1 | Rectangle 1
  | rect2 | Rectangle 2

Return values:

  | CRect* | The intersection area of the two rectangles, you become the owner and responsible for deletion

long Exponent::MathTools::CRect::getLeft | ( |  | ) | const`[inline]`

Get the left

Return values:

  | long | The left

Definition at line 157 of file CRect.hpp.

References m_left.

Referenced by rectanglesIntersect(), and rectIsInside().

virtual void Exponent::MathTools::CRect::getObjectDescription | ( | char * | string,
|  | const long | size |
| ) |  |  | const`[virtual]`

Get a description of the object

Parameters:

  | string | On return is filled with the description
  | size | The size of the stirng

CPoint Exponent::MathTools::CRect::getOrigin | ( |  | ) | const`[inline]`

Get the top left as a point

Return values:

  | CPoint | The top left as a point

Definition at line 193 of file CRect.hpp.

References m_left, and m_top.

long Exponent::MathTools::CRect::getRight | ( |  | ) | const`[inline]`

Get the right

Return values:

  | long | The right

Definition at line 163 of file CRect.hpp.

References m_right.

Referenced by rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::getTop | ( |  | ) | const`[inline]`

Get the top

Return values:

  | long | The top

Definition at line 169 of file CRect.hpp.

References m_top.

Referenced by rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::getWidth | ( |  | ) | const`[inline]`

Get the width

Return values:

  | long | The width

Definition at line 181 of file CRect.hpp.

References m_width.

void Exponent::MathTools::CRect::inset | ( | const long | amount | ) |

Inset the position of the rectangle (adds the values to the left and right, and removes it from the width)

Parameters:

  | amount | The amount to inset

__forceinline bool Exponent::MathTools::CRect::isRectangleEmpty | ( |  | ) | const`[inline]`

Is this rectangle empty?

Return values:

  | bool | True if the rectangle is of size 0, false otherwise

Definition at line 284 of file CRect.hpp.

References m_height, m_left, m_top, and m_width.

void Exponent::MathTools::CRect::offset | ( | const CPoint & | point | ) |

Offset the position of the rectangle

Parameters:

  | point | The amount to move the left and top by

virtual CRect& Exponent::MathTools::CRect::operator= | ( | const CRect & | rect | ) | `[virtual]`

Assignment operator

Parameters:

  | rect | The rect to copy

Return values:

  | CRect& | A Reference to this

virtual bool Exponent::MathTools::CRect::operator== | ( | const CRect & | rect | ) | `[virtual]`

Equality operator

Parameters:

  | rect | The rect to compare to

Return values:

  | bool | True if rects are the same, false toherwise

__forceinline bool Exponent::MathTools::CRect::pointIsInside | ( | const CPoint & | point | ) | const`[inline]`

Is the point inside the rectangle

Parameters:

  | point | The point to determine if its inside this rectangle

Return values:

  | bool | True if the point is inside this rectangle, false otherwise

Definition at line 246 of file CRect.hpp.

References Exponent::MathTools::CPoint::getXPosition(), Exponent::MathTools::CPoint::getYPosition(), m_bottom, m_left, m_right, and m_top.

__forceinline bool Exponent::MathTools::CRect::rectanglesIntersect | ( | const CRect & | other | ) | const`[inline]`

Does this rectangle interesect another?

Parameters:

  | other | The other rectangle to check if this intersects with

Return values:

  | bool | True if rectangles intersect, false otherwise

Definition at line 272 of file CRect.hpp.

References getBottom(), getLeft(), getRight(), getTop(), m_bottom, m_left, m_right, and m_top.

__forceinline bool Exponent::MathTools::CRect::rectIsInside | ( | const CRect & | rect | ) | const`[inline]`

Is the rectangle completely inside this rectange

Parameters:

  | rect | The rectangle to determine if its inside this one

Return values:

  | bool | True if rect is completely inside this rectangle, false otherwise

Definition at line 259 of file CRect.hpp.

References getBottom(), getLeft(), getRight(), getTop(), m_bottom, m_left, m_right, and m_top.

void Exponent::MathTools::CRect::scale | ( | const double | amount | ) |

Scale the rect (every value * by the value you give

Parameters:

  | amount | The amount to scale by

void Exponent::MathTools::CRect::setDimensions | ( | const CDimension & | dimension | ) |

Set the dimension

Parameters:

  | dimension | The dimensions of the rect

void Exponent::MathTools::CRect::setFromRect | ( | RECT & | rect | ) |

Set from a window rect

Parameters:

  | rect | The windows rect to copy

void Exponent::MathTools::CRect::setHeight | ( | const long | height | ) |

Set the height

Parameters:

  | height | The height of the rectangle

void Exponent::MathTools::CRect::setLeft | ( | const long | left | ) |

Set the left

Parameters:

  | left | The left position

void Exponent::MathTools::CRect::setOrigin | ( | const CPoint & | point | ) |

Set the origin

Parameters:

  | point | The origin (left,top) point

void Exponent::MathTools::CRect::setRect | ( | const CPoint & | origin,
|  | const CDimension & | dimension |
| ) |  |  |

Set the rectangle

Parameters:

  | origin | The origin of the control
  | dimension | The dimensions of the rect

void Exponent::MathTools::CRect::setRect | ( | const long | left,
|  | const long | top,
|  | const long | width,
|  | const long | height |
| ) |  |  |

Set the entire rectangle

Parameters:

  | left | The left position
  | top | The top position
  | width | The width of the rectangle
  | height | The height of the rectangle

void Exponent::MathTools::CRect::setTop | ( | const long | top | ) |

Set the top

Parameters:

  | top | The top position

void Exponent::MathTools::CRect::setWidth | ( | const long | width | ) |

void Exponent::MathTools::CRect::unionWith | ( | const CRect & | rect | ) |

Union this rectangle with another (creates rectangle the big enough to hold both)

Parameters:

  | rect | The rect to create a union with

## Member Data Documentation

long Exponent::MathTools::CRect::m_bottom`[protected]`

Bottom position of the rectangle

Definition at line 355 of file CRect.hpp.

Referenced by getBottom(), pointIsInside(), rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::m_height`[protected]`

Height of the rectangle

Definition at line 350 of file CRect.hpp.

Referenced by getDimension(), getHeight(), and isRectangleEmpty().

long Exponent::MathTools::CRect::m_left`[protected]`

Left position of the rectangle

Definition at line 352 of file CRect.hpp.

Referenced by getLeft(), getOrigin(), isRectangleEmpty(), pointIsInside(), rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::m_right`[protected]`

Right position of the rectangle

Definition at line 353 of file CRect.hpp.

Referenced by getRight(), pointIsInside(), rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::m_top`[protected]`

Top position of the rectangle

Definition at line 354 of file CRect.hpp.

Referenced by getOrigin(), getTop(), isRectangleEmpty(), pointIsInside(), rectanglesIntersect(), and rectIsInside().

long Exponent::MathTools::CRect::m_width`[protected]`

Width of the rectangel

Definition at line 349 of file CRect.hpp.

Referenced by getDimension(), getWidth(), and isRectangleEmpty().