indexing
	description: "List of images. The list is cached to avoid multiplication of indexes for the same image"
	legal: "See notice at end of class."
	status: "See notice at end of class."
	date: "$Date$"
	revision: "$Revision$"

class interface
	EV_IMAGE_LIST_IMP

create 
	make_with_size (a_width, a_height: INTEGER_32)
			-- Create image list with all images
			-- `a_width' by `a_height' pixels

feature -- Initialization

	make (given_width: INTEGER_32; given_height: INTEGER_32; color_depth: INTEGER_32; masked_bitmap: BOOLEAN)
			-- Initialization with an empty image list. Images located
			-- in this imageList must have the a width equal to `given_width'
			-- and a height equal to `given_height'. 
			--
			-- The flag `color_depth' determines the color depth of the bitmaps.
			-- (bitmaps with a different color depth than indicated in
			-- `image_type' will automatically be converted)
			-- See Ilc_colorXXXX in WEL_ILC_CONSTANTS for possible values
			--
			-- The flag `masked_bitmap' specify whether we are using Bitmaps with mask, or plain
			-- bitmaps.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			valid_width: given_width > 0
			valid_height: given_height > 0
	
feature -- Access

	count: INTEGER_32
			-- Retrieves the number of images in the image list.
			-- (from WEL_IMAGE_LIST)

	generating_type: STRING_8
			-- Name of current object's generating type
			-- (type of which it is a direct instance)
			-- (from ANY)

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)

	item: POINTER
			-- Generic Windows handle or structure pointer.
			-- Can be a HWND, HICON, RECT *, WNDCLASS *, etc...
			-- (from WEL_ANY)

	last_position: INTEGER_32
			-- Position of last image inserted/deleted.
			-- updated by `add_image'.
			-- (from WEL_IMAGE_LIST)

	use_masked_bitmap: BOOLEAN
			-- Does the ImageList contains 'Bitmap+Mask' or
			-- only 'Bitmap'
			--
			-- Note: to use masked bitmap, create the ImageList
			--       using `Ilc_mask + Ilc_colorXXXX' as `image_type'
			-- (from WEL_IMAGE_LIST)
	
feature -- Comparison

	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		ensure -- from ANY
			shallow_implies_deep: standard_equal (some, other) implies Result
			both_or_none_void: (some = Void) implies (Result = (other = Void))
			same_type: (Result and (some /= Void)) implies some.same_type (other)
			symmetric: Result implies deep_equal (other, some)

	frozen equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		ensure -- from ANY
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

	is_equal (other: like Current): 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.is_equal (Current)
			consistent: standard_is_equal (other) implies Result

	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
			-- Are `some' and `other' 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
			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

	frozen standard_is_equal (other: like Current): 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

	bitmaps_height: INTEGER_32
			-- height of all bitmaps located in this imageList
			-- (from WEL_IMAGE_LIST)

	bitmaps_width: INTEGER_32
			-- width of all bitmaps located in this imageList
			-- (from WEL_IMAGE_LIST)

	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

	exists: BOOLEAN
			-- Does the item exist?
			-- (from WEL_ANY)
		require -- from  WEL_REFERENCE_TRACKABLE
			True
		ensure -- from WEL_ANY
			Result = (item /= default_pointer)

	get_background_color: WEL_COLOR_REF
			-- Retrieves the current background color for this image list. 
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			exists: exists
		ensure -- from WEL_IMAGE_LIST
			result_not_void: Result /= Void

	pixmap_position (a_pixmap: EV_PIXMAP)
			-- Update last_position with the position of `a_pixmap'
			-- in the image list. Set last_position to -1 if `a_pixmap'
			-- is not present in the image list.
		require
			a_pixmap_not_void: a_pixmap /= 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))

	shared: BOOLEAN
			-- Is item shared by another object?
			-- If False (by default), item will
			-- be destroyed by destroy_item.
			-- If True, item will not be destroyed.
			-- (from WEL_ANY)
	
feature -- Status setting

	set_shared
			-- Set shared to True.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			shared: shared

	set_unshared
			-- Set shared to False.
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			unshared: not shared
	
