Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12954 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6a2575c9d2
commit
a01d14b2db
|
@ -1,5 +1,5 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
// Copyright (c) 2001-2005, Haiku
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -23,125 +23,119 @@
|
|||
// Author: Frans van Nispen (xlr8@tref.nl)
|
||||
// Description: BRect represents a rectangular area.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef _RECT_H
|
||||
#define _RECT_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <math.h>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <SupportDefs.h>
|
||||
#include <Point.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
#include <math.h>
|
||||
|
||||
|
||||
// BRect class -----------------------------------------------------------------
|
||||
class BRect {
|
||||
public:
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
public:
|
||||
float left;
|
||||
float top;
|
||||
float right;
|
||||
float bottom;
|
||||
|
||||
BRect();
|
||||
BRect(const BRect &r);
|
||||
BRect(float l, float t, float r, float b);
|
||||
BRect(BPoint lt, BPoint rb);
|
||||
BRect();
|
||||
BRect(const BRect &r);
|
||||
BRect(float l, float t, float r, float b);
|
||||
BRect(BPoint lt, BPoint rb);
|
||||
|
||||
BRect &operator=(const BRect &r);
|
||||
void Set(float l, float t, float r, float b);
|
||||
BRect &operator=(const BRect &r);
|
||||
void Set(float l, float t, float r, float b);
|
||||
|
||||
void PrintToStream() const;
|
||||
void PrintToStream() const;
|
||||
|
||||
BPoint LeftTop() const;
|
||||
BPoint RightBottom() const;
|
||||
BPoint LeftBottom() const;
|
||||
BPoint RightTop() const;
|
||||
BPoint LeftTop() const;
|
||||
BPoint RightBottom() const;
|
||||
BPoint LeftBottom() const;
|
||||
BPoint RightTop() const;
|
||||
|
||||
void SetLeftTop(const BPoint p);
|
||||
void SetRightBottom(const BPoint p);
|
||||
void SetLeftBottom(const BPoint p);
|
||||
void SetRightTop(const BPoint p);
|
||||
void SetLeftTop(const BPoint p);
|
||||
void SetRightBottom(const BPoint p);
|
||||
void SetLeftBottom(const BPoint p);
|
||||
void SetRightTop(const BPoint p);
|
||||
|
||||
// transformation
|
||||
void InsetBy(BPoint p);
|
||||
void InsetBy(float dx, float dy);
|
||||
void OffsetBy(BPoint p);
|
||||
void OffsetBy(float dx, float dy);
|
||||
void OffsetTo(BPoint p);
|
||||
void OffsetTo(float x, float y);
|
||||
// transformation
|
||||
void InsetBy(BPoint p);
|
||||
void InsetBy(float dx, float dy);
|
||||
void OffsetBy(BPoint p);
|
||||
void OffsetBy(float dx, float dy);
|
||||
void OffsetTo(BPoint p);
|
||||
void OffsetTo(float x, float y);
|
||||
|
||||
// expression transformations
|
||||
BRect & InsetBySelf(BPoint);
|
||||
BRect & InsetBySelf(float dx, float dy);
|
||||
BRect InsetByCopy(BPoint);
|
||||
BRect InsetByCopy(float dx, float dy);
|
||||
BRect & OffsetBySelf(BPoint);
|
||||
BRect & OffsetBySelf(float dx, float dy);
|
||||
BRect OffsetByCopy(BPoint);
|
||||
BRect OffsetByCopy(float dx, float dy);
|
||||
BRect & OffsetToSelf(BPoint);
|
||||
BRect & OffsetToSelf(float dx, float dy);
|
||||
BRect OffsetToCopy(BPoint);
|
||||
BRect OffsetToCopy(float dx, float dy);
|
||||
// expression transformations
|
||||
BRect& InsetBySelf(BPoint);
|
||||
BRect& InsetBySelf(float dx, float dy);
|
||||
BRect InsetByCopy(BPoint);
|
||||
BRect InsetByCopy(float dx, float dy);
|
||||
BRect& OffsetBySelf(BPoint);
|
||||
BRect& OffsetBySelf(float dx, float dy);
|
||||
BRect OffsetByCopy(BPoint);
|
||||
BRect OffsetByCopy(float dx, float dy);
|
||||
BRect& OffsetToSelf(BPoint);
|
||||
BRect& OffsetToSelf(float dx, float dy);
|
||||
BRect OffsetToCopy(BPoint);
|
||||
BRect OffsetToCopy(float dx, float dy);
|
||||
|
||||
// comparison
|
||||
bool operator==(BRect r) const;
|
||||
bool operator!=(BRect r) const;
|
||||
// comparison
|
||||
bool operator==(BRect r) const;
|
||||
bool operator!=(BRect r) const;
|
||||
|
||||
// intersection and union
|
||||
BRect operator&(BRect r) const;
|
||||
BRect operator|(BRect r) const;
|
||||
|
||||
bool Intersects(BRect r) const;
|
||||
bool IsValid() const;
|
||||
float Width() const;
|
||||
int32 IntegerWidth() const;
|
||||
float Height() const;
|
||||
int32 IntegerHeight() const;
|
||||
bool Contains(BPoint p) const;
|
||||
bool Contains(BRect r) const;
|
||||
// intersection and union
|
||||
BRect operator&(BRect r) const;
|
||||
BRect operator|(BRect r) const;
|
||||
|
||||
bool Intersects(BRect r) const;
|
||||
bool IsValid() const;
|
||||
float Width() const;
|
||||
int32 IntegerWidth() const;
|
||||
float Height() const;
|
||||
int32 IntegerHeight() const;
|
||||
bool Contains(BPoint p) const;
|
||||
bool Contains(BRect r) const;
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// inline definitions ----------------------------------------------------------
|
||||
|
||||
inline BPoint BRect::LeftTop() const
|
||||
inline BPoint
|
||||
BRect::LeftTop() const
|
||||
{
|
||||
return(*((const BPoint*)&left));
|
||||
return *(const BPoint *)&left;
|
||||
}
|
||||
|
||||
inline BPoint BRect::RightBottom() const
|
||||
inline BPoint
|
||||
BRect::RightBottom() const
|
||||
{
|
||||
return(*((const BPoint*)&right));
|
||||
return *(const BPoint *)&right;
|
||||
}
|
||||
|
||||
inline BPoint BRect::LeftBottom() const
|
||||
inline BPoint
|
||||
BRect::LeftBottom() const
|
||||
{
|
||||
return(BPoint(left, bottom));
|
||||
return BPoint(left, bottom);
|
||||
}
|
||||
|
||||
inline BPoint BRect::RightTop() const
|
||||
inline BPoint
|
||||
BRect::RightTop() const
|
||||
{
|
||||
return(BPoint(right, top));
|
||||
return BPoint(right, top);
|
||||
}
|
||||
|
||||
inline BRect::BRect()
|
||||
inline
|
||||
BRect::BRect()
|
||||
{
|
||||
top = left = 0;
|
||||
bottom = right = -1;
|
||||
}
|
||||
|
||||
inline BRect::BRect(float l, float t, float r, float b)
|
||||
inline
|
||||
BRect::BRect(float l, float t, float r, float b)
|
||||
{
|
||||
left = l;
|
||||
top = t;
|
||||
|
@ -149,7 +143,8 @@ inline BRect::BRect(float l, float t, float r, float b)
|
|||
bottom = b;
|
||||
}
|
||||
|
||||
inline BRect::BRect(const BRect &r)
|
||||
inline
|
||||
BRect::BRect(const BRect &r)
|
||||
{
|
||||
left = r.left;
|
||||
top = r.top;
|
||||
|
@ -157,7 +152,8 @@ inline BRect::BRect(const BRect &r)
|
|||
bottom = r.bottom;
|
||||
}
|
||||
|
||||
inline BRect::BRect(BPoint leftTop, BPoint rightBottom)
|
||||
inline
|
||||
BRect::BRect(BPoint leftTop, BPoint rightBottom)
|
||||
{
|
||||
left = leftTop.x;
|
||||
top = leftTop.y;
|
||||
|
@ -165,7 +161,8 @@ inline BRect::BRect(BPoint leftTop, BPoint rightBottom)
|
|||
bottom = rightBottom.y;
|
||||
}
|
||||
|
||||
inline BRect &BRect::operator=(const BRect& from)
|
||||
inline BRect &
|
||||
BRect::operator=(const BRect& from)
|
||||
{
|
||||
left = from.left;
|
||||
top = from.top;
|
||||
|
@ -174,7 +171,8 @@ inline BRect &BRect::operator=(const BRect& from)
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline void BRect::Set(float l, float t, float r, float b)
|
||||
inline void
|
||||
BRect::Set(float l, float t, float r, float b)
|
||||
{
|
||||
left = l;
|
||||
top = t;
|
||||
|
@ -182,42 +180,34 @@ inline void BRect::Set(float l, float t, float r, float b)
|
|||
bottom = b;
|
||||
}
|
||||
|
||||
inline bool BRect::IsValid() const
|
||||
inline bool
|
||||
BRect::IsValid() const
|
||||
{
|
||||
if (left <= right && top <= bottom)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return left <= right && top <= bottom;
|
||||
}
|
||||
|
||||
inline int32 BRect::IntegerWidth() const
|
||||
inline int32
|
||||
BRect::IntegerWidth() const
|
||||
{
|
||||
return((int32)ceil(right - left));
|
||||
return (int32)ceil(right - left);
|
||||
}
|
||||
|
||||
inline float BRect::Width() const
|
||||
inline float
|
||||
BRect::Width() const
|
||||
{
|
||||
return(right - left);
|
||||
return right - left;
|
||||
}
|
||||
|
||||
inline int32 BRect::IntegerHeight() const
|
||||
inline int32
|
||||
BRect::IntegerHeight() const
|
||||
{
|
||||
return((int32)ceil(bottom - top));
|
||||
return (int32)ceil(bottom - top);
|
||||
}
|
||||
|
||||
inline float BRect::Height() const
|
||||
inline float
|
||||
BRect::Height() const
|
||||
{
|
||||
return(bottom - top);
|
||||
return bottom - top;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif // _RECT_H
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue