#include <e32std.h>

class TRect |

Public Attributes | |
---|---|

TPoint | iBr |

TPoint | iTl |

Public Member Enumerations | |
---|---|

enum | TUninitialized { EUninitialized } |

Public Member Functions | |
---|---|

TRect(TUninitialized) | |

TRect() | |

TRect(TInt, TInt, TInt, TInt) | |

TRect(const TPoint &, const TPoint &) | |

TRect(const TPoint &, const TSize &) | |

TRect(const TSize &) | |

IMPORT_C void | BoundingRect(const TRect &) |

IMPORT_C TPoint | Center() |

IMPORT_C TBool | Contains(const TPoint &) |

IMPORT_C void | Grow(TInt, TInt) |

IMPORT_C void | Grow(const TSize &) |

IMPORT_C TInt | Height() |

IMPORT_C void | Intersection(const TRect &) |

IMPORT_C TBool | Intersects(const TRect &) |

IMPORT_C TBool | IsEmpty() |

IMPORT_C TBool | IsNormalized() |

IMPORT_C void | Move(TInt, TInt) |

IMPORT_C void | Move(const TPoint &) |

IMPORT_C void | Normalize() |

IMPORT_C void | Resize(TInt, TInt) |

IMPORT_C void | Resize(const TSize &) |

IMPORT_C void | SetHeight(TInt) |

IMPORT_C void | SetRect(TInt, TInt, TInt, TInt) |

IMPORT_C void | SetRect(const TPoint &, const TPoint &) |

IMPORT_C void | SetRect(const TPoint &, const TSize &) |

IMPORT_C void | SetSize(const TSize &) |

IMPORT_C void | SetWidth(TInt) |

IMPORT_C void | Shrink(TInt, TInt) |

IMPORT_C void | Shrink(const TSize &) |

IMPORT_C TSize | Size() |

IMPORT_C TInt | Width() |

IMPORT_C TBool | operator!=(const TRect &) |

IMPORT_C TBool | operator==(const TRect &) |

Geometric rectangle.

The class represents a rectangle whose sides are parallel with the axes of the co-ordinate system.

The co-ordinates of the top-left and bottom-right corners are used to set the dimensions of the rectangle. The bottom right co-ordinate is outside the rectangle. Thus TRect(TPoint(2,2),TSize(4,4)) is equal to TRect(TPoint(2,2),TPoint(6,6)), and in both cases you get a 4x4 pixel rectangle on the screen.

Functions are provided to initialise and manipulate the rectangle and to extract information about it.

Enumerator | Value | Description |
---|---|---|

EUninitialized |

TRect | ( | TUninitialized | ) | [inline] |

Constructs a default rectangle.

This initialises the co-ordinates of its top left and bottom right corners to (0,0).

IMPORT_C | TRect | ( | ) |

Constructs a default rectangle.

This initialises the co-ordinates of its top left and bottom right corners to (0,0).

Constructs the rectangle, initialising its top left and bottom right hand corners with four TInt values.

Parameters | |
---|---|

aAx | The horizontal co-ordinate of the left hand side of the rectangle. |

aAy | The vertical co-ordinate of the top of the rectangle. |

aBx | The horizontal co-ordinate of the right hand side of the rectangle. |

aBy | The vertical co-ordinate of the bottom of the rectangle. |

Constructs the rectangle with two TPoints, corresponding to its top left and bottom right hand corners.

Parameters | |
---|---|

aPointA | The co-ordinates of the rectangle's top left hand corner. |

aPointB | The co-ordinates of the rectangle's bottom right hand corner. |

IMPORT_C void | BoundingRect | ( | const TRect & | aRect | ) |

Gets the minimal rectangle which bounds both this rectangle and the specified rectangle, and assigns it to this rectangle.

Parameters | |
---|---|

aRect | The rectangle to use with this rectangle to get the minimal bounding rectangle. |

IMPORT_C TPoint | Center | ( | ) | const |

Gets the point at the centre of the rectangle.

- Return Value
- The point at the centre of the rectangle.

Tests whether a point is located within the rectangle.

Note that a point located on the top or left hand side of the rectangle is within the rectangle. A point located on the right hand side or bottom is considered to be outside the rectangle.

Parameters | |
---|---|

aPoint | The point to be tested. |

- Return Value
- True, if the point is within the rectangle; false, otherwise.

Grows the rectangle using the specified horizontal and vertical offsets.

The offset values are subtracted from the co-ordinates of its top left hand corner, and the same values are added to the co-ordinates of its bottom right hand corner. The co-ordinates of the centre of the rectangle remain unchanged. If either value is negative, the rectangle shrinks in the corresponding direction.

Parameters | |
---|---|

aDx | The number of pixels by which to move the left and right hand sides of the rectangle. A positive value increases the width, a negative value reduces it. |

aDy | The number of pixels by which to move the top and bottom of the rectangle. A positive value increases the height, a negative value reduces it. |

IMPORT_C void | Grow | ( | const TSize & | aSize | ) |

Grows a rectangle using the specified TSize offset.

The rectangle grows by twice the value of the height and width specified in the TSize. The co-ordinates of the centre of the rectangle remain unchanged. If either value is negative, the rectangle shrinks in the corresponding direction.

Parameters | |
---|---|

aSize | The number of pixels by which to move the left and right hand sides of the rectangle (by aSize.iWidth) and the top and bottom (by aSize.iHeight). |

IMPORT_C TInt | Height | ( | ) | const |

Gets the height of the rectangle.

- Return Value
- The height of the rectangle.

IMPORT_C void | Intersection | ( | const TRect & | aRect | ) |

Gets the area of intersection between this rectangle and the specified rectangle, and assigns it to this rectangle.

