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

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 CEGUIBASE_API Rect
00041 {
00042 public:
00043         Rect(void) {}
00044 
00045 
00050         Rect(float left, float top, float right, float bottom);
00051 
00052 
00057         ~Rect(void) {}
00058 
00059 
00064         Point   getPosition(void) const         {return Point(d_left, d_top);}
00065 
00070         float   getWidth(void) const            {return d_right - d_left;}
00071 
00072 
00077         float   getHeight(void) const           {return d_bottom - d_top;}
00078 
00079 
00084         Size    getSize(void) const                     {return Size(getWidth(), getHeight());}
00085 
00086 
00091         void    setPosition(const Point& pt);
00092 
00093 
00098         void    setWidth(float width)           {d_right = d_left + width;}
00099 
00104         void    setHeight(float height)         {d_bottom = d_top + height;}
00105 
00106 
00111         void    setSize(const Size& sze)        {setWidth(sze.d_width); setHeight(sze.d_height);}
00112 
00113 
00122         Rect    getIntersection(const Rect& rect) const;
00123 
00124 
00135         Rect&   offset(const Point& pt);
00136 
00137 
00148         bool    isPointInRect(const Point& pt) const;
00149 
00150 
00161         Rect&   constrainSizeMax(const Size& sz);
00162 
00163 
00174         Rect&   constrainSizeMin(const Size& sz);
00175 
00176 
00190         Rect&   constrainSize(const Size& max_sz, const Size& min_sz);
00191 
00192 
00193         /*************************************************************************
00194                 Operators
00195         *************************************************************************/
00196         bool    operator==(const Rect& rhs) const
00197         {
00198                 return ((d_left == rhs.d_left) && (d_right == rhs.d_right) && (d_top == rhs.d_top) && (d_bottom == rhs.d_bottom));
00199         }
00200 
00201         bool    operator!=(const Rect& rhs) const               {return !operator==(rhs);}
00202 
00203         Rect&   operator=(const Rect& rhs);
00204 
00205 
00206         /*************************************************************************
00207                 Data Fields
00208         *************************************************************************/
00209         float   d_top, d_bottom, d_left, d_right;
00210 };
00211 
00212 } // End of  CEGUI namespace section
00213 
00214 
00215 #endif  // end of guard _CEGUIRect_h_

Generated on Wed Feb 16 12:41:07 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1