Haiku API Bindings
Region
Not logged in

Documentation | InterfaceKit | Region

SYNOPSIS

Perl

use HaikuR1::Region;

my $region = HaikuR1::Alignment->new($rect);
$region->SetTo($rect2);

Python

from HaikuR1.InterfaceKit import Region

region = Alignment(rect)
region.SetTo(rect2)

DESCRIPTION

Exposes the BRegion object.

A Region is a set of rectangles. Although its interface works with both Rects (which contain floating point numbers) and clipping_rects (which contain integers), internally it stores the rectangles as clipping_rects.

For more information on Region, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates a Region.

Perl

HaikuR1::Region->new($rect);
HaikuR1::Region->new($copy_from);
HaikuR1::Region->new();

Python

Region(rect)
Region(copy_from)
Region()

copy

Copies the contents of another object into this object.

Perl

$region->copy($copy_from);

Python

region.copy(copy_from)

Contains

Returns true if the given Point or coordinate pair lies within the Region.

Perl

$region->Contains($point);
$region->Contains($x, $y);

Python

region.Contains(point)
region.Contains(x, y)

Exclude

Removes the given rectangle or region from this Region.

Perl

$region->Exclude($rect);
$region->Exclude($region);

Python

region.Exclude(rect)
region.Exclude(region)

ExclusiveInclude

Removes all parts of the Region that are in common with the given Region.

Perl

$region->ExclusiveInclude($region);

Python

region.ExclusiveInclude(region)

Frame

FrameInt

Returns the smallest rectangle that completely includes the Region. Frame returns it as a Rect, FrameInt returns it as a clipping_rect.

Perl

$region->Frame();
$region->FrameInt();

Python

region.Frame()
region.FrameInt()

Include

Adds the given rectangle or region to this Region.

Perl

$region->Include($rect);
$region->Include($region);

Python

region.Include(rect)
region.Include(region)

Intersects

Returns true if the Region intersects with the given rectangle.

Perl

$region->Intersects($rect);

Python

region.Intersects(rect)

IntersectWith

Returns the parts of the Region that are in common with the given Region.

Perl

$region->IntersectWith($region);

Python

region.IntersectWith(region)

MakeEmpty

Clears the Region so it contains no rectangles.

Perl

$region->MakeEmpty();

Python

region.MakeEmpty()

OffsetBy

Moves the Region by the given Point or coordinate pair.

Perl

$region->OffsetBy($point);
$region->OffsetBy($x, $y);

Python

region.OffsetBy(point)
region.OffsetBy(x, y)

PrintToStream

Prints the contents to standard out as data[i] = BRect(left, top, right, bottom); one such line is printed for each Rect in the Region's list of Rects, and the Rect's values are constrained to integers.

Perl

$region->PrintToStream();

Python

region.PrintToStream()

Rectangles

CountRects

RectAt

RectAtInt

CountRects returns the number of rectangles in the Region's list of rectangles. RectAt returns the rectagnle at the given index as a Rect, while RectAtInt returns it as a clipping_rect.

Perl

$region->RectAt($index);
$region->RectAtInt($index);

Python

region.RectAt(index)
region.RectAtInt(index)

ScaleBy

Scales the Region by the given Size or pair of scaling factors.

Perl

$region->ScaleBy($scale);
$region->ScaleBy($x, $y);

Python

region.ScaleBy(scale)
region.ScaleBy(x, y)

Set

Sets the contents of the Region.

Perl

$region->Set($rect);

Python

region.Set(rect)

OPERATORS

==

Returns true if the Region objects refer to the same region.

!=

Returns true if the Region objects do not refer to the same region.