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

FXSize.h

00001 /******************************************************************************** 00002 * * 00003 * S i z e C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1994,2005 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: FXSize.h,v 1.9 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXSIZE_H 00025 #define FXSIZE_H 00026 00027 00028 namespace FX { 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 /// Equality 00043 friend FXAPI FXbool operator==(const FXSize& s,const FXSize& t){ return s.w==t.w && s.h==t.h; } 00044 friend FXAPI FXbool operator!=(const FXSize& s,const FXSize& t){ return s.w!=t.w || s.h!=t.h; } 00045 00046 /// Assignment 00047 FXSize& operator=(const FXSize& s){ w=s.w; h=s.h; return *this; } 00048 00049 /// Assignment operators 00050 FXSize& operator+=(const FXSize& s){ w+=s.w; h+=s.h; return *this; } 00051 FXSize& operator-=(const FXSize& s){ w-=s.w; h-=s.h; return *this; } 00052 FXSize& operator*=(FXshort c){ w*=c; h*=c; return *this; } 00053 FXSize& operator/=(FXshort c){ w/=c; h/=c; return *this; } 00054 00055 /// Negation 00056 FXSize operator-(){ return FXSize(-w,-h); } 00057 00058 /// Other operators 00059 friend FXAPI FXSize operator+(const FXSize& s,const FXSize& t){ return FXSize(s.w+t.w,s.h+t.h); } 00060 friend FXAPI FXSize operator-(const FXSize& s,const FXSize& t){ return FXSize(s.w-t.w,s.h-t.h); } 00061 friend FXAPI FXSize operator*(const FXSize& s,FXshort c){ return FXSize(s.w*c,s.h*c); } 00062 friend FXAPI FXSize operator*(FXshort c,const FXSize& s){ return FXSize(c*s.w,c*s.h); } 00063 friend FXAPI FXSize operator/(const FXSize& s,FXshort c){ return FXSize(s.w/c,s.h/c); } 00064 friend FXAPI FXSize operator/(FXshort c,const FXSize& s){ return FXSize(c/s.w,c/s.h); } 00065 00066 /// Save object to a stream 00067 friend FXAPI FXStream& operator<<(FXStream& store,const FXSize& s); 00068 00069 /// Load object from a stream 00070 friend FXAPI FXStream& operator>>(FXStream& store,FXSize& s); 00071 }; 00072 00073 } 00074 00075 #endif

Copyright © 1997-2005 Jeroen van der Zijp