indexing description: "[ Custom widget demo: A drawing panel. ]" date: "$Date$" revision: "$Revision$" class DRAWING_DEMO_PANEL inherit EM_PANEL create make feature {NONE} -- Initialisation make is -- Initialise panel. local text: STRING label: EM_LABEL slider: EM_SLIDER button: EM_BUTTON do make_void_surface -- Help text create text.make_empty text.append_string ("See DRAWABLE_PANEL for an example of a custom widget.%N") text.append_string ("Basic approach:%N") text.append_string (" - inherit from EM_PANEL%N") text.append_string (" - redefine 'draw_body' to draw, redefine 'next_frame' to animate widget%N") text.append_string (" - subscribe on desired event types to react on input events") create label.make_from_text (text) label.set_position (70, 10) label.set_dimension (500, 90) label.enable_multilined label.align_top add_widget (label) -- Drawing panel create drawing_panel.make (500, 500) drawing_panel.set_position (70, 100) drawing_panel.set_border (create {EM_BEVEL_BORDER}.make_down) add_widget (drawing_panel) -- Usage text create label.make_from_text ("drag mouse to draw - right click to set sweep line") label.set_position (70, 620) label.set_dimension (500, 20) label.align_center add_widget (label) create label.make_from_text ("Sweep line delay (0ms - 1000ms)") label.set_position (70, 600) add_widget (label) create slider.make_from_range_horizontal (0, 1000) slider.set_current_value (drawing_panel.sweep_line_timeout) slider.position_changed_event.subscribe (agent drawing_panel.set_sweep_line_timout (?)) slider.set_position (70+label.width+10, 600) slider.set_dimension (460-slider.x, 20) add_widget (slider) create button.make_from_text ("clear drawing") button.set_position (470, 600) button.set_dimension (100, 20) button.clicked_event.subscribe (agent drawing_panel.clear_drawing) add_widget (button) end feature -- Access drawing_panel: DRAWING_PANEL -- Drawing panel end