Crazy Eddies GUI System: CEGUIRect.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIRect.h

    00001 /***********************************************************************
    00002         filename:       CEGUIRect.h
    00003         created:        8/3/2004
    00004         author:         Paul D Turner
    00005
    00006         purpose:        Defines 'Rect' class
    00007 *************************************************************************/
    00008 /***************************************************************************
    00009  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
    00010  *
    00011  *   Permission is hereby granted, free of charge, to any person obtaining
    00012  *   a copy of this software and associated documentation files (the
    00013  *   "Software"), to deal in the Software without restriction, including
    00014  *   without limitation the rights to use, copy, modify, merge, publish,
    00015  *   distribute, sublicense, and/or sell copies of the Software, and to
    00016  *   permit persons to whom the Software is furnished to do so, subject to
    00017  *   the following conditions:
    00018  *
    00019  *   The above copyright notice and this permission notice shall be
    00020  *   included in all copies or substantial portions of the Software.
    00021  *
    00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00028  *   OTHER DEALINGS IN THE SOFTWARE.
    00029  ***************************************************************************/
    00030 #ifndef _CEGUIRect_h_
    00031 #define _CEGUIRect_h_
    00032
    00033 #include "CEGUIBase.h"
    00034 #include "CEGUIVector.h"
    00035 #include "CEGUISize.h"
    00036
    00037 // Start of CEGUI namespace section
    00038 namespace CEGUI
    00039 {
    00044 class CEGUIEXPORT Rect
    00045 {
    00046 public:
    00047         Rect(void) {}
    00048
    00049
    00054         Rect(float left, float top, float right, float bottom);
    00055
    00056     Rect(Point pos, Size sz);
    00057
    00058
    00063         Point   getPosition(void) const         {return Point(d_left, d_top);}
    00064
    00069         float   getWidth(void) const            {return d_right - d_left;}
    00070
    00071
    00076         float   getHeight(void) const           {return d_bottom - d_top;}
    00077
    00078
    00083         Size    getSize(void) const                     {return Size(getWidth(), getHeight());}
    00084
    00085
    00090         void    setPosition(const Point& pt);
    00091
    00092
    00097         void    setWidth(float width)           {d_right = d_left + width;}
    00098
    00103         void    setHeight(float height)         {d_bottom = d_top + height;}
    00104
    00105
    00110         void    setSize(const Size& sze)        {setWidth(sze.d_width); setHeight(sze.d_height);}
    00111
    00112
    00121         Rect    getIntersection(const Rect& rect) const;
    00122
    00123
    00134         Rect&   offset(const Point& pt);
    00135
    00136
    00147         bool    isPointInRect(const Point& pt) const;
    00148
    00149
    00160         Rect&   constrainSizeMax(const Size& sz);
    00161
    00162
    00173         Rect&   constrainSizeMin(const Size& sz);
    00174
    00175
    00189         Rect&   constrainSize(const Size& max_sz, const Size& min_sz);
    00190
    00191
    00192         /*************************************************************************
    00193                 Operators
    00194         *************************************************************************/
    00195         bool    operator==(const Rect& rhs) const
    00196         {
    00197                 return ((d_left == rhs.d_left) && (d_right == rhs.d_right) && (d_top == rhs.d_top) && (d_bottom == rhs.d_bottom));
    00198         }
    00199
    00200         bool    operator!=(const Rect& rhs) const               {return !operator==(rhs);}
    00201
    00202         Rect&   operator=(const Rect& rhs);
    00203
    00204     Rect operator*(float scalar) const      { return Rect(d_left * scalar, d_top * scalar, d_right * scalar, d_bottom * scalar); }
    00205     const Rect& operator*=(float scalar)    { d_left *= scalar; d_top *= scalar; d_right *= scalar; d_bottom *= scalar; return *this; }
    00206
    00207         Rect operator+(const Rect& r) const             { return Rect(d_left + r.d_left, d_top + r.d_top, d_right + r.d_right, d_bottom + r.d_bottom); }
    00208
    00209
    00210         /*************************************************************************
    00211                 Data Fields
    00212         *************************************************************************/
    00213         float   d_left, d_top, d_right, d_bottom;
    00214 };
    00215
    00216 } // End of  CEGUI namespace section
    00217
    00218
    00219 #endif  // end of guard _CEGUIRect_h_
    00220