Version: 3.3.1
wxRect2DDouble Class Reference

#include <wx/geometry.h>

Detailed Description

wxRect2DDouble is an axis-aligned rectangle; each side of the rect is parallel to the X or Y axis.

The rectangle is either defined by the top left and bottom right corner, or by the top left corner and size.

A point is contained within the rectangle if left <= m_x < right and top <= m_y < bottom; thus, it is a half open interval.

Note
wxRect2DDouble has subtle differences from wxRect in how its edge and corner functions work. With wxRect2DDouble, there are two counterparts:
  • SetXXX functions, which keep the other corners at their position whenever sensible
  • MoveXXX functions, which keep the size of the rectangle and move the other corners appropriately

Public Member Functions

 wxRect2DDouble ()
 Default constructor. More...
 
 wxRect2DDouble (wxDouble x, wxDouble y, wxDouble width, wxDouble height)
 Creates a wxRect2DDouble object from x, y, width and height values. More...
 
 wxRect2DDouble (const wxRect &rect)
 Constructs a wxRect2DDouble from a wxRect. More...
 
wxPoint2DDouble GetPosition () const
 Returns the position. More...
 
wxSize GetSize () const
 Returns the size. More...
 
wxDouble GetX () const
 Returns the left position of the rectangle. More...
 
wxDouble GetY () const
 Returns the top position of the rect. More...
 
wxDouble GetWidth () const
 Returns the width. More...
 
void SetWidth (wxDouble w)
 Sets the width. More...
 
wxDouble GetHeight () const
 Returns the height. More...
 
void SetHeight (wxDouble h)
 Sets the height. More...
 
wxDouble GetLeft () const
 Returns the left point of the rectangle (the same as GetX()). More...
 
void SetLeft (wxDouble n)
 Set the left side of the rectangle. More...
 
void MoveLeftTo (wxDouble n)
 Sets the left position, which may adjust the width of the rectangle. More...
 
wxDouble GetTop () const
 Returns the top point of the rectangle (the same as GetY()). More...
 
void SetTop (wxDouble n)
 Set the top edge of the rectangle. More...
 
void MoveTopTo (wxDouble n)
 Set the top edge of the rectangle, preserving the height. More...
 
wxDouble GetBottom () const
 Returns the bottom point of the rectangle. More...
 
void SetBottom (wxDouble n)
 Set the bottom edge of the rectangle. More...
 
void MoveBottomTo (wxDouble n)
 Set the bottom edge of the rectangle, preserving the height. More...
 
wxDouble GetRight () const
 Returns the right point of the rectangle. More...
 
void SetRight (wxDouble n)
 Set the right side of the rectangle. More...
 
void MoveRightTo (wxDouble n)
 Set the right side of the rectangle, preserving the width. More...
 
wxPoint2DDouble GetLeftTop () const
 Returns the position of the top left corner of the rectangle, same as GetPosition(). More...
 
void SetLeftTop (const wxPoint2DDouble &pt)
 Set the top-left point of the rectangle. More...
 
void MoveLeftTopTo (const wxPoint2DDouble &pt)
 Set the top-left point of the rectangle, while preserving the width and height of the rectangle. More...
 
wxPoint2DDouble GetLeftBottom () const
 Returns the position of the bottom left corner. More...
 
void SetLeftBottom (const wxPoint2DDouble &pt)
 Set the bottom-left point of the rectangle. More...
 
void MoveLeftBottomTo (const wxPoint2DDouble &pt)
 Set the bottom-left point of the rectangle, while preserving the width and height of the rectangle. More...
 
wxPoint2DDouble GetRightTop () const
 Returns the position of the top right corner. More...
 
void SetRightTop (const wxPoint2DDouble &pt)
 Set the top-right point of the rectangle. More...
 
void MoveRightTopTo (const wxPoint2DDouble &pt)
 Set the top-right point of the rectangle, while preserving the width and height of the rectangle. More...
 
wxPoint2DDouble GetRightBottom () const
 Returns the position of the bottom right corner. More...
 
void SetRightBottom (const wxPoint2DDouble &pt)
 Set the bottom-right point of the rectangle. More...
 
void MoveRightBottomTo (const wxPoint2DDouble &pt)
 Set the bottom-right point of the rectangle, while preserving the width and height of the rectangle. More...
 
wxPoint2DDouble GetCentre () const
 Returns the centre point of the rectangle. More...
 
