indexing description: "[ Base class for all components which are displayed on an EM_COMPNENT_SCENE. To place a component on a scene call `add_component' on an EM_COMPONENT_SCENE and set the position and dimension of `Current' with `set_position' and `set_dimension'. Components provide: - Mouse events (See EM_MOUSE_SENSITIVE) - Keyboard events (See EM_KEYBOARD_SENSITIVE) - Tooltips (See `set_tooltip') - Drawing `prepare_drawing' will be called before each `draw'. `finish_drawing' will be called afterwards. Events: - `move_event': Triggered when position changed. Passes no arguments. - `resize_event': Triggered when dimension changed. Passes no arguments. - `show_event': Triggered when set to visible. Passes no arguments. - `hide_event': Triggered when set to invisible. Passes no arguments. Subclasses must call `make_component' at creation. See EM_2D_COMPONENT, EM_3D_COMPONENT ]" date: "$Date$" revision: "$Revision$" deferred class EM_COMPONENT inherit EM_INPUT_SENSITIVE EM_SHARED_SUBSYSTEMS export {NONE} all end EM_SHARED_FOCUS export {NONE} all end EM_SHARED_COMPONENT_EVENT_QUEUE export {NONE} all end feature {NONE} -- Initialisation make_component is -- Initialise default values. do is_make_component_called := True make_input_sensitive create move_event create resize_event create hide_event create show_event is_visible := True is_enabled := True tooltip := Void end is_make_component_called: BOOLEAN -- Is `make_component' called? feature -- Access tooltip: STRING -- Tooltip of `Current' x: INTEGER -- X position of `Current' relative to parent y: INTEGER -- Y position of `Current' relative to parent feature -- Measurement width: INTEGER -- Width of `Current' height: INTEGER -- Height of `Current' feature -- Status report is_visible: BOOLEAN -- Is `Current' visible? is_enabled: BOOLEAN -- Is `Current' enabled? feature -- Status setting hide is -- Hide `Current'. -- This will trigger a hide event. do is_visible := False Component_event_queue.add_event (hide_event, []) ensure not_visible: not is_visible end show is -- Show `Current'. -- This will trigger a show event. do is_visible := True Component_event_queue.add_event (show_event, []) ensure visible: is_visible end enable is -- Enable `Current'. do is_enabled := True enable_input_events ensure enabled: is_enabled end disable is -- Disable `Current'. do is_enabled := False disable_input_events ensure not_enabled: not is_enabled end set_enabled (a_value: like is_enabled) is -- Set `is_enabled' to `a_value'. do if a_value then enable else disable end ensure is_enabled_set: is_enabled = a_value end feature -- Element change set_tooltip (a_tooltip: like tooltip) is -- Set `tooltip' to `a_tooltip'. do tooltip := a_tooltip ensure tooltip_set: tooltip = a_tooltip end set_position (a_x: like x; a_y: like y) is -- Set position to `a_x' `a_y'. -- This will trigger a move event. do x := a_x y := a_y Component_event_queue.add_event (move_event, []) ensure x_set: x = a_x y_set: y = a_y end set_x (a_x: like x) is -- Set `x' to `a_x'. do x := a_x Component_event_queue.add_event (move_event, []) ensure x_set: x = a_x end set_y (a_y: like y) is -- Set `y' to `a_y'. do y := a_y Component_event_queue.add_event (move_event, []) ensure y_set: y = a_y end feature -- Resizing set_dimension (a_width: like width; a_height: like height) is -- Set dimension to `a_width' `a_height'. -- This will trigger a resize event. require a_width_not_negative: a_width >= 0 a_height_not_negative: a_height >= 0 do width := a_width height := a_height Component_event_queue.add_event (resize_event, []) ensure width_set: width = a_width height_set: height = a_height end set_width (a_width: like width) is -- Set `width' to `a_width'. require a_width_not_negative: a_width >= 0 do set_dimension (a_width, height) ensure width_set: width = a_width end set_height (a_height: like height) is -- Set `height' to `a_height'. require a_height_not_negative: a_height >= 0 do set_dimension (width, a_height) ensure height_set: height = a_height end feature -- Drawing redraw is -- Redraw `Current'. do prepare_drawing draw finish_drawing end prepare_drawing is -- Prepare to draw `Current'. deferred end draw is -- Draw `Current'. deferred end finish_drawing is -- Finish drawing `Current'. deferred end feature -- Events move_event: EM_EVENT_CHANNEL [TUPLE []] -- Component moved event resize_event: EM_EVENT_CHANNEL [TUPLE []] -- Component resized event show_event: EM_EVENT_CHANNEL [TUPLE []] -- Component shown event hide_event: EM_EVENT_CHANNEL [TUPLE []] -- Component hidden event feature {EM_COMPONENT_SCENE, EM_COMPONENT} -- Mouse management mouse_button_down (event: EM_MOUSEBUTTON_EVENT) is -- Handle mouse button down event. do mouse_button_down_event.publish ([event]) end mouse_button_up (event: EM_MOUSEBUTTON_EVENT) is -- Handle mouse button down event. do mouse_button_up_event.publish ([event]) end mouse_clicked (event: EM_MOUSEBUTTON_EVENT) is -- Handle mouse clicked event. do mouse_clicked_event.publish ([event]) end mouse_moved (event: EM_MOUSEMOTION_EVENT) is -- Handle mouse motion event. do mouse_moved_event.publish ([event]) end mouse_dragged (event: EM_MOUSEMOTION_EVENT) is -- Handle mouse dragging event. do mouse_dragged_event.publish ([event]) end mouse_drag_start (event: EM_MOUSE_EVENT) is -- Handle mouse drag start event. do mouse_drag_start_event.publish ([event]) end mouse_drag_stop (event: EM_MOUSE_EVENT) is -- Handle mouse drag stop event. do mouse_drag_stop_event.publish ([event]) end mouse_wheel_up is -- Handle mouse wheel up event. do mouse_wheel_up_event.publish ([]) end mouse_wheel_down is -- Handle mouse wheel down event. do mouse_wheel_down_event.publish ([]) end mouse_entered is -- Handle mouse entered event. do mouse_entered_event.publish ([]) end mouse_exited is -- Handle mouse exited event. do mouse_exited_event.publish ([]) end invariant 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 end