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

em.widget

Class EM_WIDGET_SCENE


Direct ancestors

EM_COMPONENT_SCENE, EM_WIDGET, EM_TIME_SINGLETON

Creation

Features

Invariants

indexing

description

Scene that contains EM_WIDGET's.
Widgets can be added using add_widget.

The next scene can be set and started using set_next_scene and start_next_scene.

Subclasses must call make_widget_scene at creation.

date

$Date: 2005/10/23 11:07:51 $

revision

$Revision: 1.12 $

class

EM_WIDGET_SCENE

inherit

EM_COMPONENT_SCENE
EM_WIDGET

create

make_widget_scene

-- Initialise widget scene.

feature -- Initialisation

initialize_scene

-- Initialize the scene.

-- (From EM_SCENE)

feature -- Initialization

uninitialize_scene

-- Uninitialize scene.
-- This is called right before next scene is displayed.
-- Redefine this to clean up some needed things (openGl properties, images, ...)

-- (From EM_SCENE)

feature -- Access

background: EM_BACKGROUND

-- Background of widget

-- (From EM_WIDGET)

border: EM_BORDER

-- Border of widget

-- (From EM_WIDGET)

component_at_position (a_x, a_y: INTEGER): EM_COMPONENT

-- Top most component at position a_x a_y

-- (From EM_COMPONENT_SCENE)

components: DS_LINEAR [EM_COMPONENT]

-- List of components

-- (From EM_COMPONENT_SCENE)

ensure
components_not_void: Result /= Void
delegate: EM_WIDGET_DELEGATE

-- Delegate which draws widget

-- (From EM_WIDGET)

event_loop: EM_EVENT_LOOP

-- Event loop that makes scene running

-- (From EM_SCENE)

font: EM_FONT

-- Font of widget

-- (From EM_WIDGET)

foreground_color: EM_COLOR

-- Foreground color of widget

-- (From EM_WIDGET)

next_scene: EM_SCENE

-- Scene that should be executed after this scene ends.
-- If next_scene = Void the program just ends.

-- (From EM_SCENE)

screen: EM_VIDEO_SURFACE

-- Surface where scene is drawed

-- (From EM_SCENE)

screen_x: INTEGER

-- X position of Current on screen

-- (From EM_WIDGET)

screen_y: INTEGER

-- Y position of Current on screen

-- (From EM_WIDGET)

surface: EM_SURFACE

-- Surface to draw on

-- (From EM_2D_COMPONENT)

tooltip: STRING

-- Tooltip of Current

-- (From EM_COMPONENT)

widgets: DS_LINEAR [EM_WIDGET]

-- Nested widgets.

-- (From EM_WIDGET)

ensure
widgets_not_void: Result /= Void

feature -- Measurement

height: INTEGER

-- Height of scene

-- (From EM_COMPONENT_SCENE)

inner_height: INTEGER

-- Inner height of Current

-- (From EM_WIDGET)

ensure
height_minus_border: Result = height - border.top - border.bottom
inner_width: INTEGER

-- Inner width of Current

-- (From EM_WIDGET)

ensure
width_minus_border: Result = width - border.left - border.right
width: INTEGER

-- Width of scene

-- (From EM_COMPONENT_SCENE)

feature -- Status report

has_component (a_component: EM_COMPONENT): BOOLEAN

-- Does Current has a_component to display?

-- (From EM_COMPONENT_SCENE)

require
a_component_not_void: a_component /= Void
ensure
consistent: Result = components.has (a_component)
has_widget (a_widget: EM_WIDGET): BOOLEAN

--Is a_widget present on this widget?

-- (From EM_WIDGET)

require
a_widget_not_void: a_widget /= Void
is_changed: BOOLEAN

-- Is this widget changed since last draw?

-- (From EM_WIDGET)

is_enabled: BOOLEAN

-- Is Current enabled?

-- (From EM_COMPONENT)

