indexing description: "[ Window demo. ]" date: "$Date$" revision: "$Revision$" class WINDOW_DEMO_PANEL inherit EM_PANEL create make feature {NONE} -- Initialisation make is -- Initialise panel. local label: EM_LABEL button: EM_BUTTON message_dialog: EM_MESSAGE_DIALOG do make_void_surface create button.make_from_text ("Create dialog") button.set_position (10, 10) button.set_dimension (150, 20) button.clicked_event.subscribe (agent create_new_dialog (False)) add_widget (button) create button.make_from_text ("Create modal dialog") button.set_position (10, 35) button.set_dimension (150, 20) button.clicked_event.subscribe (agent create_new_dialog (True)) add_widget (button) -- File dialog create label.make_empty label.set_position (170, 60) label.set_dimension (300, 20) add_widget (label) create button.make_from_text ("Create file dialog") button.set_position (10, 60) button.set_dimension (150, 20) button.clicked_event.subscribe (agent create_file_dialog (label)) add_widget (button) -- Message dialog create label.make_empty label.set_position (170, 85) label.set_dimension (140, 20) add_widget (label) create message_dialog.make_from_message ("A message dialog%Nwith a very long message%Nto show that multiple lines%Ncan be displayed%Nand the shadow effect%Ncan be enabled") message_dialog.text_label.align_center message_dialog.text_label.enable_shadow message_dialog.button_clicked_event.subscribe (agent handle_dialog_button_clicked (message_dialog, label)) create button.make_from_text ("Show message dialog") button.set_position (10, 85) button.set_dimension (150, 20) button.clicked_event.subscribe (agent message_dialog.show) add_widget (button) -- Warning dialog create label.make_empty label.set_position (170, 110) label.set_dimension (140, 20) add_widget (label) create message_dialog.make_from_warning ("A warning dialog") message_dialog.display_ok_cancel message_dialog.button_clicked_event.subscribe (agent handle_dialog_button_clicked (message_dialog, label)) create button.make_from_text ("Show warning dialog") button.set_position (10, 110) button.set_dimension (150, 20) button.clicked_event.subscribe (agent message_dialog.show) add_widget (button) -- Error dialog create label.make_empty label.set_position (170, 135) label.set_dimension (140, 20) add_widget (label) create message_dialog.make_from_error ("An error dialog") message_dialog.display_yes_no_cancel message_dialog.center_on_screen message_dialog.button_clicked_event.subscribe (agent handle_dialog_button_clicked (message_dialog, label)) create button.make_from_text ("Show error dialog") button.set_position (10, 135) button.set_dimension (150, 20) button.clicked_event.subscribe (agent message_dialog.show) add_widget (button) end feature -- Access window_number: INTEGER -- Number of windows shown action_status_label: EM_LABEL -- Label of clicked button feature -- Basic operations create_new_dialog (modal: BOOLEAN) is -- Create new dialog. local dialog: EM_DIALOG title: STRING do window_number := window_number + 1 title := "Window "+window_number.out if modal then title.append_string (" - modal") end create dialog.make_from_title (title) dialog.set_modal (modal) dialog.set_dimension (200, 100) dialog.set_position (120+(window_number \\ 20)*10+(window_number // 20)*50, 200+(window_number \\ 20)*10) dialog.show end create_file_dialog (a_label: EM_LABEL) is -- Create new file dialog. local file_dialog: EM_FILE_DIALOG do create file_dialog.make file_dialog.show file_dialog.button_clicked_event.subscribe (agent handle_flie_dialog_button_clicked (file_dialog, a_label)) end handle_dialog_button_clicked (a_window: EM_MESSAGE_DIALOG; a_label: EM_LABEL) is -- Handle click of a button on 'a_window'. do if a_window.was_cancel_pressed then a_label.set_text ("Cancel pressed") elseif a_window.was_ok_pressed then a_label.set_text ("Ok pressed") elseif a_window.was_yes_pressed then a_label.set_text ("Yes pressed") elseif a_window.was_no_pressed then a_label.set_text ("No pressed") else a_label.set_text ("No button pressed") end end handle_flie_dialog_button_clicked (a_file_dialog: EM_FILE_DIALOG; a_label: EM_LABEL) is -- Handle click of a button on 'a_file_dialog'. do if a_file_dialog. was_cancel_clicked then a_label.set_text ("Cancel clicked") a_label.resize_to_optimal_dimension elseif a_file_dialog.was_ok_clicked then if a_file_dialog.is_file_selected then a_label.set_text (a_file_dialog.absolute_filename) else a_label.set_text ("No file selected") end a_label.resize_to_optimal_dimension else a_label.set_text ("No button pressed") a_label.resize_to_optimal_dimension end end end