note
	description: "[
		A GAME_SURFACE that represent a text.
		Rendering from this class does not use
		alpha blending. You have to specify the
		background color.
	]"
	author: "Louis Marchand"
	date: "Mon, 30 Mar 2015 01:20:46 +0000"
	revision: "2.0"

class interface
	TEXT_SURFACE_SHADED

create 
	make (a_text: READABLE_STRING_GENERAL; a_font: TEXT_FONT; a_foreground_color, a_background_color: GAME_COLOR_READABLE)
			-- Initialization for Current from the text l_text
			-- using the font l_font and color a_foreground_color
			-- with a background color a_background_color.
		require
			text_is_enabled: Text_library.is_text_enable
			font_is_open: a_font.is_open

feature -- Access

	as_converted_to_pixel_format (a_pixel_format: GAME_PIXEL_FORMAT_READABLE): GAME_SURFACE
			-- Create a copy of Current conforming to a_pixel_format.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_convert_is_open: is_open
			not_locked: not is_locked

	background_color: GAME_COLOR_READABLE
			-- The color to draw in the background of the text

	foreground_color: GAME_COLOR_READABLE
			-- The color used to write the text on the surface.
			-- (from TEXT_SURFACE)

	color_multiplier: TUPLE [red_multipier: NATURAL_8; green_multipier: NATURAL_8; blue_multipier: NATURAL_8]
			-- The additional color value multiplied into drawing operations
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
			not_locked: not is_locked

	disable_blending
			-- Disable every blending mode to use for drawing operations.
			-- No blending mode:	dstRGBA = srcRGBA
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	disable_rle_acceleration
			-- Disable the possible optimisation when using drawing with transparent_color enabled or enable_alpha_blending.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
			not_locked: not is_locked

	disable_transparent
			-- Remove the transparency by color key.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_is_open: is_open
			not_locked: not is_locked

	draw_rectangle (a_color: GAME_COLOR; a_x, a_y, a_width, a_height: INTEGER_32)
			-- Draw a a_color rectangle of dimension a_width x a_height on Current at (a_x,a_y).
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_draw_is_open: is_open
			not_locked: not is_locked

	draw_rectangles (a_color: GAME_COLOR; a_rectangles: CHAIN [TUPLE [x: INTEGER_32; y: INTEGER_32; width: INTEGER_32; height: INTEGER_32]])
			-- Drawing every a_color rectangle in a_rectangles
			-- that has it's left frontier at
			-- x, it's top frontier at y, with
			-- dimension widthxheight
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_draw_is_open: is_open
			not_locked: not is_locked

	draw_sub_surface (a_other: GAME_SURFACE; a_x_source, a_y_source, a_width, a_height, a_x_destination, a_y_destination: INTEGER_32)
			-- Draw on Current at (a_x_destination,a_y_destination) the portion of a_other
			-- starting at (a_x_source,a_y_source) with dimension a_width x a_height.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_draw_is_open: is_open
			not_locked: not is_locked

	draw_sub_surface_with_scale (a_other: GAME_SURFACE; a_x_source, a_y_source, a_width_source, a_height_source, a_x_destination, a_y_destination, a_width_destination, a_height_destination: INTEGER_32)
			-- Draw on Current at (a_x_destination,a_y_destination) the portion of a_other
			-- starting at (a_x_source,a_y_source) with dimension a_width x a_height.
			-- Will scale a_other using a_width_destination and a_height_destination
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_draw_is_open: is_open
			not_locked: not is_locked

	draw_surface (a_other: GAME_SURFACE; a_x, a_y: INTEGER_32)
			-- Draw the whole surface a_other on Current at (a_x,a_y).
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_draw_is_open: is_open
			not_locked: not is_locked

	enable_additive_blending
			-- Set the additive blending mode to use for drawing operations.
			-- Additive blending:	dstRGB = (srcRGB * srcA) + dstRGB
			--						dstA = dstA
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	enable_alpha_blending
			-- Set the alpha blending mode to use for drawing operations.
			-- Alpha blending:	dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
			--					dstA = srcA + (dstA * (1-srcA))
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	enable_modulate_blending
			-- Set the color modulate blending mode to use for drawing operations.
			-- Color modulate:	dstRGB = srcRGB * dstRGB
			--					dstA = dstA
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	enable_rle_acceleration
			-- Enable possible optimisation when using drawing with transparent_color enabled or enable_alpha_blending.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
			not_locked: not is_locked

	font: TEXT_FONT
			-- The font use to create the surface.
			-- (from TEXT_SURFACE)

	Game_library: GAME_LIBRARY_CONTROLLER
			-- The main controller of the game library
			-- (from GAME_LIBRARY_SHARED)

	generating_type: TYPE [detachable TEXT_SURFACE_SHADED]
			-- Type of current object
			-- (type of which it is a direct instance)
			-- (from ANY)
		ensure -- from ANY
			generating_type_not_void: Result /= Void

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
		ensure -- from ANY
			generator_not_void: Result /= Void
			generator_not_empty: not Result.is_empty

	has_error: BOOLEAN
			-- Is the library has generate an error
			-- (from GAME_ERROR_MANAGER)

	height: INTEGER_32
			-- The height of Current.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open

	image: GAME_IMAGE
			-- The GAME_IMAGE that has served for creating Current
			-- (from GAME_SURFACE)

	is_additive_blending_enabled: BOOLEAN
			-- True if the blending mode for drawing operation is additive blending.
			-- Additive blending:	dstRGB = (srcRGB * srcA) + dstRGB
			--						dstA = dstA
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	is_alpha_blending_enabled: BOOLEAN
			-- True if the blending mode for drawing operation is alpha blending.
			-- Alpha blending:	dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
			--					dstA = srcA + (dstA * (1-srcA))
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	is_blending_disabled: BOOLEAN
			-- True if no blending mode is used for drawing operations.
			-- No blending mode:	dstRGBA = srcRGBA
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	is_locked: BOOLEAN
			-- Current is locked to access pixels. Current cannot be used until unlock is called.
			-- (from GAME_SURFACE)

	is_modulate_blending_enabled: BOOLEAN
			-- True if the blending mode for drawing operation is color modulate blending.
			-- Color modulate:	dstRGB = srcRGB * dstRGB
			--					dstA = dstA
			-- (from GAME_BLENDABLE)
		require -- from GAME_BLENDABLE
			blendable_is_valid: is_open

	is_open: BOOLEAN
			-- Current has been opened properly
			-- (from GAME_SURFACE)

	is_transparent_enable: BOOLEAN
			-- Is transparency by color key is enabled.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_is_open: is_open
			not_locked: not is_locked

	last_error: READABLE_STRING_GENERAL
			-- The last error generate by the library
			-- (from GAME_SDL_ANY)

	lock
			-- Lock Current to access pixels.
			-- Must used unlock after the edition.
			-- You cannot draw on Current while locked.
			-- (from GAME_SURFACE)
		ensure -- from GAME_SURFACE
			is_locked: not has_error implies is_locked

	must_lock: BOOLEAN
			-- Current must be locked for pixel access
			-- (from GAME_SURFACE)

	overall_alpha: NATURAL_8 assign set_overall_alpha
			-- The Additionnal alpha value to use in drawing operation.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
			not_locked: not is_locked

	pixel_format: GAME_PIXEL_FORMAT_READABLE
			-- The internal format of the pixel representation in memory.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_pixel_format_is_open: is_open

	pixels: GAME_PIXEL_READER_WRITER
			-- Used to fetch and edit pixels in Current
			-- Use lock before to access multiple pixels
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			locked_if_needed: must_lock implies is_locked

	save_bmp (a_filename: READABLE_STRING_GENERAL)
			-- Save Current into a BMP image file
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open

	set_color_multiplier (a_red_multiplier, a_green_multiplier, a_blue_multiplier: NATURAL_8)
			-- Assign the Additionnal color_multiplier value to use into drawing operation to a_red_multiplier,
			-- a_green_multiplier, a_blue_multiplier.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
			not_locked: not is_locked

	set_overall_alpha (a_overall_alpha: NATURAL_8)
			-- Assign the Additionnal overall_alpha value to use in drawing operation to a_overall_alpha.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
			not_locked: not is_locked

	set_transparent_color (a_color: GAME_COLOR_READABLE)
			-- Change all pixel of color color into transparency (and enable it). The transparency by color don't work if the surface
			-- have an alpha blending activated.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_is_open: is_open
			not_locked: not is_locked

	text: READABLE_STRING_GENERAL
			-- The text use to create the surface.
			-- (from TEXT_SURFACE)

	Text_library: TEXT_CONTROLLER
			-- The main manager of the text library
			-- (from TEXT_LIBRARY_SHARED)

	transparent_color: GAME_COLOR_READABLE assign set_transparent_color
			-- The color that will be remove in the surface (the transparent color).
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_video_enable: Game_library.is_video_enable
			surface_is_open: is_open
			surface_transparent_color_is_enable: is_transparent_enable
			not_locked: not is_locked

	unlock
			-- Unlock Current after access pixels.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			is_locked: is_locked
		ensure -- from GAME_SURFACE
			not_locked: not is_locked

	width: INTEGER_32
			-- The width of Current.
			-- (from GAME_SURFACE)
		require -- from GAME_SURFACE
			surface_is_open: is_open
	
