Original Symbian headers
Selected EUSER, Window Server, networking, graphics and device declarations
Loading...
Searching...
No Matches
TRect Class Reference

Geometric rectangle. More...

#include <e32std.h>

Public Types

enum  TUninitialized { EUninitialized }
 

Public Member Functions

 TRect (TUninitialized)
 Constructs a default rectangle.
 
IMPORT_C TRect ()
 Constructs a default rectangle.
 
IMPORT_C TRect (TInt aAx, TInt aAy, TInt aBx, TInt aBy)
 Constructs the rectangle, initialising its top left and bottom right hand corners with four TInt values.
 
IMPORT_C TRect (const TPoint &aPointA, const TPoint &aPointB)
 Constructs the rectangle with two TPoints, corresponding to its top left and bottom right hand corners.
 
IMPORT_C TRect (const TPoint &aPoint, const TSize &aSize)
 Constructs the rectangle with a TPoint for its top left corner, and a TSize for its width and height.
 
IMPORT_C TRect (const TSize &aSize)
 Constructs the rectangle with a TSize.
 
IMPORT_C TBool operator== (const TRect &aRect) const
 Compares two rectangles for equality.
 
IMPORT_C TBool operator!= (const TRect &aRect) const
 Compares two rectangles for inequality.
 
IMPORT_C void SetRect (TInt aAx, TInt aAy, TInt aBx, TInt aBy)
 Sets the rectangle's position using four TInts.
 
IMPORT_C void SetRect (const TPoint &aPointTL, const TPoint &aPointBR)
 Sets the rectangle's position using two TPoints.
 
IMPORT_C void SetRect (const TPoint &aPoint, const TSize &aSize)
 Sets the rectangle's position using a TPoint and a TSize.
 
IMPORT_C void Move (TInt aDx, TInt aDy)
 Moves the rectangle by adding an x, y offset.
 
IMPORT_C void Move (const TPoint &aOffset)
 Moves the rectangle by adding a TPoint offset.
 
IMPORT_C void Resize (TInt aDx, TInt aDy)
 Resizes a rectangle by adding a horizontal and vertical offset.
 
IMPORT_C void Resize (const TSize &aSize)
 Resizes a rectangle by adding a TSize offset.
 
IMPORT_C void Shrink (TInt aDx, TInt aDy)
 Shrinks a rectangle using specified horizontal and vertical offsets.
 
IMPORT_C void Shrink (const TSize &aSize)
 Shrinks a rectangle using a specified TSize offset.
 
IMPORT_C void Grow (TInt aDx, TInt aDy)
 Grows the rectangle using the specified horizontal and vertical offsets.
 
IMPORT_C void Grow (const TSize &aSize)
 Grows a rectangle using the specified TSize offset.
 
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.
 
IMPORT_C TBool IsEmpty () const
 Tests whether the rectangle is empty.
 
IMPORT_C TBool Intersects (const TRect &aRect) const
 Tests whether this rectangle overlaps with the specified 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.
 
IMPORT_C void Normalize ()
 Ensures that the rectangle's width and height have positive values.
 
IMPORT_C TBool Contains (const TPoint &aPoint) const
 Tests whether a point is located within the rectangle.
 
IMPORT_C TSize Size () const
 Gets the size of the rectangle.
 
IMPORT_C TInt Width () const
 Gets the width of the rectangle.
 
IMPORT_C TInt Height () const
 Gets the height of the rectangle.
 
IMPORT_C TBool IsNormalized () const
 Tests whether the rectangle is normalised.
 
IMPORT_C TPoint Center () const
 Gets the point at the centre of the rectangle.
 
IMPORT_C void SetSize (const TSize &aSize)
 Sets the size of the rectangle.
 
IMPORT_C void SetWidth (TInt aWidth)
 Sets the width of the rectangle.
 
IMPORT_C void SetHeight (TInt aHeight)
 Sets the height of the rectangle.
 

Public Attributes

TPoint iTl
 The x and y co-ordinates of the top left hand corner of the rectangle.
 
TPoint iBr
 The x and y co-ordinates of the bottom right hand corner of the rectangle.
 

Detailed Description

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.

API status
Published to all clients. Released API.

