2014-06-04 04:28:44 +04:00
|
|
|
/*
|
2014-06-04 19:56:12 +04:00
|
|
|
* Copyright 2014 Haiku, Inc. All rights reserved.
|
2014-06-04 04:28:44 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Stephan Aßmus, superstippi@gmx.de
|
|
|
|
* Stefano Ceccherini, burton666@libero.it
|
|
|
|
* John Scipione, jscipione@gmail.com
|
|
|
|
*
|
|
|
|
* Corresponds to:
|
2014-06-04 19:56:12 +04:00
|
|
|
* headers/os/interface/Region.h hrev47312
|
|
|
|
* src/kits/interface/Region.cpp hrev47312
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file Region.h
|
|
|
|
\ingroup interface
|
|
|
|
\ingroup libbe
|
|
|
|
\brief BRegion class definition.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class BRegion
|
|
|
|
\ingroup interface
|
|
|
|
\ingroup libbe
|
|
|
|
\brief 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.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRegion::BRegion()
|
|
|
|
\brief Initializes an empty region. The region contains no rectangles,
|
|
|
|
and its bounds are invalid.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRegion::BRegion(const BRegion& other)
|
|
|
|
\brief Initializes a region as a copy of \a other.
|
|
|
|
|
|
|
|
\param other The region to copy.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRegion::BRegion(const BRect rect)
|
|
|
|
\brief Initializes a region to contain a \a rect.
|
|
|
|
|
|
|
|
\param rect The BRect to add to the region.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R5
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-04 19:56:12 +04:00
|
|
|
\fn BRegion::BRegion(const clipping_rect& clipping)
|
2014-06-04 04:28:44 +04:00
|
|
|
\brief Initializes a region to contain a clipping_rect.
|
|
|
|
|
2014-06-04 19:56:12 +04:00
|
|
|
\param clipping The clipping_rect to set the region to, already in
|
2014-06-04 04:28:44 +04:00
|
|
|
internal rect format.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRegion::~BRegion()
|
|
|
|
\brief Destroys the BRegion freeing any memory allocated by it.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
/*!
|
|
|
|
\name Operators
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//! @{
|
|
|
|
|
|
|
|
|
2014-06-04 04:28:44 +04:00
|
|
|
/*!
|
|
|
|
\fn BRegion& BRegion::operator=(const BRegion& other)
|
|
|
|
\brief Modifies the BRegion to be a copy of \a other.
|
|
|
|
|
|
|
|
\param other the BRegion to copy.
|
|
|
|
|
|
|
|
\return This method always returns \c *this.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BRegion::operator==(const BRegion& other) const
|
|
|
|
\brief Compares this region to \a other by value.
|
|
|
|
|
|
|
|
\param other the BRegion to compare to.
|
|
|
|
|
|
|
|
\return \c true if the regions are the same, \c false otherwise.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
//! @}
|
|
|
|
|
|
|
|
|
2014-06-04 04:28:44 +04:00
|
|
|
/*!
|
2014-06-14 01:25:02 +04:00
|
|
|
\fn void BRegion::Set(BRect rect)
|
2014-06-04 04:28:44 +04:00
|
|
|
\brief Set the region to bounds of \a newBounds.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\param rect The BRect to set the bounds to.
|
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-06-14 01:25:02 +04:00
|
|
|
\fn void BRegion::Set(clipping_rect clipping)
|
2014-06-04 04:28:44 +04:00
|
|
|
\brief Set the region to the bounds of \a clipping_rect.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\param clipping The clipping_rect to set the bounds to.
|
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRect BRegion::Frame() const
|
2014-06-14 01:25:02 +04:00
|
|
|
\brief Returns a rectangle that encloses the BRegion.
|
|
|
|
|
|
|
|
\return A BRect that encloses the BRegion.
|
2014-06-04 04:28:44 +04:00
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn clipping_rect BRegion::FrameInt() const
|
|
|
|
\brief Returns the bounds of the region as a clipping_rect
|
|
|
|
(which has integer coordinates).
|
|
|
|
|
|
|
|
\return The clipping_rect which represents the region's bounds.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRect BRegion::RectAt(int32 index)
|
|
|
|
\brief Returns the rectangle contained in the region at the given \a index.
|
|
|
|
|
|
|
|
\param index The index of the BRect to retreive.
|
|
|
|
|
|
|
|
\return If the given index is valid, it returns the BRect at that index,
|
|
|
|
otherwise, it returns an invalid BRect.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BRect BRegion::RectAt(int32 index) const
|
|
|
|
\brief Returns the rectangle contained in the region at the given \a index.
|
|
|
|
|
|
|
|
\param index The index of the BRect to retreive. (zero based)
|
|
|
|
|
|
|
|
\return If the given index is valid, it returns the BRect at that index,
|
|
|
|
otherwise, it returns an invalid BRect.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
fn clipping_rect BRegion::RectAtInt(int32 index)
|
|
|
|
\brief Returns the clipping_rect contained in the region at the given
|
|
|
|
\a index.
|
|
|
|
|
|
|
|
\param index The index of the clipping_rect to retrieve. (zero based)
|
|
|
|
|
|
|
|
\return If the given index is valid, it returns the clipping_rect at that
|
|
|
|
index, otherwise, it returns an invalid clipping_rect.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn clipping_rect BRegion::RectAtInt(int32 index) const
|
|
|
|
\brief Returns the clipping_rect contained in the region at the given
|
|
|
|
\a index.
|
|
|
|
|
|
|
|
\param index The index of the clipping_rect to retrieve. (zero based)
|
|
|
|
|
|
|
|
\return If the given index is valid, it returns the clipping_rect at that
|
|
|
|
index, otherwise, it returns an invalid clipping_rect.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int32 BRegion::CountRects()
|
|
|
|
\brief Returns the number of rectangles contained in the region.
|
|
|
|
|
|
|
|
\return The number of rectangles in the region as an int32.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn int32 BRegion::CountRects() const
|
|
|
|
\brief Returns the number of rectangles contained in the region.
|
|
|
|
|
|
|
|
\return The number of rectangles in the region as an int32.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BRegion::Intersects(BRect rect) const
|
|
|
|
\brief Returns whether or not the region has any area in common with
|
|
|
|
\a rect.
|
|
|
|
|
|
|
|
\param rect The BRect to check the region against.
|
|
|
|
|
|
|
|
\return \c true if the region has any area in common with the BRect,
|
|
|
|
\c false if not.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BRegion::Intersects(clipping_rect clipping) const
|
|
|
|
\brief Returns whether or not the region has any area in common with
|
|
|
|
\a clipping.
|
|
|
|
|
|
|
|
\param clipping The clipping_rect to check the region against.
|
|
|
|
|
|
|
|
\return \c true if the region has any area in common with the
|
|
|
|
clipping_rect, \c false if not.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BRegion::Contains(BPoint point) const
|
|
|
|
\brief Returns whether or not if the region contains the given \a point.
|
|
|
|
|
|
|
|
\param point The \a point to check.
|
|
|
|
|
|
|
|
\return \c true if the region contains the \a point, \c false if not.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BRegion::Contains(int32 x, int32 y)
|
|
|
|
\brief Returns whether or not the region contains the given coordinates.
|
|
|
|
|
|
|
|
\param x The \c x coordinate of the point to check.
|
|
|
|
\param y The \c y coordinate of the point to check.
|
|
|
|
|
|
|
|
\return \c true if the region contains the point, \c false if not.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn bool BRegion::Contains(int32 x, int32 y) const
|
|
|
|
\brief Return whether or not the region contains the given coordinates.
|
|
|
|
|
|
|
|
\param x The \c x coordinate of the point to check.
|
|
|
|
\param y The \c y coordinate of the point to check.
|
|
|
|
|
|
|
|
\return \c true if the region contains the point, \c false if not.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::PrintToStream() const
|
|
|
|
\brief Prints each rect in the the BRegion to standard output.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::OffsetBy(const BPoint& point)
|
|
|
|
\brief Applies the given offsets given by the x and y coordinates of
|
|
|
|
\a point to each rectangle contained in the region and recalculates
|
|
|
|
the region's bounds.
|
|
|
|
|
|
|
|
\param point The point to get the coordinates to offset by.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::OffsetBy(int32 x, int32 y)
|
|
|
|
\brief Applies the given \a x and \a y offsets to each rectangle contained
|
|
|
|
in the region and recalculates the region's bounds.
|
|
|
|
|
|
|
|
\param x The horizontal offset.
|
|
|
|
\param y The vertical offset.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-06-19 20:40:29 +04:00
|
|
|
/*!
|
|
|
|
\fn void BRegion::ScaleBy(BSize scale)
|
|
|
|
\brief Resize each of the contained rectangles by the given factor
|
|
|
|
and recalculates the region's bounds.
|
|
|
|
|
|
|
|
\param scale The scale factor
|
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::ScaleBy(float x, float y)
|
|
|
|
\brief Resize each of the contained rectangles by the given factors
|
|
|
|
and recalculates the region's bounds.
|
|
|
|
|
|
|
|
\param x The horizontal scale.
|
|
|
|
\param y The vertical scale.
|
|
|
|
|
|
|
|
\since Haiku R1
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2014-06-04 04:28:44 +04:00
|
|
|
/*!
|
|
|
|
\fn void BRegion::MakeEmpty()
|
|
|
|
\brief Empties the region so that it doesn't containt any rects, and
|
|
|
|
invalidates its bounds.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::Include(BRect rect)
|
|
|
|
\brief Modifies the region so that it includes the given \a rect.
|
|
|
|
|
|
|
|
\param rect The BRect to include in the region.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::Include(clipping_rect clipping)
|
|
|
|
\brief Modifies the region so that it includes the given \a clipping
|
|
|
|
rectangle.
|
|
|
|
|
|
|
|
\param clipping The clipping_rect to include in the region.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::Include(const BRegion* region)
|
|
|
|
\brief Modifies the region to include the area of the given \a region.
|
|
|
|
|
|
|
|
\param region The \a region to be included.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::Exclude(BRect rect)
|
|
|
|
\brief Modifies the region excluding the area of the given \a rect.
|
|
|
|
|
|
|
|
\param rect The BRect to be excluded.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::Exclude(clipping_rect clipping)
|
|
|
|
\brief Modifies the region excluding the area of the given \a clipping
|
|
|
|
rectangle.
|
|
|
|
|
|
|
|
\param clipping The clipping_rect to be excluded.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::Exclude(const BRegion* region)
|
|
|
|
\brief Modifies the region excluding the area contained by the given
|
|
|
|
\a region.
|
|
|
|
|
|
|
|
\param region The BRegion to be excluded.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::IntersectWith(const BRegion* region)
|
|
|
|
\brief Modifies the region, so that it will contain only the area
|
|
|
|
in common with \a region.
|
|
|
|
|
|
|
|
\param region the BRegion to intersect with.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since BeOS R3
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BRegion::ExclusiveInclude(const BRegion* region)
|
|
|
|
\brief Modifies the region so that it contains only the area
|
|
|
|
which the BRegion and \a region do NOT have in common.
|
|
|
|
|
|
|
|
\param region the BRegion to exclusively include.
|
|
|
|
|
2014-06-14 01:25:02 +04:00
|
|
|
\since Haiku R1
|
2014-06-04 04:28:44 +04:00
|
|
|
*/
|