2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: imaglist.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxImageList
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxImageList
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-17 16:55:12 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxImageList is used principally in conjunction with wxTreeCtrl and
|
|
|
|
wxListCtrl classes.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{gdi}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxTreeCtrl, wxListCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxImageList : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
2008-10-17 16:55:12 -04:00
|
|
|
/**
|
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxImageList();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor specifying the image size, whether image masks should be created,
|
|
|
|
and the initial size of the list.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
Width of the images in the list.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
Height of the images in the list.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param mask
|
2008-03-09 08:33:59 -04:00
|
|
|
@true if masks should be created for all images.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param initialCount
|
2008-03-09 08:33:59 -04:00
|
|
|
The initial size of the list.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Create()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxImageList(int width, int height, bool mask = true,
|
2008-03-08 09:43:31 -05:00
|
|
|
int initialCount = 1);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-17 16:55:12 -04:00
|
|
|
Adds a new image or images using a bitmap and optional mask bitmap.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
Bitmap representing the opaque areas of the image.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param mask
|
2008-03-09 08:33:59 -04:00
|
|
|
Monochrome mask bitmap, representing the transparent areas of the image.
|
2008-10-17 16:55:12 -04:00
|
|
|
|
|
|
|
@return 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 Add(const wxBitmap& bitmap,
|
|
|
|
const wxBitmap& mask = wxNullBitmap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a new image or images using a bitmap and mask colour.
|
|
|
|
|
|
|
|
@param bitmap
|
|
|
|
Bitmap representing the opaque areas of the image.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param maskColour
|
2008-03-09 08:33:59 -04:00
|
|
|
Colour indicating which parts of the image are transparent.
|
2008-10-17 16:55:12 -04:00
|
|
|
|
|
|
|
@return 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 Add(const wxBitmap& bitmap, const wxColour& maskColour);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a new image using an icon.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param icon
|
2008-03-09 08:33:59 -04:00
|
|
|
Icon to use as the image.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return The new zero-based image index.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-10-17 16:55:12 -04:00
|
|
|
@remarks The original bitmap or icon is not affected by the Add()
|
2008-03-09 08:33:59 -04:00
|
|
|
operation, and can be deleted afterwards.
|
2008-10-17 16:55:12 -04:00
|
|
|
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.
|
2008-11-10 16:33:25 -05:00
|
|
|
|
|
|
|
@onlyfor{wxmsw,wxmac}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
int Add(const wxIcon& icon);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initializes the list. See wxImageList() for details.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(int width, int height, bool mask = true,
|
2008-03-08 08:52:38 -05:00
|
|
|
int initialCount = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Draws a specified image onto a device context.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param index
|
2008-03-09 08:33:59 -04:00
|
|
|
Image index, starting from zero.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param dc
|
2008-03-09 08:33:59 -04:00
|
|
|
Device context to draw on.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param x
|
2008-03-09 08:33:59 -04:00
|
|
|
X position on the device context.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param y
|
2008-03-09 08:33:59 -04:00
|
|
|
Y position on the device context.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param flags
|
2008-03-09 08:33:59 -04:00
|
|
|
How to draw the image. A bitlist of a selection of the following:
|
2008-10-17 16:55:12 -04:00
|
|
|
- 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.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param solidBackground
|
2008-03-09 08:33:59 -04:00
|
|
|
For optimisation - drawing can be faster if the function is told
|
|
|
|
that the background is solid.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool Draw(int index, wxDC& dc, int x, int y,
|
|
|
|
int flags = wxIMAGELIST_DRAW_NORMAL,
|
|
|
|
bool solidBackground = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the bitmap corresponding to the given index.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxBitmap GetBitmap(int index) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the icon corresponding to the given index.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxIcon GetIcon(int index) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of images in the list.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetImageCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Retrieves the size of the images in the list. Currently, the @a index
|
2008-03-08 08:52:38 -05:00
|
|
|
parameter is ignored as all images in the list have the same size.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param index
|
2008-03-09 08:33:59 -04:00
|
|
|
currently unused, should be 0
|
2008-03-08 09:43:31 -05:00
|
|
|
@param width
|
2008-03-09 08:33:59 -04:00
|
|
|
receives the width of the images in the list
|
2008-03-08 09:43:31 -05:00
|
|
|
@param height
|
2008-03-09 08:33:59 -04:00
|
|
|
receives the height of the images in the list
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-10-17 16:55:12 -04:00
|
|
|
@return @true if the function succeeded, @false if it failed
|
|
|
|
(for example, if the image list was not yet initialized).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool GetSize(int index, int& width, int& height) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Removes the image at the given position.
|
|
|
|
*/
|
|
|
|
bool Remove(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Removes all the images in the list.
|
|
|
|
*/
|
|
|
|
bool RemoveAll();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Replaces the existing image with the new image.
|
2008-10-17 16:55:12 -04:00
|
|
|
Windows only.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-10-17 16:55:12 -04:00
|
|
|
@param index
|
|
|
|
The index of the bitmap to be replaced.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param bitmap
|
2008-03-09 08:33:59 -04:00
|
|
|
Bitmap representing the opaque areas of the image.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param mask
|
2008-03-09 08:33:59 -04:00
|
|
|
Monochrome mask bitmap, representing the transparent areas of the image.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the replacement was successful, @false otherwise.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-10-17 16:55:12 -04:00
|
|
|
@remarks The original bitmap or icon is not affected by the Replace()
|
2008-03-09 08:33:59 -04:00
|
|
|
operation, and can be deleted afterwards.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool Replace(int index, const wxBitmap& bitmap,
|
|
|
|
const wxBitmap& mask = wxNullBitmap);
|
2008-10-17 16:55:12 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Replaces the existing image with the new image.
|
|
|
|
|
|
|
|
@param index
|
|
|
|
The index of the bitmap to be replaced.
|
|
|
|
@param icon
|
|
|
|
Icon to use as the image.
|
|
|
|
|
|
|
|
@return @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.
|
2008-11-10 16:33:25 -05:00
|
|
|
|
|
|
|
@onlyfor{wxmsw,wxmac}
|
2008-10-17 16:55:12 -04:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
bool Replace(int index, const wxIcon& icon);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|