feature -- Element change

	add_pixmap (a_pixmap: EV_PIXMAP)
			-- Add the pixmap `a_pixmap' into the image list.
			--
			-- last_position is updated.

	extend_pixmap (a_pixmap: EV_PIXMAP)
			-- Add the pixmap `a_pixmap' at the end of the image list.
			-- Do not test for possible cached version.
			--
			-- last_position is updated.

	set_item (an_item: POINTER)
			-- Set item with `an_item'
			-- (from WEL_ANY)
		ensure -- from WEL_ANY
			item_set: item = an_item
	
feature -- Removal

	delete
			-- Destroy inner structure of `Current'.
			-- To be called when Current is no more needed
			-- (from WEL_REFERENCE_TRACKABLE)
		require -- from WEL_REFERENCE_TRACKABLE
			reference_not_tracked: not reference_tracked
		ensure -- from WEL_REFERENCE_TRACKABLE
			destroyed: not shared implies not exists

	destroy
			-- destroy item by calling the
			-- corresponding Windows function and
			-- set item to default_pointer.
			-- (from WEL_IMAGE_LIST)

	dispose
			-- Destroy inner structure of `Current'.
			-- (from WEL_REFERENCE_TRACKABLE)
		require -- from  DISPOSABLE
			True
		ensure then -- from WEL_REFERENCE_TRACKABLE
			internal_object_id_freed: internal_object_id = 0
	
feature -- Duplication

	copy (other: like Current)
			-- 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: is_equal (other)

	frozen deep_copy (other: like Current)
			-- 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: like Current
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		ensure -- from ANY
			deep_equal: deep_equal (Current, Result)

	frozen standard_copy (other: like Current)
			-- 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: like Current
			-- 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: like Current
			-- New object equal to `Current'
			-- twin calls copy; to change copying/twining semantics, redefine copy.
			-- (from ANY)
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result.is_equal (Current)
	
