Version: 3.1.0
wxImageList Class Reference

#include <wx/imaglist.h>

+ Inheritance diagram for wxImageList:

Detailed Description

A wxImageList 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.

wxImageList is used principally in conjunction with wxTreeCtrl and wxListCtrl classes.

Library:  wxCore
Category:  Graphics Device Interface (GDI)
See Also
wxTreeCtrl, wxListCtrl

Public Member Functions

 wxImageList ()
 Default ctor.
 
 wxImageList (int width, int height, bool mask=true, int initialCount=1)
 Constructor specifying the image size, whether image masks should be created, and the initial size of the list.
 
int Add (const wxBitmap &bitmap, const wxBitmap &mask=wxNullBitmap)
 Adds a new image or images using a bitmap and optional mask bitmap.
 
int Add (const wxBitmap &bitmap, const wxColour &maskColour)
 Adds a new image or images using a bitmap and mask colour.
 
int Add (const wxIcon &icon)
 Adds a new image using an icon.
 
bool Create (int width, int height, bool mask=true, int initialCount=1)
 Initializes the list.
 
virtual bool Draw (int index, wxDC &dc, int x, int y, int flags=wxIMAGELIST_DRAW_NORMAL, bool solidBackground=false)
 Draws a specified image onto a device context.
 
wxBitmap GetBitmap (int index) const
 Returns the bitmap corresponding to the given index.
 
wxIcon GetIcon (int index) const
 Returns the icon corresponding to the given index.
 
virtual int GetImageCount () const
 Returns the number of images in the list.
 
virtual bool GetSize (int index, int &width, int &height) const
 Retrieves the size of the images in the list.
 
bool Remove (int index)
 Removes the image at the given position.
 
bool RemoveAll ()
 Removes all the images in the list.
 
bool Replace (int index, const wxBitmap &bitmap, const wxBitmap &mask=wxNullBitmap)
 Replaces the existing image with the new image.
 
bool Replace (int index, const wxIcon &icon)
 Replaces the existing image with the new image.
 
- Public Member Functions inherited from wxObject
 wxObject ()
 Default ctor; initializes to NULL the internal reference data.
 
 wxObject (const wxObject &other)
 Copy ctor.
 
virtual ~wxObject ()
 Destructor.
 
virtual wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar).
 
wxObjectRefDataGetRefData () const
 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
 
bool IsKindOf (const wxClassInfo *info) const
 Determines whether this class is a subclass of (or the same class as) the given class.
 
bool IsSameAs (const wxObject &obj) const
 Returns true if this object has the same data pointer as obj.
 
void Ref (const wxObject &clone)
 Makes this object refer to the data in clone.
 
void SetRefData (wxObjectRefData *data)
 Sets the wxObject::m_refData pointer.
 
void UnRef ()
 Decrements the reference count in the associated data, and if it is zero, deletes the data.
 
void UnShare ()
 This is the same of AllocExclusive() but this method is public.
 
void operator delete (void *buf)
 The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined.
 
void * operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
 The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined.
 

Additional Inherited Members

- Protected Member Functions inherited from wxObject
void AllocExclusive ()
 Ensure that this object's data is not shared with any other object.
 
virtual wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it.
 
virtual wxObjectRefDataCloneRefData (const wxObjectRefData *data) const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data.
 
- Protected Attributes inherited from wxObject
wxObjectRefDatam_refData
 Pointer to an object which is the object's reference-counted data.
 

Constructor & Destructor Documentation

wxImageList::wxImageList ( )

Default ctor.

wxImageList::wxImageList ( int  width,
int  height,
bool  mask = true,
int  initialCount = 1 
)

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

Parameters
widthWidth of the images in the list.
heightHeight of the images in the list.
masktrue if masks should be created for all images.
initialCountThe initial size of the list.
See Also
Create()

Member Function Documentation

int wxImageList::Add ( const wxBitmap bitmap,
const wxBitmap mask = wxNullBitmap 
)

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

Parameters
bitmapBitmap representing the opaque areas of the image.
maskMonochrome mask bitmap, representing the transparent areas of the image.
Returns
The new zero-based image index.
Remarks
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.
int wxImageList::Add ( const wxBitmap bitmap,
const wxColour maskColour 
)

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

Parameters
bitmapBitmap representing the opaque areas of the image.
maskColourColour indicating which parts of the image are transparent.
Returns
The new zero-based image index.
Remarks
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.
int wxImageList::Add ( const wxIcon icon)

Adds a new image using an icon.

Parameters
iconIcon to use as the image.
Returns
The new zero-based image index.
Remarks
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 the wxMSW, wxOSX ports.
bool wxImageList::Create ( int  width,
int  height,
bool  mask = true,
int  initialCount = 1 
)

Initializes the list.

See wxImageList() for details.

virtual bool wxImageList::Draw ( int  index,
wxDC dc,
int  x,
int  y,
int  flags = wxIMAGELIST_DRAW_NORMAL,
bool  solidBackground = false 
)
virtual

Draws a specified image onto a device context.

Parameters
indexImage index, starting from zero.
dcDevice context to draw on.
xX position on the device context.
yY position on the device context.
flagsHow to draw the image. A bitlist of a selection of the following:
  • wxIMAGELIST_DRAW_NORMAL: Draw the image normally.
  • wxIMAGELIST_DRAW_TRANSPARENT: Draw the image with transparency.
  • wxIMAGELIST_DRAW_SELECTED: Draw the image in selected state.
  • wxIMAGELIST_DRAW_FOCUSED: Draw the image in a focused state.
solidBackgroundFor optimisation - drawing can be faster if the function is told that the background is solid.
wxBitmap wxImageList::GetBitmap ( int  index) const

Returns the bitmap corresponding to the given index.

wxIcon wxImageList::GetIcon ( int  index) const

Returns the icon corresponding to the given index.

virtual int wxImageList::GetImageCount ( ) const
virtual

Returns the number of images in the list.

virtual bool wxImageList::GetSize ( int  index,
int &  width,
int &  height 
) const
virtual

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
indexcurrently unused, should be 0
widthreceives the width of the images in the list
heightreceives the height of the images in the list
Returns
true if the function succeeded, false if it failed (for example, if the image list was not yet initialized).
bool wxImageList::Remove ( int  index)

Removes the image at the given position.

bool wxImageList::RemoveAll ( )

Removes all the images in the list.

bool wxImageList::Replace ( int  index,
const wxBitmap bitmap,
const wxBitmap mask = wxNullBitmap 
)

Replaces the existing image with the new image.

Windows only.

Parameters
indexThe index of the bitmap to be replaced.
bitmapBitmap representing the opaque areas of the image.
maskMonochrome mask bitmap, representing the transparent areas of the image.
Returns
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.
bool wxImageList::Replace ( int  index,
const wxIcon icon 
)

Replaces the existing image with the new image.

Parameters
indexThe index of the bitmap to be replaced.
iconIcon to use as the image.
Returns
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.
Availability:  only available for the wxMSW, wxOSX ports.