wxRuby Documentation Home

Wx::Rect

A class for manipulating rectangles.

Derived from

None

See also

Point, Size

Methods

Rect.new

Rect.new(Integer x,  Integer y,  Integer width, 
         Integer height)

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

Rect.new(Point topLeft,  Point bottomRight)

Creates a Rect object from top-left and bottom-right points.

Rect.new(Point pos,  Size size)

Creates a Rect object from position and size values.

Rect.new(Size size)

Creates a Rect object from size values at the origin.

Rect#x

intx

x coordinate of the top-level corner of the rectangle.

Rect#y

inty

y coordinate of the top-level corner of the rectangle.

Rect#width

intwidth

Width member.

Rect#height

intheight

Height member.

Rect#centre_in

Rect centre_in(Rect r,  Integer dir = BOTH)
Rect center_in(Rect r,  Integer dir = BOTH)

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 VERTICAL or only HORIZONTAL flag, then it is only centered in this direction while the other component of its position remains unchanged.

Rect#contains

Boolean contains(Integer x,  Integer y)
Boolean contains(Point pt)

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

Boolean contains(Rect rect)

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

Rect#deflate

deflate(Integer dx,  Integer dy)
deflate(Size diff)
deflate(Integer diff)
Rect deflate(Integer dx,  Integer 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.

See also

Inflate

Rect#get_bottom

Integer get_bottom()

Gets the bottom point of the rectangle.

Rect#get_height

Integer get_height()

Gets the height member.

Rect#get_left

Integer get_left()

Gets the left point of the rectangle (the same as Rect#get_x).

Rect#get_position

Point get_position()

Gets the position.

Rect#get_top_left

Point get_top_left()

Gets the position of the top left corner of the rectangle, same as get_position.

Rect#get_top_right

Point get_top_right()

Gets the position of the top right corner.

Rect#get_bottom_left

Point get_bottom_left()

Gets the position of the bottom left corner.

Rect#get_bottom_right

Point get_bottom_right()

Gets the position of the bottom right corner.

Rect#get_right

Integer get_right()

Gets the right point of the rectangle.

Rect#get_size

Size get_size()

Gets the size.

See also

Rect#set_size

Rect#get_top

Integer get_top()

Gets the top point of the rectangle (the same as Rect#get_y).

Rect#get_width

Integer get_width()

Gets the width member.

Rect#get_x

Integer get_x()

Gets the x member.

Rect#get_y

Integer get_y()

Gets the y member.

Rect#inflate

inflate(Integer dx,  Integer dy)
inflate(Size diff)
inflate(Integer diff)
Rect inflate(Integer dx,  Integer dy)

Increases the size of the rectangle.

The second form uses the same diff for both dx and dy.

The first two versions modify the rectangle in place, the last one returns a new rectangle leaving this one unchanged.

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 the the width and height of the rectangle thus change by 2dx and 2dy, 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. (the versions prior to 2.5.4 forced the top left coordinate to not fall below (0, 0), which implied a forced move of the rectangle.)
  1. 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

Rect#intersects

Boolean intersects(Rect rect)

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

Rect#is_empty

Boolean is_empty()

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

Rect#offset

offset(Integer dx,  Integer dy)
offset(Point 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.

Rect#set_height

set_height(Integer height)

Sets the height.

Rect#set_size

set_size(Size s)

Sets the size.

See also

Rect#get_size

Rect#set_width

set_width(Integer width)

Sets the width.

Rect#set_x

set_x(Integer x)

Sets the x position.

Rect#set_y

set_y(Integer y)

Sets the y position.

Rect#union

Rect union(Rect rect)
Rect union(Rect rect)

Modifies the rectangle to contain the bounding box of this rectangle and the one passed in as parameter. The const version returns the new rectangle, the other one modifies this rectangle in place.

Rect#=

operator $=$(Rect rect)

Assignment operator.

Rect#==

Boolean operator $==$(Rect rect)

Equality operator.

Rect#!=

Boolean operator $!=$(Rect rect)

Inequality operator.

[This page automatically generated from the Textile source at Thu May 01 00:50:42 +0100 2008]