]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/icon.tex
more files I forgot to commit (wxFile/wxTempFile/wxTextFile docs)
[wxWidgets.git] / docs / latex / wx / icon.tex
1 \section{\class{wxIcon}}\label{wxicon}
2
3 An icon is a small rectangular bitmap usually used for denoting a
4 minimized application.
5
6 \wxheading{Remarks}
7
8 It is optional (but desirable) to associate a
9 pertinent icon with a frame. Obviously icons in X and MS Windows are
10 created in a different manner, and colour icons in X are difficult
11 to arrange. Therefore, separate icons will be created for the different
12 environments. Platform-specific methods for creating a {\bf wxIcon}\rtfsp
13 structure are catered for, and this is an occasion where conditional
14 compilation will probably be required.
15
16 Note that a new icon must be created for every time the icon is to be
17 used for a new window. In X, this will ensure that fresh X resources
18 are allocated for this frame. In MS Windows, the icon will not be
19 reloaded if it has already been used. An icon allocated to a frame will
20 be deleted when the frame is deleted.
21
22 The following shows the conditional compilation required to define an
23 icon in X and in MS Windows. The alternative is to use the string
24 version of the icon constructor, which loads a file under X and a
25 resource under MS Windows, but has the disadvantage of requiring the
26 X 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
56 Default constructor.
57
58 \func{}{wxIcon}{\param{const wxIcon\& }{icon}}
59
60 Copy constructor.
61
62 \func{}{wxIcon}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
63
64 Creates an icon from the given data, which can be of arbitrary type.
65
66 \func{}{wxIcon}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
67 \param{int}{ depth = 1}}
68
69 Creates an icon from an array of bits.
70
71 \func{}{wxIcon}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
72
73 Creates a new icon.
74
75 \func{}{wxIcon}{\param{const char**}{ bits}}
76
77 Creates an icon from XPM data.
78
79 \func{}{wxIcon}{\param{const wxString\& }{name}, \param{long}{ type},
80 \param{int}{ desiredWidth = -1}, \param{int}{ desiredHeight = -1}}
81
82 Loads 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
92 \docparam{desiredWidth}{Specifies the desired width of the icon. This
93 parameter only has an effect in Windows (32-bit) where icon resources can contain
94 several icons of different sizes.}
95
96 \docparam{desiredWidth}{Specifies the desired height of the icon. This
97 parameter only has an effect in Windows (32-bit) where icon resources can contain
98 several icons of different sizes.}
99
100 \docparam{depth}{Specifies the depth of the icon. If this is omitted, the display depth of the
101 screen is used.}
102
103 \docparam{name}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
104 Its 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
118 The validity of these flags depends on the platform and wxWindows configuration.
119 If all possible wxWindows settings are used, the Windows platform supports ICO, ICO\_RESOURCE,
120 XPM\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.}
121
122 \wxheading{Remarks}
123
124 The first form constructs an icon object with no data; an assignment or another member function such as Create
125 or LoadFile must be called subsequently.
126
127 The second and third forms provide copy constructors. Note that these do not copy the
128 icon data, but instead a pointer to the data, keeping a reference count. They are therefore
129 very efficient operations.
130
131 The fourth form constructs an icon from data whose type and value depends on
132 the value of the {\it type} argument.
133
134 The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
135 X and Windows.
136
137 The sixth form constructs a new icon.
138
139 The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
140 to incorporate this feature.
141
142 To use this constructor, you must first include an XPM file. For
143 example, assuming that the file {\tt mybitmap.xpm} contains an XPM array
144 of character pointers called mybitmap:
145
146 \begin{verbatim}
147 #include "mybitmap.xpm"
148
149 ...
150
151 wxIcon *icon = new wxIcon(mybitmap);
152 \end{verbatim}
153
154 The eighth form constructs an icon from a file or resource. {\it name} can refer
155 to a resource name under MS Windows, or a filename under MS Windows and X.
156
157 Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_ICO\_RESOURCE.
158 Under 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
168 Destroys the wxIcon object and possibly the underlying icon data.
169 Because reference counting is used, the icon may not actually be
170 destroyed at this point - only when the reference count is zero will the
171 data be deleted.
172
173 If the application omits to delete the icon explicitly, the icon will be
174 destroyed automatically by wxWindows when the application exits.
175
176 Do not delete an icon that is selected into a memory device context.
177
178 \begin{comment}
179 \membersection{wxIcon::Create}\label{wxiconcreate}
180
181 \func{virtual bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
182
183 Creates a fresh icon. If the final argument is omitted, the display depth of
184 the screen is used.
185
186 \func{virtual bool}{Create}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
187
188 Creates 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
201 of possible values.}
202
203 \wxheading{Return value}
204
205 TRUE if the call succeeded, FALSE otherwise.
206
207 \wxheading{Remarks}
208
209 The first form works on all platforms. The portability of the second form depends on the
210 type 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
222 Gets the colour depth of the icon. A value of 1 indicates a
223 monochrome icon.
224
225 \membersection{wxIcon::GetHeight}\label{wxicongetheight}
226
227 \constfunc{int}{GetHeight}{\void}
228
229 Gets the height of the icon in pixels.
230
231 \membersection{wxIcon::GetWidth}\label{wxicongetwidth}
232
233 \constfunc{int}{GetWidth}{\void}
234
235 Gets 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
243 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type}}
244
245 Loads an icon from a file or resource.
246
247 \wxheading{Parameters}
248
249 \docparam{name}{Either a filename or a Windows resource name.
250 The 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
263 The validity of these flags depends on the platform and wxWindows configuration.}
264
265 \wxheading{Return value}
266
267 TRUE 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
277 Returns 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
284 Saves 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
300 The 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
303 probably be eliminated; instead the app should set the palette before saving.}
304
305 \wxheading{Return value}
306
307 TRUE if the operation succeeded, FALSE otherwise.
308
309 \wxheading{Remarks}
310
311 Depending 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
322 Sets 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
332 Sets 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
342 Sets 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
352 Sets 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
362 Assignment operator. This operator does not copy any data, but instead
363 passes a pointer to the data in {\it icon} and increments a reference
364 counter. It is a fast operation.
365
366 \wxheading{Parameters}
367
368 \docparam{icon}{Icon to assign.}
369
370 \wxheading{Return value}
371
372 Returns 'this' object.
373
374 \membersection{wxIcon::operator $==$}
375
376 \func{bool}{operator $==$}{\param{const wxIcon\& }{icon}}
377
378 Equality operator. This operator tests whether the internal data pointers are
379 equal (a fast test).
380
381 \wxheading{Parameters}
382
383 \docparam{icon}{Icon to compare with 'this'}
384
385 \wxheading{Return value}
386
387 Returns TRUE if the icons were effectively equal, FALSE otherwise.
388
389 \membersection{wxIcon::operator $!=$}
390
391 \func{bool}{operator $!=$}{\param{const wxIcon\& }{icon}}
392
393 Inequality operator. This operator tests whether the internal data pointers are
394 unequal (a fast test).
395
396 \wxheading{Parameters}
397
398 \docparam{icon}{Icon to compare with 'this'}
399
400 \wxheading{Return value}
401
402 Returns TRUE if the icons were unequal, FALSE otherwise.
403
404