# 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.h

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 #ifndef NL_RECT_H
00027 #define NL_RECT_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 
00031 
00032 namespace NLMISC {
00033 
00034 class CVector2f;
00035 
00036 
00043 class CRect
00044 {
00045 public:
00047         CRect() {}
00048 
00050         CRect (sint32 x, sint32 y, uint32 width, uint32 height);        
00051 
00053         CRect (sint32 x, sint32 y)
00054         {
00055                 X=x;
00056                 Y=y;
00057                 Width=0;
00058                 Height=0;
00059         }
00060 
00062         void setWH(sint32 x, sint32 y, uint32 width, uint32 height);
00063 
00065         void set(sint32 x0, sint32 y0, sint32 x1, sint32 y1);
00066 
00068         void            extend (sint32 x, sint32 y);
00069 
00071         sint32          left() const
00072         {
00073                 return X;
00074         }
00075 
00077         sint32          right() const
00078         {
00079                 return X+(sint32)Width;
00080         }
00081 
00083         sint32          top() const
00084         {
00085                 return Y;
00086         }
00087 
00089         sint32          bottom() const
00090         {
00091                 return Y+(sint32)Height;
00092         }
00093 
00095         sint32          getXCenter() const
00096         {
00097                 return X+(sint32)(Width>>1);
00098         }
00099 
00101         sint32          getYCenter() const
00102         {
00103                 return Y+(sint32)(Height>>1);
00104         }
00105 
00107         sint32          X;
00108 
00110         sint32          Y;
00111 
00113         uint32          Width;
00114 
00116         uint32          Height;
00117 };
00118 
00119 
00120 } // NLMISC
00121 
00122 
00123 #endif // NL_RECT_H
00124 
00125 /* End of rect.h */