Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.video

Class EM_DRAWABLE


Direct ancestors

EM_CONSTANTS

Known direct descendants

EM_FRAME_COUNTER, EM_BITMAP, EM_SPRITE, EM_STRING, EM_GOOF_PHYSICS, EM_DRAWABLE_CONTAINER, EM_VIDEO_DECODER, EM_NEVER_ENDING_BACKGROUND, EM_TRANSFORMER, EM_TILE_PATTERN, EM_CHARACTER, EM_FIGURE

Features

Invariants

indexing

description

This is an important interface in the EiffelMedia library.
Anything that can be drawn through an EM_SURFACE
should implement EM_DRAWABLE.

date

$Date: 2005/10/23 10:40:29 $

revision

$Revision: 1.5 $

deferred class

EM_DRAWABLE

feature -- Status report

height: INTEGER

-- Height of Current in pixels

ensure
result_not_negative: Result >= 0
is_size_fixed: BOOLEAN

-- Should Current not scale when drawed?
-- True means that the object will be drawed unscaled
-- but its position (reference_point) will still be transformed correctly
-- if drawed on a transformed scaled coordinate system
-- (This is handled accordingly by draw_object of EM_SURFACE)

width: INTEGER

-- Width of Current in pixels

ensure
result_not_negative: Result >= 0
x: INTEGER

-- Horizontal position, distance in pixels from left

y: INTEGER

-- Vertical position, distance in pixels from top

feature -- Status setting

set_size_fixed (a_boolean: BOOLEAN)

-- Set is_size_fixed to a_boolean.

ensure
size_fixed_set: is_size_fixed = a_boolean
set_x (x_position: INTEGER)

-- Set x to x_position.

ensure
x_set: x = x_position
set_x_y (an_x, a_y: INTEGER)

-- Set x to an_x and y to a_y.

ensure
x_set: x = an_x
y_set: y = a_y
set_y (y_position: INTEGER)

-- Set y to y_position.

ensure
y_set: y = y_position

feature -- Drawing

draw (a_surface: EM_SURFACE)

-- Draw Current onto a_surface.

require
a_surface_not_void: a_surface /= Void
draw_part (a_rect: EM_RECT; a_surface: EM_SURFACE)

-- Draw rectangular part of Current defined by a_rect to a_surface.
-- (Subclasses could redefine this feature for providing an implementation
-- with better performance, otherwise its just done per default by
-- transforming and clipping coordinates on a_surface before calling draw).

require
a_surface_not_void: a_surface /= Void
a_rect_not_void: a_rect /= Void

feature -- Mouse events

events_initialized: BOOLEAN

-- Have events been initialized?

initialize_events

-- Event initialization.
-- Needs to be called before subscribing for events.

require
not_yet_initialized: not events_initialized
ensure
events_initialized: events_initialized
mouse_button_down_event_initialized: mouse_button_down_event /= Void
mouse_button_up_event_initialized: mouse_button_up_event /= Void
mouse_motion_event_initialized: mouse_motion_event /= Void
mouse_button_down_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button down event,
-- gets published when the mouse button is pressed over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

mouse_button_up_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEBUTTON_EVENT is passed as argument

mouse_motion_event: EM_EVENT_TYPE [TUPLE [EM_MOUSE_EVENT]]

-- Mouse button up event,
-- gets published when the mouse button is released over Current,
-- an EM_MOUSEMOTION_EVENT is passed as argument

publish_mouse_event (a_mouse_event: EM_MOUSE_EVENT)

-- Publish mouse event when a_mouse_event occured on Current.
-- Descendants should redefine this feature
-- for only catching and publishing their mouse events when mouse pointer
-- is realy inside object or for
-- distributing mouse events to child objects.

require
a_mouse_event_not_void: a_mouse_event /= Void

feature -- Queries

bounding_box: EM_ORTHOGONAL_RECTANGLE

-- Orthogonal rectangle surrounding Current; (i.e. usefull
-- for visibility testing if it intersects with
-- coordinate_area of EM_SURFACE) TODO: We create a new
-- one on each call. Maybe there is a more efficient way to
-- do that?

ensure
result_not_void: Result /= Void
reference_point: EM_VECTOR_2D

-- Reference point of Current relative to which it should be positioned.
-- (i.e. important when drawn on a scaled coordinate system and is_size_fixed is True)

ensure
result_not_void: Result /= Void

invariant

mouse_button_down_event_initialized: events_initialized implies mouse_button_down_event /= Void
mouse_button_up_event_initialized: events_initialized implies mouse_button_up_event /= Void
mouse_motion_event_initialized: events_initialized implies mouse_motion_event /= Void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end