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