wxRuby Documentation Home

Wx::Rect

A class for manipulating rectangles.

Derived from

None

See also

Point, Size

Methods

Rect.new

Rect.new(%(arg-type)Integer% x, Integer y, Integer width, Integer height)

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

Rect.new(%(arg-type)Point% topLeft, Point bottomRight)

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

Rect.new(%(arg-type)Point% pos, Size size)

Creates a Rect object from position and size values.

Rect.new(%(arg-type)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(%(arg-type)Rect% r, Integer dir = BOTH) Rect center_in(%(arg-type)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(%(arg-type)Integer% x, Integer y) Boolean contains(%(arg-type)Point% pt)

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

Boolean contains(%(arg-type)Rect% rect)

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

Rect#deflate

deflate(%(arg-type)Integer% dx, Integer dy) deflate(%(arg-type)Size% diff) deflate(%(arg-type)Integer% diff) Rect deflate(%(arg-type)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(%(arg-type)Integer% dx, Integer dy) inflate(%(arg-type)Size% diff) inflate(%(arg-type)Integer% diff) Rect inflate(%(arg-type)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 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. (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(%(arg-type)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(%(arg-type)Integer% dx, Integer dy) offset(%(arg-type)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(%(arg-type)Integer% height)

Sets the height.

Rect#set_size

set_size(%(arg-type)Size% s)

Sets the size.

See also

Rect#get_size

Rect#set_width

set_width(%(arg-type)Integer% width)

Sets the width.

Rect#set_x

set_x(%(arg-type)Integer% x)

Sets the x position.

Rect#set_y

set_y(%(arg-type)Integer% y)

Sets the y position.

Rect#union

Rect union(%(arg-type)Rect% rect) Rect union(%(arg-type)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 $=$(%(arg-type)Rect% rect)

Assignment operator.

Rect#==

Boolean operator $==$(%(arg-type)Rect% rect)

Equality operator.

Rect#!=

Boolean operator $!=$(%(arg-type)Rect% rect)

Inequality operator.

[This page automatically generated from the Textile source at 2023-06-13 21:31:41 +0000]