is_joystick_sensitive: BOOLEAN

-- Does Current handle joystick events?

-- (From EM_INPUT_SENSITIVE)

is_keyboard_sensitive: BOOLEAN

-- Does Current handle keyboard events?

-- (From EM_INPUT_SENSITIVE)

is_mouse_sensitive: BOOLEAN

-- Does Current handle mouse events?

-- (From EM_INPUT_SENSITIVE)

is_running: BOOLEAN

-- Is scene currently running?
-- Otherwise no events are dispatched and no animation will run right now.

-- (From EM_SCENE)

is_visible: BOOLEAN

-- Is Current visible?

-- (From EM_COMPONENT)

feature -- Status setting

disable

-- Disable widget.

-- (From EM_COMPONENT)

ensure
not_enabled: not is_enabled
ensure then
is_changed: is_changed
enable

-- Enable widget.

-- (From EM_COMPONENT)

ensure
enabled: is_enabled
ensure then
is_changed: is_changed
hide

-- Hide Current.
-- This will trigger a hide event.

-- (From EM_COMPONENT)

ensure
not_visible: not is_visible
set_changed

-- Set this widget's changed status to true.
-- This also sets the changed status of the parent widget (if any) to true.

-- (From EM_WIDGET)

ensure
is_changed: is_changed
set_enabled (a_value: like is_enabled)

-- Set is_enabled to a_value.

-- (From EM_COMPONENT)

ensure
is_enabled_set: is_enabled = a_value
set_frame_counter_visibility (a_value: BOOLEAN)

-- If a_value is True make frame counter visible,
-- else make it invisible.

-- (From EM_SCENE)

set_joystick_sensitive (sensitive: BOOLEAN)

-- Set joystick sensitivity status.

-- (From EM_INPUT_SENSITIVE)

ensure
joystick_sensitivity_set: is_joystick_sensitive = sensitive
set_keyboard_sensitive (sensitive: BOOLEAN)

-- Set keyboard sensitivity status.

-- (From EM_INPUT_SENSITIVE)

ensure
keyboard_sensitivity_set: is_keyboard_sensitive = sensitive
set_mouse_sensitive (sensitive: BOOLEAN)

-- Set mouse sensitivity status.

-- (From EM_INPUT_SENSITIVE)

ensure
mouse_sensitivity_set: is_mouse_sensitive = sensitive
set_unchanged

-- Set widget's changed status to false.

-- (From EM_WIDGET)

ensure
not_changed: not is_changed
show

-- Show Current.
-- This will trigger a show event.

-- (From EM_COMPONENT)

ensure
visible: is_visible

feature -- Element change

add_component (a_component: EM_COMPONENT)

-- Add a_component to components.

-- (From EM_COMPONENT_SCENE)

require
a_component_not_void: a_component /= Void
a_component_not_present: not components.has (a_component)
ensure
a_component_added: components.has (a_component)
components_size_incremented: components.count = old components.count + 1
add_widget (a_widget: EM_WIDGET)

-- Add a_widget to nested widgets.

-- (From EM_WIDGET)

require
a_widget_not_void: a_widget /= Void
a_widget_not_present: not widgets.has (a_widget)
a_widget_not_current: a_widget /= Current
ensure
a_widget_added: widgets.has (a_widget)
a_widgets_parent_set: a_widget.parent_widget = Current
changed: is_changed
callback_for_set_next_scene_and_start: FUNCTION[ANY, TUPLE[], EM_SCENE]

-- we have to create next scene in same thread as the SDL thread
-- this function should point to a feature were next scene is created

-- (From EM_SCENE)

next_scene_is_set: BOOLEAN

-- Indicates that next scene is set and must be proceeded by
-- the main SDL Thread (syncronise both threads)

-- (From EM_SCENE)

resize_to_optimal_dimension

-- Set dimension to optimal_width optimal_height.

-- (From EM_WIDGET)

