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