void SetCentre (const wxPoint2DDouble &pt)
 Recenters (i.e., moves) the rectangle to the given point. More...
 
void MoveCentreTo (const wxPoint2DDouble &pt)
 An alias for MoveCentreTo(). More...
 
wxOutCode GetOutCode (const wxPoint2DDouble &pt) const
 Returns the relative location of a point to the rectangle (e.g., inside or to the left of it). More...
 
bool Contains (const wxPoint2DDouble &pt) const
 Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise. More...
 
bool Contains (const wxRect2DDouble &rect) const
 Returns true if the given rectangle is completely inside this rectangle (or touches its boundary) 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...
 
bool HaveEqualSize (const wxRect2DDouble &rect) const
 Returns true if another rectangle has the same width and height. More...
 
void Inset (wxDouble x, wxDouble y)
 Offsets the rectangle by x and y, but maintains the bottom right corner. More...
 
void Inset (wxDouble left, wxDouble top, wxDouble right, wxDouble bottom)
 
void Offset (const wxPoint2DDouble &pt)
 Moves the rectangle by the specified offset. More...
 
void Offset (wxDouble dx, wxDouble dy)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void ConstrainTo (const wxRect2DDouble &rect)
 Resizes the rectangle to fit within the dimensions of another rectangle. More...
 
wxPoint2DDouble Interpolate (wxInt32 widthfactor, wxInt32 heightfactor) const
 
void Intersect (const wxRect2DDouble &otherRect)
 Constrains the rectangle to the intersection of another rectangle. More...
 
wxRect2DDouble CreateIntersection (const wxRect2DDouble &otherRect) const
 Returns the intersecting rectangle of this rectangle with another one. More...
 
bool Intersects (const wxRect2DDouble &rect) const
 Returns true if this rectangle has a non-empty intersection with the rectangle rect and false otherwise. More...
 
void Union (const wxRect2DDouble &otherRect)
 Expands the rectangle to the union with another rectangle. More...
 
void Union (const wxPoint2DDouble &pt)
 Expands the rectangle to include the point at pt. More...
 
wxRect2DDouble CreateUnion (const wxRect2DDouble &otherRect) const
 Returns the union of this rectangle with another one. More...
 
void Scale (wxDouble f)
 
void Scale (wxInt32 num, wxInt32 denum)
 
wxRect ToRect () const
 Returns the rectangle as a wxRect. More...
 
wxRect2DDoubleInflate (wxDouble dx, wxDouble dy)
 Increases the size of the rectangle. More...
 
wxRect2DDoubleInflate (const wxSize &d)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
wxRect2DDoubleInflate (wxDouble d)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
wxRect2DDouble Inflate (wxDouble dx, wxDouble dy) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
wxRect2DDoubleDeflate (wxDouble dx, wxDouble dy)
 Decrease the rectangle size. More...
 
wxRect2DDoubleDeflate (const wxSize &d)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
wxRect2DDoubleDeflate (wxDouble d)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
wxRect2DDouble Deflate (wxDouble dx, wxDouble dy) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
Miscellaneous operators
wxRect2DDoubleoperator= (const wxRect2DDouble &rect)
 Assignment operator. More...
 
bool operator== (const wxRect2DDouble &rect) const
 Equality operator. More...
 
bool operator!= (const wxRect2DDouble &rect) const
 Inequality operator. More...
 

Static Public Member Functions

static void Intersect (const wxRect2DDouble &src1, const wxRect2DDouble &src2, wxRect2DDouble *dest)
 Returns the intersecting rectangle of two rectangles. More...
 
static void Union (const wxRect2DDouble &src1, const wxRect2DDouble &src2, wxRect2DDouble *dest)
 Returns the union rectangle of two rectangles. More...
 

Public Attributes

wxDouble m_x
 
wxDouble m_y
 
wxDouble m_width
 
wxDouble m_height
 

Constructor & Destructor Documentation

◆ wxRect2DDouble() [1/3]

wxRect2DDouble::wxRect2DDouble ( )

Default constructor.

Initializes to zero the internal m_x, m_y, m_width and m_height members.

◆ wxRect2DDouble() [2/3]

wxRect2DDouble::wxRect2DDouble ( wxDouble  x,
wxDouble  y,
wxDouble  width,
wxDouble  height 
)

