Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

point.h

00001 /*
00002   libwftk - Worldforge Toolkit - a widget library
00003   Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org>
00004   Based on code copyright  (C) 1999-2002  Karsten Laux
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either
00009   version 2.1 of the License, or (at your option) any later version.
00010   
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015   
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library; if not, write to the
00018   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019   Boston, MA  02111-1307, SA.
00020 */
00021 
00022 #ifndef _POINT_H
00023 #define _POINT_H
00024 
00025 #include <iosfwd>
00026 
00027 namespace wftk {
00028 
00030 class Point
00031 {
00032  public:
00034   Point() : x(0), y(0) {}
00036   Point(int x_, int y_) : x(x_), y(y_) {}
00038   Point& operator+=(const Point& p)                             
00039     {  x += p.x; y += p.y;  return *this; }
00041   Point& operator-=(const Point& p)                             
00042     {  x -= p.x; y -= p.y;  return *this; }
00044   ~Point() {};
00046   friend Point operator+(const Point& p, const Point& q)
00047     { return Point(p) += q; }
00049   friend Point operator-(const Point& p, const Point& q)
00050     { return Point(p) -= q; }   
00052   Point operator-() const {return Point(-x, -y);}
00054   friend bool operator==(const Point &p, const Point &q)
00055     { return (p.x == q.x) && (p.y == q.y); }
00057   friend bool operator!=(const Point &p, const Point &q)
00058     { return (p.x != q.x) || (p.y != q.y); }
00060   friend bool operator<(const Point &p, const Point &q)
00061     { return p.x < q.x || (p.x == q.x && p.y < q.y); }
00063   friend std::ostream& operator<<(std::ostream& s, const Point& p);
00065   int x;
00067   int y;
00068 
00069 };
00070 
00071 } // namespace wftk
00072 
00073 #endif // _POINT_H

Generated Thu Mar 18 20:06:04 2004.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.