OWLNext 7.0
Borland's Object Windows Library for the modern age
|
TRect is a mathematical class derived from tagRect. More...
#include <owl/geometry.h>
Public Member Functions | |
TRect () | |
Default constructor that does nothing. | |
TRect (const tagRECT &rect) | |
Copy from an existing rectangle. | |
TRect (const TRect &rect) | |
Copy from an existing rectangle. | |
TRect (int _left, int _top, int _right, int _bottom) | |
Constructor that sets all the values explicitly. | |
TRect (const TPoint &upLeft, const TPoint &loRight) | |
Creates a rectangle with the given top left and bottom right points. | |
TRect (const TPoint &origin, const TSize &extent) | |
Creates a rectangle with its origin (top left) at origin, width at extent.cx, height at extent.cy. | |
void | SetNull () |
Sets the left, top, right, and bottom of the rectangle to 0. | |
void | SetEmpty () |
Empties this rectangle by setting left, top, right, and bottom to 0. | |
void | Set (int _left, int _top, int _right, int _bottom) |
Repositions and resizes this rectangle to the given values. | |
void | SetWH (int _left, int _top, int w, int h) |
Determines the rectangle, given its upperleft point, width, and height. | |
operator const TPoint * () const | |
Type conversion operators converting the pointer to this rectangle to type pointer to TPoint. | |
operator TPoint * () | |
Type conversion operators converting the pointer to this rectangle to type pointer to TPoint. | |
bool | IsEmpty () const |
Returns true if left >= right or top >= bottom; otherwise, returns false. | |
bool | IsNull () const |
Returns true if left, right, top, and bottom are all 0; otherwise, returns false. | |
bool | operator== (const TRect &other) const |
Returns true if this rectangle has identical corner coordinates to the other rectangle; otherwise, returns false. | |
bool | operator!= (const TRect &other) const |
Returns false if this rectangle has identical corner coordinates to the other rectangle; otherwise, returns true. | |
int | Left () const |
Returns the left value. | |
int | X () const |
Returns the left value. | |
int | Top () const |
Returns the top value. | |
int | Y () const |
Returns the top value. | |
int | Right () const |
Returns the right value. | |
int | Bottom () const |
Returns the bottom value. | |
const TPoint & | TopLeft () const |
Returns the upperleft point. | |
TPoint & | TopLeft () |
Returns the upperleft point. | |
TPoint | TopRight () const |
Returns the upperright point. | |
TPoint | BottomLeft () const |
Returns the TPoint object representing the bottom left corner of this rectangle. | |
const TPoint & | BottomRight () const |
Returns the TPoint object representing the bottom right corner of this rectangle. | |
TPoint & | BottomRight () |
Returns the TPoint object representing the bottom right corner of this rectangle. | |
int | Width () const |
Returns the width of this rectangle (right - left). | |
int | Height () const |
Returns the height of this rectangle (bottom - top). | |
TSize | Size () const |
Returns the size of rectangle. | |
long | Area () const |
Returns the area of this rectangle. | |
bool | Contains (const TPoint &point) const |
Returns true if the given point lies within this rectangle; otherwise, it returns false. | |
bool | Contains (const TRect &other) const |
Returns true if the other rectangle lies on or within this rectangle; otherwise, it returns false. | |
bool | Touches (const TRect &other) const |
Returns true if the other rectangle shares any interior points with this rectangle; otherwise, returns false. | |
TRect | OffsetBy (int dx, int dy) const |
Returns a rectangle with the corners offset by the given delta values. | |
TRect | operator+ (const TSize &size) const |
Returns a rectangle offset positively by the delta values' given sizes. | |
TRect | operator- (const TSize &size) const |
Returns a rectangle offset negatively by the delta values' given sizes. | |
TRect | MovedTo (int x, int y) |
Moves the upper left point of the rectangle while maintaining the current dimension. | |
TRect | InflatedBy (int dx, int dy) const |
Returns a rectangle inflated by the given delta arguments. | |
TRect | InflatedBy (const TSize &size) const |
Returns a rectangle inflated by the given delta arguments. | |
TRect | Normalized () const |
Returns a normalized rectangle with the top left corner at (Min(left, right), Min(top, bottom)) and the bottom right corner at (Max(left, right), Max(top,
bottom)). | |
TRect | operator& (const TRect &other) const |
Returns the intersection of this rectangle and the other rectangle. | |
TRect | operator| (const TRect &other) const |
Returns the union of this rectangle and the other rectangle. | |
int | Subtract (const TRect &other, TRect result[]) const |
Determines the parts of this rect that do not lie within "other" region. | |
TRect & | Normalize () |
Normalizes this rectangle by switching the left and right data member values if left > right, and switching the top and bottom data member values if top > bottom. | |
TRect & | Offset (int dx, int dy) |
Changes this rectangle so its corners are offset by the given delta values. | |
TRect & | operator+= (const TSize &delta) |
Changes this rectangle so its corners are offset by the given delta values, delta.x and delta.y. | |
TRect & | operator-= (const TSize &delta) |
Changes this rectangle so its corners are offset negatively by the given delta values, delta.x and delta.y. | |
TRect & | MoveTo (int x, int y) |
Moves the upper left corner of the rectangle to a new location and maintains the current dimension. | |
TRect & | Inflate (int dx, int dy) |
Inflates a rectangle inflated by the given delta arguments. | |
TRect & | DeflateRect (int dx, int dy) |
TRect & | Inflate (const TSize &delta) |
Inflates a rectangle inflated by the given delta arguments. | |
TRect & | DeflateRect (const TSize &delta) |
DLN MFC look-alike. | |
TRect & | operator&= (const TRect &other) |
Changes this rectangle to its intersection with the other rectangle. | |
TRect & | operator|= (const TRect &other) |
Changes this rectangle to its union with the other rectangle. | |
TRect is a mathematical class derived from tagRect.
The tagRect struct is defined as
TRect encapsulates the properties of rectangles with sides parallel to the x- and y-axes. In ObjectWindows, these rectangles define the boundaries of windows, boxes, and clipping regions. TRect inherits four data members from tagRect left, top, right, and bottom. These represent the top left and bottom right (x, y) coordinates of the rectangle. Note that x increases from left to right, and y increases from top to bottom.
TRect places no restrictions on the relative positions of top left and bottom right, so it is legal to have left > right and top > bottom. However, many manipulations–such as determining width and height, and forming unions and intersections–are simplified by normalizing the TRect objects involved. Normalizing a rectangle means interchanging the corner point coordinate values so that left < right and top < bottom. Normalization does not alter the physical properties of a rectangle. myRect.Normalized creates normalized copy of myRect without changing myRect, while myRect.Normalize changes myRect to a normalized format. Both members return the normalized rectangle.
TRect constructors are provided to create rectangles from either four ints, two TPoint objects, or one TPoint and one TSize object. In the latter case, the TPoint object specifies the top left point (also known as the rectangle's origin) and the TSize object supplies the width and height of the rectangle. Member functions perform a variety of rectangle tests and manipulations. Overloaded << and >> operators allow chained insertion and extraction of TRect objects with streams.
Definition at line 308 of file geometry.h.
|
inline |
Default constructor that does nothing.
Definition at line 889 of file geometry.h.
References SetNull().
|
inline |
Copy from an existing rectangle.
Definition at line 1111 of file geometry.h.
|
inline |
Copy from an existing rectangle.
Definition at line 1120 of file geometry.h.
Constructor that sets all the values explicitly.
Definition at line 1129 of file geometry.h.
References Set().
Creates a rectangle with the given top left and bottom right points.
Definition at line 1138 of file geometry.h.
References Set().
Creates a rectangle with its origin (top left) at origin, width at extent.cx, height at extent.cy.
Definition at line 1148 of file geometry.h.
References Set().
|
inline |
Returns the area of this rectangle.
Definition at line 1066 of file geometry.h.
|
inline |
Returns the bottom value.
Definition at line 974 of file geometry.h.
|
inline |
Returns the TPoint object representing the bottom left corner of this rectangle.
Definition at line 1010 of file geometry.h.
|
inline |
Returns the TPoint object representing the bottom right corner of this rectangle.
Definition at line 1030 of file geometry.h.
|
inline |
Returns the TPoint object representing the bottom right corner of this rectangle.
Definition at line 1020 of file geometry.h.
Returns true if the given point lies within this rectangle; otherwise, it returns false.
If point is on the left vertical or on the top horizontal borders of the rectangle, Contains also returns true, but if point is on the right vertical or bottom horizontal borders, Contains returns false.
Definition at line 1200 of file geometry.h.
References owl::ToBool().
Returns true if the other rectangle lies on or within this rectangle; otherwise, it returns false.
Definition at line 1211 of file geometry.h.
References owl::ToBool().
Definition at line 142 of file geometry.cpp.
References Inflate().
|
inline |
Returns the height of this rectangle (bottom - top).
Definition at line 1048 of file geometry.h.
Inflates a rectangle inflated by the given delta arguments.
The new corners are (left - size.cx, top - size.cy) and (right + size.cx, bottom + size.cy).
Definition at line 1386 of file geometry.h.
References Inflate().
Inflates a rectangle inflated by the given delta arguments.
The top left corner of the returned rectangle is (left - dx, top - dy), while its bottom right corner is (right + dx, bottom + dy).
Definition at line 129 of file geometry.cpp.
Returns a rectangle inflated by the given delta arguments.
The new corners are (left - size.cx, top - size.cy) and (right + size.cx, bottom + size.cy). The calling rectangle object is unchanged.
Definition at line 1292 of file geometry.h.
References InflatedBy().
Returns a rectangle inflated by the given delta arguments.
The top left corner of the returned rectangle is (left - dx, top - dy), while its bottom right corner is (right + dx, bottom + dy). The calling rectangle object is unchanged.
Definition at line 1281 of file geometry.h.
References TRect().
|
inline |
Returns true if left >= right or top >= bottom; otherwise, returns false.
Definition at line 1157 of file geometry.h.
References owl::ToBool().
|
inline |
Returns true if left, right, top, and bottom are all 0; otherwise, returns false.
Definition at line 1167 of file geometry.h.
References owl::ToBool().
|
inline |
Returns the left value.
Definition at line 929 of file geometry.h.
Moves the upper left point of the rectangle while maintaining the current dimension.
Definition at line 1270 of file geometry.h.
Moves the upper left corner of the rectangle to a new location and maintains the current dimension.
Definition at line 1371 of file geometry.h.
TRect & owl::TRect::Normalize | ( | ) |
Normalizes this rectangle by switching the left and right data member values if left > right, and switching the top and bottom data member values if top > bottom.
Normalize returns the normalized rectangle. A valid but nonnormal rectangle might have left > right or top > bottom or both. In such cases, many manipulations (such as determining width and height) become unnecessarily complicated. Normalizing a rectangle means interchanging the corner point values so that left < right and top < bottom. The physical properties of a rectangle are unchanged by this process.
Definition at line 99 of file geometry.cpp.
References Swap().
|
inline |
Returns a normalized rectangle with the top left corner at (Min(left, right), Min(top, bottom)) and the bottom right corner at (Max(left, right), Max(top, bottom)).
The calling rectangle object is unchanged. A valid but nonnormal rectangle might have left > right or top > bottom or both. In such cases, many manipulations (such as determining width and height) become unnecessarily complicated. Normalizing a rectangle means interchanging the corner point values so that left < right and top < bottom. The physical properties of a rectangle are unchanged by this process. Note that many calculations assume a normalized rectangle. Some Windows API functions behave erratically if an inside-out Rect is passed.
Definition at line 1310 of file geometry.h.
References TRect().
Changes this rectangle so its corners are offset by the given delta values.
The revised rectangle has a top left corner at (left + dx, top + dy) and a right bottom corner at (right + dx, bottom + dy). The revised rectangle is returned.
Definition at line 114 of file geometry.cpp.
Returns a rectangle with the corners offset by the given delta values.
The returned rectangle has a top left corner at (left + dx, top + dy) and a right bottom corner at (right + dx, bottom + dy). The calling rectangle object is unchanged
Definition at line 1234 of file geometry.h.
References TRect().
|
inline |
Type conversion operators converting the pointer to this rectangle to type pointer to TPoint.
Return an array of two points (upperleft and bottomright)
Definition at line 909 of file geometry.h.
|
inline |
Type conversion operators converting the pointer to this rectangle to type pointer to TPoint.
Return an array of two points (upperleft and bottomright)
Definition at line 920 of file geometry.h.
Returns false if this rectangle has identical corner coordinates to the other rectangle; otherwise, returns true.
Definition at line 1188 of file geometry.h.
References owl::ToBool().
Returns the intersection of this rectangle and the other rectangle.
The calling rectangle object is unchanged. Returns a NULL rectangle if the two don't intersect.
Definition at line 1322 of file geometry.h.
Changes this rectangle to its intersection with the other rectangle.
This rectangle object is returned. Returns a NULL rectangle if there is no intersection.
Definition at line 153 of file geometry.cpp.
Returns a rectangle offset positively by the delta values' given sizes.
The returned rectangle has a top left corner at (left + size.x, top + size.y) and a right bottom corner at (right + size.x, bottom + size.y). The calling rectangle object is unchanged.
Definition at line 1246 of file geometry.h.
References OffsetBy().
Changes this rectangle so its corners are offset by the given delta values, delta.x and delta.y.
The revised rectangle has a top left corner at (left + delta.x, top + delta.y) and a right bottom corner at (right + delta.x, bottom + delta.y). The revised rectangle is returned.
Definition at line 1348 of file geometry.h.
References Offset().
Returns a rectangle offset negatively by the delta values' given sizes.
The returned rectangle has a top left corner at (left - size.cx, top - size.cy) and a right bottom corner at (right - size.cx, bottom - size.cy). The calling rectangle object is unchanged.
Definition at line 1258 of file geometry.h.
References OffsetBy().
Changes this rectangle so its corners are offset negatively by the given delta values, delta.x and delta.y.
The revised rectangle has a top left corner at (left - delta.x, top - delta.y) and a right bottom corner at (right - delta.x, bottom - delta.y). The revised rectangle is returned.
Definition at line 1361 of file geometry.h.
Returns true if this rectangle has identical corner coordinates to the other rectangle; otherwise, returns false.
Definition at line 1177 of file geometry.h.
References owl::ToBool().
Returns the union of this rectangle and the other rectangle.
The calling rectangle object is unchanged.
Definition at line 1335 of file geometry.h.
References TRect().
Changes this rectangle to its union with the other rectangle.
This rectangle object is returned.
Definition at line 173 of file geometry.cpp.
References IsNull().
|
inline |
Returns the right value.
Definition at line 965 of file geometry.h.
Repositions and resizes this rectangle to the given values.
Definition at line 1087 of file geometry.h.
|
inline |
Empties this rectangle by setting left, top, right, and bottom to 0.
Definition at line 898 of file geometry.h.
References SetNull().
|
inline |
Sets the left, top, right, and bottom of the rectangle to 0.
Definition at line 1075 of file geometry.h.
Determines the rectangle, given its upperleft point, width, and height.
Definition at line 1099 of file geometry.h.
|
inline |
Returns the size of rectangle.
Definition at line 1057 of file geometry.h.
Determines the parts of this rect that do not lie within "other" region.
The resulting rectangles are placed in the "result" array. Returns the resulting number of rectangles. This number will be 1, 2, 3, or 4.
Definition at line 194 of file geometry.cpp.
References Touches().
|
inline |
Returns the top value.
Definition at line 947 of file geometry.h.
|
inline |
Returns the upperleft point.
Definition at line 992 of file geometry.h.
|
inline |
Returns the upperleft point.
Definition at line 983 of file geometry.h.
|
inline |
Returns the upperright point.
Definition at line 1001 of file geometry.h.
Returns true if the other rectangle shares any interior points with this rectangle; otherwise, returns false.
Definition at line 1222 of file geometry.h.
References owl::ToBool().
|
inline |
Returns the width of this rectangle (right - left).
Definition at line 1039 of file geometry.h.
|
inline |
Returns the left value.
Definition at line 938 of file geometry.h.
|
inline |
Returns the top value.
Definition at line 956 of file geometry.h.