Public Member Functions | List of all members
BRegion Class Reference

An area composed of rectangles. More...

Public Member Functions

 BRegion ()
 Initializes an empty region. The region contains no rectangles, and its bounds are invalid. More...
 
 BRegion (const BRegion &other)
 Initializes a region as a copy of other. More...
 
 BRegion (const BRect rect)
 Initializes a region to contain a rect. More...
 
virtual ~BRegion ()
 Destroys the BRegion freeing any memory allocated by it. More...
 
bool Contains (BPoint point) const
 Returns whether or not if the region contains the given point. More...
 
bool Contains (int32 x, int32 y)
 Returns whether or not the region contains the given coordinates. More...
 
bool Contains (int32 x, int32 y) const
 Return whether or not the region contains the given coordinates. More...
 
int32 CountRects ()
 Returns the number of rectangles contained in the region. More...
 
int32 CountRects () const
 Returns the number of rectangles contained in the region. More...
 
void Exclude (BRect rect)
 Modifies the region excluding the area of the given rect. More...
 
void Exclude (clipping_rect clipping)
 Modifies the region excluding the area of the given clipping rectangle. More...
 
void Exclude (const BRegion *region)
 Modifies the region excluding the area contained by the given region. More...
 
void ExclusiveInclude (const BRegion *region)
 Modifies the region so that it contains only the area which the BRegion and region do NOT have in common. More...
 
BRect Frame () const
 Returns a rectangle that encloses the BRegion. More...
 
clipping_rect FrameInt () const
 Returns the bounds of the region as a clipping_rect (which has integer coordinates). More...
 
void Include (BRect rect)
 Modifies the region so that it includes the given rect. More...
 
void Include (clipping_rect clipping)
 Modifies the region so that it includes the given clipping rectangle. More...
 
void Include (const BRegion *region)
 Modifies the region to include the area of the given region. More...
 
bool Intersects (BRect rect) const
 Returns whether or not the region has any area in common with rect. More...
 
bool Intersects (clipping_rect clipping) const
 Returns whether or not the region has any area in common with clipping. More...
 
void IntersectWith (const BRegion *region)
 Modifies the region, so that it will contain only the area in common with region. More...
 
void MakeEmpty ()
 Empties the region so that it doesn't containt any rects, and invalidates its bounds. More...
 
void OffsetBy (const BPoint &point)
 Applies the given offsets given by the x and y coordinates of point to each rectangle contained in the region and recalculates the region's bounds. More...
 
void OffsetBy (int32 x, int32 y)
 Applies the given x and y offsets to each rectangle contained in the region and recalculates the region's bounds. More...
 
void PrintToStream () const
 Prints each rect in the the BRegion to standard output. More...
 
BRect RectAt (int32 index)
 Returns the rectangle contained in the region at the given index. More...
 
BRect RectAt (int32 index) const
 Returns the rectangle contained in the region at the given index. More...
 
clipping_rect RectAtInt (int32 index) const
 Returns the clipping_rect contained in the region at the given index. More...
 
void ScaleBy (BSize scale)
 Resize each of the contained rectangles by the given factor and recalculates the region's bounds. More...
 
void ScaleBy (float x, float y)
 Resize each of the contained rectangles by the given factors and recalculates the region's bounds. More...
 
void Set (BRect rect)
 Set the region to bounds of newBounds. More...
 
void Set (clipping_rect clipping)
 Set the region to the bounds of clipping_rect. More...
 
Operators
BRegionoperator= (const BRegion &other)
 Modifies the BRegion to be a copy of other. More...
 
bool operator== (const BRegion &other) const
 Compares this region to other by value. More...
 

Detailed Description

An area composed of rectangles.

The rectangles do not need to overlap. This class is useful for creating clipping masks.

Warning
BRegion is designed to be used with integral coordinates only.
Since
BeOS R3

Constructor & Destructor Documentation

◆ BRegion() [1/3]

BRegion::BRegion ( )

Initializes an empty region. The region contains no rectangles, and its bounds are invalid.

Since
BeOS R3

