]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/imaglist.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxImageList
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 Flag values for Set/GetImageList
13 wxIMAGE_LIST_NORMAL
, // Normal icons
14 wxIMAGE_LIST_SMALL
, // Small icons
15 wxIMAGE_LIST_STATE
// State icons: unimplemented (see WIN32 documentation)
21 #define wxIMAGELIST_DRAW_NORMAL 0x0001
22 #define wxIMAGELIST_DRAW_TRANSPARENT 0x0002
23 #define wxIMAGELIST_DRAW_SELECTED 0x0004
24 #define wxIMAGELIST_DRAW_FOCUSED 0x0008
30 A wxImageList contains a list of images, which are stored in an unspecified
31 form. Images can have masks for transparent drawing, and can be made from a
32 variety of sources including bitmaps and icons.
34 wxImageList is used principally in conjunction with wxTreeCtrl and
40 @see wxTreeCtrl, wxListCtrl
42 class wxImageList
: public wxObject
51 Constructor specifying the image size, whether image masks should be created,
52 and the initial size of the list.
55 Width of the images in the list.
57 Height of the images in the list.
59 @true if masks should be created for all images.
61 The initial size of the list.
65 wxImageList(int width
, int height
, bool mask
= true,
66 int initialCount
= 1);
69 Adds a new image or images using a bitmap and optional mask bitmap.
72 Bitmap representing the opaque areas of the image.
74 Monochrome mask bitmap, representing the transparent areas of the image.
76 @return The new zero-based image index.
78 @remarks The original bitmap or icon is not affected by the Add()
79 operation, and can be deleted afterwards.
80 If the bitmap is wider than the images in the list, then the
81 bitmap will automatically be split into smaller images, each
82 matching the dimensions of the image list.
83 This does not apply when adding icons.
85 int Add(const wxBitmap
& bitmap
,
86 const wxBitmap
& mask
= wxNullBitmap
);
89 Adds a new image or images using a bitmap and mask colour.
92 Bitmap representing the opaque areas of the image.
94 Colour indicating which parts of the image are transparent.
96 @return The new zero-based image index.
98 @remarks The original bitmap or icon is not affected by the Add()
99 operation, and can be deleted afterwards.
100 If the bitmap is wider than the images in the list, then the
101 bitmap will automatically be split into smaller images, each
102 matching the dimensions of the image list.
103 This does not apply when adding icons.
105 int Add(const wxBitmap
& bitmap
, const wxColour
& maskColour
);
108 Adds a new image using an icon.
111 Icon to use as the image.
113 @return The new zero-based image index.
115 @remarks The original bitmap or icon is not affected by the Add()
116 operation, and can be deleted afterwards.
117 If the bitmap is wider than the images in the list, then the
118 bitmap will automatically be split into smaller images, each
119 matching the dimensions of the image list.
120 This does not apply when adding icons.
122 @onlyfor{wxmsw,wxosx}
124 int Add(const wxIcon
& icon
);
127 Initializes the list. See wxImageList() for details.
129 bool Create(int width
, int height
, bool mask
= true,
130 int initialCount
= 1);
133 Draws a specified image onto a device context.
136 Image index, starting from zero.
138 Device context to draw on.
140 X position on the device context.
142 Y position on the device context.
144 How to draw the image. A bitlist of a selection of the following:
145 - wxIMAGELIST_DRAW_NORMAL: Draw the image normally.
146 - wxIMAGELIST_DRAW_TRANSPARENT: Draw the image with transparency.
147 - wxIMAGELIST_DRAW_SELECTED: Draw the image in selected state.
148 - wxIMAGELIST_DRAW_FOCUSED: Draw the image in a focused state.
149 @param solidBackground
150 For optimisation - drawing can be faster if the function is told
151 that the background is solid.
153 virtual bool Draw(int index
, wxDC
& dc
, int x
, int y
,
154 int flags
= wxIMAGELIST_DRAW_NORMAL
,
155 bool solidBackground
= false);
158 Returns the bitmap corresponding to the given index.
160 wxBitmap
GetBitmap(int index
) const;
163 Returns the icon corresponding to the given index.
165 wxIcon
GetIcon(int index
) const;
168 Returns the number of images in the list.
170 virtual int GetImageCount() const;
173 Retrieves the size of the images in the list. Currently, the @a index
174 parameter is ignored as all images in the list have the same size.
177 currently unused, should be 0
179 receives the width of the images in the list
181 receives the height of the images in the list
183 @return @true if the function succeeded, @false if it failed
184 (for example, if the image list was not yet initialized).
186 virtual bool GetSize(int index
, int& width
, int& height
) const;
189 Removes the image at the given position.
191 bool Remove(int index
);
194 Removes all the images in the list.
199 Replaces the existing image with the new image.
203 The index of the bitmap to be replaced.
205 Bitmap representing the opaque areas of the image.
207 Monochrome mask bitmap, representing the transparent areas of the image.
209 @return @true if the replacement was successful, @false otherwise.
211 @remarks The original bitmap or icon is not affected by the Replace()
212 operation, and can be deleted afterwards.
214 bool Replace(int index
, const wxBitmap
& bitmap
,
215 const wxBitmap
& mask
= wxNullBitmap
);
218 Replaces the existing image with the new image.
221 The index of the bitmap to be replaced.
223 Icon to use as the image.
225 @return @true if the replacement was successful, @false otherwise.
227 @remarks The original bitmap or icon is not affected by the Replace()
228 operation, and can be deleted afterwards.
230 @onlyfor{wxmsw,wxosx}
232 bool Replace(int index
, const wxIcon
& icon
);