Class: Wx::ImageList

Inherits:
Object show all
Defined in:
lib/wx/doc/gen/image_list.rb

Overview

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

Images can use alpha channel or 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. Use of this class is not recommended in the new code as it doesn’t support showing DPI-dependent bitmaps. Please use WithImages#set_images instead of WithImages#set_image_list.

Category: Graphics Device Interface (GDI)

See Also:

Requires:

  • USE_IMAGLIST

Instance Method Summary collapse

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initializeWx::ImageList #initialize(width, height, mask = true, initialCount = 1) ⇒ Wx::ImageList

Returns a new instance of ImageList.

Overloads:

  • #initializeWx::ImageList

    Default ctor.

    Note that the object created using the default ctor is invalid and calling any methods other than #create on it will result in an assertion failure.

  • #initialize(width, height, mask = true, initialCount = 1) ⇒ Wx::ImageList

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

    Note that the size is specified in physical pixels and must correspond to the size of bitmaps, in pixels, that will be added to this list.

    Parameters:

    • width (Integer)

      Width of the images in the list.

    • height (Integer)

      Height of the images in the list.

    • mask (Boolean) (defaults to: true)

      If true, all images will have masks, with the mask being created from the light grey pixels if not specified otherwise, i.e. if the image doesn’t have neither alpha channel nor mask and no mask is explicitly specified when adding it. Note that if an image does have alpha channel or mask, it will always be used, whether this parameter is true or false.

    • initialCount (Integer) (defaults to: 1)

      The initial size of the list.

    See Also:



62
# File 'lib/wx/doc/gen/image_list.rb', line 62

def initialize(*args) end

Instance Method Details

#add(bitmap, mask = Wx::NULL_BITMAP) ⇒ Integer #add(bitmap, maskColour) ⇒ Integer #add(icon) ⇒ Integer

Overloads:

  • #add(bitmap, mask = Wx::NULL_BITMAP) ⇒ Integer

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

    The physical size of the bitmap should be the same as the size specified when constructing Wx::ImageList. If the width of the bitmap is greater than the image list width, bitmap is split into smaller images of the required width, allowing to add multiple images from a single bitmap.

    The new zero-based image index.

    Parameters:

    • bitmap (Wx::Bitmap)

      Bitmap representing the opaque areas of the image.

    • mask (Wx::Bitmap) (defaults to: Wx::NULL_BITMAP)

      Monochrome mask bitmap, representing the transparent areas of the image.

    Returns:

    • (Integer)
  • #add(bitmap, maskColour) ⇒ Integer

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

    The physical size of the bitmap should be the same as the size specified when constructing Wx::ImageList. If the width of the bitmap is greater than the image list width, bitmap is split into smaller images of the required width, allowing to add multiple images from a single bitmap.

    The new zero-based image index.

    Parameters:

    • bitmap (Wx::Bitmap)

      Bitmap representing the opaque areas of the image.

    • maskColour (Wx::Colour, String, Symbol)

      Colour indicating which parts of the image are transparent.

    Returns:

    • (Integer)
  • #add(icon) ⇒ Integer

    Adds a new image using an icon.

    The physical size of the icon should be the same as the size specified when constructing Wx::ImageList.

    The new zero-based image index.

    Availability: only available for the WXMSW, WXOSX/Cocoa ports.

    Parameters:

    • icon (Wx::Icon)

      Icon to use as the image.

    Returns:

    • (Integer)

    Requires:

    • WXMSW or WXOSX


93
# File 'lib/wx/doc/gen/image_list.rb', line 93

def add(*args) end

#create(width, height, mask = true, initialCount = 1) ⇒ Boolean

Initializes the list.

See image_list for details. This function can be called only once after creating the object using its default ctor or after calling #destroy.

Parameters:

  • width (Integer)
  • height (Integer)
  • mask (Boolean) (defaults to: true)
  • initialCount (Integer) (defaults to: 1)

Returns:

  • (Boolean)


104
# File 'lib/wx/doc/gen/image_list.rb', line 104

