indexing description: "[ Create Rectangle Tool ]" date: "$Date$" revision: "$Revision$" class CREATE_RECTANGLE_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 scene.history.execute (create {CREATE_RECTANGLE}.make, [scene.rectangles, rectangle]) if scene.history.execute_successful then scene.set_changed end end rectangle := Void drag_start_coords := Void end handle_mouse_motion_event (event: EM_MOUSEMOTION_EVENT) is -- Handle mouse motion event. local coords: EM_VECTOR_2D do x := event.screen_x y := event.screen_y - 32 if is_pressed and drag_start_coords /= Void then -- the mouse is dragged over the scene, creating a rectangle coords := scene.coordinates_from_screen_position (x, y) if rectangle = Void then create rectangle.make_obj (drag_start_coords, coords, scene) scene.rectangles.force_last (rectangle) else rectangle.set_new_size (drag_start_coords, coords) 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 rectangle: RECTANGLE -- current rectangle (if not void it is just beeing created and executed upon release) end