◆ BRegion() [2/3]

BRegion::BRegion ( const BRegion other)

Initializes a region as a copy of other.

Parameters
otherThe region to copy.
Since
BeOS R3

◆ BRegion() [3/3]

BRegion::BRegion ( const BRect  rect)

Initializes a region to contain a rect.

Parameters
rectThe BRect to add to the region.
Since
BeOS R5

◆ ~BRegion()

BRegion::~BRegion ( )
virtual

Destroys the BRegion freeing any memory allocated by it.

Since
BeOS R3

Member Function Documentation

◆ Contains() [1/3]

bool BRegion::Contains ( BPoint  point) const

Returns whether or not if the region contains the given point.

Parameters
pointThe point to check.
Returns
true if the region contains the point, false if not.
Since
BeOS R3

◆ Contains() [2/3]

bool BRegion::Contains ( int32  x,
int32  y 
)

Returns whether or not the region contains the given coordinates.

Parameters
xThe x coordinate of the point to check.
yThe y coordinate of the point to check.
Returns
true if the region contains the point, false if not.
Since
Haiku R1

◆ Contains() [3/3]

bool BRegion::Contains ( int32  x,
int32  y 
) const

Return whether or not the region contains the given coordinates.

Parameters
xThe x coordinate of the point to check.
yThe y coordinate of the point to check.
Returns
true if the region contains the point, false if not.
Since
Haiku R1

◆ CountRects() [1/2]

int32 BRegion::CountRects ( )

Returns the number of rectangles contained in the region.

Returns
The number of rectangles in the region as an int32.
Since
BeOS R3

◆ CountRects() [2/2]

int32 BRegion::CountRects ( ) const

Returns the number of rectangles contained in the region.

Returns
The number of rectangles in the region as an int32.
Since
Haiku R1

◆ Exclude() [1/3]

void BRegion::Exclude ( BRect  rect)

Modifies the region excluding the area of the given rect.

Parameters
rectThe BRect to be excluded.
Since
BeOS R3

◆ Exclude() [2/3]

void BRegion::Exclude ( clipping_rect  clipping)

Modifies the region excluding the area of the given clipping rectangle.

Parameters
clippingThe clipping_rect to be excluded.
Since
Haiku R1

◆ Exclude() [3/3]

void BRegion::Exclude ( const BRegion region)

Modifies the region excluding the area contained by the given region.

Parameters
regionThe BRegion to be excluded.
Since
BeOS R3

◆ ExclusiveInclude()

void BRegion::ExclusiveInclude ( const BRegion region)

Modifies the region so that it contains only the area which the BRegion and region do NOT have in common.

Parameters
regionthe BRegion to exclusively include.
Since
Haiku R1

◆ Frame()

BRect BRegion::Frame ( ) const

Returns a rectangle that encloses the BRegion.

Returns
A BRect that encloses the BRegion.
Since
BeOS R3

◆ FrameInt()

clipping_rect BRegion::FrameInt ( ) const

Returns the bounds of the region as a clipping_rect (which has integer coordinates).

Returns
The clipping_rect which represents the region's bounds.
Since
Haiku R1

◆ Include() [1/3]

void BRegion::Include ( BRect  rect)

Modifies the region so that it includes the given rect.

Parameters
rectThe BRect to include in the region.
Since
BeOS R3

◆ Include() [2/3]

void BRegion::Include ( clipping_rect  clipping)

Modifies the region so that it includes the given clipping rectangle.

Parameters
clippingThe clipping_rect to include in the region.
Since
Haiku R1

◆ Include() [3/3]

void BRegion::Include ( const BRegion region)

Modifies the region to include the area of the given region.

Parameters
regionThe region to be included.
Since
BeOS R3

◆ Intersects() [1/2]

bool BRegion::Intersects ( BRect  rect) const

Returns whether or not the region has any area in common with rect.

Parameters
rectThe BRect to check the region against.
Returns
true if the region has any area in common with the BRect, false if not.
Since
BeOS R3

◆ Intersects() [2/2]

bool BRegion::Intersects ( clipping_rect  clipping) const

