note description : "Main window for this application" author : "Generated by the New Vision2 Application Wizard." date : "$Date$" revision : "1.0.0" class MAIN_WINDOW inherit EV_TITLED_WINDOW redefine initialize, is_in_default_state end INTERFACE_NAMES export {NONE} all undefine default_create, copy end create default_create feature {NONE} -- Initialization initialize -- Build the interface for this window. do Precursor {EV_TITLED_WINDOW} build_main_container extend (main_container) -- Execute `request_close_window' when the user clicks -- on the cross in the title bar. close_request_actions.extend (agent request_close_window) -- Set the title of the window set_title (Window_title) -- Set the initial size of the window set_size (Window_width, Window_height) end is_in_default_state: BOOLEAN -- Is the window in its default state -- (as stated in `initialize') do Result := true -- Result := (width = Window_width) and then -- (height = Window_height) and then -- (title.is_equal (Window_title)) end feature {NONE} -- Implementation, Close event request_close_window -- The user wants to close the window local question_dialog: EV_CONFIRMATION_DIALOG do create question_dialog.make_with_text (Label_confirm_close_window) question_dialog.show_modal_to_window (Current) if question_dialog.selected_button.is_equal ((create {EV_DIALOG_CONSTANTS}).ev_ok) then -- Destroy the window destroy; -- End the application --| TODO: Remove this line if you don't want the application --| to end when the first window is closed.. (create {EV_ENVIRONMENT}).application.destroy end end feature {NONE} -- Implementation main_container: EV_VERTICAL_BOX -- Main container (contains all widgets displayed in this window) build_main_container -- Create and populate `main_container'. require main_container_not_yet_created: main_container = Void do create main_container -- Init world init_world -- Create drawing area create da.default_create da.set_minimum_size (world.abs_right-world.abs_left, world.abs_bottom-world.abs_top) -- Create and start model thread create running.make_and_launch (world, Current) -- Create start/pause toggle button create start_pause_button.make_with_text_and_action ("Start/Pause", agent do running.toggle_start_pause end) main_container.extend (start_pause_button) main_container.extend (da) ensure main_container_created: main_container /= Void end feature {NONE} -- Implementation / Constants Window_title: STRING = "circles_vision2" -- Title of the window. Window_width: INTEGER = 595 -- Initial width for this window. Window_height: INTEGER = 400 -- Initial height for this window. feature -- Access da: attached EV_DRAWING_AREA feature {NONE} -- Implementation start_pause_button: attached EV_BUTTON world: attached WORLD running: attached RUNNING init_world local setup: SETUP do create setup.make world := setup.create_world world.wall_friction := 1 end end