indexing description: "[ A widget which visually displays a progress of a task. The task has a number of steps which is greater than zero. To advance the progress call `advance'. To reset the progress call `reset'. ]" date: "$Date$" revision: "$Revision$" class EM_PROGRESS_BAR inherit EM_WIDGET redefine make_void_surface end create make_from_steps, make_from_dimension, make_void_surface feature {NONE} -- Initialisation make_from_steps (a_value: INTEGER) is -- Initialise the progressbar to display `a_value' different steps. require a_value_valid: a_value > 0 do make_void_surface steps := a_value current_step := 0 resize_to_optimal_dimension ensure steps_set: steps = a_value current_step_set: current_step = 0 end make_void_surface is -- Initialise default values. -- Per defautl `steps' is 10. do Precursor {EM_WIDGET} steps := 10 current_step := 0 end delegate_factory: FUNCTION [ANY, TUPLE [], like delegate] is -- Factory to create default delegate do Result := theme_delegates.progress_bar_delegate_factory end feature -- Access steps: INTEGER -- Number of different progress steps current_step: INTEGER -- Current step feature -- Element change set_steps (a_value: like steps) is -- Set `steps' to `a_value'. -- This will reset `current_step' to 0. require a_value_positive: a_value > 0 do steps := a_value current_step := 0 set_changed ensure steps_set: steps = a_value current_step_reset: current_step = 0 end set_current_step (a_step: like current_step) is -- Set `current_step' to `a_step'. require a_step_valid: 0 <= a_step and a_step <= steps do current_step := a_step set_changed ensure current_step_set: current_step = a_step changed: is_changed end feature -- Basic operations advance is -- Advance one step. do if current_step /= steps then set_current_step (current_step + 1) end set_changed ensure current_step_increased_or_finished: current_step = old current_step + 1 or current_step = steps changed: is_changed end reset is -- Reset progress to zero. do set_current_step (0) ensure current_step_zero: current_step = 0 changed: is_changed end end