Creates a wxRect2DDouble object from x, y, width and height values.

◆ wxRect2DDouble() [3/3]

wxRect2DDouble::wxRect2DDouble ( const wxRect rect)
explicit

Constructs a wxRect2DDouble from a wxRect.

Since
3.3.0

Member Function Documentation

◆ ConstrainTo()

void wxRect2DDouble::ConstrainTo ( const wxRect2DDouble rect)

Resizes the rectangle to fit within the dimensions of another rectangle.

◆ Contains() [1/2]

bool wxRect2DDouble::Contains ( const wxPoint2DDouble pt) const

Returns true if the given point is inside the rectangle (or on its boundary) and false otherwise.

◆ Contains() [2/2]

bool wxRect2DDouble::Contains ( const wxRect2DDouble rect) const

Returns true if the given rectangle is completely inside this rectangle (or touches its boundary) and false otherwise.

◆ CreateIntersection()

wxRect2DDouble wxRect2DDouble::CreateIntersection ( const wxRect2DDouble otherRect) const

Returns the intersecting rectangle of this rectangle with another one.

◆ CreateUnion()

wxRect2DDouble wxRect2DDouble::CreateUnion ( const wxRect2DDouble otherRect) const

Returns the union of this rectangle with another one.

◆ Deflate() [1/4]

