note
	description: "[
			Root class for tools used in the VITP game.
			]"
	author: "Jimmy J. Johnson"

deferred class
	VITP_TOOL

inherit

	TOOL
		rename
			target as vitp
		redefine
			create_interface_objects,
			initialize,
			add_actions,
			target_imp
--			set_target
		end

feature {NONE} -- Initialization

	create_interface_objects
			-- Create objects to be used by `Current' in `initialize'
			-- Implemented by descendants to create attached objects
			-- in order to adhere to void-safety due to the implementation bridge pattern.
		do
			print ("VITP_TOOL.create_interface_objects %N")
			Precursor {TOOL}
			print ("%T VITP_TOOL.create_interface_objects  after Precursor {TOOL} %N")
			create zoom_in_button
			create zoom_out_button
			create fit_button
			zoom_in_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_zoom_in_color_buffer))
			zoom_in_button.set_tooltip ("Zoom In")
			zoom_out_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (Icon_zoom_out_color_buffer))
			zoom_out_button.set_tooltip ("Zoom Out")
			fit_button.set_pixmap (create {EV_PIXMAP}.make_with_pixel_buffer (icon_format_exporteds_color_buffer))
			fit_button.set_tooltip ("Fit to View")
		end

	initialize
			-- Build the interface for this window
		do
			Precursor {TOOL}
			build_tool_bar
			split_manager.enable_mode_changes
			split_manager.set_horizontal
		end

	build_tool_bar
			-- Add buttons to `tool_bar' (from TOOL).
		local
			vs: EV_VERTICAL_SEPARATOR
		do
				-- Add a separator and space it out with minimum size.
			create vs
			tool_bar.extend (vs)
			tool_bar.disable_item_expand (vs)
			vs.set_minimum_width (20)
				-- Add the zoom buttons
			tool_bar.extend (zoom_in_button)
			tool_bar.extend (zoom_out_button)
			tool_bar.extend (fit_button)
			tool_bar.disable_item_expand (zoom_in_button)
			tool_bar.disable_item_expand (zoom_out_button)
			tool_bar.disable_item_expand (fit_button)
				-- Add a separator and space it out with minimum size.
			create vs
			tool_bar.extend (vs)
			tool_bar.disable_item_expand (vs)
			vs.set_minimum_width (20)
		end

	add_actions
			-- Add functionality to the buttons
		do
			Precursor {TOOL}
			zoom_in_button.select_actions.extend (agent on_zoom_in)
			zoom_out_button.select_actions.extend (agent on_zoom_out)
			fit_button.select_actions.extend (agent on_fit)
		end

feature -- Access

	focused_view: VITP_CELL_VIEW
			-- The view that currently has the focus
		deferred
		end

feature {NONE} -- Implementation (actions)

	on_set_defaults
			-- Restore the view-vector to the default settings.
		do
		end

	on_zoom_in
			-- Make the board larger
		do
			focused_view.scale_up
		end

	on_zoom_out
			-- Make the board smaller
		do
			focused_view.scale_down
		end

	on_fit
			-- Make the content fit the view
		do
			focused_view.fit_to_screen
			focused_view.resize_if_necessary
			focused_view.crop
		end

	Default_object: VITP_GAME
			--
		once
			create Result
		end

feature {NONE} -- Implementation

	target_imp: detachable VITP_GAME
			-- Detachable implementation of `target' for void safety

	zoom_in_button: EV_BUTTON	--EV_TOOL_BAR_BUTTON
			-- Button to make the game board larger.

	zoom_out_button: EV_BUTTON	--EV_TOOL_BAR_BUTTON
			-- Button to make the game board smaller.

	fit_button: EV_BUTTON
			-- Button to fit the content to the view

end