Definition at line 2669 of file e32std.h.

Member Enumeration Documentation

◆ TUninitialized

Enumerator
EUninitialized 

Definition at line 2672 of file e32std.h.

Constructor & Destructor Documentation

◆ TRect() [1/6]

TRect::TRect ( TUninitialized  )
inline

Constructs a default rectangle.

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

Definition at line 2679 of file e32std.h.

◆ TRect() [2/6]

IMPORT_C TRect::TRect ( )

Constructs a default rectangle.

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

(generated from Symbian Developer Library)

◆ TRect() [3/6]

IMPORT_C TRect::TRect ( TInt  aAx,
TInt  aAy,
TInt  aBx,
TInt  aBy 
)

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

Parameters
aAxThe horizontal co-ordinate of the left hand side of the rectangle.
aAyThe vertical co-ordinate of the top of the rectangle.
aBxThe horizontal co-ordinate of the right hand side of the rectangle.
aByThe vertical co-ordinate of the bottom of the rectangle.

(generated from Symbian Developer Library)

◆ TRect() [4/6]

IMPORT_C TRect::TRect ( const TPoint &  aPointA,
const TPoint &  aPointB 
)

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

Parameters
aPointAThe co-ordinates of the rectangle's top left hand corner.
aPointBThe co-ordinates of the rectangle's bottom right hand corner.

(generated from Symbian Developer Library)

◆ TRect() [5/6]

IMPORT_C TRect::TRect ( const TPoint &  aPoint,
const TSize &  aSize 
)

Constructs the rectangle with a TPoint for its top left corner, and a TSize for its width and height.

Parameters
aPointThe rectangle's top left hand corner.
aSizeThe rectangle's width and height.

(generated from Symbian Developer Library)

◆ TRect() [6/6]

IMPORT_C TRect::TRect ( const TSize &  aSize)

Constructs the rectangle with a TSize.

The co-ordinates of its top left hand corner are initialised to (0,0) and its width and height are initialised to the values contained in the argument.

Parameters
aSizeThe width and height of the rectangle.

(generated from Symbian Developer Library)

Member Function Documentation

◆ BoundingRect()

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

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

Parameters
aRectThe rectangle to use with this rectangle to get the minimal bounding rectangle.

(generated from Symbian Developer Library)

◆ Center()

IMPORT_C TPoint TRect::Center ( ) const

Gets the point at the centre of the rectangle.

(generated from Symbian Developer Library)

◆ Contains()

IMPORT_C TBool TRect::Contains ( const TPoint &  aPoint) const

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
aPointThe point to be tested.

(generated from Symbian Developer Library)

◆ Grow() [1/2]

IMPORT_C void TRect::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
aSizeThe 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).

(generated from Symbian Developer Library)

◆ Grow() [2/2]

IMPORT_C void TRect::Grow ( TInt  aDx,
TInt  aDy 
)

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
aDxThe 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.
aDyThe 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.

(generated from Symbian Developer Library)

◆ Height()

IMPORT_C TInt TRect::Height ( ) const

Gets the height of the rectangle.

(generated from Symbian Developer Library)

◆ Intersection()

IMPORT_C void TRect::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.

TRect::Intersects

Parameters
aRectThe rectangle to be used with this rectangle to get the area of intersection.

(generated from Symbian Developer Library)

◆ Intersects()

IMPORT_C TBool TRect::Intersects ( const TRect &  aRect) const

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
aRectThe rectangle to compare with this rectangle for an intersection.

(generated from Symbian Developer Library)

◆ IsEmpty()

IMPORT_C TBool TRect::IsEmpty ( ) const

Tests whether the rectangle is empty.

(generated from Symbian Developer Library)

◆ IsNormalized()

IMPORT_C TBool TRect::IsNormalized ( ) const

Tests whether the rectangle is normalised.

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

(generated from Symbian Developer Library)

◆ Move() [1/2]

IMPORT_C void TRect::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
aOffsetThe number of pixels to move the rectangle; horizontally by aOffset.iX and vertically by aOffset.iY.

(generated from Symbian Developer Library)

◆ Move() [2/2]

