|
OWLNext 6.32
|
#include <geometry.h>
Public Member Functions | |
| TRect () | |
| TRect (const tagRECT &rect) | |
| TRect (const TRect &rect) | |
| TRect (int _left, int _top, int _right, int _bottom) | |
| TRect (const TPoint &upLeft, const TPoint &loRight) | |
| TRect (const TPoint &origin, const TSize &extent) | |
| void | SetNull () |
| void | SetEmpty () |
| void | Set (int _left, int _top, int _right, int _bottom) |
| void | SetWH (int _left, int _top, int w, int h) |
| operator const TPoint * () const | |
| operator TPoint * () | |
| bool | IsEmpty () const |
| bool | IsNull () const |
| bool | operator== (const TRect &other) const |
| bool | operator!= (const TRect &other) const |
| int | Left () const |
| int | X () const |
| int | Top () const |
| int | Y () const |
| int | Right () const |
| int | Bottom () const |
| const TPoint & | TopLeft () const |
| TPoint & | TopLeft () |
| TPoint | TopRight () const |
| TPoint | BottomLeft () const |
| const TPoint & | BottomRight () const |
| TPoint & | BottomRight () |
| int | Width () const |
| int | Height () const |
| TSize | Size () const |
| long | Area () const |
| bool | Contains (const TPoint &point) const |
| bool | Contains (const TRect &other) const |
| bool | Touches (const TRect &other) const |
| TRect | OffsetBy (int dx, int dy) const |
| TRect | operator+ (const TSize &size) const |
| TRect | operator- (const TSize &size) const |
| TRect | MovedTo (int x, int y) |
| TRect | InflatedBy (int dx, int dy) const |
| TRect | InflatedBy (const TSize &size) const |
| TRect | Normalized () const |
| TRect | operator& (const TRect &other) const |
| TRect | operator| (const TRect &other) const |
| int | Subtract (const TRect &other, TRect result[]) const |
| TRect & | Normalize () |
| TRect & | Offset (int dx, int dy) |
| TRect & | operator+= (const TSize &delta) |
| TRect & | operator-= (const TSize &delta) |
| TRect & | MoveTo (int x, int y) |
| TRect & | Inflate (int dx, int dy) |
| TRect & | DeflateRect (int dx, int dy) |
| TRect & | Inflate (const TSize &delta) |
| TRect & | DeflateRect (const TSize &delta) |
| TRect & | operator&= (const TRect &other) |
| TRect & | operator|= (const TRect &other) |
TRect is a mathematical class derived from tagRect. The tagRect struct is defined as
struct tagRECT { int left; int top; int right; int bottom; };
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.
| owl::TRect::TRect | ( | ) | [inline] |
Default constructor that does nothing.
| owl::TRect::TRect | ( | const tagRECT & | rect | ) | [inline] |
Copy from an existing rectangle.
| owl::TRect::TRect | ( | const TRect & | rect | ) | [inline] |
Copy from an existing rectangle.
| owl::TRect::TRect | ( | int | _left, |
| int | _top, | ||
| int | _right, | ||
| int | _bottom | ||
| ) | [inline] |
Constructor that sets all the values explicitly.
Creates a rectangle with the given top left and bottom right points.
Creates a rectangle with its origin (top left) at origin, width at extent.cx, height at extent.cy.
| long owl::TRect::Area | ( | ) | const [inline] |
Returns the area of this rectangle.
| int owl::TRect::Bottom | ( | ) | const [inline] |
Returns the bottom value.
| TPoint owl::TRect::BottomLeft | ( | ) | const [inline] |
Returns the TPoint object representing the bottom left corner of this rectangle.
| const TPoint & owl::TRect::BottomRight | ( | ) | const [inline] |
Returns the TPoint object representing the bottom right corner of this rectangle.
| TPoint & owl::TRect::BottomRight | ( | ) | [inline] |
Returns the TPoint object representing the bottom right corner of this rectangle.
| bool owl::TRect::Contains | ( | const TPoint & | point | ) | const [inline] |
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.
| bool owl::TRect::Contains | ( | const TRect & | other | ) | const [inline] |
Returns true if the other rectangle lies on or within this rectangle; otherwise, it returns false.
| int owl::TRect::Height | ( | ) | const [inline] |
Returns the height of this rectangle (bottom - top).
| TRect & owl::TRect::Inflate | ( | int | dx, |
| int | dy | ||
| ) |
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).
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).
| TRect owl::TRect::InflatedBy | ( | int | dx, |
| int | dy | ||
| ) | const [inline] |
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.
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.
| bool owl::TRect::IsEmpty | ( | ) | const [inline] |
Returns true if left >= right or top >= bottom; otherwise, returns false.
| bool owl::TRect::IsNull | ( | ) | const [inline] |
Returns true if left, right, top, and bottom are all 0; otherwise, returns false.
| int owl::TRect::Left | ( | ) | const [inline] |
Returns the left value.
| TRect owl::TRect::MovedTo | ( | int | x, |
| int | y | ||
| ) | [inline] |
Moves the upper left point of the rectangle while maintaining the current dimension.
| TRect & owl::TRect::MoveTo | ( | int | x, |
| int | y | ||
| ) | [inline] |
Moves the upper left corner of the rectangle to a new location and maintains the current dimension.
| 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.
| TRect owl::TRect::Normalized | ( | ) | const [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.
| TRect & owl::TRect::Offset | ( | int | dx, |
| int | dy | ||
| ) |
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.
| TRect owl::TRect::OffsetBy | ( | int | dx, |
| int | dy | ||
| ) | const [inline] |
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
| owl::TRect::operator const TPoint * | ( | ) | const [inline] |
Type conversion operators converting the pointer to this rectangle to type pointer to TPoint. Return an array of two points (upperleft and bottomright)
| owl::TRect::operator TPoint * | ( | ) | [inline] |
Type conversion operators converting the pointer to this rectangle to type pointer to TPoint. Return an array of two points (upperleft and bottomright)
| bool owl::TRect::operator!= | ( | const TRect & | other | ) | const [inline] |
Returns false if this rectangle has identical corner coordinates to the other rectangle; otherwise, returns true.
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.
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.
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.
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.
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.
| bool owl::TRect::operator== | ( | const TRect & | other | ) | const [inline] |
Returns true if this rectangle has identical corner coordinates to the other rectangle; otherwise, returns false.
Returns the union of this rectangle and the other rectangle. The calling rectangle object is unchanged.
Changes this rectangle to its union with the other rectangle. This rectangle object is returned.
References IsNull().
| int owl::TRect::Right | ( | ) | const [inline] |
Returns the right value.
| void owl::TRect::Set | ( | int | _left, |
| int | _top, | ||
| int | _right, | ||
| int | _bottom | ||
| ) | [inline] |
Repositions and resizes this rectangle to the given values.
| void owl::TRect::SetEmpty | ( | ) | [inline] |
Empties this rectangle by setting left, top, right, and bottom to 0.
| void owl::TRect::SetNull | ( | ) | [inline] |
Sets the left, top, right, and bottom of the rectangle to 0.
| void owl::TRect::SetWH | ( | int | _left, |
| int | _top, | ||
| int | w, | ||
| int | h | ||
| ) | [inline] |
Determines the rectangle, given its upperleft point, width, and height.
| TSize owl::TRect::Size | ( | ) | const [inline] |
Returns the size of rectangle.
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.
References Touches().
| int owl::TRect::Top | ( | ) | const [inline] |
Returns the top value.
| const TPoint & owl::TRect::TopLeft | ( | ) | const [inline] |
Returns the upperleft point.
| TPoint & owl::TRect::TopLeft | ( | ) | [inline] |
Returns the upperleft point.
| TPoint owl::TRect::TopRight | ( | ) | const [inline] |
Returns the upperright point.
| bool owl::TRect::Touches | ( | const TRect & | other | ) | const [inline] |
Returns true if the other rectangle shares any interior points with this rectangle; otherwise, returns false.
| int owl::TRect::Width | ( | ) | const [inline] |
Returns the width of this rectangle (right - left).
| int owl::TRect::X | ( | ) | const [inline] |
Returns the left value.
| int owl::TRect::Y | ( | ) | const [inline] |
Returns the top value.
1.7.4