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 11#include "IntPoint.h" 12 13#include <stdio.h> 14 15#include "IntRect.h" 16 17 18void 19IntPoint::ConstrainTo(const IntRect& r) 20{ 21 x = max_c(min_c(x, r.right), r.left); 22 y = max_c(min_c(y, r.bottom), r.top); 23} 24 25 26void 27IntPoint::PrintToStream() const 28{ 29 printf("IntPoint(x:%" B_PRId32 ", y:%" B_PRId32 ")\n", x, y); 30} 31 32 33IntPoint 34IntPoint::operator+(const IntPoint& p) const 35{ 36 return IntPoint(x + p.x, y + p.y); 37} 38 39 40IntPoint 41IntPoint::operator-(const IntPoint& p) const 42{ 43 return IntPoint(x - p.x, y - p.y); 44} 45 46 47IntPoint & 48IntPoint::operator+=(const IntPoint& p) 49{ 50 x += p.x; 51 y += p.y; 52 53 return *this; 54} 55 56 57IntPoint & 58IntPoint::operator-=(const IntPoint& p) 59{ 60 x -= p.x; 61 y -= p.y; 62 63 return *this; 64} 65 66 67bool 68IntPoint::operator!=(const IntPoint& p) const 69{ 70 return x != p.x || y != p.y; 71} 72 73 74bool 75IntPoint::operator==(const IntPoint& p) const 76{ 77 return x == p.x && y == p.y; 78} 79 80