00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CEGUIRect_h_
00031 #define _CEGUIRect_h_
00032
00033 #include "CEGUIBase.h"
00034 #include "CEGUIVector.h"
00035 #include "CEGUISize.h"
00036
00037
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
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
00208
00209
00210
00211 float d_top, d_bottom, d_left, d_right;
00212 };
00213
00214 }
00215
00216
00217 #endif // end of guard _CEGUIRect_h_