IMPORT_C void TRect::Move ( TInt  aDx,
TInt  aDy 
)

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
aDxThe number of pixels to move the rectangle horizontally. If negative, the rectangle moves leftwards.
aDyThe number of pixels to move the rectangle vertically. If negative, the rectangle moves upwards.

(generated from Symbian Developer Library)

◆ Normalize()

IMPORT_C void TRect::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.

(generated from Symbian Developer Library)

◆ operator!=()

IMPORT_C TBool TRect::operator!= ( const TRect &  aRect) const

Compares two rectangles for inequality.

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

Parameters
aRectThe rectangle to compare with this rectangle.

(generated from Symbian Developer Library)

◆ operator==()

IMPORT_C TBool TRect::operator== ( const TRect &  aRect) const

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
aRectThe rectangle to compare with this rectangle.

(generated from Symbian Developer Library)

◆ Resize() [1/2]

IMPORT_C void TRect::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
aSizeThe number of pixels by which to move the rectangle; the right hand side by aSize.iWidth and the bottom by aSize.iHeight.

(generated from Symbian Developer Library)

◆ Resize() [2/2]

IMPORT_C void TRect::Resize ( TInt  aDx,
TInt  aDy 
)

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
aDxThe number of pixels by which to move the right hand side of the rectangle.
aDyThe number of pixels by which to move the bottom of the rectangle.

(generated from Symbian Developer Library)

◆ SetHeight()

IMPORT_C void TRect::SetHeight ( TInt  aHeight)

Sets the height of the rectangle.

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

Parameters
aHeightThe new height of the rectangle.

(generated from Symbian Developer Library)

◆ SetRect() [1/3]

IMPORT_C void TRect::SetRect ( const TPoint &  aPoint,
const TSize &  aSize 
)

Sets the rectangle's position using a TPoint and a TSize.

Parameters
aPointThe co-ordinates of the rectangle's top left hand corner.
aSizeThe rectangle's width and height.

(generated from Symbian Developer Library)

◆ SetRect() [2/3]

IMPORT_C void TRect::SetRect ( const TPoint &  aPointTL,
const TPoint &  aPointBR 
)

Sets the rectangle's position using two TPoints.

Parameters
aPointTLThe co-ordinates of the rectangle's top left hand corner.
aPointBRThe co-ordinates of the rectangle's bottom right hand corner.

(generated from Symbian Developer Library)

◆ SetRect() [3/3]

IMPORT_C void TRect::SetRect ( TInt  aAx,
TInt  aAy,
TInt  aBx,
TInt  aBy 
)

Sets the rectangle's position using four TInts.

Parameters
aAxThe horizontal co-ordinate of the left hand side of the rectangle.
aAyThe vertical co-ordinate of the top of the rectangle.
aBxThe horizontal co-ordinate of the right hand side of the rectangle.
aByThe vertical co-ordinate of the bottom of the rectangle.

(generated from Symbian Developer Library)

◆ SetSize()

IMPORT_C void TRect::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
aSizeThe new width is aSize.iWidth. The new height is aSize.iHeight.

(generated from Symbian Developer Library)

◆ SetWidth()

IMPORT_C void TRect::SetWidth ( TInt  aWidth)

Sets the width of the rectangle.

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

Parameters
aWidthThe new width of the rectangle.

(generated from Symbian Developer Library)

◆ Shrink() [1/2]

IMPORT_C void TRect::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
aSizeThe 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).

(generated from Symbian Developer Library)

◆ Shrink() [2/2]

IMPORT_C void TRect::Shrink ( TInt  aDx,
TInt  aDy 
)

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
aDxThe 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.
aDyThe 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.

(generated from Symbian Developer Library)

◆ Size()

IMPORT_C TSize TRect::Size ( ) const

Gets the size of the rectangle.

(generated from Symbian Developer Library)

◆ Width()

IMPORT_C TInt TRect::Width ( ) const

Gets the width of the rectangle.

(generated from Symbian Developer Library)

Member Data Documentation

◆ iBr

TPoint TRect::iBr

The x and y co-ordinates of the bottom right hand corner of the rectangle.

Definition at line 2723 of file e32std.h.

◆ iTl

TPoint TRect::iTl

The x and y co-ordinates of the top left hand corner of the rectangle.

Definition at line 2718 of file e32std.h.


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