TRegion Class Reference

class TRegion

Clipping region - abstract base class.

This abstract base class represents a 2-dimensional area which is used by Graphics, the graphics window server, and the text window server to define regions of the display which need to be updated, or regions within which all operations must occur.

A TRegion is defined in terms of an array of TRects and the more complex the region, the more TRects are required to represent it.

A clipping region initially has space allocated for five rectangles. If manipulations result in a region which requires more than this, an attempt is made to allocate more rectangles. If this cannot be done, an error flag is set, and all subsequent operations involving the region have no effect (except possibly to propagate the error flag to other regions). The CheckError() member function allows the error flag to be tested; Clear() can be used to clear it.

The redraw logic of application programs may use the TRegion in various ways:

1. minimally, they pass it to the graphics context as the clipping region; when a graphics context is activated to a window, the clipping region is set up automatically

2. if they wish to avoid redrawing objects which are outside the general area of the region, they may use TRegion::BoundingRect() to return the rectangle which bounds the clipping region, and draw only primitives that lie within that rectangle

3. if they wish to exercise finer control, they may extract the individual rectangles that comprise the clipping region using Operator[]().

Application programs may also manipulate clipping regions in order to constrain parts of their redrawing to narrower areas of the screen than the clipping region offered by the window server. To do this, functions that allow clipping region manipulation may be used; for example, adding or removing rectangles or finding the intersection or union of two regions.

Public Member Functions
IMPORT_C voidAddRect(const TRect &)
IMPORT_C TRectBoundingRect()
TBool CheckError()
IMPORT_C voidClear()
IMPORT_C voidClipRect(const TRect &)
IMPORT_C TBoolContains(const TPoint &)
IMPORT_C voidCopy(const TRegion &)
TInt Count()
IMPORT_C voidForceError()
IMPORT_C voidIntersect(const TRegion &)
IMPORT_C voidIntersection(const TRegion &, const TRegion &)
IMPORT_C TBoolIntersects(const TRect &)
IMPORT_C TBoolIsContainedBy(const TRect &)
IMPORT_C TBoolIsEmpty()
IMPORT_C voidOffset(TInt, TInt)
IMPORT_C voidOffset(const TPoint &)
const TRect *RectangleList()
IMPORT_C TIntSort()
IMPORT_C TIntSort(const TPoint &)
IMPORT_C voidSubRect(const TRect &, TRegion *)
IMPORT_C voidSubRegion(const TRegion &, TRegion *)
IMPORT_C voidTidy()
IMPORT_C voidUnion(const TRegion &)
IMPORT_C const TRect &operator[](TInt)
Protected Member Functions
TRegion(TInt)
TRegion()
voidAppendRect(const TRect &)
voidAppendRegion(TRegion &)
voidDeleteRect(TRect *)
TRect *ExpandRegion(TInt)
voidMergeRect(const TRect &, TBool)
IMPORT_C TRect *RectangleListW()
TBool SetListSize(TInt)
voidShrinkRegion()
voidSubtractRegion(const TRegion &, TRegion *)
Protected Attributes
TInt iAllocedRects
TInt iCount
TBool iError

Constructor & Destructor Documentation

TRegion(TInt)

IMPORT_CTRegion(TIntaAllocedRects)[protected]

Parameters

TInt aAllocedRects

TRegion()

TRegion()[protected, inline]

Member Functions Documentation

AddRect(const TRect &)

IMPORT_C voidAddRect(const TRect &aRect)

Parameters

const TRect & aRect

AppendRect(const TRect &)

voidAppendRect(const TRect &aRect)[protected]

Parameters

const TRect & aRect

AppendRegion(TRegion &)

voidAppendRegion(TRegion &aRegion)[protected]

Parameters

TRegion & aRegion

BoundingRect()

IMPORT_C TRectBoundingRect()const

CheckError()

TBool CheckError()const [inline]

Tests whether the region's error flag is set.

The error flag may be set:

1. when an attempt to allocate more memory for the region fails

2. if an attempt is made to expand a fixed size region beyond its allocated size

3. if ForceError() has been called.

Use Clear() to unset the error flag, clear the region and free all allocated memory.