feature -- Basic operations

	add_bitmap (bitmap_to_add: WEL_BITMAP)
			-- Add the bitmap `bitmap_to_add' into the image list.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			bitmap_not_void: bitmap_to_add /= Void
			compatible_width_for_bitmap: bitmap_to_add.width = bitmaps_width
			compatible_height_for_bitmap: bitmap_to_add.height = bitmaps_height
			exists: exists

	add_color_masked_bitmap (bitmap_to_add: WEL_BITMAP; mask_color: WEL_COLOR_REF)
			-- Add the bitmap `bitmap_to_add' into the image list.
			-- `mask_color' represents the color used to generate the mask. 
			-- Each pixel of this color in the specified bitmap is changed to black
			-- and the corresponding bit in the mask is set to 1.
			--
			-- Note: Bitmaps with color depth greater than 8bpp are not supported
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			bitmap_not_void: bitmap_to_add /= Void
			mask_color_not_void: mask_color /= Void
			compatible_width_for_bitmap: bitmap_to_add.width = bitmaps_width
			compatible_height_for_bitmap: bitmap_to_add.height = bitmaps_height
			exists: exists

	add_icon (icon_to_add: WEL_GRAPHICAL_RESOURCE)
			-- Adds the icon or cursor `icon_to_add' to this image list
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			icon_not_void: icon_to_add /= Void
			exists: exists

	add_masked_bitmap (bitmap_to_add: WEL_BITMAP; bitmap_mask: WEL_BITMAP)
			-- Add the bitmap `bitmap_to_add' into the image list.
			-- `bitmap_mask' represents the mask for the bitmap.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			bitmap_not_void: bitmap_to_add /= Void
			mask_not_void: bitmap_mask /= Void
			compatible_width_for_bitmap: bitmap_to_add.width = bitmaps_width
			compatible_height_for_bitmap: bitmap_to_add.height = bitmaps_height
			compatible_width_for_mask: bitmap_mask.width = bitmaps_width
			compatible_height_for_mask: bitmap_mask.height = bitmaps_height
			masked_bitmap_in_use: use_masked_bitmap
			exists: exists

	frozen default: like Current
			-- 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)

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

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)

	get_icon (index, flags: INTEGER_32): WEL_ICON
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			index_not_too_small: index >= 0
			index_not_too_big: index < count
			exists: exists

	remove_all_images (index: INTEGER_32)
			-- Remove all images from the image list.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			exists: exists

	remove_image (index: INTEGER_32)
			-- Remove the image at index `index' from the image list.
			--
			-- When an image is removed, the indexes of the remaining images are 
			-- adjusted so that the image indexes always range from zero to one
			-- less than the number of images in the image list. 
			-- For example, if you remove the image at index 0, then image 1 becomes 
			-- image 0, image 2 becomes image 1, and so on. 
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			index_not_too_small: index >= 0
			index_not_too_big: index < count
			exists: exists

	replace_bitmap (bitmap_to_add: WEL_BITMAP; index: INTEGER_32)
			-- Replace the bitmap at position `index' in the imageList by
			-- `bitmap_to_add'.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			bitmap_not_void: bitmap_to_add /= Void
			not_use_masked_bitmap: not use_masked_bitmap
			index_not_too_small: index >= 0
			index_not_too_big: index < count
			exists: exists

	replace_icon (icon_to_add: WEL_GRAPHICAL_RESOURCE; index: INTEGER_32)
			-- Replace the bitmap at position `index' in the imageList by
			-- the cursor or icon `icon_to_add'.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			icon_not_void: icon_to_add /= Void
			index_not_too_small: index >= 0
			index_not_too_big: index < count
			exists: exists

	replace_masked_bitmap (bitmap_to_add: WEL_BITMAP; bitmap_mask: WEL_BITMAP; index: INTEGER_32)
			-- Replace the bitmap at position `index' in the imageList by
			-- `bitmap_to_add'.
			-- `bitmap_mask' represents the mask for the bitmap.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			bitmap_not_void: bitmap_to_add /= Void
			mask_not_void: bitmap_mask /= Void
			compatible_width_for_bitmap: bitmap_to_add.width = bitmaps_width
			compatible_height_for_bitmap: bitmap_to_add.height = bitmaps_height
			compatible_width_for_mask: bitmap_mask.width = bitmaps_width
			compatible_height_for_mask: bitmap_mask.height = bitmaps_height
			masked_bitmap_in_use: use_masked_bitmap
			index_not_too_small: index >= 0
			index_not_too_big: index < count
			exists: exists

	set_background_color (new_color: WEL_COLOR_REF)
			-- Sets the background color for this image list.
			-- (from WEL_IMAGE_LIST)
		require -- from WEL_IMAGE_LIST
			new_color_not_void: new_color /= Void
			exists: exists
	
feature -- Output

	io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of tagged_out.
			-- (from ANY)

	print (some: ANY)
			-- Write terse external representation of `some'
			-- on standard output.
			-- (from ANY)

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- Was declared in ANY as synonym of out.
			-- (from ANY)
	
feature -- Platform

	operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
	
feature -- Status Report

	reference_tracked: BOOLEAN
			-- Are number references of `Current' tracked?
			-- (from WEL_REFERENCE_TRACKABLE)

	references_count: INTEGER_32
			-- Number of object referring to current object.
			-- (from WEL_REFERENCE_TRACKABLE)
	
feature -- Status Setting

	decrement_reference
			-- Decrement number of references to current object.
			-- When number of references reaches zero, 
			-- delete is called if object is not protected.
			-- (from WEL_REFERENCE_TRACKABLE)
		require -- from WEL_REFERENCE_TRACKABLE
			exists: exists
			tracking_references_started: reference_tracked

	enable_reference_tracking
			-- Set `references_tracked' to True.
			-- (from WEL_REFERENCE_TRACKABLE)
		require -- from WEL_REFERENCE_TRACKABLE
			exists: exists
			tracking_reference_not_started: not reference_tracked

	increment_reference
			-- Increment number of references to current object.
			-- (from WEL_REFERENCE_TRACKABLE)
		require -- from WEL_REFERENCE_TRACKABLE
			exists: exists
			tracking_references_started: reference_tracked

	object_id: INTEGER_32
			-- Runtime Id of `Current'.
			-- (from WEL_REFERENCE_TRACKABLE)
	
invariant
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

indexing
	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		356 Storke Road, Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class EV_IMAGE_LIST_IMP