1 /* 2 * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Frans van Nispen 7 */ 8 #ifndef _POINT_H 9 #define _POINT_H 10 11 12 #include <BeBuild.h> 13 #include <SupportDefs.h> 14 15 16 class BRect; 17 18 class BPoint { 19 public: 20 float x; 21 float y; 22 23 BPoint(); 24 BPoint(float X, float Y); 25 BPoint(const BPoint &p); 26 27 BPoint &operator=(const BPoint &p); 28 void Set(float X, float Y); 29 30 void ConstrainTo(BRect r); 31 void PrintToStream() const; 32 33 BPoint operator-() const; 34 BPoint operator+(const BPoint &p) const; 35 BPoint operator-(const BPoint &p) const; 36 BPoint& operator+=(const BPoint &p); 37 BPoint& operator-=(const BPoint &p); 38 39 bool operator!=(const BPoint &p) const; 40 bool operator==(const BPoint &p) const; 41 }; 42 43 44 extern const BPoint B_ORIGIN; 45 // returns (0,0) 46 47 48 inline 49 BPoint::BPoint() 50 { 51 x = y = 0; 52 } 53 54 55 inline 56 BPoint::BPoint(float X, float Y) 57 { 58 x = X; 59 y = Y; 60 } 61 62 63 inline 64 BPoint::BPoint(const BPoint& pt) 65 { 66 x = pt.x; 67 y = pt.y; 68 } 69 70 71 inline BPoint & 72 BPoint::operator=(const BPoint& from) 73 { 74 x = from.x; 75 y = from.y; 76 return *this; 77 } 78 79 80 inline void 81 BPoint::Set(float X, float Y) 82 { 83 x = X; 84 y = Y; 85 } 86 87 #endif // _POINT_H 88