Table Of Contents

Previous topic

ImageHistogram

Next topic

ImagePNGType

This Page

phoenix_title ImageList

A ImageList contains a list of images, which are stored in an unspecified form.

Images can have masks for transparent drawing, and can be made from a variety of sources including bitmaps and icons.

ImageList is used principally in conjunction with TreeCtrl and ListCtrl classes.


class_hierarchy Inheritance Diagram

Inheritance diagram for class ImageList

Inheritance diagram of ImageList


method_summary Methods Summary

__init__ Default constructor.
Add Adds a new image or images using a bitmap and optional mask bitmap.
Create Initializes the list.
Draw Draws a specified image onto a device context.
GetBitmap Returns the bitmap corresponding to the given index.
GetIcon Returns the icon corresponding to the given index.
GetImageCount Returns the number of images in the list.
GetSize Retrieves the size of the images in the list.
Remove Removes the image at the given position.
RemoveAll Removes all the images in the list.
Replace Replaces the existing image with the new image.

property_summary Properties Summary

ImageCount See GetImageCount

api Class API



class ImageList(Object)

A ImageList contains a list of images, which are stored in an unspecified form.

Possible constructors:

ImageList()

ImageList(width, height, mask=True, initialCount=1)

Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.



__init__ (self, width, height, mask=True, initialCount=1)

Constructor specifying the image size, whether image masks should be created, and the initial size of the list.

Parameters:
  • width (int) – Width of the images in the list.
  • height (int) – Height of the images in the list.
  • mask (bool) – True if masks should be created for all images.
  • initialCount (int) – The initial size of the list.

See also

Create





Add(self, *args, **kw)

overload Overloaded Implementations:



Add (self, bitmap, mask=NullBitmap)

Adds a new image or images using a bitmap and optional mask bitmap.

Parameters:
  • bitmap (Bitmap) – Bitmap representing the opaque areas of the image.
  • mask (Bitmap) – Monochrome mask bitmap, representing the transparent areas of the image.
Return type:

int

Returns:

The new zero-based image index.

Note

The original bitmap or icon is not affected by the Add operation, and can be deleted afterwards. If the bitmap is wider than the images in the list, then the bitmap will automatically be split into smaller images, each matching the dimensions of the image list. This does not apply when adding icons.



Add (self, bitmap, maskColour)

Adds a new image or images using a bitmap and mask colour.

Parameters:
  • bitmap (Bitmap) – Bitmap representing the opaque areas of the image.
  • maskColour (Colour) – Colour indicating which parts of the image are transparent.
Return type:

int

Returns:

The new zero-based image index.

Note

The original bitmap or icon is not affected by the Add operation, and can be deleted afterwards. If the bitmap is wider than the images in the list, then the bitmap will automatically be split into smaller images, each matching the dimensions of the image list. This does not apply when adding icons.



Add (self, icon)

Adds a new image using an icon.

Parameters:icon (Icon) – Icon to use as the image.
Return type:int
Returns:The new zero-based image index.

Note

The original bitmap or icon is not affected by the Add operation, and can be deleted afterwards. If the bitmap is wider than the images in the list, then the bitmap will automatically be split into smaller images, each matching the dimensions of the image list. This does not apply when adding icons.

Availability

Only available for MSW, OSX.





Create(self, width, height, mask=True, initialCount=1)

Initializes the list.

See ImageList for details.

Parameters:
  • width (int) –
  • height (int) –
  • mask (bool) –
  • initialCount (int) –
Return type:

bool



Draw(self, index, dc, x, y, flags=IMAGELIST_DRAW_NORMAL, solidBackground=False)

Draws a specified image onto a device context.

Parameters:
  • index (int) – Image index, starting from zero.
  • dc (DC) – Device context to draw on.
  • x (int) – X position on the device context.
  • y (int) – Y position on the device context.
  • flags (int) – How to draw the image. A bitlist of a selection of the following:

    • IMAGELIST_DRAW_NORMAL: Draw the image normally.
    • IMAGELIST_DRAW_TRANSPARENT: Draw the image with transparency.
    • IMAGELIST_DRAW_SELECTED: Draw the image in selected state.
    • IMAGELIST_DRAW_FOCUSED: Draw the image in a focused state.
  • solidBackground (bool) – For optimisation - drawing can be faster if the function is told that the background is solid.
Return type:

bool



GetBitmap(self, index)

Returns the bitmap corresponding to the given index.

Parameters:index (int) –
Return type: Bitmap


GetIcon(self, index)

Returns the icon corresponding to the given index.

Parameters:index (int) –
Return type: Icon


GetImageCount(self)

Returns the number of images in the list.

Return type:int


GetSize(self, index)

Retrieves the size of the images in the list.

Currently, the index parameter is ignored as all images in the list have the same size.

Parameters:index (int) – currently unused, should be 0

receives the width of the images in the list

receives the height of the images in the list

Return type:tuple
Returns:( width, height )


Remove(self, index)

Removes the image at the given position.

Parameters:index (int) –
Return type:bool


RemoveAll(self)

Removes all the images in the list.

Return type:bool


Replace(self, *args, **kw)

overload Overloaded Implementations:



Replace (self, index, bitmap, mask=NullBitmap)

Replaces the existing image with the new image.

Windows only.

Parameters:
  • index (int) – The index of the bitmap to be replaced.
  • bitmap (Bitmap) – Bitmap representing the opaque areas of the image.
  • mask (Bitmap) – Monochrome mask bitmap, representing the transparent areas of the image.
Return type:

bool

Returns:

True if the replacement was successful, False otherwise.

Note

The original bitmap or icon is not affected by the Replace operation, and can be deleted afterwards.



Replace (self, index, icon)

Replaces the existing image with the new image.

Parameters:
  • index (int) – The index of the bitmap to be replaced.
  • icon (Icon) – Icon to use as the image.
Return type:

bool

Returns:

True if the replacement was successful, False otherwise.

Note

The original bitmap or icon is not affected by the Replace operation, and can be deleted afterwards.

Availability

Only available for MSW, OSX.




Properties



ImageCount

See GetImageCount