It is usual to call TRect::Intersects() first to verify whether the two rectangles intersect. If the two rectangles do not intersect, then, on return, this rectangle is set to be empty.

See also: TRect::Intersects

Parameters | |
---|---|

aRect | The rectangle to be used with this rectangle to get the area of intersection. |

Tests whether this rectangle overlaps with the specified rectangle.

Two rectangles overlap if any point is located within both rectangles. There is no intersection if two adjacent sides touch without overlapping, or if either rectangle is empty.

Parameters | |
---|---|

aRect | The rectangle to compare with this rectangle for an intersection. |

- Return Value
- True, if the two rectangles overlap; false, if there is no overlap.

IMPORT_C TBool | IsEmpty | ( | ) | const |

Tests whether the rectangle is empty.

- Return Value
- True, if empty; false, if not.

IMPORT_C TBool | IsNormalized | ( | ) | const |

Tests whether the rectangle is normalised.

A rectangle is normalised when its width and height are both zero or greater.

- Return Value
- True, if normalised; false, if not.

Moves the rectangle by adding an x, y offset.

The offset is added to the co-ordinates of both its top left and bottom right hand corners. The size of the rectangle is unchanged.

Parameters | |
---|---|

aDx | The number of pixels to move the rectangle horizontally. If negative, the rectangle moves leftwards. |

aDy | The number of pixels to move the rectangle vertically. If negative, the rectangle moves upwards. |

IMPORT_C void | Move | ( | const TPoint & | aOffset | ) |

Moves the rectangle by adding a TPoint offset.

The offset is added to the co-ordinates of both its top left and bottom right hand corners. The size of the rectangle is unchanged.

Parameters | |
---|---|

aOffset | The number of pixels to move the rectangle; horizontally by aOffset.iX and vertically by aOffset.iY. |

IMPORT_C void | Normalize | ( | ) |

Ensures that the rectangle's width and height have positive values.

For example, if the rectangle's co-ordinates are such that the top is below the bottom, or the right hand side is to the left of the left hand side, normalisation swaps the co-ordinates of the top and bottom or of the left and right.

Resizes a rectangle by adding a horizontal and vertical offset.

The offset is added to the co-ordinates of its bottom right hand corner. If either value is negative, the rectangle shrinks in the corresponding direction. The co-ordinates of the rectangle's top left hand corner are unaffected.

Parameters | |
---|---|

aDx | The number of pixels by which to move the right hand side of the rectangle. |

aDy | The number of pixels by which to move the bottom of the rectangle. |

IMPORT_C void | Resize | ( | const TSize & | aSize | ) |

Resizes a rectangle by adding a TSize offset.

The offset is added to the co-ordinates of its bottom right hand corner. If either value in the TSize is negative, the rectangle shrinks in the corresponding direction. The co-ordinates of the rectangle's top left hand corner are unaffected.

Parameters | |
---|---|

aSize | The number of pixels by which to move the rectangle; the right hand side by aSize.iWidth and the bottom by aSize.iHeight. |

IMPORT_C void | SetHeight | ( | TInt | aHeight | ) |

Sets the height of the rectangle.

Only the position of the bottom of the rectangle is affected.

Parameters | |
---|---|

aHeight | The new height of the rectangle. |

Sets the rectangle's position using four TInts.

Parameters | |
---|---|

aAx | The horizontal co-ordinate of the left hand side of the rectangle. |

aAy | The vertical co-ordinate of the top of the rectangle. |

aBx | The horizontal co-ordinate of the right hand side of the rectangle. |

aBy | The vertical co-ordinate of the bottom of the rectangle. |

IMPORT_C void | SetSize | ( | const TSize & | aSize | ) |

Sets the size of the rectangle.

Only the co-ordinates of the bottom right hand corner of the rectangle are affected.

Parameters | |
---|---|

aSize | The new width is aSize.iWidth. The new height is aSize.iHeight. |

IMPORT_C void | SetWidth | ( | TInt | aWidth | ) |

Sets the width of the rectangle.

Only the position of the rectangle's right hand side is affected.

Parameters | |
---|---|

aWidth | The new width of the rectangle. |

Shrinks a rectangle using specified horizontal and vertical offsets.

The offset values are added to the co-ordinates of its top left hand corner, and the same values are subtracted from the co-ordinates of its bottom right hand corner. The co-ordinates of the centre of the rectangle remain unchanged. If either value is negative, the rectangle expands in the corresponding direction.

Parameters | |
---|---|

aDx | The number of pixels by which to move the left and right hand sides of the rectangle. A positive value reduces the width, a negative value increases it. |

aDy | The number of pixels by which to move the top and bottom of the rectangle. A positive value reduces the height, a negative value increases it. |

IMPORT_C void | Shrink | ( | const TSize & | aSize | ) |

Shrinks a rectangle using a specified TSize offset.

The rectangle shrinks by twice the value of the height and width specified in the TSize. The co-ordinates of the centre of the rectangle remain unchanged. If either value is negative, the rectangle expands in the corresponding direction.

Parameters | |
---|---|

aSize | The number of pixels by which to move the left and right hand sides of the rectangle (by aSize.iWidth) and the top and bottom (by aSize.iHeight). |

Compares two rectangles for inequality.

Two rectangles are unequal if any of their co-ordinates differ.

Parameters | |
---|---|

aRect | The rectangle to compare with this rectangle. |

- Return Value
- True, if the rectangles do not have the same co-ordinates; false, if all co-ordinates are equal.

Compares two rectangles for equality.

For two rectangles to be equal, the co-ordinates of both their top left and bottom right hand corners must be equal.

Parameters | |
---|---|

aRect | The rectangle to compare with this rectangle. |

- Return Value
- True, if the rectangles have the same co-ordinates; false, otherwise.