True, if the error flag is set; false, otherwise.

TRegion::ForceError

TRegion::Clear

Clear()

IMPORT_C voidClear()

ClipRect(const TRect &)

IMPORT_C voidClipRect(const TRect &aRect)

Parameters

const TRect & aRect

Contains(const TPoint &)

IMPORT_C TBoolContains(const TPoint &aPoint)const

Parameters

const TPoint & aPoint

Copy(const TRegion &)

IMPORT_C voidCopy(const TRegion &aRegion)

Parameters

const TRegion & aRegion

Count()

TInt Count()const [inline]

Gets the number of rectangles in this region.

The number of rectangles.

DeleteRect(TRect *)

voidDeleteRect(TRect *aRect)[protected]

Parameters

TRect * aRect

ExpandRegion(TInt)

TRect *ExpandRegion(TIntaCount)[protected]

Parameters

TInt aCount

ForceError()

IMPORT_C voidForceError()

Intersect(const TRegion &)

IMPORT_C voidIntersect(const TRegion &aRegion)

Parameters

const TRegion & aRegion

Intersection(const TRegion &, const TRegion &)

IMPORT_C voidIntersection(const TRegion &aRegion,
const TRegion &aRegion2
)

Parameters

const TRegion & aRegion
const TRegion & aRegion2

Intersects(const TRect &)

IMPORT_C TBoolIntersects(const TRect &aRect)const

Parameters

const TRect & aRect

IsContainedBy(const TRect &)

IMPORT_C TBoolIsContainedBy(const TRect &aRect)const

Parameters

const TRect & aRect

IsEmpty()

IMPORT_C TBoolIsEmpty()const

MergeRect(const TRect &, TBool)

voidMergeRect(const TRect &aRect,
TBoolaEnclosed
)[protected]

Parameters

const TRect & aRect
TBool aEnclosed

Offset(TInt, TInt)

IMPORT_C voidOffset(TIntaXoffset,
TIntaYoffset
)

Parameters

TInt aXoffset
TInt aYoffset

Offset(const TPoint &)

IMPORT_C voidOffset(const TPoint &aOffset)

Parameters

const TPoint & aOffset

RectangleList()

const TRect *RectangleList()const [inline]

Gets a pointer to the array of rectangles defining this region.

Pointer to the array of rectangles. Note that array is a standard C++ array, i.e. a concatenated set of TRect objects. Use Count() to get the number of rectangles.

TRegion::Count

RectangleListW()

IMPORT_C TRect *RectangleListW()[protected]

SetListSize(TInt)

TBool SetListSize(TIntaCount)[protected]

Parameters

TInt aCount

ShrinkRegion()

voidShrinkRegion()[protected]

Sort()

IMPORT_C TIntSort()

Sort(const TPoint &)

IMPORT_C TIntSort(const TPoint &aOffset)

Parameters

const TPoint & aOffset

SubRect(const TRect &, TRegion *)

IMPORT_C voidSubRect(const TRect &aRect,
TRegion *aSubtractedRegion = NULL
)

Parameters

const TRect & aRect
TRegion * aSubtractedRegion = NULL

SubRegion(const TRegion &, TRegion *)

IMPORT_C voidSubRegion(const TRegion &aRegion,
TRegion *aSubtractedRegion = NULL
)

Parameters

const TRegion & aRegion
TRegion * aSubtractedRegion = NULL

SubtractRegion(const TRegion &, TRegion *)

voidSubtractRegion(const TRegion &aRegion,
TRegion *aSubtractedRegion = NULL
)[protected]

Parameters

const TRegion & aRegion
TRegion * aSubtractedRegion = NULL

Tidy()

IMPORT_C voidTidy()

Union(const TRegion &)

IMPORT_C voidUnion(const TRegion &aRegion)

Parameters

const TRegion & aRegion

operator[](TInt)

IMPORT_C const TRect &operator[](TIntaIndex)const

Parameters

TInt aIndex

Member Data Documentation

TInt iAllocedRects

TInt iAllocedRects[protected]

TInt iCount

TInt iCount[protected]

TBool iError

TBool iError[protected]