2007-05-12 19:49:01 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Frans van Nispen
|
|
|
|
*/
|
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 <BeBuild.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BRect;
|
|
|
|
|
|
|
|
class BPoint {
|
|
|
|
public:
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
|
|
|
BPoint();
|
|
|
|
BPoint(float X, float Y);
|
|
|
|
BPoint(const BPoint &p);
|
|
|
|
|
|
|
|
BPoint &operator=(const BPoint &p);
|
|
|
|
void Set(float X, float Y);
|
|
|
|
|
|
|
|
void ConstrainTo(BRect r);
|
|
|
|
void PrintToStream() const;
|
|
|
|
|
2007-05-12 20:15:20 +04:00
|
|
|
BPoint operator-() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
BPoint operator+(const BPoint &p) const;
|
|
|
|
BPoint operator-(const BPoint &p) const;
|
|
|
|
BPoint& operator+=(const BPoint &p);
|
|
|
|
BPoint& operator-=(const BPoint &p);
|
|
|
|
|
|
|
|
bool operator!=(const BPoint &p) const;
|
|
|
|
bool operator==(const BPoint &p) const;
|
|
|
|
};
|
|
|
|
|
2007-07-06 14:35:17 +04:00
|
|
|
|
|
|
|
extern const BPoint B_ORIGIN;
|
|
|
|
// returns (0,0)
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
inline
|
|
|
|
BPoint::BPoint()
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
x = y = 0;
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
BPoint::BPoint(float X, float Y)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
x = X;
|
|
|
|
y = Y;
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
BPoint::BPoint(const BPoint& pt)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
x = pt.x;
|
|
|
|
y = pt.y;
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline BPoint &
|
|
|
|
BPoint::operator=(const BPoint& from)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
x = from.x;
|
|
|
|
y = from.y;
|
|
|
|
return *this;
|
|
|
|
}
|
2007-05-12 19:49:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
inline void
|
|
|
|
BPoint::Set(float X, float Y)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
x = X;
|
|
|
|
y = Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // _POINT_H
|