]> git.saurik.com Git - wxWidgets.git/blame - interface/imaglist.h
added convenient wxON_BLOCK_EXIT_THISn() macros wrapping wxON_BLOCK_EXIT_OBJn(*this)
[wxWidgets.git] / interface / imaglist.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: imaglist.h
e54c96f1 3// Purpose: interface of wxImageList
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxImageList
11 @wxheader{imaglist.h}
7c913512 12
23324ae1
FM
13 A wxImageList contains a list of images, which are stored in
14 an unspecified form. Images can have masks for transparent
15 drawing, and can be made from a variety of sources including bitmaps
16 and icons.
7c913512 17
23324ae1
FM
18 wxImageList is used principally in conjunction with wxTreeCtrl and
19 wxListCtrl classes.
7c913512 20
23324ae1
FM
21 @library{wxcore}
22 @category{gdi}
7c913512 23
e54c96f1 24 @see wxTreeCtrl, wxListCtrl
23324ae1
FM
25*/
26class wxImageList : public wxObject
27{
28public:
29 //@{
30 /**
31 Constructor specifying the image size, whether image masks should be created,
32 and the initial size of the list.
3c4f71cc 33
7c913512 34 @param width
4cc4bfaf 35 Width of the images in the list.
7c913512 36 @param height
4cc4bfaf 37 Height of the images in the list.
7c913512 38 @param mask
4cc4bfaf 39 @true if masks should be created for all images.
7c913512 40 @param initialCount
4cc4bfaf 41 The initial size of the list.
3c4f71cc 42
4cc4bfaf 43 @see Create()
23324ae1
FM
44 */
45 wxImageList();
4cc4bfaf 46 wxImageList(int width, int height, bool mask = true,
7c913512 47 int initialCount = 1);
23324ae1
FM
48 //@}
49
50 //@{
51 /**
52 Adds a new image using an icon.
3c4f71cc 53
7c913512 54 @param bitmap
4cc4bfaf 55 Bitmap representing the opaque areas of the image.
7c913512 56 @param mask
4cc4bfaf 57 Monochrome mask bitmap, representing the transparent areas of the image.
7c913512 58 @param maskColour
4cc4bfaf 59 Colour indicating which parts of the image are transparent.
7c913512 60 @param icon
4cc4bfaf 61 Icon to use as the image.
3c4f71cc 62
23324ae1 63 @returns The new zero-based image index.
3c4f71cc 64
23324ae1 65 @remarks The original bitmap or icon is not affected by the Add
4cc4bfaf 66 operation, and can be deleted afterwards.
23324ae1
FM
67 */
68 int Add(const wxBitmap& bitmap,
69 const wxBitmap& mask = wxNullBitmap);
7c913512
FM
70 int Add(const wxBitmap& bitmap, const wxColour& maskColour);
71 int Add(const wxIcon& icon);
23324ae1
FM
72 //@}
73
74 /**
75 Initializes the list. See wxImageList() for details.
76 */
4cc4bfaf 77 bool Create(int width, int height, bool mask = true,
23324ae1
FM
78 int initialCount = 1);
79
80 /**
81 Draws a specified image onto a device context.
3c4f71cc 82
7c913512 83 @param index
4cc4bfaf 84 Image index, starting from zero.
7c913512 85 @param dc
4cc4bfaf 86 Device context to draw on.
7c913512 87 @param x
4cc4bfaf 88 X position on the device context.
7c913512 89 @param y
4cc4bfaf 90 Y position on the device context.
7c913512 91 @param flags
4cc4bfaf 92 How to draw the image. A bitlist of a selection of the following:
3c4f71cc
VS
93
94
95
96
97
98
4cc4bfaf 99 wxIMAGELIST_DRAW_NORMAL
3c4f71cc
VS
100
101
102
103
4cc4bfaf 104 Draw the image normally.
3c4f71cc
VS
105
106
107
108
109
4cc4bfaf 110 wxIMAGELIST_DRAW_TRANSPARENT
3c4f71cc
VS
111
112
113
114
4cc4bfaf 115 Draw the image with transparency.
3c4f71cc
VS
116
117
118
119
120
4cc4bfaf 121 wxIMAGELIST_DRAW_SELECTED
3c4f71cc
VS
122
123
124
125
4cc4bfaf 126 Draw the image in selected state.
3c4f71cc
VS
127
128
129
130
131
4cc4bfaf 132 wxIMAGELIST_DRAW_FOCUSED
3c4f71cc
VS
133
134
135
136
4cc4bfaf 137 Draw the image in a focused state.
7c913512 138 @param solidBackground
4cc4bfaf
FM
139 For optimisation - drawing can be faster if the function is told
140 that the background is solid.
23324ae1
FM
141 */
142 bool Draw(int index, wxDC& dc, int x, int y,
143 int flags = wxIMAGELIST_DRAW_NORMAL,
4cc4bfaf 144 bool solidBackground = false);
23324ae1
FM
145
146 /**
147 Returns the bitmap corresponding to the given index.
148 */
328f5751 149 wxBitmap GetBitmap(int index) const;
23324ae1
FM
150
151 /**
152 Returns the icon corresponding to the given index.
153 */
328f5751 154 wxIcon GetIcon(int index) const;
23324ae1
FM
155
156 /**
157 Returns the number of images in the list.
158 */
328f5751 159 int GetImageCount() const;
23324ae1
FM
160
161 /**
4cc4bfaf 162 Retrieves the size of the images in the list. Currently, the @a index
23324ae1 163 parameter is ignored as all images in the list have the same size.
3c4f71cc 164
7c913512 165 @param index
4cc4bfaf 166 currently unused, should be 0
7c913512 167 @param width
4cc4bfaf 168 receives the width of the images in the list
7c913512 169 @param height
4cc4bfaf 170 receives the height of the images in the list
3c4f71cc 171
23324ae1 172 @returns @true if the function succeeded, @false if it failed (for example,
4cc4bfaf 173 if the image list was not yet initialized).
23324ae1 174 */
328f5751 175 bool GetSize(int index, int& width, int& height) const;
23324ae1
FM
176
177 /**
178 Removes the image at the given position.
179 */
180 bool Remove(int index);
181
182 /**
183 Removes all the images in the list.
184 */
185 bool RemoveAll();
186
187 //@{
188 /**
189 Replaces the existing image with the new image.
3c4f71cc 190
7c913512 191 @param bitmap
4cc4bfaf 192 Bitmap representing the opaque areas of the image.
7c913512 193 @param mask
4cc4bfaf 194 Monochrome mask bitmap, representing the transparent areas of the image.
7c913512 195 @param icon
4cc4bfaf 196 Icon to use as the image.
3c4f71cc 197
23324ae1 198 @returns @true if the replacement was successful, @false otherwise.
3c4f71cc 199
23324ae1 200 @remarks The original bitmap or icon is not affected by the Replace
4cc4bfaf 201 operation, and can be deleted afterwards.
23324ae1
FM
202 */
203 bool Replace(int index, const wxBitmap& bitmap,
204 const wxBitmap& mask = wxNullBitmap);
7c913512 205 bool Replace(int index, const wxIcon& icon);
23324ae1
FM
206 //@}
207};
e54c96f1 208