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 FXSIZE_H
00025 #define FXSIZE_H
00026
00027
00028 namespace FX {
00029
00030
00032 class FXAPI FXSize {
00033 public:
00034 FXshort w;
00035 FXshort h;
00036 public:
00037
00039 FXSize(){ }
00040 FXSize(const FXSize& s):w(s.w),h(s.h){ }
00041 FXSize(FXshort ww,FXshort hh):w(ww),h(hh){ }
00042
00044 bool empty() const { return w<=0 || h<=0; }
00045
00047 bool operator!() const { return w==0 && h==0; }
00048
00050 bool operator==(const FXSize& s) const { return w==s.w && h==s.h; }
00051 bool operator!=(const FXSize& s) const { return w!=s.w || h!=s.h; }
00052
00054 FXSize& grow(FXshort margin);
00055 FXSize& grow(FXshort hormargin,FXshort vermargin);
00056 FXSize& grow(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin);
00057
00059 FXSize& shrink(FXshort margin);
00060 FXSize& shrink(FXshort hormargin,FXshort vermargin);
00061 FXSize& shrink(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin);
00062
00064 FXSize& operator=(const FXSize& s){ w=s.w; h=s.h; return *this; }
00065
00067 FXSize& set(const FXSize& s){ w=s.w; h=s.h; return *this; }
00068
00070 FXSize& set(FXshort ww,FXshort hh){ w=ww; h=hh; return *this; }
00071
00073 FXSize& operator+=(const FXSize& s){ w+=s.w; h+=s.h; return *this; }
00074 FXSize& operator-=(const FXSize& s){ w-=s.w; h-=s.h; return *this; }
00075 FXSize& operator*=(FXshort c){ w*=c; h*=c; return *this; }
00076 FXSize& operator/=(FXshort c){ w/=c; h/=c; return *this; }
00077
00079 FXSize operator-(){ return FXSize(-w,-h); }
00080
00082 FXSize operator+(const FXSize& s) const { return FXSize(w+s.w,h+s.h); }
00083 FXSize operator-(const FXSize& s) const { return FXSize(w-s.w,h-s.h); }
00084
00086 friend inline FXSize operator*(const FXSize& s,FXshort c);
00087 friend inline FXSize operator*(FXshort c,const FXSize& s);
00088 friend inline FXSize operator/(const FXSize& s,FXshort c);
00089 friend inline FXSize operator/(FXshort c,const FXSize& s);
00090
00092 friend FXAPI FXStream& operator<<(FXStream& store,const FXSize& s);
00093
00095 friend FXAPI FXStream& operator>>(FXStream& store,FXSize& s);
00096 };
00097
00098 inline FXSize operator*(const FXSize& s,FXshort c){ return FXSize(s.w*c,s.h*c); }
00099 inline FXSize operator*(FXshort c,const FXSize& s){ return FXSize(c*s.w,c*s.h); }
00100 inline FXSize operator/(const FXSize& s,FXshort c){ return FXSize(s.w/c,s.h/c); }
00101 inline FXSize operator/(FXshort c,const FXSize& s){ return FXSize(c/s.w,c/s.h); }
00102
00103 extern FXAPI FXStream& operator<<(FXStream& store,const FXSize& s);
00104 extern FXAPI FXStream& operator>>(FXStream& store,FXSize& s);
00105
00106 }
00107
00108 #endif