wxRuby Documentation Home

# Wx::ImageList

A ImageList contains a list of images, which can be used to supply
images/icons to controls. The images are stored in an unspecified form
and can have masks for transparent drawing. The images in a list can be
supplied by a variety of classes including bitmaps and
icons. In almost all cases, it’s easier to use
Bitmap as the formats supported by this class are more
consistent across platforms.

ImageList is used in conjunction with TreeCtrl,
ListCtrl and Notebook classes. All of
these classes have methods to assign an ImageList to the control, and
then methods to select which image to use for a particular item within
the control, by using the index of the image in the list. Note that a
particular ImageList should only be assigned to one control – don’t try
to share an ImageList instance between different Windows.

## Derived from

Object

## See also

TreeCtrl, ListCtrl

## Methods

- ImageList.new
- ImageList#add
- ImageList#create
- ImageList#draw
- ImageList#get_bitmap
- ImageList#get_icon
- ImageList#get_image_count
- ImageList#get_size
- ImageList#remove
- ImageList#remove_all
- ImageList#replace

### ImageList.new

ImageList.new(%(arg-type)Integer% width, Integer height, Boolean mask = true, Integer initialCount = 1)

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

#### Parameters

- width Width of the images in the list.
- height Height of the images in the list.
- mask true if masks should be created for all images.
- initialCount The initial size of the list.

#### See also

ImageList#create

### ImageList#add

Integer add(%(arg-type)Bitmap% bitmap, Bitmap mask = NullBitmap)

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

Integer add(%(arg-type)Bitmap% bitmap, Colour maskColour)

Adds a new image using a bitmap and mask colour.

Integer add(%(arg-type)Icon% icon)

Adds a new image using an icon.

Note that “<<” is an alias for “add”.

#### Parameters

- bitmap Bitmap representing the opaque areas of the image.
- mask Monochrome mask bitmap, representing the transparent areas of the image.
- maskColour Colour indicating which parts of the image are transparent.
- icon Icon to use as the image.

#### Return value

The new zero-based image index.

#### Remarks

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

### ImageList#create

Boolean create(%(arg-type)Integer% width, Integer height, Boolean mask = true, Integer initialCount = 1)

Initializes the list. See ImageList.new for details.

### ImageList#draw

Boolean draw(%(arg-type)Integer% index, DC dc, Integer x, Integer y, Integer flags = IMAGELIST_DRAW_NORMAL, Boolean solidBackground = false)

Draws a specified image onto a device context.

#### Parameters

- index Image index, starting from zero.
- dc Device context to draw on.
- x X position on the device context.
- y Y position on the device context.
- flags 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 For optimisation – drawing can be faster if the function is told
  that the background is solid.

### ImageList#get_bitmap

Bitmap get_bitmap(%(arg-type)Integer% index)

Returns the bitmap corresponding to the given index.

### ImageList#get_icon

Icon get_icon(%(arg-type)Integer% index)

Returns the icon corresponding to the given index.

### ImageList#get_image_count

Integer get_image_count()

Returns the number of images in the list.

### ImageList#get_size

Boolean get_size(%(arg-type)Integer% index, Integer width, Integer height)

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 currently unused, should be 0
- width receives the width of the images in the list
- height receives the height of the images in the list

#### Return value

true if the function succeeded, false if it failed (for example, if the image
list was not yet initialized).

### ImageList#remove

Boolean remove(%(arg-type)Integer% index)

Removes the image at the given position.

### ImageList#remove_all

Boolean remove_all()

Removes all the images in the list.

### ImageList#replace

Boolean replace(%(arg-type)Integer% index, Bitmap bitmap, Bitmap mask = NullBitmap)

Replaces the existing image with the new image.

Windows only.

Boolean replace(%(arg-type)Integer% index, Icon icon)

Replaces the existing image with the new image.

#### Parameters

- bitmap Bitmap representing the opaque areas of the image.
- mask Monochrome mask bitmap, representing the transparent areas of the image.
- icon Icon to use as the image.

#### Return value

true if the replacement was successful, false otherwise.

#### Remarks

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

[This page automatically generated from the Textile source at 2023-06-09 00:45:36 +0000]