ensure
width_set: width = optimal_width
height_set: height = optimal_height
changed: is_changed
set_background (a_background: like background)

-- Set background to a_background.

-- (From EM_WIDGET)

ensure
background_set: background = a_background
changed: is_changed
set_background_color (a_color: EM_COLOR)

-- Set background to display a_color as color.
-- If a_color has an alpha value of 255, an EM_COLOR_BACKGROUND will be used.
-- Otherwise an EM_ALPHA_COLOR_BACKGROUND or an
-- EM_TRANSPARENT_BACKGROUND is used.

-- (From EM_WIDGET)

require
a_color_not_void: a_color /= Void
ensure
background_set: background /= Void
changed: is_changed
set_border (a_border: like border)

-- Set border to a_border.
-- To clear the border, pass 'Void'.

-- (From EM_WIDGET)

ensure
border_set: a_border /= Void implies border = a_border
border_empty: a_border = Void implies border = No_border
changed: is_changed
set_delegate (a_delegate: like delegate)

-- Set delegate to a_delegate.

-- (From EM_WIDGET)

ensure
delegate_set: delegate = a_delegate
set_font (a_font: like font)

-- Set font to a_font.

-- (From EM_WIDGET)

require
a_font_not_void: a_font /= Void
ensure
font_set: font = a_font
changed: is_changed
set_foreground_color (a_color: like foreground_color)

-- Set foreground_color to a_color.

-- (From EM_WIDGET)

require
a_color_not_void: a_color /= Void
ensure
foreground_color_set: foreground_color = a_color
changed: is_changed
set_next_scene (a_scene: like next_scene)

-- Set next_scene to a_scene.

-- (From EM_SCENE)

ensure
next_scene_set: next_scene = a_scene
set_next_scene_from_outside (a_callback: like callback_for_set_next_scene_and_start)

-- Set next_scene to a_scene from an other thread
-- Make sure that start_next_scene is called by the main SDL Thread

-- (From EM_SCENE)

ensure
next_scene_set: callback_for_set_next_scene_and_start = a_callback
next_scene_set: next_scene_is_set = true
set_optimal_dimension (a_width: like optimal_width; a_height: like optimal_height)

-- Set optimal dimension to a_width a_height.
-- The dimenson of the widget will not change, but subsequent calls to optimal_width
-- and optimal_height will return a_width and a_height. Also a call to resize_to_optimal_dimension
-- will set the widget's dimension to a_width a_height.
-- This setting will overwrite the optimal dimension definded by the widget delegate.
-- If a negative width or height is set, the optimal dimension will be set by the
-- delegate again.

-- (From EM_WIDGET)

ensure
optimal_width_set: a_width >= 0 implies optimal_width = a_width
optimal_height_set: a_height >= 0 implies optimal_height = a_height
set_tooltip (a_tooltip: like tooltip)

-- Set tooltip to a_tooltip.

-- (From EM_COMPONENT)

ensure
tooltip_set: tooltip = a_tooltip
set_transparent
ensure
background_set: background /= Void
changed: is_changed
set_transparent_color (a_color: EM_COLOR)

-- Set background to be transparent and use a_color as transparent colorkey (this color will be 100% transparent).
-- This sets the background to a EM_COLOR_BACKGROUND using a_color as color and
-- also sets the transparent colorkey of the surface to a_color

-- (From EM_WIDGET)

ensure
surface_colorkey_set: surface.has_transparent_colorkey
changed: is_changed
set_x (a_x: like x)

-- Set x to a_x.

-- (From EM_COMPONENT)

ensure
x_set: x = a_x
set_y (a_y: like y)

-- Set y to a_y.

-- (From EM_COMPONENT)

ensure
y_set: y = a_y

feature -- Removal

remove_component (a_component: EM_COMPONENT)

-- Remove a_component from components.

-- (From EM_COMPONENT_SCENE)

