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 #ifndef _CEGUIRect_h_
00027 #define _CEGUIRect_h_
00028
00029 #include "CEGUIBase.h"
00030 #include "CEGUIVector.h"
00031 #include "CEGUISize.h"
00032
00033
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
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
00208
00209 float d_top, d_bottom, d_left, d_right;
00210 };
00211
00212 }
00213
00214
00215 #endif // end of guard _CEGUIRect_h_