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 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
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
00206
00207 float d_top, d_bottom, d_left, d_right;
00208 };
00209
00210 }
00211
00212
00213 #endif // end of guard _CEGUIRect_h_