feature -- Comparison

	frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			shallow_implies_deep: standard_equal (a, b) implies Result
			both_or_none_void: (a = Void) implies (Result = (b = Void))
			same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
			symmetric: Result implies deep_equal (b, a)

	frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b))

	frozen is_deep_equal alias "≡≡≡" (other: TEXT_SURFACE_SHADED): BOOLEAN
			-- Are Current and other attached to isomorphic object structures?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			shallow_implies_deep: standard_is_equal (other) implies Result
			same_type: Result implies same_type (other)
			symmetric: Result implies other.is_deep_equal (Current)

	is_equal (other: TEXT_SURFACE_SHADED): BOOLEAN
			-- Is other attached to an object considered
			-- equal to current object?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			symmetric: Result implies other ~ Current
			consistent: standard_is_equal (other) implies Result

	frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b))

	frozen standard_is_equal alias "" (other: TEXT_SURFACE_SHADED): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of other (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of other?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
	
feature -- Duplication

	copy (other: TEXT_SURFACE_SHADED)
			-- Update current object using fields of object attached
			-- to other, so as to yield equal objects.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_equal: Current ~ other

	frozen deep_copy (other: TEXT_SURFACE_SHADED)
			-- Effect equivalent to that of:
			--		copy (other . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)

	frozen deep_twin: TEXT_SURFACE_SHADED
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		ensure -- from ANY
			deep_twin_not_void: Result /= Void
			deep_equal: deep_equal (Current, Result)

	frozen standard_copy (other: TEXT_SURFACE_SHADED)
			-- Copy every field of other onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)

	frozen standard_twin: TEXT_SURFACE_SHADED
			-- New object field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)

	frozen twin: TEXT_SURFACE_SHADED
			-- New object equal to Current
			-- twin calls copy; to change copying/twinning semantics, redefine copy.
			-- (from ANY)
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result ~ Current
	
feature -- Basic operations

	frozen default: detachable TEXT_SURFACE_SHADED
			-- Default value of object's type
			-- (from ANY)

	frozen default_pointer: POINTER
			-- Default value of type POINTER
			-- (Avoid the need to write p.default for
			-- some p of type POINTER.)
			-- (from ANY)
		ensure -- from ANY
			instance_free: class

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
	
feature -- Output

	Io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			io_not_void: Result /= Void

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		ensure -- from ANY
			out_not_void: Result /= Void

	print (o: detachable ANY)
			-- Write terse external representation of o
			-- on standard output.
			-- (from ANY)
		ensure -- from ANY
			instance_free: class

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		ensure -- from ANY
			tagged_out_not_void: Result /= Void
	
feature -- Platform

	Operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
		ensure -- from ANY
			instance_free: class
			operating_environment_not_void: Result /= Void
	
invariant
		-- from GAME_SURFACE
	surface_valid: is_open implies image.is_open

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class TEXT_SURFACE_SHADED

Generated by ISE EiffelStudio