#include <wx/gdicmn.h>
A class for manipulating rectangles.
Note that the x, y coordinates and the width and height stored inside a wxRect object may be negative and that wxRect functions do not perform any check against negative values.
Public Member Functions | |
wxRect () | |
Default constructor. | |
wxRect (int x, int y, int width, int height) | |
Creates a wxRect object from x, y, width and height values. | |
wxRect (const wxPoint &topLeft, const wxPoint &bottomRight) | |
Creates a wxRect object from top-left and bottom-right points. | |
wxRect (const wxPoint &pos, const wxSize &size) | |
Creates a wxRect object from position pos and size values. | |
wxRect (const wxSize &size) | |
Creates a wxRect object from size values at the origin. | |
bool | Contains (int x, int y) const |
Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise. | |
bool | Contains (const wxPoint &pt) const |
Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise. | |
bool | Contains (const wxRect &rect) const |
Returns true if the given rectangle is completely inside this rectangle (or touches its boundary) and false otherwise. | |
int | GetBottom () const |
Gets the bottom point of the rectangle. | |
wxPoint | GetBottomLeft () const |
Gets the position of the bottom left corner. | |
wxPoint | GetBottomRight () const |
Gets the position of the bottom right corner. | |
int | GetHeight () const |
Gets the height member. | |
int | GetLeft () const |
Gets the left point of the rectangle (the same as GetX()). | |
wxPoint | GetPosition () const |
Gets the position. | |
int | GetRight () const |
Gets the right point of the rectangle. | |
wxSize | GetSize () const |
Gets the size. | |
int | GetTop () const |
Gets the top point of the rectangle (the same as GetY()). | |
wxPoint | GetTopLeft () const |
Gets the position of the top left corner of the rectangle, same as GetPosition(). | |
wxPoint | GetTopRight () const |
Gets the position of the top right corner. | |
int | GetWidth () const |
Gets the width member. | |
int | GetX () const |
Gets the x member. | |
int | GetY () const |
Gets the y member. | |
wxRect & | Intersect (const wxRect &rect) |
Modifies this rectangle to contain the overlapping portion of this rectangle and the one passed in as parameter. | |
wxRect | Intersect (const wxRect &rect) const |
Returns the overlapping portion of this rectangle and the one passed in as parameter. | |
bool | Intersects (const wxRect &rect) const |
Returns true if this rectangle has a non-empty intersection with the rectangle rect and false otherwise. | |
bool | IsEmpty () const |
Returns true if this rectangle has a width or height less than or equal to 0 and false otherwise. | |
void | SetHeight (int height) |
Sets the height. | |
void | SetPosition (const wxPoint &pos) |
Sets the position. | |
void | SetSize (const wxSize &s) |
Sets the size. | |
void | SetWidth (int width) |
Sets the width. | |
void | SetX (int x) |
Sets the x position. | |
void | SetY (int y) |
Sets the y position. | |
void | SetLeft (int left) |
Set the left side of the rectangle. | |
void | SetRight (int right) |
Set the right side of the rectangle. | |
void | SetTop (int top) |
Set the top edge of the rectangle. | |
void | SetBottom (int bottom) |
Set the bottom edge of the rectangle. | |
void | SetTopLeft (const wxPoint &p) |
Set the top-left point of the rectangle. | |
void | SetBottomRight (const wxPoint &p) |
Set the bottom-right point of the rectangle. | |
void | SetTopRight (const wxPoint &p) |
Set the top-right point of the rectangle. | |
void | SetBottomLeft (const wxPoint &p) |
Set the bottom-left point of the rectangle. | |
bool | operator!= (const wxRect &r1, const wxRect &r2) |
Inequality operator. | |
wxRect & | operator= (const wxRect &rect) |
Assignment operator. | |
bool | operator== (const wxRect &r1, const wxRect &r2) |
Equality operator. | |
wxRect | CentreIn (const wxRect &r, int dir=wxBOTH) const |
Returns the rectangle having the same size as this one but centered relatively to the given rectangle r. | |
wxRect | CenterIn (const wxRect &r, int dir=wxBOTH) const |
Returns the rectangle having the same size as this one but centered relatively to the given rectangle r. | |
wxRect & | Deflate (wxCoord dx, wxCoord dy) |
Decrease the rectangle size. | |
wxRect & | Deflate (const wxSize &diff) |
Decrease the rectangle size. | |
wxRect & | Deflate (wxCoord diff) |
Decrease the rectangle size. | |
wxRect | Deflate (wxCoord dx, wxCoord dy) const |
Decrease the rectangle size. | |
wxRect & | Inflate (wxCoord dx, wxCoord dy) |
Increases the size of the rectangle. | |
wxRect & | Inflate (const wxSize &diff) |
Increases the size of the rectangle. | |
wxRect & | Inflate (wxCoord diff) |
Increases the size of the rectangle. | |
wxRect | Inflate (wxCoord dx, wxCoord dy) const |
Increases the size of the rectangle. | |
void | Offset (wxCoord dx, wxCoord dy) |
Moves the rectangle by the specified offset. | |
void | Offset (const wxPoint &pt) |
Moves the rectangle by the specified offset. | |
wxRect | Union (const wxRect &rect) const |
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. | |
wxRect & | Union (const wxRect &rect) |
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. | |
wxRect | operator+ (const wxRect &r1, const wxRect &r2) |
Like Union(), but doesn't treat empty rectangles specially. | |
wxRect & | operator+= (const wxRect &r) |
Like Union(), but doesn't treat empty rectangles specially. | |
wxRect | operator* (const wxRect &r1, const wxRect &r2) |
Returns the intersection of two rectangles (which may be empty). | |
wxRect & | operator*= (const wxRect &r) |
Returns the intersection of two rectangles (which may be empty). | |
Public Attributes | |
int | height |
Height member. | |
int | width |
Width member. | |
int | x |
x coordinate of the top-level corner of the rectangle. | |
int | y |
y coordinate of the top-level corner of the rectangle. | |
wxRect::wxRect | ( | ) |
Default constructor.
Initializes to zero the internal x, y, width and height members.
wxRect::wxRect | ( | int | x, |
int | y, | ||
int | width, | ||
int | height | ||
) |
Creates a wxRect object from x, y, width and height values.
Creates a wxRect object from top-left and bottom-right points.
Creates a wxRect object from position pos and size values.
Returns the rectangle having the same size as this one but centered relatively to the given rectangle r.
By default, rectangle is centred in both directions but if dir includes only wxVERTICAL
or only wxHORIZONTAL
, then it is only centered in this direction while the other component of its position remains unchanged.
Returns the rectangle having the same size as this one but centered relatively to the given rectangle r.
By default, rectangle is centred in both directions but if dir includes only wxVERTICAL
or only wxHORIZONTAL
, then it is only centered in this direction while the other component of its position remains unchanged.
bool wxRect::Contains | ( | int | x, |
int | y | ||
) | const |
Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise.
bool wxRect::Contains | ( | const wxPoint & | pt | ) | const |
Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise.
bool wxRect::Contains | ( | const wxRect & | rect | ) | const |
Returns true if the given rectangle is completely inside this rectangle (or touches its boundary) and false otherwise.
int wxRect::GetBottom | ( | ) | const |
Gets the bottom point of the rectangle.
wxPoint wxRect::GetBottomLeft | ( | ) | const |
Gets the position of the bottom left corner.
wxPoint wxRect::GetBottomRight | ( | ) | const |
Gets the position of the bottom right corner.
int wxRect::GetHeight | ( | ) | const |
Gets the height member.
int wxRect::GetLeft | ( | ) | const |
Gets the left point of the rectangle (the same as GetX()).
wxPoint wxRect::GetPosition | ( | ) | const |
Gets the position.
int wxRect::GetRight | ( | ) | const |
Gets the right point of the rectangle.
int wxRect::GetTop | ( | ) | const |
Gets the top point of the rectangle (the same as GetY()).
wxPoint wxRect::GetTopLeft | ( | ) | const |
Gets the position of the top left corner of the rectangle, same as GetPosition().
wxPoint wxRect::GetTopRight | ( | ) | const |
Gets the position of the top right corner.
int wxRect::GetWidth | ( | ) | const |
Gets the width member.
int wxRect::GetX | ( | ) | const |
Gets the x member.
int wxRect::GetY | ( | ) | const |
Gets the y member.
Increases the size of the rectangle.
The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
Inflating and deflating behaves "naturally". Defined more precisely, that means:
Increases the size of the rectangle.
The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
Inflating and deflating behaves "naturally". Defined more precisely, that means:
Increases the size of the rectangle.
The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
Inflating and deflating behaves "naturally". Defined more precisely, that means:
Increases the size of the rectangle.
The left border is moved farther left and the right border is moved farther right by dx. The upper border is moved farther up and the bottom border is moved farther down by dy. (Note that the width and height of the rectangle thus change by 2*dx and 2*dy, respectively.) If one or both of dx and dy are negative, the opposite happens: the rectangle size decreases in the respective direction.
Inflating and deflating behaves "naturally". Defined more precisely, that means:
Modifies this rectangle to contain the overlapping portion of this rectangle and the one passed in as parameter.
Returns the overlapping portion of this rectangle and the one passed in as parameter.
bool wxRect::Intersects | ( | const wxRect & | rect | ) | const |
Returns true if this rectangle has a non-empty intersection with the rectangle rect and false otherwise.
bool wxRect::IsEmpty | ( | ) | const |
Returns true if this rectangle has a width or height less than or equal to 0 and false otherwise.
Moves the rectangle by the specified offset.
If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
void wxRect::Offset | ( | const wxPoint & | pt | ) |
Moves the rectangle by the specified offset.
If dx is positive, the rectangle is moved to the right, if dy is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.
Returns the intersection of two rectangles (which may be empty).
Returns the intersection of two rectangles (which may be empty).
Like Union(), but doesn't treat empty rectangles specially.
Like Union(), but doesn't treat empty rectangles specially.
void wxRect::SetBottom | ( | int | bottom | ) |
Set the bottom edge of the rectangle.
Notice that this doesn't affect GetTop() return value but changes the rectangle height to set its bottom side to the given position.
void wxRect::SetBottomLeft | ( | const wxPoint & | p | ) |
Set the bottom-left point of the rectangle.
void wxRect::SetBottomRight | ( | const wxPoint & | p | ) |
Set the bottom-right point of the rectangle.
void wxRect::SetHeight | ( | int | height | ) |
Sets the height.
void wxRect::SetLeft | ( | int | left | ) |
Set the left side of the rectangle.
Notice that because the rectangle stores its left side and width, calling SetLeft() changes the right side position too – but does preserve the width.
void wxRect::SetPosition | ( | const wxPoint & | pos | ) |
Sets the position.
void wxRect::SetRight | ( | int | right | ) |
Set the right side of the rectangle.
Notice that this doesn't affect GetLeft() return value but changes the rectangle width to set its right side to the given position.
void wxRect::SetTop | ( | int | top | ) |
Set the top edge of the rectangle.
Notice that because the rectangle stores its top side and height, calling SetTop() changes the bottom side position too – but does preserve the height.
void wxRect::SetTopLeft | ( | const wxPoint & | p | ) |
Set the top-left point of the rectangle.
void wxRect::SetTopRight | ( | const wxPoint & | p | ) |
Set the top-right point of the rectangle.
void wxRect::SetWidth | ( | int | width | ) |
Sets the width.
void wxRect::SetX | ( | int | x | ) |
Sets the x position.
void wxRect::SetY | ( | int | y | ) |
Sets the y position.
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter.
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter.
int wxRect::height |
Height member.
int wxRect::width |
Width member.
int wxRect::x |
x coordinate of the top-level corner of the rectangle.
int wxRect::y |
y coordinate of the top-level corner of the rectangle.