indexing description: "[ Create Circle Tool ]" date: "$Date$" revision: "$Revision$" class CREATE_CIRCLE_TOOL inherit TOOL create make feature -- Access cursor: MOUSE_CURSOR is -- appropriate cursor. do Result := arrow_cursor end feature -- Event Handling handle_mouse_button_down_event (event: EM_MOUSEBUTTON_EVENT) is -- Handle mouse button down event. do if scene.focus_on_scene and event.is_left_button then drag_start_coords := scene.coordinates_from_screen_position (x, y) is_pressed := True end end handle_mouse_button_up_event (event: EM_MOUSEBUTTON_EVENT) is -- Handle mouse button up event. do if event.is_left_button then is_pressed := False end if event.is_left_button then scene.history.execute (create {CREATE_CIRCLE}.make, [scene.circles, circle]) if scene.history.execute_successful then scene.set_changed circle.set_changed end circle := Void drag_start_coords := Void end end handle_mouse_motion_event (event: EM_MOUSEMOTION_EVENT) is -- Handle mouse motion event. local coords: EM_VECTOR_2D r: DOUBLE do x := event.screen_x y := event.screen_y - 32 if is_pressed and event.button_state_left and drag_start_coords /= Void then -- the mouse is dragged over the scene, creating a circle coords := scene.coordinates_from_screen_position (x, y) r := coords.distance (drag_start_coords) if r = 0 then r := 1 end if circle = Void then create circle.make_obj (drag_start_coords, r, scene) scene.circles.force_last (circle) else circle.set_radius (r) circle.set_changed end end last_x := x last_y := y end handle_key_down_event (event: EM_KEYBOARD_EVENT) is -- Handle key down event. do end handle_key_up_event (event: EM_KEYBOARD_EVENT) is -- Handle key up event. do end feature {NONE} -- Implementation drag_start_coords: EM_VECTOR_2D -- where the mouse started dragging circle: CIRCLE -- current circle (if not void it is just beeing created and added upon release) end