Returns whether or not the region has any area in common with clipping.

Parameters
clippingThe clipping_rect to check the region against.
Returns
true if the region has any area in common with the clipping_rect, false if not.
Since
Haiku R1

◆ IntersectWith()

void BRegion::IntersectWith ( const BRegion region)

Modifies the region, so that it will contain only the area in common with region.

Parameters
regionthe BRegion to intersect with.
Since
BeOS R3

◆ MakeEmpty()

void BRegion::MakeEmpty ( )

Empties the region so that it doesn't containt any rects, and invalidates its bounds.

Since
BeOS R3

◆ OffsetBy() [1/2]

void BRegion::OffsetBy ( const BPoint point)

Applies the given offsets given by the x and y coordinates of point to each rectangle contained in the region and recalculates the region's bounds.

Parameters
pointThe point to get the coordinates to offset by.
Since
Haiku R1

◆ OffsetBy() [2/2]

void BRegion::OffsetBy ( int32  x,
int32  y 
)

Applies the given x and y offsets to each rectangle contained in the region and recalculates the region's bounds.

Parameters
xThe horizontal offset.
yThe vertical offset.
Since
BeOS R3

◆ operator=()

BRegion & BRegion::operator= ( const BRegion other)

Modifies the BRegion to be a copy of other.

Parameters
otherthe BRegion to copy.
Returns
This method always returns *this.
Since
BeOS R3

◆ operator==()

bool BRegion::operator== ( const BRegion other) const

Compares this region to other by value.

Parameters
otherthe BRegion to compare to.
Returns
true if the regions are the same, false otherwise.
Since
BeOS R3

◆ PrintToStream()

void BRegion::PrintToStream ( ) const

Prints each rect in the the BRegion to standard output.

Since
BeOS R3

◆ RectAt() [1/2]

BRect BRegion::RectAt ( int32  index)

Returns the rectangle contained in the region at the given index.

Parameters
indexThe index of the BRect to retreive.
Returns
If the given index is valid, it returns the BRect at that index, otherwise, it returns an invalid BRect.
Since
BeOS R3

◆ RectAt() [2/2]

BRect BRegion::RectAt ( int32  index) const

Returns the rectangle contained in the region at the given index.

Parameters
indexThe index of the BRect to retreive. (zero based)
Returns
If the given index is valid, it returns the BRect at that index, otherwise, it returns an invalid BRect.
Since
Haiku R1

◆ RectAtInt()

clipping_rect BRegion::RectAtInt ( int32  index) const

Returns the clipping_rect contained in the region at the given index.

fn clipping_rect BRegion::RectAtInt(int32 index)

Parameters
indexThe index of the clipping_rect to retrieve. (zero based)
Returns
If the given index is valid, it returns the clipping_rect at that index, otherwise, it returns an invalid clipping_rect.
Since
Haiku R1

Returns the clipping_rect contained in the region at the given index.

Parameters
indexThe index of the clipping_rect to retrieve. (zero based)
Returns
If the given index is valid, it returns the clipping_rect at that index, otherwise, it returns an invalid clipping_rect.
Since
Haiku R1

◆ ScaleBy() [1/2]

void BRegion::ScaleBy ( BSize  scale)

Resize each of the contained rectangles by the given factor and recalculates the region's bounds.

Parameters
scaleThe scale factor
Since
Haiku R1

◆ ScaleBy() [2/2]

void BRegion::ScaleBy ( float  x,
float  y 
)

Resize each of the contained rectangles by the given factors and recalculates the region's bounds.

Parameters
xThe horizontal scale.
yThe vertical scale.
Since
Haiku R1

◆ Set() [1/2]

void BRegion::Set ( BRect  rect)

Set the region to bounds of newBounds.

Parameters
rectThe BRect to set the bounds to.
Since
BeOS R3

◆ Set() [2/2]

void BRegion::Set ( clipping_rect  clipping)

Set the region to the bounds of clipping_rect.

Parameters
clippingThe clipping_rect to set the bounds to.
Since
Haiku R1