Files
haiku-beta6/headers/os/interface/Point.h
T

88 lines
1.1 KiB
C++
Raw Normal View History

2007-05-12 15:49:01 +00:00
/*
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Frans van Nispen
*/
2002-07-09 12:24:59 +00:00
#ifndef _POINT_H
#define _POINT_H
2002-07-09 12:24:59 +00: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 16:15:20 +00:00
BPoint operator-() const;
2002-07-09 12:24:59 +00: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;
};
extern const BPoint B_ORIGIN;
// returns (0,0)
2002-07-09 12:24:59 +00:00
2007-05-12 15:49:01 +00:00
inline
BPoint::BPoint()
2002-07-09 12:24:59 +00:00
{
x = y = 0;
}
2007-05-12 15:49:01 +00:00
inline
BPoint::BPoint(float X, float Y)
2002-07-09 12:24:59 +00:00
{
x = X;
y = Y;
}
2007-05-12 15:49:01 +00:00
inline
BPoint::BPoint(const BPoint& pt)
2002-07-09 12:24:59 +00:00
{
x = pt.x;
y = pt.y;
}
2007-05-12 15:49:01 +00:00
inline BPoint &
BPoint::operator=(const BPoint& from)
2002-07-09 12:24:59 +00:00
{
x = from.x;
y = from.y;
return *this;
}
2007-05-12 15:49:01 +00:00
inline void
BPoint::Set(float X, float Y)
2002-07-09 12:24:59 +00:00
{
x = X;
y = Y;
}
#endif // _POINT_H