wxRect2DDouble& wxRect2DDouble::Deflate ( const wxSize d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Deflate() [2/4]

wxRect2DDouble& wxRect2DDouble::Deflate ( wxDouble  d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Deflate() [3/4]

wxRect2DDouble& wxRect2DDouble::Deflate ( wxDouble  dx,
wxDouble  dy 
)

Decrease the rectangle size.

This method is the opposite from Inflate(): Deflate(a, b) is equivalent to Inflate(-a, -b). Please refer to Inflate() for full description.

Since
3.3.0

◆ Deflate() [4/4]

wxRect2DDouble wxRect2DDouble::Deflate ( wxDouble  dx,
wxDouble  dy 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ GetBottom()

wxDouble wxRect2DDouble::GetBottom ( ) const

Returns the bottom point of the rectangle.

◆ GetCentre()

wxPoint2DDouble wxRect2DDouble::GetCentre ( ) const

Returns the centre point of the rectangle.

◆ GetHeight()

wxDouble wxRect2DDouble::GetHeight ( ) const

Returns the height.

Since
3.3.0

◆ GetLeft()

wxDouble wxRect2DDouble::GetLeft ( ) const

Returns the left point of the rectangle (the same as GetX()).

◆ GetLeftBottom()

wxPoint2DDouble wxRect2DDouble::GetLeftBottom ( ) const

Returns the position of the bottom left corner.

◆ GetLeftTop()

wxPoint2DDouble wxRect2DDouble::GetLeftTop ( ) const

Returns the position of the top left corner of the rectangle, same as GetPosition().

◆ GetOutCode()

wxOutCode wxRect2DDouble::GetOutCode ( const wxPoint2DDouble pt) const

Returns the relative location of a point to the rectangle (e.g., inside or to the left of it).

◆ GetPosition()

wxPoint2DDouble wxRect2DDouble::GetPosition ( ) const

Returns the position.

◆ GetRight()

wxDouble wxRect2DDouble::GetRight ( ) const

Returns the right point of the rectangle.

◆ GetRightBottom()

wxPoint2DDouble wxRect2DDouble::GetRightBottom ( ) const

Returns the position of the bottom right corner.

◆ GetRightTop()

wxPoint2DDouble wxRect2DDouble::GetRightTop ( ) const

Returns the position of the top right corner.

◆ GetSize()

wxSize wxRect2DDouble::GetSize ( ) const

Returns the size.

◆ GetTop()

wxDouble wxRect2DDouble::GetTop ( ) const

Returns the top point of the rectangle (the same as GetY()).

◆ GetWidth()

wxDouble wxRect2DDouble::GetWidth ( ) const

Returns the width.

Since
3.3.0

◆ GetX()

wxDouble wxRect2DDouble::GetX ( ) const

Returns the left position of the rectangle.

Since
3.3.0

◆ GetY()

wxDouble wxRect2DDouble::GetY ( ) const

Returns the top position of the rect.

Since
3.3.0

◆ HaveEqualSize()

bool wxRect2DDouble::HaveEqualSize ( const wxRect2DDouble rect) const

Returns true if another rectangle has the same width and height.

◆ Inflate() [1/4]

wxRect2DDouble& wxRect2DDouble::Inflate ( const wxSize d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Inflate() [2/4]

wxRect2DDouble& wxRect2DDouble::Inflate ( wxDouble  d)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Inflate() [3/4]

wxRect2DDouble& wxRect2DDouble::Inflate ( wxDouble  dx,
wxDouble  dy 
)

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:

  1. "Real" inflates (that is, dx and/or dy = 0) are not constrained. Thus inflating a rectangle can cause its upper left corner to move into the negative numbers. (2.5.4 and older forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.)
  2. Deflates are clamped to not reduce the width or height of the rectangle below zero. In such cases, the top-left corner is nonetheless handled properly. For example, a rectangle at (10, 10) with size (20, 40) that is inflated by (-15, -15) will become located at (20, 25) at size (0, 10). Finally, observe that the width and height are treated independently. In the above example, the width is reduced by 20, whereas the height is reduced by the full 30 (rather than also stopping at 20, when the width reached zero).
See also
Deflate()
Since
3.3.0

◆ Inflate() [4/4]

wxRect2DDouble wxRect2DDouble::Inflate ( wxDouble  dx,
wxDouble  dy 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Inset() [1/2]

void wxRect2DDouble::Inset ( wxDouble  left,
wxDouble  top,
wxDouble  right,
wxDouble  bottom 
)

◆ Inset() [2/2]

void wxRect2DDouble::Inset ( wxDouble  x,
wxDouble  y 
)

Offsets the rectangle by x and y, but maintains the bottom right corner.

Note
This will affect the width and height of the rectangle.

◆ Interpolate()

wxPoint2DDouble wxRect2DDouble::Interpolate ( wxInt32  widthfactor,
wxInt32  heightfactor 
) const

◆ Intersect() [1/2]

void wxRect2DDouble::Intersect ( const wxRect2DDouble otherRect)

Constrains the rectangle to the intersection of another rectangle.

◆ Intersect() [2/2]

static void wxRect2DDouble::Intersect ( const wxRect2DDouble src1,
const wxRect2DDouble src2,
wxRect2DDouble dest 
)
static

Returns the intersecting rectangle of two rectangles.

◆ Intersects()

bool wxRect2DDouble::Intersects ( const wxRect2DDouble rect) const

Returns true if this rectangle has a non-empty intersection with the rectangle rect and false otherwise.

◆ IsEmpty()

bool wxRect2DDouble::IsEmpty ( ) const

Returns true if this rectangle has a width or height less than or equal to 0 and false otherwise.

◆ MoveBottomTo()

void wxRect2DDouble::MoveBottomTo ( wxDouble  n)

Set the bottom edge of the rectangle, preserving the height.

◆ MoveCentreTo()

void wxRect2DDouble::MoveCentreTo ( const wxPoint2DDouble pt)

An alias for MoveCentreTo().

◆ MoveLeftBottomTo()

void wxRect2DDouble::MoveLeftBottomTo ( const wxPoint2DDouble pt)

Set the bottom-left point of the rectangle, while preserving the width and height of the rectangle.

◆ MoveLeftTo()

void wxRect2DDouble::MoveLeftTo ( wxDouble  n)

Sets the left position, which may adjust the width of the rectangle.

◆ MoveLeftTopTo()

void wxRect2DDouble::MoveLeftTopTo ( const wxPoint2DDouble pt)

Set the top-left point of the rectangle, while preserving the width and height of the rectangle.

◆ MoveRightBottomTo()

void wxRect2DDouble::MoveRightBottomTo ( const wxPoint2DDouble pt)

Set the bottom-right point of the rectangle, while preserving the width and height of the rectangle.

◆ MoveRightTo()

void wxRect2DDouble::MoveRightTo ( wxDouble  n)

Set the right side of the rectangle, preserving the width.

◆ MoveRightTopTo()

void wxRect2DDouble::MoveRightTopTo ( const wxPoint2DDouble pt)

Set the top-right point of the rectangle, while preserving the width and height of the rectangle.

◆ MoveTopTo()

void wxRect2DDouble::MoveTopTo ( wxDouble  n)

Set the top edge of the rectangle, preserving the height.

◆ Offset() [1/2]

void wxRect2DDouble::Offset ( const wxPoint2DDouble pt)

Moves the rectangle by the specified offset.

If X of pt is positive, the rectangle is moved to the right, if Y of pt is positive, it is moved to the bottom, otherwise it is moved to the left or top respectively.

◆ Offset() [2/2]

void wxRect2DDouble::Offset ( wxDouble  dx,
wxDouble  dy 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
3.3.0

◆ operator!=()

bool wxRect2DDouble::operator!= ( const wxRect2DDouble rect) const

Inequality operator.

◆ operator=()

wxRect2DDouble& wxRect2DDouble::operator= ( const wxRect2DDouble rect)

Assignment operator.

◆ operator==()

bool wxRect2DDouble::operator== ( const wxRect2DDouble rect) const

Equality operator.

◆ Scale() [1/2]

void wxRect2DDouble::Scale ( wxDouble  f)

◆ Scale() [2/2]

void wxRect2DDouble::Scale ( wxInt32  num,
wxInt32  denum 
)

◆ SetBottom()

void wxRect2DDouble::SetBottom ( wxDouble  n)

Set the bottom edge of the rectangle.

Note
This will preserve the top position and alter the height of the rectangle. Use MoveBottomTo() to only move the bottom.

◆ SetCentre()

void wxRect2DDouble::SetCentre ( const wxPoint2DDouble pt)

Recenters (i.e., moves) the rectangle to the given point.

◆ SetHeight()

void wxRect2DDouble::SetHeight ( wxDouble  h)
inline

Sets the height.

Since
3.3.0

◆ SetLeft()

void wxRect2DDouble::SetLeft ( wxDouble  n)

Set the left side of the rectangle.

Note
This will preserve the width of the rectangle. Use MoveLeftTo() to change the left position of the rectangle, adjusting its width accordingly.

◆ SetLeftBottom()

void wxRect2DDouble::SetLeftBottom ( const wxPoint2DDouble pt)

Set the bottom-left point of the rectangle.

Note
This will alter the width and height of the rectangle. Use MoveLeftBottomTo() to only move the left bottom corner.

◆ SetLeftTop()

void wxRect2DDouble::SetLeftTop ( const wxPoint2DDouble pt)

Set the top-left point of the rectangle.

Note
This will alter the height of the rectangle. Use MoveLeftTopTo() to only move the top.

◆ SetRight()

void wxRect2DDouble::SetRight ( wxDouble  n)

Set the right side of the rectangle.

Note
This will preserve the left position and alter the width of the rectangle. Use MoveRightTo() to only move the bottom.

◆ SetRightBottom()

void wxRect2DDouble::SetRightBottom ( const wxPoint2DDouble pt)

Set the bottom-right point of the rectangle.

Note
This will alter the width and height of the rectangle. Use MoveRightBottomTo() to only move the right bottom corner.

◆ SetRightTop()

void wxRect2DDouble::SetRightTop ( const wxPoint2DDouble pt)

Set the top-right point of the rectangle.

Note
This will alter the width and height of the rectangle. Use MoveRightTopTo() to only move the right top corner.

◆ SetTop()

void wxRect2DDouble::SetTop ( wxDouble  n)

Set the top edge of the rectangle.

Note
This will alter the height of the rectangle. Use MoveTopTo() to only move the top.

◆ SetWidth()

void wxRect2DDouble::SetWidth ( wxDouble  w)

Sets the width.

Since
3.3.0

◆ ToRect()

wxRect wxRect2DDouble::ToRect ( ) const

Returns the rectangle as a wxRect.

Since
3.3.0

◆ Union() [1/3]

void wxRect2DDouble::Union ( const wxPoint2DDouble pt)

Expands the rectangle to include the point at pt.

◆ Union() [2/3]

void wxRect2DDouble::Union ( const wxRect2DDouble otherRect)

Expands the rectangle to the union with another rectangle.

◆ Union() [3/3]

static void wxRect2DDouble::Union ( const wxRect2DDouble src1,
const wxRect2DDouble src2,
wxRect2DDouble dest 
)
static

Returns the union rectangle of two rectangles.

Member Data Documentation

◆ m_height

wxDouble wxRect2DDouble::m_height

◆ m_width

wxDouble wxRect2DDouble::m_width

◆ m_x

wxDouble wxRect2DDouble::m_x

◆ m_y

wxDouble wxRect2DDouble::m_y