# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

rect.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #include "stdmisc.h"
00027 
00028 #include "nel/misc/rect.h"
00029 #include "nel/misc/vector_2f.h"
00030 
00031 
00032 namespace NLMISC {
00033 
00034 // *********************************************************************
00035 void CRect::extend (sint32 x, sint32 y)
00036 {
00037         if (x<X)
00038         {
00039                 Width+=(uint32)(X-x);
00040                 x=X;
00041         }
00042         else if (x>=(X+(sint32)Width))
00043                 Width=(uint32)(x-X+1);
00044         if (y<Y)
00045         {
00046                 Height+=(uint32)(Y-y);
00047                 y=Y;
00048         }
00049         else if (y>=(Y+(sint32)Height))
00050                 Height=(uint32)(y-Y+1);
00051 }
00052 
00053 
00054 // *********************************************************************
00055 void CRect::setWH(sint32 x, sint32 y, uint32 width, uint32 height)
00056 {
00057         X=x;
00058         Y=y;
00059         Width=width;
00060         Height=height;
00061 }
00062 
00063 
00064 // *********************************************************************
00065 void CRect::set(sint32 x0, sint32 y0, sint32 x1, sint32 y1)
00066 {
00067         if (x0 < x1)
00068         {
00069                 X = x0;
00070                 Width = x1 - x0;
00071         }
00072         else
00073         {
00074                 X = x1;
00075                 Width = y0 - y1;
00076         }
00077 
00078         if (y0 < y1)
00079         {
00080                 Y = y0;
00081                 Height = y1 - y0;
00082         }
00083         else
00084         {
00085                 Y = y1;
00086                 Height = y0 - y1;
00087         }
00088 }
00089 
00090 // *********************************************************************
00091 CRect::CRect (sint32 x, sint32 y, uint32 width, uint32 height)
00092 {
00093         setWH(x, y, width, height);
00094 }
00095 
00096 
00097 
00098 
00099 } // NLMISC