]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/icon.tex
Changes for 16-bit BC++ (not there yet), GnuWin32; typetest sample
[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
4minimized application.
5
6\wxheading{Remarks}
7
8It is optional (but desirable) to associate a
9pertinent icon with a frame. Obviously icons in X and MS Windows are
10created in a different manner, and colour icons in X are difficult
11to arrange. Therefore, separate icons will be created for the different
12environments. Platform-specific methods for creating a {\bf wxIcon}\rtfsp
13structure are catered for, and this is an occasion where conditional
14compilation will probably be required.
15
16Note that a new icon must be created for every time the icon is to be
17used for a new window. In X, this will ensure that fresh X resources
18are allocated for this frame. In MS Windows, the icon will not be
19reloaded if it has already been used. An icon allocated to a frame will
20be deleted when the frame is deleted.
21
22The following shows the conditional compilation required to define an
23icon in X and in MS Windows. The alternative is to use the string
24version of the icon constructor, which loads a file under X and a
25resource under MS Windows, but has the disadvantage of requiring the
26X icon file to be available at run-time.
27
28\begin{verbatim}
29#ifdef wx_x
30#include "aiai.xbm"
31#endif
32#ifdef wx_msw
33 wxIcon *icon = new wxIcon("aiai");
34#endif
35#ifdef wx_x
36 wxIcon *icon = new wxIcon(aiai_bits, aiai_width, aiai_height);
37#endif
38\end{verbatim}
39
40\wxheading{Derived from}
41
42\helpref{wxBitmap}{wxbitmap}\\
43\helpref{wxGDIObject}{wxgdiobject}\\
44\helpref{wxObject}{wxobject}
45
46\wxheading{See also}
47
48\helpref{wxIcon overview}{wxiconoverview}, \helpref{wxDC::DrawIcon}{wxdcdrawicon}, \helpref{wxCursor}{wxcursor}
49
50\latexignore{\rtfignore{\wxheading{Members}}}
51
52\membersection{wxIcon::wxIcon}\label{wxiconconstr}
53
54\func{}{wxIcon}{\void}
55
56Default constructor.
57
58\func{}{wxIcon}{\param{const wxIcon\& }{icon}}
59
1e6d9499 60Copy constructor.
a660d684 61
eaaa6a06 62\func{}{wxIcon}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
a660d684
KB
63
64Creates an icon from the given data, which can be of arbitrary type.
65
eaaa6a06
JS
66\func{}{wxIcon}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
67 \param{int}{ depth = 1}}
a660d684
KB
68
69Creates an icon from an array of bits.
70
eaaa6a06 71\func{}{wxIcon}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
a660d684
KB
72
73Creates a new icon.
74
75\func{}{wxIcon}{\param{const char**}{ bits}}
76
77Creates an icon from XPM data.
78
f60d0f94
JS
79\func{}{wxIcon}{\param{const wxString\& }{name}, \param{long}{ type},
80 \param{int}{ desiredWidth = -1}, \param{int}{ desiredHeight = -1}}
a660d684
KB
81
82Loads an icon from a file or resource.
83
84\wxheading{Parameters}
85
86\docparam{bits}{Specifies an array of pixel values.}
87
88\docparam{width}{Specifies the width of the icon.}
89
90\docparam{height}{Specifies the height of the icon.}
91
f60d0f94
JS
92\docparam{desiredWidth}{Specifies the desired width of the icon. This
93parameter only has an effect in Windows (32-bit) where icon resources can contain
94several icons of different sizes.}
95
96\docparam{desiredWidth}{Specifies the desired height of the icon. This
97parameter only has an effect in Windows (32-bit) where icon resources can contain
98several icons of different sizes.}
99
a660d684
KB
100\docparam{depth}{Specifies the depth of the icon. If this is omitted, the display depth of the
101screen is used.}
102
103\docparam{name}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
104Its meaning is determined by the {\it flags} parameter.}
105
106\docparam{type}{May be one of the following:
107
108\twocolwidtha{5cm}
109\begin{twocollist}
110\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_ICO}}}{Load a Windows icon file.}
111\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_ICO\_RESOURCE}}}{Load a Windows icon from the resource database.}
112\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_GIF}}}{Load a GIF bitmap file.}
113\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_XBM}}}{Load an X bitmap file.}
114\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_XPM}}}{Load an XPM bitmap file.}
115%\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_RESOURCE}}}{Load a Windows resource name.}
116\end{twocollist}
117
118The validity of these flags depends on the platform and wxWindows configuration.
119If all possible wxWindows settings are used, the Windows platform supports ICO, ICO\_RESOURCE,
120XPM\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.}
121
122\wxheading{Remarks}
123
124The first form constructs an icon object with no data; an assignment or another member function such as Create
125or LoadFile must be called subsequently.
126
127The second and third forms provide copy constructors. Note that these do not copy the
128icon data, but instead a pointer to the data, keeping a reference count. They are therefore
129very efficient operations.
130
131The fourth form constructs an icon from data whose type and value depends on
132the value of the {\it type} argument.
133
134The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
135X and Windows.
136
137The sixth form constructs a new icon.
138
139The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
140to incorporate this feature.
141
142To use this constructor, you must first include an XPM file. For
143example, assuming that the file {\tt mybitmap.xpm} contains an XPM array
144of character pointers called mybitmap:
145
146\begin{verbatim}
147#include "mybitmap.xpm"
148
149...
150
151wxIcon *icon = new wxIcon(mybitmap);
152\end{verbatim}
153
154The eighth form constructs an icon from a file or resource. {\it name} can refer
155to a resource name under MS Windows, or a filename under MS Windows and X.
156
157Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_ICO\_RESOURCE.
158Under X, {\it type} defaults to wxBITMAP\_TYPE\_XBM.
159
160\wxheading{See also}
161
162\helpref{wxIcon::LoadFile}{wxiconloadfile}
163
164\membersection{wxIcon::\destruct{wxIcon}}
165
166\func{}{\destruct{wxIcon}}{\void}
167
168Destroys the wxIcon object and possibly the underlying icon data.
169Because reference counting is used, the icon may not actually be
170destroyed at this point - only when the reference count is zero will the
171data be deleted.
172
173If the application omits to delete the icon explicitly, the icon will be
174destroyed automatically by wxWindows when the application exits.
175
176Do not delete an icon that is selected into a memory device context.
177
178\begin{comment}
179\membersection{wxIcon::Create}\label{wxiconcreate}
180
eaaa6a06 181\func{virtual bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
a660d684
KB
182
183Creates a fresh icon. If the final argument is omitted, the display depth of
184the screen is used.
185
eaaa6a06 186\func{virtual bool}{Create}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
a660d684
KB
187
188Creates an icon from the given data, which can be of arbitrary type.
189
190\wxheading{Parameters}
191
192\docparam{width}{The width of the icon in pixels.}
193
194\docparam{height}{The height of the icon in pixels.}
195
196\docparam{depth}{The depth of the icon in pixels. If this is -1, the screen depth is used.}
197
198\docparam{data}{Data whose type depends on the value of {\it type}.}
199
200\docparam{type}{An icon type identifier - see \helpref{wxIcon::wxIcon}{wxiconconstr} for a list
201of possible values.}
202
203\wxheading{Return value}
204
205TRUE if the call succeeded, FALSE otherwise.
206
207\wxheading{Remarks}
208
209The first form works on all platforms. The portability of the second form depends on the
210type of data.
211
212\wxheading{See also}
213
214\helpref{wxIcon::wxIcon}{wxiconconstr}
215
216\end{comment}
217
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
302\docparam{palette}{An optional palette used for saving the icon. TODO: this parameter should
303probably be eliminated; instead the app should set the palette before saving.}
304
305\wxheading{Return value}
306
307TRUE if the operation succeeded, FALSE otherwise.
308
309\wxheading{Remarks}
310
311Depending on how wxWindows has been configured, not all formats may be available.
312
313\wxheading{See also}
314
315\helpref{wxIcon::LoadFile}{wxiconloadfile}
316\end{comment}
317
318\membersection{wxIcon::SetDepth}\label{wxiconsetdepth}
319
320\func{void}{SetDepth}{\param{int }{depth}}
321
322Sets the depth member (does not affect the icon data).
323
324\wxheading{Parameters}
325
326\docparam{depth}{Icon depth.}
327
328\membersection{wxIcon::SetHeight}\label{wxiconsetheight}
329
330\func{void}{SetHeight}{\param{int }{height}}
331
332Sets the height member (does not affect the icon data).
333
334\wxheading{Parameters}
335
336\docparam{height}{Icon height in pixels.}
337
338\membersection{wxIcon::SetOk}
339
340\func{void}{SetOk}{\param{int }{isOk}}
341
342Sets the validity member (does not affect the icon data).
343
344\wxheading{Parameters}
345
346\docparam{isOk}{Validity flag.}
347
348\membersection{wxIcon::SetWidth}
349
350\func{void}{SetWidth}{\param{int }{width}}
351
352Sets the width member (does not affect the icon data).
353
354\wxheading{Parameters}
355
356\docparam{width}{Icon width in pixels.}
357
358\membersection{wxIcon::operator $=$}
359
360\func{wxIcon\& }{operator $=$}{\param{const wxIcon\& }{icon}}
361
362Assignment operator. This operator does not copy any data, but instead
363passes a pointer to the data in {\it icon} and increments a reference
364counter. It is a fast operation.
365
366\wxheading{Parameters}
367
368\docparam{icon}{Icon to assign.}
369
370\wxheading{Return value}
371
372Returns 'this' object.
373
374\membersection{wxIcon::operator $==$}
375
376\func{bool}{operator $==$}{\param{const wxIcon\& }{icon}}
377
378Equality operator. This operator tests whether the internal data pointers are
379equal (a fast test).
380
381\wxheading{Parameters}
382
383\docparam{icon}{Icon to compare with 'this'}
384
385\wxheading{Return value}
386
387Returns TRUE if the icons were effectively equal, FALSE otherwise.
388
389\membersection{wxIcon::operator $!=$}
390
391\func{bool}{operator $!=$}{\param{const wxIcon\& }{icon}}
392
393Inequality operator. This operator tests whether the internal data pointers are
394unequal (a fast test).
395
396\wxheading{Parameters}
397
398\docparam{icon}{Icon to compare with 'this'}
399
400\wxheading{Return value}
401
402Returns TRUE if the icons were unequal, FALSE otherwise.
403
404