INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Defines the coordinates of the upper-left and ", "lower-right corners of a rectangle. ", "WEL: library of reusable components for Eiffel. ", "Based on WEL library for ISE Eiffel, used with permission. "
project: "Windows Eiffel Library"
copyright: "(c) 1986-1997 Interactive Software Engineering Inc. ", "Modifications and extensions: ", "(c) 1997 Object Tools ", "All rights reserved. Duplication and distribution prohibited", "May be used only with Visual Eiffel under terms of user ", "license "
cluster: wel
class WEL_RECT
inherit

WEL_STRUCTURE
rename
make as structure_make
export
{ANY}
clone,
copy,
is_equal
redefine
is_equal
end
creation

make,
make_by_pointer,
make_client,
make_window
feature {NONE}-- Initialization

make (a_left, a_top, a_right, a_bottom: INTEGER)
-- Make a rectangle and set `left', `top',
-- `right', `bottom' with `a_left', `a_top',
-- `a_right', `a_bottom'
require
right_larger_than_left: a_right >= a_left
bottom_larger_than_top: a_bottom >= a_top
ensure
left_set: left = a_left
top_set: top = a_top
right_set: right = a_right
bottom_set: bottom = a_bottom

make_client (window: WEL_WINDOW)
-- Make a client rectangle with `window'
require
window_not_void: window /= void
window_exists: window.exists
ensure
left_equal_zero: left = 0
top_equal_zero: top = 0
client_rect_set: is_equal (window.client_rect)

make_window (window: WEL_WINDOW)
-- Make a window rectangle with `window'
-- (absolute position)
require
window_not_void: window /= void
window_exists: window.exists
ensure
window_rect_set: is_equal (window.window_rect)
feature -- Access

left, x: INTEGER
-- Position of the left border

top, y: INTEGER
-- Position of the top border

right: INTEGER
-- Position of the right border

bottom: INTEGER
-- Position of the bottom border

width: INTEGER
-- Width of current rect

height: INTEGER
-- Height of current rect
feature -- Element change

set_rect (a_left, a_top, a_right, a_bottom: INTEGER)
-- Quick set of `left', `top', `right', `bottom'
-- with `a_left', `a_top', `a_right', `a_bottom'
-- respectively.
require
right_larger_than_left: a_right >= a_left
bottom_larger_than_top: a_bottom >= a_top
ensure
left_set: left = a_left
top_set: top = a_top
right_set: right = a_right
bottom_set: bottom = a_bottom

set_left (a_left: INTEGER)
-- Set `left' with `a_left'
require
left_smaller_than_right: a_left <= right
ensure
left_set: left = a_left

set_top (a_top: INTEGER)
-- Set `top' with `a_top'
require
top_smaller_than_bottom: a_top <= bottom
ensure
top_set: top = a_top

set_right (a_right: INTEGER)
-- Set `right' with `a_right'
require
right_larger_than_left: a_right >= left
ensure
right_set: right = a_right

set_bottom (a_bottom: INTEGER)
-- Set `bottom' with `a_bottom'
require
bottom_larger_than_top: a_bottom >= top
ensure
bottom_set: bottom = a_bottom
feature -- Basic operations

offset (a_x, a_y: INTEGER)
-- Moves the rectangle by the specified
-- offsets `a_x' and `a_y'.
ensure
x_set: x = x + a_x
y_set: y = y + a_y
right_set: right = right + a_x
bottom_set: bottom = bottom + a_y

inflate (a_x, a_y: INTEGER)
-- Inflate the rectangle by `a_x' and `a_y'.
-- Positive values increase the width and height,
-- and negative values decrease them.
ensure
left_set: left = left - a_x
top_set: top = top - a_x
right_set: right = right + a_y
bottom_set: bottom = bottom + a_y

union (rect1, rect2: WEL_RECT)
-- Set the current rectangle by the smallest
-- rectangle that contains both source
-- rectangles `rect1' and `rect2'.
require
rect1_not_void: rect1 /= void
rect2_not_void: rect2 /= void

subtract (rect1, rect2: WEL_RECT)
-- Set the current rectangle by subtracting
-- `rect1' from `rect2'.
require
rect1_not_void: rect1 /= void
rect2_not_void: rect2 /= void

intersect (rect1, rect2: WEL_RECT)
-- Calculates the intersection of `rect1'
-- and `rect2'. If `rect1' and `rect2' do not
-- intersect then `empty' becomes True.
require
rect1_not_void: rect1 /= void
rect2_not_void: rect2 /= void
feature -- Status report

empty: BOOLEAN
-- Is it empty?
-- A rectangle is empty if the coordinate of the right
-- side is less than or equal to the coordinate
-- of the left side, or the coordinate of the bottom
-- side is less than or equal to the coordinate of
-- the top side.

point_in (point: WEL_POINT): BOOLEAN
-- Is `point' in the rectangle?
require
point_not_void: point /= void
feature -- Comparison

is_equal (other: like Current): BOOLEAN
-- Is `Current' equal to `other'?
feature -- Measurement

structure_size: INTEGER
-- Size to allocate (in bytes)
invariant

right_larger_than_left: right >= left
bottom_larger_than_top: bottom >= top
positive_width: width >= 0
positive_height: height >= 0
end -- class WEL_RECT

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES