Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CEGUIRect.h

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIRect.h
00003         created:        8/3/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Defines 'Rect' class
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUIRect_h_
00027 #define _CEGUIRect_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUIVector.h"
00031 #include "CEGUISize.h"
00032 
00033 // Start of CEGUI namespace section
00034 namespace CEGUI
00035 {
00040 class CEGUIEXPORT Rect
00041 {
00042 public:
00043         Rect(void) {}
00044 
00045 
00050         Rect(float left, float top, float right, float bottom);
00051 
00052     Rect(Point pos, Size sz);
00053 
00054 
00059         Point   getPosition(void) const         {return Point(d_left, d_top);}
00060 
00065         float   getWidth(void) const            {return d_right - d_left;}
00066 
00067 
00072         float   getHeight(void) const           {return d_bottom - d_top;}
00073 
00074 
00079         Size    getSize(void) const                     {return Size(getWidth(), getHeight());}
00080 
00081 
00086         void    setPosition(const Point& pt);
00087 
00088 
00093         void    setWidth(float width)           {d_right = d_left + width;}
00094 
00099         void    setHeight(float height)         {d_bottom = d_top + height;}
00100 
00101 
00106         void    setSize(const Size& sze)        {setWidth(sze.d_width); setHeight(sze.d_height);}
00107 
00108 
00117         Rect    getIntersection(const Rect& rect) const;
00118 
00119 
00130         Rect&   offset(const Point& pt);
00131 
00132 
00143         bool    isPointInRect(const Point& pt) const;
00144 
00145 
00156         Rect&   constrainSizeMax(const Size& sz);
00157 
00158 
00169         Rect&   constrainSizeMin(const Size& sz);
00170 
00171 
00185         Rect&   constrainSize(const Size& max_sz, const Size& min_sz);
00186 
00187 
00188         /*************************************************************************
00189                 Operators
00190         *************************************************************************/
00191         bool    operator==(const Rect& rhs) const
00192         {
00193                 return ((d_left == rhs.d_left) && (d_right == rhs.d_right) && (d_top == rhs.d_top) && (d_bottom == rhs.d_bottom));
00194         }
00195 
00196         bool    operator!=(const Rect& rhs) const               {return !operator==(rhs);}
00197 
00198         Rect&   operator=(const Rect& rhs);
00199 
00200     Rect operator*(float scalar) const      { return Rect(d_left * scalar, d_top * scalar, d_right * scalar, d_bottom * scalar); }
00201     const Rect& operator*=(float scalar)    { d_left *= scalar; d_top *= scalar; d_right *= scalar; d_bottom *= scalar; return *this; }
00202 
00203 
00204         /*************************************************************************
00205                 Data Fields
00206         *************************************************************************/
00207         float   d_top, d_bottom, d_left, d_right;
00208 };
00209 
00210 } // End of  CEGUI namespace section
00211 
00212 
00213 #endif  // end of guard _CEGUIRect_h_

Generated on Wed Sep 7 09:56:33 2005 for Crazy Eddies GUI System by  doxygen 1.4.3