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