Made the BRect::*Copy() methods const as they should have been.

This commit is contained in:
Axel Dörfler 2012-11-04 14:07:46 +01:00
parent 2267b7e7fb
commit 6643ead593
2 changed files with 88 additions and 27 deletions

View File

@ -1,16 +1,16 @@
/* /*
* Copyright 2001-2009, Haiku, Inc. All rights reserved. * Copyright 2001-2012, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _RECT_H #ifndef _RECT_H
#define _RECT_H #define _RECT_H
#include <math.h>
#include <Point.h> #include <Point.h>
#include <Size.h> #include <Size.h>
#include <math.h>
class BRect { class BRect {
public: public:
@ -54,16 +54,16 @@ public:
// Expression transformations // Expression transformations
BRect& InsetBySelf(BPoint inset); BRect& InsetBySelf(BPoint inset);
BRect& InsetBySelf(float dx, float dy); BRect& InsetBySelf(float dx, float dy);
BRect InsetByCopy(BPoint inset); BRect InsetByCopy(BPoint inset) const;
BRect InsetByCopy(float dx, float dy); BRect InsetByCopy(float dx, float dy) const;
BRect& OffsetBySelf(BPoint offset); BRect& OffsetBySelf(BPoint offset);
BRect& OffsetBySelf(float dx, float dy); BRect& OffsetBySelf(float dx, float dy);
BRect OffsetByCopy(BPoint offset); BRect OffsetByCopy(BPoint offset) const;
BRect OffsetByCopy(float dx, float dy); BRect OffsetByCopy(float dx, float dy) const;
BRect& OffsetToSelf(BPoint offset); BRect& OffsetToSelf(BPoint offset);
BRect& OffsetToSelf(float dx, float dy); BRect& OffsetToSelf(float dx, float dy);
BRect OffsetToCopy(BPoint offset); BRect OffsetToCopy(BPoint offset) const;
BRect OffsetToCopy(float dx, float dy); BRect OffsetToCopy(float dx, float dy) const;
// Comparison // Comparison
bool operator==(BRect r) const; bool operator==(BRect r) const;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved. * Copyright 2001-2012, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@ -80,7 +80,7 @@ BRect::InsetBySelf(float dx, float dy)
BRect BRect
BRect::InsetByCopy(BPoint point) BRect::InsetByCopy(BPoint point) const
{ {
BRect copy(*this); BRect copy(*this);
copy.InsetBy(point); copy.InsetBy(point);
@ -89,7 +89,7 @@ BRect::InsetByCopy(BPoint point)
BRect BRect
BRect::InsetByCopy(float dx, float dy) BRect::InsetByCopy(float dx, float dy) const
{ {
BRect copy(*this); BRect copy(*this);
copy.InsetBy(dx, dy); copy.InsetBy(dx, dy);
@ -134,7 +134,7 @@ BRect::OffsetBySelf(float dx, float dy)
BRect BRect
BRect::OffsetByCopy(BPoint point) BRect::OffsetByCopy(BPoint point) const
{ {
BRect copy(*this); BRect copy(*this);
copy.OffsetBy(point); copy.OffsetBy(point);
@ -143,7 +143,7 @@ BRect::OffsetByCopy(BPoint point)
BRect BRect
BRect::OffsetByCopy(float dx, float dy) BRect::OffsetByCopy(float dx, float dy) const
{ {
BRect copy(*this); BRect copy(*this);
copy.OffsetBy(dx, dy); copy.OffsetBy(dx, dy);
@ -188,7 +188,7 @@ BRect::OffsetToSelf(float dx, float dy)
BRect BRect
BRect::OffsetToCopy(BPoint point) BRect::OffsetToCopy(BPoint point) const
{ {
BRect copy(*this); BRect copy(*this);
copy.OffsetTo(point); copy.OffsetTo(point);
@ -197,7 +197,7 @@ BRect::OffsetToCopy(BPoint point)
BRect BRect
BRect::OffsetToCopy(float dx, float dy) BRect::OffsetToCopy(float dx, float dy) const
{ {
BRect copy(*this); BRect copy(*this);
copy.OffsetTo(dx, dy); copy.OffsetTo(dx, dy);
@ -268,3 +268,64 @@ BRect::Contains(BRect rect) const
return rect.left >= left && rect.right <= right return rect.left >= left && rect.right <= right
&& rect.top >= top && rect.bottom <= bottom; && rect.top >= top && rect.bottom <= bottom;
} }
// #pragma mark - BeOS compatibility only
#if __GNUC__ == 2
extern "C" BRect
InsetByCopy__5BRectG6BPoint(BRect* self, BPoint point)
{
BRect copy(*self);
copy.InsetBy(point);
return copy;
}
extern "C" BRect
InsetByCopy__5BRectff(BRect* self, float dx, float dy)
{
BRect copy(*self);
copy.InsetBy(dx, dy);
return copy;
}
extern "C" BRect
OffsetByCopy__5BRectG6BPoint(BRect* self, BPoint point)
{
BRect copy(*self);
copy.OffsetBy(point);
return copy;
}
extern "C" BRect
OffsetByCopy__5BRectff(BRect* self, float dx, float dy)
{
BRect copy(*self);
copy.OffsetBy(dx, dy);
return copy;
}
extern "C" BRect
OffsetToCopy__5BRectG6BPoint(BRect* self, BPoint point)
{
BRect copy(*self);
copy.OffsetTo(point);
return copy;
}
extern "C" BRect
OffsetToCopy__5BRectff(BRect* self, float dx, float dy)
{
BRect copy(*self);
copy.OffsetTo(dx, dy);
return copy;
}
#endif // __GNUC__ == 2