]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: icon.h | |
e54c96f1 | 3 | // Purpose: interface of wxIcon |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxIcon | |
11 | @wxheader{icon.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | An icon is a small rectangular bitmap usually used for denoting a |
14 | minimized application. It differs from a wxBitmap in always | |
15 | having a mask associated with it for transparent drawing. On some platforms, | |
16 | icons and bitmaps are implemented identically, since there is no real | |
17 | distinction between | |
18 | a wxBitmap with a mask and an icon; and there is no specific icon format on | |
19 | some platforms (X-based applications usually standardize on XPMs for small | |
20 | bitmaps | |
21 | and icons). However, some platforms (such as Windows) make the distinction, so | |
22 | a separate class is provided. | |
7c913512 | 23 | |
23324ae1 FM |
24 | @library{wxcore} |
25 | @category{gdi} | |
7c913512 | 26 | |
23324ae1 | 27 | @stdobjects |
65874118 | 28 | ::wxNullIcon |
7c913512 | 29 | |
e54c96f1 | 30 | @see @ref overview_wxbitmapoverview "Bitmap and icon overview", @ref |
23324ae1 FM |
31 | overview_supportedbitmapformats "supported bitmap file formats", wxDC::DrawIcon, wxCursor |
32 | */ | |
33 | class wxIcon : public wxBitmap | |
34 | { | |
35 | public: | |
36 | //@{ | |
37 | /** | |
e54c96f1 | 38 | Loads an icon from the specified location(). |
3c4f71cc | 39 | |
7c913512 | 40 | @param bits |
4cc4bfaf | 41 | Specifies an array of pixel values. |
7c913512 | 42 | @param width |
4cc4bfaf | 43 | Specifies the width of the icon. |
7c913512 | 44 | @param height |
4cc4bfaf | 45 | Specifies the height of the icon. |
7c913512 | 46 | @param desiredWidth |
4cc4bfaf FM |
47 | Specifies the desired width of the icon. This |
48 | parameter only has an effect in Windows (32-bit) where icon resources can | |
23324ae1 | 49 | contain |
4cc4bfaf | 50 | several icons of different sizes. |
7c913512 | 51 | @param desiredWidth |
4cc4bfaf FM |
52 | Specifies the desired height of the icon. This |
53 | parameter only has an effect in Windows (32-bit) where icon resources can | |
23324ae1 | 54 | contain |
4cc4bfaf | 55 | several icons of different sizes. |
7c913512 | 56 | @param depth |
4cc4bfaf FM |
57 | Specifies the depth of the icon. If this is omitted, the display depth of |
58 | the | |
59 | screen is used. | |
7c913512 | 60 | @param name |
4cc4bfaf | 61 | This can refer to a resource name under MS Windows, or a filename under MS |
23324ae1 | 62 | Windows and X. |
4cc4bfaf | 63 | Its meaning is determined by the flags parameter. |
7c913512 | 64 | @param loc |
4cc4bfaf FM |
65 | The object describing the location of the native icon, see |
66 | wxIconLocation. | |
7c913512 | 67 | @param type |
4cc4bfaf | 68 | May be one of the following: |
3c4f71cc VS |
69 | |
70 | ||
71 | ||
72 | ||
73 | ||
74 | ||
75 | ||
4cc4bfaf | 76 | wxBITMAP_TYPE_ICO |
3c4f71cc VS |
77 | |
78 | ||
79 | ||
80 | ||
4cc4bfaf | 81 | Load a Windows icon file. |
3c4f71cc VS |
82 | |
83 | ||
84 | ||
85 | ||
86 | ||
4cc4bfaf | 87 | wxBITMAP_TYPE_ICO_RESOURCE |
3c4f71cc VS |
88 | |
89 | ||
90 | ||
91 | ||
4cc4bfaf | 92 | Load a Windows icon from the resource database. |
3c4f71cc VS |
93 | |
94 | ||
95 | ||
96 | ||
97 | ||
4cc4bfaf | 98 | wxBITMAP_TYPE_GIF |
3c4f71cc VS |
99 | |
100 | ||
101 | ||
102 | ||
4cc4bfaf | 103 | Load a GIF bitmap file. |
3c4f71cc VS |
104 | |
105 | ||
106 | ||
107 | ||
108 | ||
4cc4bfaf | 109 | wxBITMAP_TYPE_XBM |
3c4f71cc VS |
110 | |
111 | ||
112 | ||
113 | ||
4cc4bfaf | 114 | Load an X bitmap file. |
3c4f71cc VS |
115 | |
116 | ||
117 | ||
118 | ||
119 | ||
4cc4bfaf | 120 | wxBITMAP_TYPE_XPM |
3c4f71cc VS |
121 | |
122 | ||
123 | ||
124 | ||
4cc4bfaf | 125 | Load an XPM bitmap file. |
3c4f71cc VS |
126 | |
127 | ||
128 | ||
129 | ||
130 | ||
4cc4bfaf FM |
131 | The validity of these flags depends on the platform and wxWidgets |
132 | configuration. | |
133 | If all possible wxWidgets settings are used, the Windows platform supports | |
134 | ICO file, ICO resource, | |
135 | XPM data, and XPM file. Under wxGTK, the available formats are BMP file, | |
136 | XPM data, XPM file, and PNG file. | |
137 | Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM | |
138 | file. | |
3c4f71cc | 139 | |
23324ae1 | 140 | @remarks The first form constructs an icon object with no data; an |
4cc4bfaf FM |
141 | assignment or another member function such as Create or |
142 | LoadFile must be called subsequently. | |
23324ae1 FM |
143 | */ |
144 | wxIcon(); | |
7c913512 FM |
145 | wxIcon(const wxIcon& icon); |
146 | wxIcon(void* data, int type, int width, int height, | |
147 | int depth = -1); | |
148 | wxIcon(const char bits[], int width, int height, | |
149 | int depth = 1); | |
150 | wxIcon(int width, int height, int depth = -1); | |
151 | wxIcon(const char* const* bits); | |
152 | wxIcon(const wxString& name, wxBitmapType type, | |
153 | int desiredWidth = -1, | |
154 | int desiredHeight = -1); | |
155 | wxIcon(const wxIconLocation& loc); | |
23324ae1 FM |
156 | //@} |
157 | ||
158 | /** | |
159 | Destructor. | |
160 | See @ref overview_refcountdestruct "reference-counted object destruction" for | |
161 | more info. | |
23324ae1 FM |
162 | If the application omits to delete the icon explicitly, the icon will be |
163 | destroyed automatically by wxWidgets when the application exits. | |
23324ae1 FM |
164 | Do not delete an icon that is selected into a memory device context. |
165 | */ | |
166 | ~wxIcon(); | |
167 | ||
168 | /** | |
4cc4bfaf | 169 | Copies @a bmp bitmap to this icon. Under MS Windows the bitmap |
23324ae1 | 170 | must have mask colour set. |
3c4f71cc | 171 | |
23324ae1 | 172 | LoadFile() |
3c4f71cc | 173 | |
23324ae1 FM |
174 | Wx::Icon-new( width, height, depth = -1 ) |
175 | Wx::Icon-new( name, type, desiredWidth = -1, desiredHeight = -1 ) | |
176 | Wx::Icon-newFromBits( bits, width, height, depth = 1 ) | |
177 | Wx::Icon-newFromXPM( data ) | |
178 | */ | |
179 | void CopyFromBitmap(const wxBitmap& bmp); | |
180 | ||
181 | /** | |
182 | Gets the colour depth of the icon. A value of 1 indicates a | |
183 | monochrome icon. | |
184 | */ | |
328f5751 | 185 | int GetDepth() const; |
23324ae1 FM |
186 | |
187 | /** | |
188 | Gets the height of the icon in pixels. | |
189 | */ | |
328f5751 | 190 | int GetHeight() const; |
23324ae1 FM |
191 | |
192 | /** | |
193 | Gets the width of the icon in pixels. | |
3c4f71cc | 194 | |
4cc4bfaf | 195 | @see GetHeight() |
23324ae1 | 196 | */ |
328f5751 | 197 | int GetWidth() const; |
23324ae1 FM |
198 | |
199 | /** | |
200 | Returns @true if icon data is present. | |
201 | */ | |
328f5751 | 202 | bool IsOk() const; |
23324ae1 FM |
203 | |
204 | /** | |
205 | Loads an icon from a file or resource. | |
3c4f71cc | 206 | |
7c913512 | 207 | @param name |
4cc4bfaf FM |
208 | Either a filename or a Windows resource name. |
209 | The meaning of name is determined by the type parameter. | |
7c913512 | 210 | @param type |
4cc4bfaf | 211 | One of the following values: |
3c4f71cc VS |
212 | |
213 | ||
214 | ||
215 | ||
216 | ||
217 | ||
218 | ||
4cc4bfaf | 219 | wxBITMAP_TYPE_ICO |
3c4f71cc VS |
220 | |
221 | ||
222 | ||
223 | ||
4cc4bfaf | 224 | Load a Windows icon file. |
3c4f71cc VS |
225 | |
226 | ||
227 | ||
228 | ||
229 | ||
4cc4bfaf | 230 | wxBITMAP_TYPE_ICO_RESOURCE |
3c4f71cc VS |
231 | |
232 | ||
233 | ||
234 | ||
4cc4bfaf | 235 | Load a Windows icon from the resource database. |
3c4f71cc VS |
236 | |
237 | ||
238 | ||
239 | ||
240 | ||
4cc4bfaf | 241 | wxBITMAP_TYPE_GIF |
3c4f71cc VS |
242 | |
243 | ||
244 | ||
245 | ||
4cc4bfaf | 246 | Load a GIF bitmap file. |
3c4f71cc VS |
247 | |
248 | ||
249 | ||
250 | ||
251 | ||
4cc4bfaf | 252 | wxBITMAP_TYPE_XBM |
3c4f71cc VS |
253 | |
254 | ||
255 | ||
256 | ||
4cc4bfaf | 257 | Load an X bitmap file. |
3c4f71cc VS |
258 | |
259 | ||
260 | ||
261 | ||
262 | ||
4cc4bfaf | 263 | wxBITMAP_TYPE_XPM |
3c4f71cc VS |
264 | |
265 | ||
266 | ||
267 | ||
4cc4bfaf | 268 | Load an XPM bitmap file. |
3c4f71cc VS |
269 | |
270 | ||
271 | ||
272 | ||
273 | ||
4cc4bfaf FM |
274 | The validity of these flags depends on the platform and wxWidgets |
275 | configuration. | |
3c4f71cc | 276 | |
23324ae1 | 277 | @returns @true if the operation succeeded, @false otherwise. |
3c4f71cc | 278 | |
4cc4bfaf | 279 | @see wxIcon() |
23324ae1 FM |
280 | */ |
281 | bool LoadFile(const wxString& name, wxBitmapType type); | |
282 | ||
283 | /** | |
284 | Sets the depth member (does not affect the icon data). | |
3c4f71cc | 285 | |
7c913512 | 286 | @param depth |
4cc4bfaf | 287 | Icon depth. |
23324ae1 FM |
288 | */ |
289 | void SetDepth(int depth); | |
290 | ||
291 | /** | |
292 | Sets the height member (does not affect the icon data). | |
3c4f71cc | 293 | |
7c913512 | 294 | @param height |
4cc4bfaf | 295 | Icon height in pixels. |
23324ae1 FM |
296 | */ |
297 | void SetHeight(int height); | |
298 | ||
299 | /** | |
300 | Sets the width member (does not affect the icon data). | |
3c4f71cc | 301 | |
7c913512 | 302 | @param width |
4cc4bfaf | 303 | Icon width in pixels. |
23324ae1 FM |
304 | */ |
305 | void SetWidth(int width); | |
306 | ||
307 | /** | |
308 | Assignment operator, using @ref overview_trefcount "reference counting". | |
3c4f71cc | 309 | |
7c913512 | 310 | @param icon |
4cc4bfaf | 311 | Icon to assign. |
23324ae1 FM |
312 | */ |
313 | wxIcon operator =(const wxIcon& icon); | |
314 | }; | |
e54c96f1 | 315 | |
e54c96f1 | 316 | /** |
65874118 | 317 | An empty wxIcon. |
e54c96f1 FM |
318 | */ |
319 | wxIcon wxNullIcon; | |
320 | ||
321 |