#include <wx/gdicmn.h>
Represents a rectangle with integer coordinates.
x
and y
members specify the coordinates of the rectangle top-left corner and width
and height
specify its width and height respectively. The usual C++ semi-open interval convention is used: point p
lies inside the rectangle if and only if both conditions below are satisfied:
In other words, the rectangle left and right boundaries are at x
and x+width-1
and its top and bottom boundaries are at y
and y+height-1
respectively.
Note that the x and y coordinates may be negative, but width and height are always strictly positive for non-empty rectangles.
Public Member Functions | |
wxRect () | |
Default constructor. More... | |
wxRect (int x, int y, int width, int height) | |
Creates a wxRect object from x, y, width and height values. More... | |
wxRect (const wxPoint &topLeft, const wxPoint &bottomRight) | |
Creates a wxRect object from top-left and bottom-right points. More... | |
wxRect (const wxPoint &pos, const wxSize &size) | |
Creates a wxRect object from position pos and size values. More... | |
wxRect (const wxSize &size) | |
Creates a wxRect object from size values at the origin. More... | |
bool | Contains (int x, int y) const |
Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise. More... | |
bool | Contains (const wxPoint &pt) const |
Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise. More... | |
bool | Contains (const wxRect &rect) const |
Returns true if the given rectangle is completely inside this rectangle (or touches its boundary) and false otherwise. More... | |
int | GetBottom () const |
Gets the bottom point of the rectangle. More... | |
wxPoint | GetBottomLeft () const |
Gets the position of the bottom left corner. More... | |
wxPoint | GetBottomRight () const |
Gets the position of the bottom right corner. More... | |
int | GetHeight () const |
Gets the height member. More... | |
int | GetLeft () const |
Gets the left point of the rectangle (the same as GetX()). More... | |
wxPoint | GetPosition () const |
Gets the position. More... | |
int | GetRight () const |
Gets the right point of the rectangle. More... | |
wxSize | GetSize () const |
Gets the size. More... | |
int | GetTop () const |
Gets the top point of the rectangle (the same as GetY()). More... | |
wxPoint | GetTopLeft () const |
Gets the position of the top left corner of the rectangle, same as GetPosition(). More... | |
wxPoint | GetTopRight () const |
Gets the position of the top right corner. More... | |
int | GetWidth () const |
Gets the width member. More... | |
int | GetX () const |
Gets the x member. More... | |
int | GetY () const |
Gets the y member. More... | |
wxRect & | Intersect (const wxRect &rect) |
Modifies this rectangle to contain the overlapping portion of this rectangle and the one passed in as parameter. More... | |
wxRect | Intersect (const wxRect &rect) const |
Returns the overlapping portion of this rectangle and the one passed in as parameter. More... | |
bool | Intersects (const wxRect &rect) const |
Returns true if this rectangle has a non-empty intersection with the rectangle rect and false otherwise. More... | |
bool | IsEmpty () const |
Returns true if this rectangle has a width or height less than or equal to 0 and false otherwise. More... | |
void | SetHeight (int height) |
Sets the height. More... | |
void | SetPosition (const wxPoint &pos) |
Sets the position. More... | |
void | SetSize (const wxSize &s) |
Sets the size. More... | |
void | SetWidth (int width) |
Sets the width. More... | |
void | SetX (int x) |
Sets the x position. More... | |
void | SetY (int y) |
Sets the y position. More... | |
void | SetLeft (int left) |
Set the left side of the rectangle. More... | |
void | SetRight (int right) |
Set the right side of the rectangle. More... | |
void | SetTop (int top) |
Set the top edge of the rectangle. More... | |
void | SetBottom (int bottom) |
Set the bottom edge of the rectangle. More... | |
void | SetTopLeft (const wxPoint &p) |
Set the top-left point of the rectangle. More... | |
void | SetBottomRight (const wxPoint &p) |
Set the bottom-right point of the rectangle. More... | |
void | SetTopRight (const wxPoint &p) |
Set the top-right point of the rectangle. More... | |
void | SetBottomLeft (const wxPoint &p) |
Set the bottom-left point of the rectangle. More... | |
bool | operator!= (const wxRect &r1, const wxRect &r2) |
Inequality operator. More... | |
wxRect & | operator= (const wxRect &rect) |
Assignment operator. More... | |
bool | operator== (const wxRect &r1, const wxRect &r2) |
Equality operator. More... | |
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. More... | |
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. More... | |
wxRect & | Deflate (wxCoord dx, wxCoord dy) |
Decrease the rectangle size. More... | |
wxRect & | Deflate (const wxSize &diff) |
Decrease the rectangle size. More... | |
wxRect & | Deflate (wxCoord diff) |
Decrease the rectangle size. More... | |
wxRect | Deflate (wxCoord dx, wxCoord dy) const |
Decrease the rectangle size. More... | |
wxRect & | Inflate (wxCoord dx, wxCoord dy) |
Increases the size of the rectangle. More... | |
wxRect & | Inflate (const wxSize &diff) |
Increases the size of the rectangle. More... | |
wxRect & | Inflate (wxCoord diff) |
Increases the size of the rectangle. More... | |
wxRect | Inflate (wxCoord dx, wxCoord dy) const |
Increases the size of the rectangle. More... | |
void | Offset (wxCoord dx, wxCoord dy) |
Moves the rectangle by the specified offset. More... | |
void | Offset (const wxPoint &pt) |
Moves the rectangle by the specified offset. More... | |
wxRect | Union (const wxRect &rect) const |
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. More... | |
wxRect & | Union (const wxRect &rect) |
Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. More... | |
wxRect | operator+ (const wxRect &r1, const wxRect &r2) |
Like Union(), but doesn't treat empty rectangles specially. More... | |
wxRect & | operator+= (const wxRect &r) |
Like Union(), but doesn't treat empty rectangles specially. More... | |
wxRect | operator* (const wxRect &r1, const wxRect &r2) |
Returns the intersection of two rectangles (which may be empty). More... | |
wxRect & | operator*= (const wxRect &r) |
Returns the intersection of two rectangles (which may be empty). More... | |
Public Attributes | |
int | height |
Height member. More... | |
int | width |
Width member. More... | |
int | x |
x coordinate of the top-left corner of the rectangle. More... | |
int | y |
y coordinate of the top-left corner of the rectangle. More... | |
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.
The width of the rectangle will be bottomRight.x-topLeft.x+1
and the height will be bottomRight.y-topLeft.y+1
.
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 | ( | 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.
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.
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.
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.
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-left corner of the rectangle.
int wxRect::y |
y coordinate of the top-left corner of the rectangle.