2007-05-12 19:49:01 +04:00
|
|
|
/*
|
2009-08-27 15:12:41 +04:00
|
|
|
* Copyright 2001-2009, Haiku, Inc. All rights reserved.
|
2007-05-12 19:49:01 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _POINT_H
|
|
|
|
#define _POINT_H
|
|
|
|
|
2007-07-06 14:35:17 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BRect;
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BPoint {
|
|
|
|
public:
|
2009-08-27 15:12:41 +04:00
|
|
|
float x;
|
|
|
|
float y;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
BPoint();
|
|
|
|
BPoint(float x, float y);
|
|
|
|
BPoint(const BPoint& p);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
BPoint& operator=(const BPoint& other);
|
|
|
|
void Set(float x, float y);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
void ConstrainTo(BRect rect);
|
|
|
|
void PrintToStream() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
BPoint operator-() const;
|
|
|
|
BPoint operator+(const BPoint& other) const;
|
|
|
|
BPoint operator-(const BPoint& other) const;
|
|
|
|
BPoint& operator+=(const BPoint& other);
|
|
|
|
BPoint& operator-=(const BPoint& other);
|
|
|
|
|
|
|
|
bool operator!=(const BPoint& other) const;
|
|
|
|
bool operator==(const BPoint& other) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2007-07-06 14:35:17 +04:00
|
|
|
|
|
|
|
extern const BPoint B_ORIGIN;
|
2009-08-27 15:12:41 +04:00
|
|
|
// returns (0, 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
inline
|
|
|
|
BPoint::BPoint()
|
2009-08-27 15:12:41 +04:00
|
|
|
:
|
|
|
|
x(0.0f),
|
|
|
|
y(0.0f)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline
|
2009-08-27 15:12:41 +04:00
|
|
|
BPoint::BPoint(float x, float y)
|
|
|
|
:
|
|
|
|
x(x),
|
|
|
|
y(y)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline
|
2009-08-27 15:12:41 +04:00
|
|
|
BPoint::BPoint(const BPoint& other)
|
|
|
|
:
|
|
|
|
x(other.x),
|
|
|
|
y(other.y)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
inline BPoint&
|
|
|
|
BPoint::operator=(const BPoint& other)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2009-08-27 15:12:41 +04:00
|
|
|
x = other.x;
|
|
|
|
y = other.y;
|
2002-07-09 16:24:59 +04:00
|
|
|
return *this;
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline void
|
2009-08-27 15:12:41 +04:00
|
|
|
BPoint::Set(float x, float y)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
2009-08-27 15:12:41 +04:00
|
|
|
this->x = x;
|
|
|
|
this->y = y;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
#endif // _POINT_H
|