Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXPoint.h

00001 /******************************************************************************** 00002 * * 00003 * P o i n t C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1994,2004 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXPoint.h,v 1.7 2004/02/08 17:17:34 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXPOINT_H 00025 #define FXPOINT_H 00026 00027 00028 namespace FX { 00029 00030 /// Point 00031 class FXAPI FXPoint { 00032 public: 00033 FXshort x; 00034 FXshort y; 00035 public: 00036 00037 /// Constructors 00038 FXPoint(){ } 00039 FXPoint(const FXSize& s):x(s.w),y(s.h){ } 00040 FXPoint(const FXPoint& p):x(p.x),y(p.y){ } 00041 FXPoint(FXshort xx,FXshort yy):x(xx),y(yy){ } 00042 00043 /// Equality 00044 friend FXAPI FXbool operator==(const FXPoint& p,const FXPoint& q){ return p.x==q.x && p.y==q.y; } 00045 friend FXAPI FXbool operator!=(const FXPoint& p,const FXPoint& q){ return p.x!=q.x || p.y!=q.y; } 00046 00047 /// Assignment 00048 FXPoint& operator=(const FXPoint& p){ x=p.x; y=p.y; return *this; } 00049 FXPoint& operator=(const FXSize& s){ x=s.w; y=s.h; return *this; } 00050 00051 /// Assignment operators 00052 FXPoint& operator+=(const FXPoint& p){ x+=p.x; y+=p.y; return *this; } 00053 FXPoint& operator+=(const FXSize& s){ x+=s.w; y+=s.h; return *this; } 00054 FXPoint& operator-=(const FXPoint& p){ x-=p.x; y-=p.y; return *this; } 00055 FXPoint& operator-=(const FXSize& s){ x-=s.w; y-=s.h; return *this; } 00056 FXPoint& operator*=(FXshort c){ x*=c; y*=c; return *this; } 00057 FXPoint& operator/=(FXshort c){ x/=c; y/=c; return *this; } 00058 00059 /// Negation 00060 FXPoint operator-(){ return FXPoint(-x,-y); } 00061 00062 /// Other operators 00063 friend FXAPI FXPoint operator+(const FXPoint& p,const FXPoint& q){ return FXPoint(p.x+q.x,p.y+q.y); } 00064 friend FXAPI FXPoint operator+(const FXPoint& p,const FXSize& s){ return FXPoint(p.x+s.w,p.y+s.h); } 00065 friend FXAPI FXPoint operator+(const FXSize& s,const FXPoint& p){ return FXPoint(s.w+p.x,s.h+p.y); } 00066 00067 friend FXAPI FXPoint operator-(const FXPoint& p,const FXPoint& q){ return FXPoint(p.x-q.x,p.y-q.y); } 00068 friend FXAPI FXPoint operator-(const FXPoint& p,const FXSize& s){ return FXPoint(p.x-s.w,p.y-s.h); } 00069 friend FXAPI FXPoint operator-(const FXSize& s,const FXPoint& p){ return FXPoint(s.w-p.x,s.h-p.y); } 00070 00071 friend FXAPI FXPoint operator*(const FXPoint& p,FXshort c){ return FXPoint(p.x*c,p.y*c); } 00072 friend FXAPI FXPoint operator*(FXshort c,const FXPoint& p){ return FXPoint(c*p.x,c*p.y); } 00073 friend FXAPI FXPoint operator/(const FXPoint& p,FXshort c){ return FXPoint(p.x/c,p.y/c); } 00074 friend FXAPI FXPoint operator/(FXshort c,const FXPoint& p){ return FXPoint(c/p.x,c/p.y); } 00075 00076 /// Save object to a stream 00077 friend FXAPI FXStream& operator<<(FXStream& store,const FXPoint& p); 00078 00079 /// Load object from a stream 00080 friend FXAPI FXStream& operator>>(FXStream& store,FXPoint& p); 00081 }; 00082 00083 } 00084 00085 #endif

Copyright © 1997-2004 Jeroen van der Zijp