00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXPOINT_H
00025 #define FXPOINT_H
00026
00027 #ifndef FXSIZE_H
00028 #include "FXSize.h"
00029 #endif
00030
00031 namespace FX {
00032
00033
00035 class FXAPI FXPoint {
00036 public:
00037 FXshort x;
00038 FXshort y;
00039 public:
00040
00042 FXPoint(){ }
00043 FXPoint(const FXSize& s):x(s.w),y(s.h){ }
00044 FXPoint(const FXPoint& p):x(p.x),y(p.y){ }
00045 FXPoint(FXshort xx,FXshort yy):x(xx),y(yy){ }
00046
00048 bool operator!() const { return x==0 && y==0; }
00049
00051 bool operator==(const FXPoint& p) const { return x==p.x && y==p.y; }
00052 bool operator!=(const FXPoint& p) const { return x!=p.x || y!=p.y; }
00053
00055 FXPoint& operator=(const FXPoint& p){ x=p.x; y=p.y; return *this; }
00056
00058 FXPoint& set(const FXPoint& p){ x=p.x; y=p.y; return *this; }
00059
00061 FXPoint& set(FXshort xx,FXshort yy){ x=xx; y=yy; return *this; }
00062
00064 FXPoint& operator+=(const FXPoint& p){ x+=p.x; y+=p.y; return *this; }
00065 FXPoint& operator-=(const FXPoint& p){ x-=p.x; y-=p.y; return *this; }
00066 FXPoint& operator*=(FXshort c){ x*=c; y*=c; return *this; }
00067 FXPoint& operator/=(FXshort c){ x/=c; y/=c; return *this; }
00068
00070 FXPoint operator-(){ return FXPoint(-x,-y); }
00071
00073 FXPoint operator+(const FXPoint& p) const { return FXPoint(x+p.x,y+p.y); }
00074 FXPoint operator-(const FXPoint& p) const { return FXPoint(x-p.x,y-p.y); }
00075
00077 friend inline FXPoint operator*(const FXPoint& p,FXshort c);
00078 friend inline FXPoint operator*(FXshort c,const FXPoint& p);
00079 friend inline FXPoint operator/(const FXPoint& p,FXshort c);
00080 friend inline FXPoint operator/(FXshort c,const FXPoint& p);
00081
00083 friend FXAPI FXStream& operator<<(FXStream& store,const FXPoint& p);
00084
00086 friend FXAPI FXStream& operator>>(FXStream& store,FXPoint& p);
00087 };
00088
00089
00090 inline FXPoint operator*(const FXPoint& p,FXshort c){ return FXPoint(p.x*c,p.y*c); }
00091 inline FXPoint operator*(FXshort c,const FXPoint& p){ return FXPoint(c*p.x,c*p.y); }
00092 inline FXPoint operator/(const FXPoint& p,FXshort c){ return FXPoint(p.x/c,p.y/c); }
00093 inline FXPoint operator/(FXshort c,const FXPoint& p){ return FXPoint(c/p.x,c/p.y); }
00094
00095 extern FXAPI FXStream& operator<<(FXStream& store,const FXPoint& p);
00096 extern FXAPI FXStream& operator>>(FXStream& store,FXPoint& p);
00097
00098 }
00099
00100 #endif