2 * Copyright 2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus, superstippi@gmx.de
7 * Stefano Ceccherini, burton666@libero.it
8 * John Scipione, jscipione@gmail.com
11 * headers/os/interface/Region.h hrev47312
12 * src/kits/interface/Region.cpp hrev47312
20 \brief BRegion class definition.
28 \brief An area composed of rectangles.
30 The rectangles do not need to overlap. This class is useful for creating
33 \warning BRegion is designed to be used with integral coordinates only.
40 \fn BRegion::BRegion()
41 \brief Initializes an empty region. The region contains no rectangles,
42 and its bounds are invalid.
49 \fn BRegion::BRegion(const BRegion& other)
50 \brief Initializes a region as a copy of \a other.
52 \param other The region to copy.
59 \fn BRegion::BRegion(const BRect rect)
60 \brief Initializes a region to contain a \a rect.
62 \param rect The BRect to add to the region.
69 \fn BRegion::BRegion(const clipping_rect& clipping)
70 \brief Initializes a region to contain a clipping_rect.
72 \param clipping The clipping_rect to set the region to, already in
80 \fn BRegion::~BRegion()
81 \brief Destroys the BRegion freeing any memory allocated by it.
96 \fn BRegion& BRegion::operator=(const BRegion& other)
97 \brief Modifies the BRegion to be a copy of \a other.
99 \param other the BRegion to copy.
101 \return This method always returns \c *this.
108 \fn bool BRegion::operator==(const BRegion& other) const
109 \brief Compares this region to \a other by value.
111 \param other the BRegion to compare to.
113 \return \c true if the regions are the same, \c false otherwise.
123 \fn void BRegion::Set(BRect rect)
124 \brief Set the region to bounds of \a newBounds.
126 \param rect The BRect to set the bounds to.
133 \fn void BRegion::Set(clipping_rect clipping)
134 \brief Set the region to the bounds of \a clipping_rect.
136 \param clipping The clipping_rect to set the bounds to.
143 \fn BRect BRegion::Frame() const
144 \brief Returns a rectangle that encloses the BRegion.
146 \return A BRect that encloses the BRegion.
153 \fn clipping_rect BRegion::FrameInt() const
154 \brief Returns the bounds of the region as a clipping_rect
155 (which has integer coordinates).
157 \return The clipping_rect which represents the region's bounds.
164 \fn BRect BRegion::RectAt(int32 index)
165 \brief Returns the rectangle contained in the region at the given \a index.
167 \param index The index of the BRect to retreive.
169 \return If the given index is valid, it returns the BRect at that index,
170 otherwise, it returns an invalid BRect.
177 \fn BRect BRegion::RectAt(int32 index) const
178 \brief Returns the rectangle contained in the region at the given \a index.
180 \param index The index of the BRect to retreive. (zero based)
182 \return If the given index is valid, it returns the BRect at that index,
183 otherwise, it returns an invalid BRect.
190 fn clipping_rect BRegion::RectAtInt(int32 index)
191 \brief Returns the clipping_rect contained in the region at the given
194 \param index The index of the clipping_rect to retrieve. (zero based)
196 \return If the given index is valid, it returns the clipping_rect at that
197 index, otherwise, it returns an invalid clipping_rect.
204 \fn clipping_rect BRegion::RectAtInt(int32 index) const
205 \brief Returns the clipping_rect contained in the region at the given
208 \param index The index of the clipping_rect to retrieve. (zero based)
210 \return If the given index is valid, it returns the clipping_rect at that
211 index, otherwise, it returns an invalid clipping_rect.
218 \fn int32 BRegion::CountRects()
219 \brief Returns the number of rectangles contained in the region.
221 \return The number of rectangles in the region as an int32.
228 \fn int32 BRegion::CountRects() const
229 \brief Returns the number of rectangles contained in the region.
231 \return The number of rectangles in the region as an int32.
238 \fn bool BRegion::Intersects(BRect rect) const
239 \brief Returns whether or not the region has any area in common with
242 \param rect The BRect to check the region against.
244 \return \c true if the region has any area in common with the BRect,
252 \fn bool BRegion::Intersects(clipping_rect clipping) const
253 \brief Returns whether or not the region has any area in common with
256 \param clipping The clipping_rect to check the region against.
258 \return \c true if the region has any area in common with the
259 clipping_rect, \c false if not.
266 \fn bool BRegion::Contains(BPoint point) const
267 \brief Returns whether or not if the region contains the given \a point.
269 \param point The \a point to check.
271 \return \c true if the region contains the \a point, \c false if not.
278 \fn bool BRegion::Contains(int32 x, int32 y)
279 \brief Returns whether or not the region contains the given coordinates.
281 \param x The \c x coordinate of the point to check.
282 \param y The \c y coordinate of the point to check.
284 \return \c true if the region contains the point, \c false if not.
291 \fn bool BRegion::Contains(int32 x, int32 y) const
292 \brief Return whether or not the region contains the given coordinates.
294 \param x The \c x coordinate of the point to check.
295 \param y The \c y coordinate of the point to check.
297 \return \c true if the region contains the point, \c false if not.
304 \fn void BRegion::PrintToStream() const
305 \brief Prints each rect in the the BRegion to standard output.
312 \fn void BRegion::OffsetBy(const BPoint& point)
313 \brief Applies the given offsets given by the x and y coordinates of
314 \a point to each rectangle contained in the region and recalculates
317 \param point The point to get the coordinates to offset by.
324 \fn void BRegion::OffsetBy(int32 x, int32 y)
325 \brief Applies the given \a x and \a y offsets to each rectangle contained
326 in the region and recalculates the region's bounds.
328 \param x The horizontal offset.
329 \param y The vertical offset.
336 \fn void BRegion::ScaleBy(BSize scale)
337 \brief Resize each of the contained rectangles by the given factor
338 and recalculates the region's bounds.
340 \param scale The scale factor
347 \fn void BRegion::ScaleBy(float x, float y)
348 \brief Resize each of the contained rectangles by the given factors
349 and recalculates the region's bounds.
351 \param x The horizontal scale.
352 \param y The vertical scale.
359 \fn void BRegion::MakeEmpty()
360 \brief Empties the region so that it doesn't containt any rects, and
361 invalidates its bounds.
368 \fn void BRegion::Include(BRect rect)
369 \brief Modifies the region so that it includes the given \a rect.
371 \param rect The BRect to include in the region.
378 \fn void BRegion::Include(clipping_rect clipping)
379 \brief Modifies the region so that it includes the given \a clipping
382 \param clipping The clipping_rect to include in the region.
389 \fn void BRegion::Include(const BRegion* region)
390 \brief Modifies the region to include the area of the given \a region.
392 \param region The \a region to be included.
399 \fn void BRegion::Exclude(BRect rect)
400 \brief Modifies the region excluding the area of the given \a rect.
402 \param rect The BRect to be excluded.
409 \fn void BRegion::Exclude(clipping_rect clipping)
410 \brief Modifies the region excluding the area of the given \a clipping
413 \param clipping The clipping_rect to be excluded.
420 \fn void BRegion::Exclude(const BRegion* region)
421 \brief Modifies the region excluding the area contained by the given
424 \param region The BRegion to be excluded.
431 \fn void BRegion::IntersectWith(const BRegion* region)
432 \brief Modifies the region, so that it will contain only the area
433 in common with \a region.
435 \param region the BRegion to intersect with.
442 \fn void BRegion::ExclusiveInclude(const BRegion* region)
443 \brief Modifies the region so that it contains only the area
444 which the BRegion and \a region do NOT have in common.
446 \param region the BRegion to exclusively include.