]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: imaglist.h | |
e54c96f1 | 3 | // Purpose: interface of wxImageList |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
639f8119 RD |
8 | /** |
9 | Flag values for Set/GetImageList | |
10 | */ | |
11 | enum | |
12 | { | |
13 | wxIMAGE_LIST_NORMAL, // Normal icons | |
14 | wxIMAGE_LIST_SMALL, // Small icons | |
15 | wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation) | |
16 | }; | |
17 | ||
18 | /** | |
19 | Flags for Draw | |
20 | */ | |
21 | #define wxIMAGELIST_DRAW_NORMAL 0x0001 | |
22 | #define wxIMAGELIST_DRAW_TRANSPARENT 0x0002 | |
23 | #define wxIMAGELIST_DRAW_SELECTED 0x0004 | |
24 | #define wxIMAGELIST_DRAW_FOCUSED 0x0008 | |
25 | ||
26 | ||
23324ae1 FM |
27 | /** |
28 | @class wxImageList | |
7c913512 | 29 | |
89bb3f02 FM |
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. | |
7c913512 | 33 | |
23324ae1 FM |
34 | wxImageList is used principally in conjunction with wxTreeCtrl and |
35 | wxListCtrl classes. | |
7c913512 | 36 | |
23324ae1 FM |
37 | @library{wxcore} |
38 | @category{gdi} | |
7c913512 | 39 | |
e54c96f1 | 40 | @see wxTreeCtrl, wxListCtrl |
23324ae1 FM |
41 | */ |
42 | class wxImageList : public wxObject | |
43 | { | |
44 | public: | |
89bb3f02 FM |
45 | /** |
46 | Default ctor. | |
47 | */ | |
48 | wxImageList(); | |
49 | ||
23324ae1 FM |
50 | /** |
51 | Constructor specifying the image size, whether image masks should be created, | |
52 | and the initial size of the list. | |
3c4f71cc | 53 | |
7c913512 | 54 | @param width |
4cc4bfaf | 55 | Width of the images in the list. |
7c913512 | 56 | @param height |
4cc4bfaf | 57 | Height of the images in the list. |
7c913512 | 58 | @param mask |
4cc4bfaf | 59 | @true if masks should be created for all images. |
7c913512 | 60 | @param initialCount |
4cc4bfaf | 61 | The initial size of the list. |
3c4f71cc | 62 | |
4cc4bfaf | 63 | @see Create() |
23324ae1 | 64 | */ |
4cc4bfaf | 65 | wxImageList(int width, int height, bool mask = true, |
7c913512 | 66 | int initialCount = 1); |
23324ae1 | 67 | |
23324ae1 | 68 | /** |
89bb3f02 | 69 | Adds a new image or images using a bitmap and optional mask bitmap. |
3c4f71cc | 70 | |
7c913512 | 71 | @param bitmap |
4cc4bfaf | 72 | Bitmap representing the opaque areas of the image. |
7c913512 | 73 | @param mask |
4cc4bfaf | 74 | Monochrome mask bitmap, representing the transparent areas of the image. |
89bb3f02 FM |
75 | |
76 | @return The new zero-based image index. | |
77 | ||
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. | |
84 | */ | |
85 | int Add(const wxBitmap& bitmap, | |
86 | const wxBitmap& mask = wxNullBitmap); | |
87 | ||
88 | /** | |
89 | Adds a new image or images using a bitmap and mask colour. | |
90 | ||
91 | @param bitmap | |
92 | Bitmap representing the opaque areas of the image. | |
7c913512 | 93 | @param maskColour |
4cc4bfaf | 94 | Colour indicating which parts of the image are transparent. |
89bb3f02 FM |
95 | |
96 | @return The new zero-based image index. | |
97 | ||
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. | |
104 | */ | |
105 | int Add(const wxBitmap& bitmap, const wxColour& maskColour); | |
106 | ||
107 | /** | |
108 | Adds a new image using an icon. | |
109 | ||
7c913512 | 110 | @param icon |
4cc4bfaf | 111 | Icon to use as the image. |
3c4f71cc | 112 | |
d29a9a8a | 113 | @return The new zero-based image index. |
3c4f71cc | 114 | |
89bb3f02 | 115 | @remarks The original bitmap or icon is not affected by the Add() |
4cc4bfaf | 116 | operation, and can be deleted afterwards. |
89bb3f02 FM |
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. | |
0a98423e | 121 | |
0f6c9085 | 122 | @onlyfor{wxmsw,wxosx} |
23324ae1 | 123 | */ |
7c913512 | 124 | int Add(const wxIcon& icon); |
23324ae1 FM |
125 | |
126 | /** | |
127 | Initializes the list. See wxImageList() for details. | |
128 | */ | |
4cc4bfaf | 129 | bool Create(int width, int height, bool mask = true, |
23324ae1 FM |
130 | int initialCount = 1); |
131 | ||
132 | /** | |
133 | Draws a specified image onto a device context. | |
3c4f71cc | 134 | |
7c913512 | 135 | @param index |
4cc4bfaf | 136 | Image index, starting from zero. |
7c913512 | 137 | @param dc |
4cc4bfaf | 138 | Device context to draw on. |
7c913512 | 139 | @param x |
4cc4bfaf | 140 | X position on the device context. |
7c913512 | 141 | @param y |
4cc4bfaf | 142 | Y position on the device context. |
7c913512 | 143 | @param flags |
4cc4bfaf | 144 | How to draw the image. A bitlist of a selection of the following: |
89bb3f02 FM |
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. | |
7c913512 | 149 | @param solidBackground |
4cc4bfaf FM |
150 | For optimisation - drawing can be faster if the function is told |
151 | that the background is solid. | |
23324ae1 | 152 | */ |
adaaa686 FM |
153 | virtual bool Draw(int index, wxDC& dc, int x, int y, |
154 | int flags = wxIMAGELIST_DRAW_NORMAL, | |
155 | bool solidBackground = false); | |
23324ae1 FM |
156 | |
157 | /** | |
158 | Returns the bitmap corresponding to the given index. | |
159 | */ | |
328f5751 | 160 | wxBitmap GetBitmap(int index) const; |
23324ae1 FM |
161 | |
162 | /** | |
163 | Returns the icon corresponding to the given index. | |
164 | */ | |
328f5751 | 165 | wxIcon GetIcon(int index) const; |
23324ae1 FM |
166 | |
167 | /** | |
168 | Returns the number of images in the list. | |
169 | */ | |
adaaa686 | 170 | virtual int GetImageCount() const; |
23324ae1 FM |
171 | |
172 | /** | |
4cc4bfaf | 173 | Retrieves the size of the images in the list. Currently, the @a index |
23324ae1 | 174 | parameter is ignored as all images in the list have the same size. |
3c4f71cc | 175 | |
7c913512 | 176 | @param index |
4cc4bfaf | 177 | currently unused, should be 0 |
7c913512 | 178 | @param width |
4cc4bfaf | 179 | receives the width of the images in the list |
7c913512 | 180 | @param height |
4cc4bfaf | 181 | receives the height of the images in the list |
3c4f71cc | 182 | |
89bb3f02 FM |
183 | @return @true if the function succeeded, @false if it failed |
184 | (for example, if the image list was not yet initialized). | |
23324ae1 | 185 | */ |
adaaa686 | 186 | virtual bool GetSize(int index, int& width, int& height) const; |
23324ae1 FM |
187 | |
188 | /** | |
189 | Removes the image at the given position. | |
190 | */ | |
191 | bool Remove(int index); | |
192 | ||
193 | /** | |
194 | Removes all the images in the list. | |
195 | */ | |
196 | bool RemoveAll(); | |
197 | ||
23324ae1 FM |
198 | /** |
199 | Replaces the existing image with the new image. | |
89bb3f02 | 200 | Windows only. |
3c4f71cc | 201 | |
89bb3f02 FM |
202 | @param index |
203 | The index of the bitmap to be replaced. | |
7c913512 | 204 | @param bitmap |
4cc4bfaf | 205 | Bitmap representing the opaque areas of the image. |
7c913512 | 206 | @param mask |
4cc4bfaf | 207 | Monochrome mask bitmap, representing the transparent areas of the image. |
3c4f71cc | 208 | |
d29a9a8a | 209 | @return @true if the replacement was successful, @false otherwise. |
3c4f71cc | 210 | |
89bb3f02 | 211 | @remarks The original bitmap or icon is not affected by the Replace() |
4cc4bfaf | 212 | operation, and can be deleted afterwards. |
23324ae1 FM |
213 | */ |
214 | bool Replace(int index, const wxBitmap& bitmap, | |
215 | const wxBitmap& mask = wxNullBitmap); | |
89bb3f02 FM |
216 | |
217 | /** | |
218 | Replaces the existing image with the new image. | |
219 | ||
220 | @param index | |
221 | The index of the bitmap to be replaced. | |
222 | @param icon | |
223 | Icon to use as the image. | |
224 | ||
225 | @return @true if the replacement was successful, @false otherwise. | |
226 | ||
227 | @remarks The original bitmap or icon is not affected by the Replace() | |
228 | operation, and can be deleted afterwards. | |
0a98423e | 229 | |
0f6c9085 | 230 | @onlyfor{wxmsw,wxosx} |
89bb3f02 | 231 | */ |
7c913512 | 232 | bool Replace(int index, const wxIcon& icon); |
23324ae1 | 233 | }; |
e54c96f1 | 234 |