def create(width, height, mask=true, initialCount=1) end

#destroyvoid

This method returns an undefined value.

Destroys the current list.

This function resets the object to its initial state and does more than just #remove_all in the native WXMSW version. After calling it, #create may be called again to recreate the image list, e.g. using a different size.



111
# File 'lib/wx/doc/gen/image_list.rb', line 111

def destroy; end

#draw(index, dc, x, y, flags = Wx::IMAGELIST_DRAW_NORMAL, solidBackground = false) ⇒ Boolean

Draws a specified image onto a device context.

Parameters:

  • index (Integer)

    Image index, starting from zero.

  • dc (Wx::DC)

    Device context to draw on.

  • x (Integer)

    X position on the device context.

  • y (Integer)

    Y position on the device context.

  • flags (Integer) (defaults to: Wx::IMAGELIST_DRAW_NORMAL)

    How to draw the image. A bitlist of a selection of the following:

  • solidBackground (Boolean) (defaults to: false)

    For optimisation - drawing can be faster if the function is told that the background is solid.

Returns:

  • (Boolean)


126
# File 'lib/wx/doc/gen/image_list.rb', line 126

def draw(index, dc, x, y, flags=Wx::IMAGELIST_DRAW_NORMAL, solidBackground=false) end

#get_bitmap(index) ⇒ Wx::Bitmap Also known as: bitmap

Returns the bitmap corresponding to the given index.

Parameters:

  • index (Integer)

Returns:



131
# File 'lib/wx/doc/gen/image_list.rb', line 131

def get_bitmap(index) end

#get_icon(index) ⇒ Wx::Icon Also known as: icon

Returns the icon corresponding to the given index.

Parameters:

  • index (Integer)

Returns:



137
# File 'lib/wx/doc/gen/image_list.rb', line 137

def get_icon(index) end

#get_image_countInteger Also known as: image_count

Returns the number of images in the list.

Returns:

  • (Integer)


142
# File 'lib/wx/doc/gen/image_list.rb', line 142

def get_image_count; end

#get_sizeWx::Size Also known as: size

Retrieves the size of the image list as passed to #create.

the size of the image list, which may be zero if the image list was not yet initialised.

Returns:



149
# File 'lib/wx/doc/gen/image_list.rb', line 149

def get_size; end

#remove(index) ⇒ Boolean

Removes the image at the given position.

Parameters:

  • index (Integer)

Returns:

  • (Boolean)


155
# File 'lib/wx/doc/gen/image_list.rb', line 155

def remove(index) end

#remove_allBoolean

Removes all the images in the list.

Returns:

  • (Boolean)


159
# File 'lib/wx/doc/gen/image_list.rb', line 159

def remove_all; end

#replace(index, bitmap, mask = Wx::NULL_BITMAP) ⇒ Boolean #replace(index, icon) ⇒ Boolean

Overloads:

  • #replace(index, bitmap, mask = Wx::NULL_BITMAP) ⇒ Boolean

    Replaces the existing image with the new image.

    true if the replacement was successful, false otherwise.

    Remark:

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

    Parameters:

    • index (Integer)

      The index of the bitmap to be replaced.

    • bitmap (Wx::Bitmap)

      Bitmap representing the opaque areas of the image.

    • mask (Wx::Bitmap) (defaults to: Wx::NULL_BITMAP)

      Monochrome mask bitmap, representing the transparent areas of the image.

    Returns:

    • (Boolean)
  • #replace(index, icon) ⇒ Boolean

    Replaces the existing image with the new image.

    true if the replacement was successful, false otherwise.

    Remark:

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

    Availability: only available for the WXMSW, WXOSX/Cocoa ports.

    Parameters:

    • index (Integer)

      The index of the bitmap to be replaced.

    • icon (Wx::Icon)

      Icon to use as the image.

    Returns:

    • (Boolean)

    Requires:

    • WXMSW or WXOSX


191
# File 'lib/wx/doc/gen/image_list.rb', line 191

def replace(*args) end