From 3c7dd7c3464c0575f7c0616556967d9acb3ebb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 28 Jul 2008 18:50:07 +0000 Subject: [PATCH] Added const versions of the methods that should have been declared like that from the start. Please review for possible binary compatibility problems! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26663 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/Region.h | 14 +++++++---- src/kits/interface/Region.cpp | 44 +++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/headers/os/interface/Region.h b/headers/os/interface/Region.h index 37821451c1..9096260048 100644 --- a/headers/os/interface/Region.h +++ b/headers/os/interface/Region.h @@ -31,7 +31,7 @@ class BRegion { BRegion(const BRect rect); virtual ~BRegion(); - BRegion &operator=(const BRegion &from); + BRegion &operator=(const BRegion &from); void Set(BRect newBounds); void Set(clipping_rect newBounds); @@ -39,16 +39,20 @@ class BRegion { BRect Frame() const; clipping_rect FrameInt() const; - BRect RectAt(int32 index) /*const*/; - clipping_rect RectAtInt(int32 index) /*const*/; + BRect RectAt(int32 index); + BRect RectAt(int32 index) const; + clipping_rect RectAtInt(int32 index); + clipping_rect RectAtInt(int32 index) const; - int32 CountRects() /*const*/; + int32 CountRects(); + int32 CountRects() const; bool Intersects(BRect rect) const; bool Intersects(clipping_rect rect) const; bool Contains(BPoint point) const; - bool Contains(int32 x, int32 y) /*const*/; + bool Contains(int32 x, int32 y); + bool Contains(int32 x, int32 y) const; void PrintToStream() const; diff --git a/src/kits/interface/Region.cpp b/src/kits/interface/Region.cpp index 4e44edb894..737eb0a1cc 100644 --- a/src/kits/interface/Region.cpp +++ b/src/kits/interface/Region.cpp @@ -167,13 +167,20 @@ BRegion::FrameInt() const } +BRect +BRegion::RectAt(int32 index) +{ + return const_cast(this)->RectAt(index); +} + + /*! \brief Returns the regions's BRect at the given index. \param index The index (zero based) of the wanted rectangle. \return If the given index is valid, it returns the BRect at that index, otherwise, it returns an invalid BRect. */ BRect -BRegion::RectAt(int32 index) /*const*/ +BRegion::RectAt(int32 index) const { if (index >= 0 && index < fCount) { const clipping_rect& r = fData[index]; @@ -185,13 +192,20 @@ BRegion::RectAt(int32 index) /*const*/ } +clipping_rect +BRegion::RectAtInt(int32 index) +{ + return const_cast(this)->RectAtInt(index); +} + + /*! \brief Returns the regions's clipping_rect at the given index. \param index The index (zero based) of the wanted rectangle. \return If the given index is valid, it returns the clipping_rect at that index, otherwise, it returns an invalid clipping_rect. */ clipping_rect -BRegion::RectAtInt(int32 index) /*const*/ +BRegion::RectAtInt(int32 index) const { if (index >= 0 && index < fCount) { const clipping_rect& r = fData[index]; @@ -207,7 +221,17 @@ BRegion::RectAtInt(int32 index) /*const*/ \return An int32 which is the total number of rects in the region. */ int32 -BRegion::CountRects() /*const*/ +BRegion::CountRects() +{ + return fCount; +} + + +/*! \brief Counts the region rects. + \return An int32 which is the total number of rects in the region. +*/ +int32 +BRegion::CountRects() const { return fCount; } @@ -261,7 +285,19 @@ BRegion::Contains(BPoint point) const \return \ctrue if the region contains the point, \cfalse if not. */ bool -BRegion::Contains(int32 x, int32 y) /*const*/ +BRegion::Contains(int32 x, int32 y) +{ + return Support::XPointInRegion(this, x, y); +} + + +/*! \brief Check if the region contains the given coordinates. + \param x The \cx coordinate of the point to be checked. + \param y The \cy coordinate of the point to be checked. + \return \ctrue if the region contains the point, \cfalse if not. +*/ +bool +BRegion::Contains(int32 x, int32 y) const { return Support::XPointInRegion(this, x, y); }