00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXSIZE_H
00022 #define FXSIZE_H
00023
00024
00025 namespace FX {
00026
00027
00029 class FXAPI FXSize {
00030 public:
00031 FXshort w;
00032 FXshort h;
00033 public:
00034
00036 FXSize(){ }
00037 FXSize(const FXSize& s):w(s.w),h(s.h){ }
00038 FXSize(FXshort ww,FXshort hh):w(ww),h(hh){ }
00039
00041 FXshort& operator[](FXint i){return (&w)[i];}
00042
00044 const FXshort& operator[](FXint i) const {return (&w)[i];}
00045
00047 FXbool empty() const { return w<=0 || h<=0; }
00048
00050 FXSize& grow(FXshort margin);
00051 FXSize& grow(FXshort hormargin,FXshort vermargin);
00052 FXSize& grow(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin);
00053
00055 FXSize& shrink(FXshort margin);
00056 FXSize& shrink(FXshort hormargin,FXshort vermargin);
00057 FXSize& shrink(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin);
00058
00060 FXSize& operator=(const FXSize& s){ w=s.w; h=s.h; return *this; }
00061
00063 FXSize& set(const FXSize& s){ w=s.w; h=s.h; return *this; }
00064
00066 FXSize& set(FXshort ww,FXshort hh){ w=ww; h=hh; return *this; }
00067
00069 FXSize& operator*=(FXshort c){ w*=c; h*=c; return *this; }
00070 FXSize& operator/=(FXshort c){ w/=c; h/=c; return *this; }
00071 FXSize& operator+=(const FXSize& s){ w+=s.w; h+=s.h; return *this; }
00072 FXSize& operator-=(const FXSize& s){ w-=s.w; h-=s.h; return *this; }
00073
00075 FXbool operator!() const { return w==0 && h==0; }
00076
00078 FXSize operator+() const { return *this; }
00079 FXSize operator-(){ return FXSize(-w,-h); }
00080 };
00081
00082
00084 inline FXSize operator*(const FXSize& s,FXshort c){ return FXSize(s.w*c,s.h*c); }
00085 inline FXSize operator*(FXshort c,const FXSize& s){ return FXSize(c*s.w,c*s.h); }
00086 inline FXSize operator/(const FXSize& s,FXshort c){ return FXSize(s.w/c,s.h/c); }
00087 inline FXSize operator/(FXshort c,const FXSize& s){ return FXSize(c/s.w,c/s.h); }
00088
00090 inline FXSize operator+(const FXSize& a,const FXSize& b){ return FXSize(a.w+b.w,a.h+b.h); }
00091 inline FXSize operator-(const FXSize& a,const FXSize& b){ return FXSize(a.w-b.w,a.h-b.h); }
00092
00094 inline FXbool operator==(const FXSize& a,FXshort n){ return a.w==n && a.h==n; }
00095 inline FXbool operator!=(const FXSize& a,FXshort n){ return a.w!=n || a.h!=n; }
00096 inline FXbool operator==(FXshort n,const FXSize& a){ return n==a.w && n==a.h; }
00097 inline FXbool operator!=(FXshort n,const FXSize& a){ return n!=a.w || n!=a.h; }
00098
00100 inline FXbool operator==(const FXSize& a,const FXSize& b){ return a.w==b.w && a.h==b.h; }
00101 inline FXbool operator!=(const FXSize& a,const FXSize& b){ return a.w!=b.w || a.h!=b.h; }
00102
00104 inline FXbool operator<(const FXSize& a,FXshort n){ return a.w<n && a.h<n; }
00105 inline FXbool operator<=(const FXSize& a,FXshort n){ return a.w<=n && a.h<=n; }
00106 inline FXbool operator>(const FXSize& a,FXshort n){ return a.w>n && a.h>n; }
00107 inline FXbool operator>=(const FXSize& a,FXshort n){ return a.w>=n && a.h>=n; }
00108
00110 inline FXbool operator<(FXshort n,const FXSize& a){ return n<a.w && n<a.h; }
00111 inline FXbool operator<=(FXshort n,const FXSize& a){ return n<=a.w && n<=a.h; }
00112 inline FXbool operator>(FXshort n,const FXSize& a){ return n>a.w && n>a.h; }
00113 inline FXbool operator>=(FXshort n,const FXSize& a){ return n>=a.w && n>=a.h; }
00114
00116 inline FXbool operator<(const FXSize& a,const FXSize& b){ return a.w<b.h && a.w<b.h; }
00117 inline FXbool operator<=(const FXSize& a,const FXSize& b){ return a.w<=b.h && a.w<=b.h; }
00118 inline FXbool operator>(const FXSize& a,const FXSize& b){ return a.w>b.h && a.w>b.h; }
00119 inline FXbool operator>=(const FXSize& a,const FXSize& b){ return a.w>=b.h && a.w>=b.h; }
00120
00122 inline FXSize lo(const FXSize& a,const FXSize& b){ return FXSize(FXMIN(a.w,b.w),FXMIN(a.h,b.h)); }
00123 inline FXSize hi(const FXSize& a,const FXSize& b){ return FXSize(FXMAX(a.w,b.w),FXMAX(a.h,b.h)); }
00124
00126 extern FXAPI FXStream& operator<<(FXStream& store,const FXSize& s);
00127
00129 extern FXAPI FXStream& operator>>(FXStream& store,FXSize& s);
00130
00131 }
00132
00133 #endif