require
a_component_not_void: a_component /= Void
ensure
component_removed_if_present: old components.has (a_component) implies (not components.has (a_component))
components_size_decremented: old components.has (a_component) implies (components.count = old components.count - 1)
remove_widget (a_widget: EM_WIDGET)

-- Remove a_widget from nested widgets.

-- (From EM_WIDGET)

require
a_widget_not_void: a_widget /= Void
ensure
a_widget_removed: not widgets.has (a_widget)
a_widgets_parent_set: a_widget.parent_widget = Void
changed: is_changed
wipe_out_components

-- Remove all components.

-- (From EM_COMPONENT_SCENE)

ensure
components_removed: components.is_empty

feature -- Resizing

set_dimension (a_width: like width; a_height: like height)

-- Set dimension to a_width a_height.
-- This will trigger a resize event.

-- (From EM_COMPONENT)

require
a_width_not_negative: a_width >= 0
a_height_not_negative: a_height >= 0
ensure
width_set: width = a_width
height_set: height = a_height
set_height (a_height: like height)

-- Set height to a_height.

-- (From EM_COMPONENT)

require
a_height_not_negative: a_height >= 0
ensure
height_set: height = a_height
set_width (a_width: like width)

-- Set width to a_width.

-- (From EM_COMPONENT)

require
a_width_not_negative: a_width >= 0
ensure
width_set: width = a_width

feature -- Miscellaneous

next_frame

-- React on a frame change.
-- This can be used to animate a widget.

-- (From EM_WIDGET)

quit

-- Stop scene whitout starting another one.

-- (From EM_SCENE)

run (a_screen: EM_VIDEO_SURFACE)

-- Run scene and show it on a_screen.

-- (From EM_SCENE)

require
a_screen_not_void: a_screen /= Void
start_next_scene

-- Stop Current and advance to next_scene.

-- (From EM_SCENE)

start_next_scene_threaded

-- Call creation procedure for next scene and start this scene immediadely

-- (From EM_SCENE)

theme_update

-- Update all display data according to new theme.

-- (From EM_WIDGET)

feature -- Drawing

draw

-- Draw Current.

-- (From EM_COMPONENT)

draw_body

-- Draw widget body.

-- (From EM_WIDGET)

finish_drawing

-- Finish drawing Current.

-- (From EM_COMPONENT)

prepare_drawing

-- Prepare for drawing Current.

-- (From EM_COMPONENT)

redraw

-- Redraw the scene.

-- (From EM_SCENE)

feature -- Events

animation_event: EM_EVENT_TYPE [TUPLE [INTEGER]]

-- Animation event, allows animatable objects to perform animation
-- (i.e. moving them selves) before they get drawed.
-- As an argument the reference time in milliseconds is passed
-- up to which the animatable objects should draw them selves.
-- This event gets published right before the scene is redrawed.

-- (From EM_SCENE)

focus_lost_event: EM_EVENT_TYPE [TUPLE []]

-- Focus lost event

-- (From EM_KEYBOARD_SENSITIVE)

focus_received_event: EM_EVENT_TYPE [TUPLE []]

-- Focus received event

-- (From EM_KEYBOARD_SENSITIVE)

hide_event: EM_EVENT_TYPE [TUPLE []]

-- Component hidden event

-- (From EM_COMPONENT)

joystick_button_down_event: EM_EVENT_TYPE [TUPLE [EM_JOYSTICK_BUTTON_EVENT]]

-- Joystick button down event

-- (From EM_JOYSTICK_SENSITIVE)

key_down_event: EM_EVENT_TYPE [TUPLE [EM_KEYBOARD_EVENT]]

-- Key down event

-- (From EM_KEYBOARD_SENSITIVE)

key_up_event: EM_EVENT_TYPE [TUPLE [EM_KEYBOARD_EVENT]]

-- Key up event

-- (From EM_KEYBOARD_SENSITIVE)

