Implements a caching mechanism for TCustomImageList (TImageList) instances.

imagelistcache.pas contains classes, types, and routines used to implement a cache for TCustomImageList instances. It is used mainly to cache image lists with the glyphs used on button controls.

This file is part of the Lazarus Component Library (LCL).

Interface that cache user should have to listen for cache changes.
Sets the image list for the cache listener.
TCustomImageList instance for the listener.
Sets the new image index for an image in the list.
Old image index in the listener.
New image index in the listener.
Represents an item in the cache.
Reference to the image list.
Reference to the listener interface.
Indices in the image list that the listener has reserved.
Pointer to a TImageCacheItem type.
Implements a container for cached image lists.

TImageCacheItems is a TList descendant which implements a container for cached image lists. It allows indexed access to the image lists in the container by their ordinal position. It also provides a method used to create the image list references stored in the container.

TImageCacheItems is used in the implementation of the TImageListCache class.

Notifies observers when a value in the container has been changed.
Untyped Pointer to the value for the change notification.
Action for the notification (Add, Extract, Delete).
Allocates and stores a new image list reference in the container.

GetNew is a PImageCacheItem function used to allocate and store a new reference to an image list in the container. GetNew calls New to allocate the storage needed for the return value. The Add method is called to append the reference to the storage for the container.

TList.Add
Reference for an image list stored in the container.
Provides indexed access to image list references in the container.

Items is an indexed PImageCacheItem property which provides access to an image list reference in the container by its ordinal position. Read and write access to the property value are redirected to methods in the ancestor.

Items is the default property for the container.

Ordinal position in the container for the requested image list.
Implements a caching mechanism for image lists.

TImageListCache is a class which implements a caching mechanism for TCustomImageList instances. It is used primarily to cache image lists and images used for Glyphs in TButtonGlyph.

TImageListCache contains internal members that are used for the cache storage and cache listener interfaces. The RegisterBitmap method is used to initiate actions affecting the cache storage.

TButtonGlyph
Determines if the cache storage needs to be rebuilt when the change threshold is exceeded.
Gets a TCustomImageList instance with the specified image size.
Width for the images in the image list.
Height for the images in the image list.
Marks an image list and its images as unused for the specified cache listener.
Cache listener removed in the method.
Constructor for the class instance.

Allocates resources needed for internal members in the class instance.

Destructor for the class instance.

Frees resources allocated to internal members in the class instance, including any stored images requested by cache listeners.

Adds a listener for an image list stored in the cache.

RegisterListener is a method used to add the specified cache listener in AListener to the internal list of listener interfaces. If AListener does not already exist in the list, it is added.

RegisterListener is called from the RegisterBitmap method.

TInterfaceList
Position where the specified listener was stored in the internal list.
Listener interface added to the internal list.
Removes the specified cache listener from the internal list.

UnregisterListener is a method used to remove the specified cache listener from the internal list in the class instance. If AListener exists in the interface list, the UnregisterBitmaps method is called and the listener is removed from the list.

When the number of listeners in the list reaches 0, the TImageListCache singleton used for the image list cache is set to Nil.

TInterfaceList
Cache listener removed from the list.
Adds the specified bitmap to the image list for a cache listener.

RegisterBitmap is a method used to register use the image in ABitmap for the cache listener specified in AListener. RegisterBitmap ensures that the cache listener and an image list exist in the cache. The RegisterListener method is called is the listener is not found in the cache. If an image list does not already exist in the cache, a new cache item is allocated.

ABitmap can contain a "sliced" image, which has multiple adjacent images each using the height for the bitmap. The image list in the cache is configured to use the number of images indicated in the ABitmapCount argument. Each image has the same height and width.

The cache listener in AListener is notified if an action caused a change to the index positions used in the image list.

TButtonGlyph.Glyph TButtonGlyph.Refresh
Interface for the cache listener for the bitmap.
Bitmap registered in the method.
Number of image "slices" in the bitmap.
Rebuilds the cache storage.

Removes unused image lists in the cache where the cache listener is no longer registered. Deletes any cached images no longer needed for a given cached image list. Notifies listeners of changes to cached image indexes.

Provides access to the TImageListCache singleton in the implementation.
TImageListCache instance for the implementation.