![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * S i z e C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1994,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (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 * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXSize.h,v 1.20 2009/01/06 13:07:27 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXSIZE_H 00024 #define FXSIZE_H 00025 00026 00027 namespace FX { 00028 00029 00030 /// Size 00031 class FXAPI FXSize { 00032 public: 00033 FXshort w; 00034 FXshort h; 00035 public: 00036 00037 /// Constructors 00038 FXSize(){ } 00039 FXSize(const FXSize& s):w(s.w),h(s.h){ } 00040 FXSize(FXshort ww,FXshort hh):w(ww),h(hh){ } 00041 00042 /// Test if empty 00043 FXbool empty() const { return w<=0 || h<=0; } 00044 00045 /// Test if zero 00046 FXbool operator!() const { return w==0 && h==0; } 00047 00048 /// Equality 00049 FXbool operator==(const FXSize& s) const { return w==s.w && h==s.h; } 00050 FXbool operator!=(const FXSize& s) const { return w!=s.w || h!=s.h; } 00051 00052 /// Grow by amount 00053 FXSize& grow(FXshort margin); 00054 FXSize& grow(FXshort hormargin,FXshort vermargin); 00055 FXSize& grow(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin); 00056 00057 /// Shrink by amount 00058 FXSize& shrink(FXshort margin); 00059 FXSize& shrink(FXshort hormargin,FXshort vermargin); 00060 FXSize& shrink(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin); 00061 00062 /// Assignment 00063 FXSize& operator=(const FXSize& s){ w=s.w; h=s.h; return *this; } 00064 00065 /// Set value from another size 00066 FXSize& set(const FXSize& s){ w=s.w; h=s.h; return *this; } 00067 00068 /// Set value from components 00069 FXSize& set(FXshort ww,FXshort hh){ w=ww; h=hh; return *this; } 00070 00071 /// Assignment operators 00072 FXSize& operator+=(const FXSize& s){ w+=s.w; h+=s.h; return *this; } 00073 FXSize& operator-=(const FXSize& s){ w-=s.w; h-=s.h; return *this; } 00074 FXSize& operator*=(FXshort c){ w*=c; h*=c; return *this; } 00075 FXSize& operator/=(FXshort c){ w/=c; h/=c; return *this; } 00076 00077 /// Negation 00078 FXSize operator-(){ return FXSize(-w,-h); } 00079 00080 /// Addition operators 00081 FXSize operator+(const FXSize& s) const { return FXSize(w+s.w,h+s.h); } 00082 FXSize operator-(const FXSize& s) const { return FXSize(w-s.w,h-s.h); } 00083 00084 /// Scale operators 00085 friend inline FXSize operator*(const FXSize& s,FXshort c); 00086 friend inline FXSize operator*(FXshort c,const FXSize& s); 00087 friend inline FXSize operator/(const FXSize& s,FXshort c); 00088 friend inline FXSize operator/(FXshort c,const FXSize& s); 00089 00090 /// Save object to a stream 00091 friend FXAPI FXStream& operator<<(FXStream& store,const FXSize& s); 00092 00093 /// Load object from a stream 00094 friend FXAPI FXStream& operator>>(FXStream& store,FXSize& s); 00095 }; 00096 00097 inline FXSize operator*(const FXSize& s,FXshort c){ return FXSize(s.w*c,s.h*c); } 00098 inline FXSize operator*(FXshort c,const FXSize& s){ return FXSize(c*s.w,c*s.h); } 00099 inline FXSize operator/(const FXSize& s,FXshort c){ return FXSize(s.w/c,s.h/c); } 00100 inline FXSize operator/(FXshort c,const FXSize& s){ return FXSize(c/s.w,c/s.h); } 00101 00102 extern FXAPI FXStream& operator<<(FXStream& store,const FXSize& s); 00103 extern FXAPI FXStream& operator>>(FXStream& store,FXSize& s); 00104 00105 } 00106 00107 #endif
![]() |