mouse_button_down_event: EM_EVENT_TYPE [TUPLE[EM_MOUSEBUTTON_EVENT]]

-- Mouse button down event

-- (From EM_MOUSE_SENSITIVE)

mouse_button_up_event: EM_EVENT_TYPE [TUPLE[EM_MOUSEBUTTON_EVENT]]

-- Mouse button up event

-- (From EM_MOUSE_SENSITIVE)

mouse_clicked_event: EM_EVENT_TYPE [TUPLE[EM_MOUSEBUTTON_EVENT]]

-- Mouse clicked event

-- (From EM_MOUSE_SENSITIVE)

mouse_drag_start_event: EM_EVENT_TYPE [TUPLE[EM_MOUSE_EVENT]]

-- Mouse drag start event

-- (From EM_MOUSE_SENSITIVE)

mouse_drag_stop_event: EM_EVENT_TYPE [TUPLE[EM_MOUSE_EVENT]]

-- Mouse drag stop event

-- (From EM_MOUSE_SENSITIVE)

mouse_dragged_event: EM_EVENT_TYPE [TUPLE[EM_MOUSEMOTION_EVENT]]

-- Mouse dragged event

-- (From EM_MOUSE_SENSITIVE)

mouse_entered_event: EM_EVENT_TYPE [TUPLE []]

-- Mouse entered event

-- (From EM_MOUSE_SENSITIVE)

mouse_exited_event: EM_EVENT_TYPE [TUPLE []]

-- Mouse exited event

-- (From EM_MOUSE_SENSITIVE)

mouse_moved_event: EM_EVENT_TYPE [TUPLE[EM_MOUSEMOTION_EVENT]]

-- Mouse moved event

-- (From EM_MOUSE_SENSITIVE)

mouse_wheel_down_event: EM_EVENT_TYPE [TUPLE []]

-- Mouse wheel down event

-- (From EM_MOUSE_SENSITIVE)

mouse_wheel_up_event: EM_EVENT_TYPE [TUPLE []]

-- Mouse wheel up event

-- (From EM_MOUSE_SENSITIVE)

move_event: EM_EVENT_TYPE [TUPLE []]

-- Component moved event

-- (From EM_COMPONENT)

resize_event: EM_EVENT_TYPE [TUPLE []]

-- Component resized event

-- (From EM_COMPONENT)

show_event: EM_EVENT_TYPE [TUPLE []]

-- Component shown event

-- (From EM_COMPONENT)

feature {EM_COMPONENT_SCENE, EM_COMPONENT} -- Mouse management

mouse_button_down (event: EM_MOUSEBUTTON_EVENT)

-- Handle mouse button down event.

-- (From EM_COMPONENT)

mouse_button_up (event: EM_MOUSEBUTTON_EVENT)

-- Handle mouse button down event.
-- Set new keyboard focus if applicable.

-- (From EM_COMPONENT)

mouse_clicked (event: EM_MOUSEBUTTON_EVENT)

-- Handle mouse clicked event.

-- (From EM_COMPONENT)

mouse_drag_start (event: EM_MOUSE_EVENT)

-- Handle mouse drag start event.

-- (From EM_COMPONENT)

mouse_drag_stop (event: EM_MOUSE_EVENT)

-- Handle mouse-drag drop event.

-- (From EM_COMPONENT)

mouse_dragged (event: EM_MOUSEMOTION_EVENT)

-- Handle mouse dragging event.

-- (From EM_COMPONENT)

mouse_entered

-- Handle mouse entered event.

-- (From EM_COMPONENT)

mouse_exited

-- Handle mouse exited event.

-- (From EM_COMPONENT)

mouse_moved (event: EM_MOUSEMOTION_EVENT)

-- Handle mouse motion event.

-- (From EM_COMPONENT)

mouse_wheel_down

-- Handle mouse wheel down event.

-- (From EM_COMPONENT)

mouse_wheel_up

-- Handle mouse wheel up event.

