]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/icon.tex
wxExecute() fixes and doc updates: the return value for sync exec case is now
[wxWidgets.git] / docs / latex / wx / icon.tex
CommitLineData
a660d684
KB
1\section{\class{wxIcon}}\label{wxicon}
2
3An icon is a small rectangular bitmap usually used for denoting a
2fd284a4
JS
4minimized application. It differs from a wxBitmap in always
5having a mask associated with it for transparent drawing. On some platforms,
6icons and bitmaps are implemented identically, since there is no real distinction between
7a wxBitmap with a mask and an icon; and there is no specific icon format on
8some platforms (X-based applications usually standardize on XPMs for small bitmaps
9and icons). However, some platforms (such as Windows) make the distinction, so
10a separate class is provided.
a660d684
KB
11
12\wxheading{Remarks}
13
2fd284a4
JS
14It is usually desirable to associate a pertinent icon with a frame. Icons
15can also be used for other purposes, for example with \helpref{wxTreeCtrl}{wxtreectrl}
16and \helpref{wxListCtrl}{wxlistctrl}.
17
18Icons have different formats on different platforms.
19Therefore, separate icons will usually be created for the different
a660d684
KB
20environments. Platform-specific methods for creating a {\bf wxIcon}\rtfsp
21structure are catered for, and this is an occasion where conditional
22compilation will probably be required.
23
24Note that a new icon must be created for every time the icon is to be
2fd284a4 25used for a new window. In Windows, the icon will not be
a660d684
KB
26reloaded if it has already been used. An icon allocated to a frame will
27be deleted when the frame is deleted.
28
2fd284a4 29For more information please see \helpref{Bitmap and icon overview}{wxbitmapoverview}.
a660d684
KB
30
31\wxheading{Derived from}
32
33\helpref{wxBitmap}{wxbitmap}\\
34\helpref{wxGDIObject}{wxgdiobject}\\
35\helpref{wxObject}{wxobject}
36
954b8ae6
JS
37\wxheading{Include files}
38
39<wx/icon.h>
40
a660d684
KB
41\wxheading{See also}
42
2fd284a4
JS
43\helpref{Bitmap and icon overview}{wxbitmapoverview}, \helpref{supported bitmap file formats}{supportedbitmapformats},
44\helpref{wxDC::DrawIcon}{wxdcdrawicon}, \helpref{wxCursor}{wxcursor}
a660d684
KB
45
46\latexignore{\rtfignore{\wxheading{Members}}}
47
48\membersection{wxIcon::wxIcon}\label{wxiconconstr}
49
50\func{}{wxIcon}{\void}
51
52Default constructor.
53
54\func{}{wxIcon}{\param{const wxIcon\& }{icon}}
55
1e6d9499 56Copy constructor.
a660d684 57
eaaa6a06 58\func{}{wxIcon}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
a660d684
KB
59
60Creates an icon from the given data, which can be of arbitrary type.
61
eaaa6a06
JS
62\func{}{wxIcon}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
63 \param{int}{ depth = 1}}
a660d684
KB
64
65Creates an icon from an array of bits.
66
eaaa6a06 67\func{}{wxIcon}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
a660d684
KB
68
69Creates a new icon.
70
71\func{}{wxIcon}{\param{const char**}{ bits}}
72
73Creates an icon from XPM data.
74
f60d0f94
JS
75\func{}{wxIcon}{\param{const wxString\& }{name}, \param{long}{ type},
76 \param{int}{ desiredWidth = -1}, \param{int}{ desiredHeight = -1}}
a660d684
KB
77
78Loads an icon from a file or resource.
79
80\wxheading{Parameters}
81
82\docparam{bits}{Specifies an array of pixel values.}
83
84\docparam{width}{Specifies the width of the icon.}
85
86\docparam{height}{Specifies the height of the icon.}
87
f60d0f94
JS
88\docparam{desiredWidth}{Specifies the desired width of the icon. This
89parameter only has an effect in Windows (32-bit) where icon resources can contain
90several icons of different sizes.}
91
92\docparam{desiredWidth}{Specifies the desired height of the icon. This
93parameter only has an effect in Windows (32-bit) where icon resources can contain
94several icons of different sizes.}
95
a660d684
KB
96\docparam{depth}{Specifies the depth of the icon. If this is omitted, the display depth of the
97screen is used.}
98
99\docparam{name}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
100Its meaning is determined by the {\it flags} parameter.}
101
102\docparam{type}{May be one of the following:
103
104\twocolwidtha{5cm}
105\begin{twocollist}
106\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_ICO}}}{Load a Windows icon file.}
107\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_ICO\_RESOURCE}}}{Load a Windows icon from the resource database.}
108\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_GIF}}}{Load a GIF bitmap file.}
109\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_XBM}}}{Load an X bitmap file.}
110\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_XPM}}}{Load an XPM bitmap file.}
111%\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_RESOURCE}}}{Load a Windows resource name.}
112\end{twocollist}
113
114The validity of these flags depends on the platform and wxWindows configuration.
2fd284a4
JS
115If all possible wxWindows settings are used, the Windows platform supports ICO file, ICO resource,
116XPM data, and XPM file. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
117Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.}
a660d684
KB
118
119\wxheading{Remarks}
120
121The first form constructs an icon object with no data; an assignment or another member function such as Create
122or LoadFile must be called subsequently.
123
124The second and third forms provide copy constructors. Note that these do not copy the
125icon data, but instead a pointer to the data, keeping a reference count. They are therefore
126very efficient operations.
127
128The fourth form constructs an icon from data whose type and value depends on
129the value of the {\it type} argument.
130
131The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
132X and Windows.
133
134The sixth form constructs a new icon.
135
136The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
137to incorporate this feature.
138
139To use this constructor, you must first include an XPM file. For
140example, assuming that the file {\tt mybitmap.xpm} contains an XPM array
141of character pointers called mybitmap:
142
143\begin{verbatim}
144#include "mybitmap.xpm"
145
146...
147
148wxIcon *icon = new wxIcon(mybitmap);
149\end{verbatim}
150
2fd284a4
JS
151A macro, wxICON, is available which creates an icon using an XPM
152on the appropriate platform, or an icon resource on Windows.
153
154\begin{verbatim}
155wxIcon icon(wxICON(mondrian));
156
157// Equivalent to:
158
159#if defined(__WXGTK__) || defined(__WXMOTIF__)
160wxIcon icon(mondrian_xpm);
161#endif
162
163#if defined(__WXMSW__)
164wxIcon icon("mondrian");
165#endif
166\end{verbatim}
167
a660d684
KB
168The eighth form constructs an icon from a file or resource. {\it name} can refer
169to a resource name under MS Windows, or a filename under MS Windows and X.
170
171Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_ICO\_RESOURCE.
2fd284a4 172Under X, {\it type} defaults to wxBITMAP\_TYPE\_XPM.
a660d684
KB
173
174\wxheading{See also}
175
176\helpref{wxIcon::LoadFile}{wxiconloadfile}
177
178\membersection{wxIcon::\destruct{wxIcon}}
179
180\func{}{\destruct{wxIcon}}{\void}
181
182Destroys the wxIcon object and possibly the underlying icon data.
183Because reference counting is used, the icon may not actually be
184destroyed at this point - only when the reference count is zero will the
185data be deleted.
186
187If the application omits to delete the icon explicitly, the icon will be
188destroyed automatically by wxWindows when the application exits.
189
190Do not delete an icon that is selected into a memory device context.
191
a660d684
KB
192\membersection{wxIcon::GetDepth}
193
194\constfunc{int}{GetDepth}{\void}
195
196Gets the colour depth of the icon. A value of 1 indicates a
197monochrome icon.
198
199\membersection{wxIcon::GetHeight}\label{wxicongetheight}
200
201\constfunc{int}{GetHeight}{\void}
202
203Gets the height of the icon in pixels.
204
205\membersection{wxIcon::GetWidth}\label{wxicongetwidth}
206
207\constfunc{int}{GetWidth}{\void}
208
209Gets the width of the icon in pixels.
210
211\wxheading{See also}
212
213\helpref{wxIcon::GetHeight}{wxicongetheight}
214
215\membersection{wxIcon::LoadFile}\label{wxiconloadfile}
216
eaaa6a06 217\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type}}
a660d684
KB
218
219Loads an icon from a file or resource.
220
221\wxheading{Parameters}
222
223\docparam{name}{Either a filename or a Windows resource name.
224The meaning of {\it name} is determined by the {\it type} parameter.}
225
226\docparam{type}{One of the following values:
227
228\twocolwidtha{5cm}
229\begin{twocollist}
230\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file.}
231\twocolitem{{\bf wxBITMAP\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.}
232\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
233\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Load an X bitmap file.}
234\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load an XPM bitmap file.}
235\end{twocollist}
236
237The validity of these flags depends on the platform and wxWindows configuration.}
238
239\wxheading{Return value}
240
241TRUE if the operation succeeded, FALSE otherwise.
242
243\wxheading{See also}
244
245\helpref{wxIcon::wxIcon}{wxiconconstr}
246
247\membersection{wxIcon::Ok}\label{wxiconok}
248
249\constfunc{bool}{Ok}{\void}
250
251Returns TRUE if icon data is present.
252
253\begin{comment}
254\membersection{wxIcon::SaveFile}\label{wxiconsavefile}
255
256\func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}, \param{wxPalette* }{palette = NULL}}
257
258Saves an icon in the named file.
259
260\wxheading{Parameters}
261
262\docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.}
263
264\docparam{type}{One of the following values:
265
266\twocolwidtha{5cm}
267\begin{twocollist}
268\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a Windows icon file.}
269%\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Save a GIF icon file.}
270%\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Save an X bitmap file.}
271\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save an XPM bitmap file.}
272\end{twocollist}
273
274The validity of these flags depends on the platform and wxWindows configuration.}
275
5b6aa0ff 276\docparam{palette}{An optional palette used for saving the icon.}
a660d684
KB
277
278\wxheading{Return value}
279
280TRUE if the operation succeeded, FALSE otherwise.
281
282\wxheading{Remarks}
283
284Depending on how wxWindows has been configured, not all formats may be available.
285
286\wxheading{See also}
287
288\helpref{wxIcon::LoadFile}{wxiconloadfile}
289\end{comment}
290
291\membersection{wxIcon::SetDepth}\label{wxiconsetdepth}
292
293\func{void}{SetDepth}{\param{int }{depth}}
294
295Sets the depth member (does not affect the icon data).
296
297\wxheading{Parameters}
298
299\docparam{depth}{Icon depth.}
300
301\membersection{wxIcon::SetHeight}\label{wxiconsetheight}
302
303\func{void}{SetHeight}{\param{int }{height}}
304
305Sets the height member (does not affect the icon data).
306
307\wxheading{Parameters}
308
309\docparam{height}{Icon height in pixels.}
310
311\membersection{wxIcon::SetOk}
312
313\func{void}{SetOk}{\param{int }{isOk}}
314
315Sets the validity member (does not affect the icon data).
316
317\wxheading{Parameters}
318
319\docparam{isOk}{Validity flag.}
320
321\membersection{wxIcon::SetWidth}
322
323\func{void}{SetWidth}{\param{int }{width}}
324
325Sets the width member (does not affect the icon data).
326
327\wxheading{Parameters}
328
329\docparam{width}{Icon width in pixels.}
330
331\membersection{wxIcon::operator $=$}
332
333\func{wxIcon\& }{operator $=$}{\param{const wxIcon\& }{icon}}
334
335Assignment operator. This operator does not copy any data, but instead
336passes a pointer to the data in {\it icon} and increments a reference
337counter. It is a fast operation.
338
339\wxheading{Parameters}
340
341\docparam{icon}{Icon to assign.}
342
343\wxheading{Return value}
344
345Returns 'this' object.
346
347\membersection{wxIcon::operator $==$}
348
349\func{bool}{operator $==$}{\param{const wxIcon\& }{icon}}
350
351Equality operator. This operator tests whether the internal data pointers are
352equal (a fast test).
353
354\wxheading{Parameters}
355
356\docparam{icon}{Icon to compare with 'this'}
357
358\wxheading{Return value}
359
360Returns TRUE if the icons were effectively equal, FALSE otherwise.
361
362\membersection{wxIcon::operator $!=$}
363
364\func{bool}{operator $!=$}{\param{const wxIcon\& }{icon}}
365
366Inequality operator. This operator tests whether the internal data pointers are
367unequal (a fast test).
368
369\wxheading{Parameters}
370
371\docparam{icon}{Icon to compare with 'this'}
372
373\wxheading{Return value}
374
375Returns TRUE if the icons were unequal, FALSE otherwise.
376
377