-- (From EM_COMPONENT)

set_mouse_focus (new_focus: EM_COMPONENT)

-- Set mouse focus to new_focus.

-- (From EM_COMPONENT_SCENE)

require
new_focus: new_focus /= Void implies has_component (new_focus)
ensure
mouse_focus_set: mouse_focus = new_focus

feature -- Animation

animate

-- Let all subscribed animatable objects perform their animation.
-- (Calls go_to_time of animatable objects with current time tick)

-- (From EM_SCENE)

start_animating (an_animatable: EM_ANIMATABLE)

-- Subscribe an_animatable to be animated when Current is running.

-- (From EM_SCENE)

stop_animating (an_animatable: EM_ANIMATABLE)

-- Unsubscribe an_animatable from beeing animated when Current is running.

-- (From EM_SCENE)

feature {EM_WIDGET, EM_BACKGROUND, EM_BORDER} -- Implementation

child_changed (a_widget: EM_WIDGET)

-- Tell Current that nested widget a_widget has changed.

-- (From EM_WIDGET)

require
a_widget_is_child: has_widget (a_widget)
ensure
changed: is_changed
parent_widget: EM_WIDGET

-- Parent of this widget. The changed status will be forwarded to the parent.

-- (From EM_WIDGET)

set_parent (a_widget: EM_WIDGET)

-- Set parent_widget to a_widget.
-- If the parent is alredy set, this widget will be removed from the old parent!

-- (From EM_WIDGET)

ensure
parent_widget_set: parent_widget = a_widget
top_parent: EM_WIDGET

-- Topmost parent or Current if no parent is set

-- (From EM_WIDGET)

ensure
parent_of_parent: parent_widget /= Void implies Result = parent_widget.top_parent
current_if_no_parent: parent_widget = Void implies Result = Current
top_parent_not_void: Result /= Void

invariant

make_component_scene_called: is_make_component_scene_called
components_impl_not_void: components_impl /= Void

-- From EM_SCENE
make_scene_called: is_make_scene_called
animation_event_not_void: animation_event /= Void
event_loop_not_void: event_loop /= Void
screen_not_void_when_running: is_running implies screen /= Void

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

has_running_scene_definition: has_running_scene implies running_scene /= Void

-- From EM_WIDGET
border_not_void: border /= Void

-- From EM_COMPONENT
make_component_called: is_make_component_called
resize_event_not_void: resize_event /= Void
move_event_not_void: move_event /= Void
hide_event_not_void: hide_event /= Void
show_event_not_void: show_event /= Void

key_down_event_not_void: key_down_event /= Void
key_up_event_not_void: key_up_event /= Void
focus_received_event_not_void: focus_received_event /= Void
focus_lost_event_not_void: focus_lost_event /= Void

mouse_button_down_event_not_void: mouse_button_down_event /= Void
mouse_button_up_event_not_void: mouse_button_up_event /= Void
mouse_clicked_event_not_void: mouse_clicked_event /= Void
mouse_moved_event_not_void: mouse_moved_event /= Void
mouse_dragged_event_not_void: mouse_dragged_event /= Void
mouse_drag_start_event_not_void: mouse_drag_start_event /= Void
mouse_drag_stop_event_not_void: mouse_drag_stop_event /= Void
mouse_wheel_up_event_not_void: mouse_wheel_up_event /= Void
mouse_wheel_down_event_not_void: mouse_wheel_down_event /= Void
mouse_entered_event_not_void: mouse_entered_event /= Void
mouse_exited_event_not_void: mouse_exited_event /= Void

joystick_axis_event_not_void: joystick_axis_event /= Void
joystick_ball_event_not_void: joystick_ball_event /= Void
joystick_button_down_event_not_void: joystick_button_down_event /= Void
joystick_button_up_event_not_void: joystick_button_up_event /= Void
joystick_hat_event_not_void: joystick_hat_event /= Void

end