]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/icon.tex
Changed documentation const convention for non-objects; added some manual files
[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 \func{}{wxIcon}{\param{const wxIcon* }{icon}}
61
62 Copy constructors.
63
64 \func{}{wxIcon}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
65
66 Creates an icon from the given data, which can be of arbitrary type.
67
68 \func{}{wxIcon}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
69 \param{int}{ depth = 1}}
70
71 Creates an icon from an array of bits.
72
73 \func{}{wxIcon}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
74
75 Creates a new icon.
76
77 \func{}{wxIcon}{\param{const char**}{ bits}}
78
79 Creates an icon from XPM data.
80
81 \func{}{wxIcon}{\param{const wxString\& }{name}, \param{long}{ type}}
82
83 Loads an icon from a file or resource.
84
85 \wxheading{Parameters}
86
87 \docparam{bits}{Specifies an array of pixel values.}
88
89 \docparam{width}{Specifies the width of the icon.}
90
91 \docparam{height}{Specifies the height of the icon.}
92
93 \docparam{depth}{Specifies the depth of the icon. If this is omitted, the display depth of the
94 screen is used.}
95
96 \docparam{name}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
97 Its meaning is determined by the {\it flags} parameter.}
98
99 \docparam{type}{May be one of the following:
100
101 \twocolwidtha{5cm}
102 \begin{twocollist}
103 \twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_ICO}}}{Load a Windows icon file.}
104 \twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_ICO\_RESOURCE}}}{Load a Windows icon from the resource database.}
105 \twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_GIF}}}{Load a GIF bitmap file.}
106 \twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_XBM}}}{Load an X bitmap file.}
107 \twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_XPM}}}{Load an XPM bitmap file.}
108 %\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_RESOURCE}}}{Load a Windows resource name.}
109 \end{twocollist}
110
111 The validity of these flags depends on the platform and wxWindows configuration.
112 If all possible wxWindows settings are used, the Windows platform supports ICO, ICO\_RESOURCE,
113 XPM\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.}
114
115 \wxheading{Remarks}
116
117 The first form constructs an icon object with no data; an assignment or another member function such as Create
118 or LoadFile must be called subsequently.
119
120 The second and third forms provide copy constructors. Note that these do not copy the
121 icon data, but instead a pointer to the data, keeping a reference count. They are therefore
122 very efficient operations.
123
124 The fourth form constructs an icon from data whose type and value depends on
125 the value of the {\it type} argument.
126
127 The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
128 X and Windows.
129
130 The sixth form constructs a new icon.
131
132 The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
133 to incorporate this feature.
134
135 To use this constructor, you must first include an XPM file. For
136 example, assuming that the file {\tt mybitmap.xpm} contains an XPM array
137 of character pointers called mybitmap:
138
139 \begin{verbatim}
140 #include "mybitmap.xpm"
141
142 ...
143
144 wxIcon *icon = new wxIcon(mybitmap);
145 \end{verbatim}
146
147 The eighth form constructs an icon from a file or resource. {\it name} can refer
148 to a resource name under MS Windows, or a filename under MS Windows and X.
149
150 Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_ICO\_RESOURCE.
151 Under X, {\it type} defaults to wxBITMAP\_TYPE\_XBM.
152
153 \wxheading{See also}
154
155 \helpref{wxIcon::LoadFile}{wxiconloadfile}
156
157 \membersection{wxIcon::\destruct{wxIcon}}
158
159 \func{}{\destruct{wxIcon}}{\void}
160
161 Destroys the wxIcon object and possibly the underlying icon data.
162 Because reference counting is used, the icon may not actually be
163 destroyed at this point - only when the reference count is zero will the
164 data be deleted.
165
166 If the application omits to delete the icon explicitly, the icon will be
167 destroyed automatically by wxWindows when the application exits.
168
169 Do not delete an icon that is selected into a memory device context.
170
171 \begin{comment}
172 \membersection{wxIcon::Create}\label{wxiconcreate}
173
174 \func{virtual bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
175
176 Creates a fresh icon. If the final argument is omitted, the display depth of
177 the screen is used.
178
179 \func{virtual bool}{Create}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
180
181 Creates an icon from the given data, which can be of arbitrary type.
182
183 \wxheading{Parameters}
184
185 \docparam{width}{The width of the icon in pixels.}
186
187 \docparam{height}{The height of the icon in pixels.}
188
189 \docparam{depth}{The depth of the icon in pixels. If this is -1, the screen depth is used.}
190
191 \docparam{data}{Data whose type depends on the value of {\it type}.}
192
193 \docparam{type}{An icon type identifier - see \helpref{wxIcon::wxIcon}{wxiconconstr} for a list
194 of possible values.}
195
196 \wxheading{Return value}
197
198 TRUE if the call succeeded, FALSE otherwise.
199
200 \wxheading{Remarks}
201
202 The first form works on all platforms. The portability of the second form depends on the
203 type of data.
204
205 \wxheading{See also}
206
207 \helpref{wxIcon::wxIcon}{wxiconconstr}
208
209 \end{comment}
210
211 \membersection{wxIcon::GetDepth}
212
213 \constfunc{int}{GetDepth}{\void}
214
215 Gets the colour depth of the icon. A value of 1 indicates a
216 monochrome icon.
217
218 \membersection{wxIcon::GetHeight}\label{wxicongetheight}
219
220 \constfunc{int}{GetHeight}{\void}
221
222 Gets the height of the icon in pixels.
223
224 \membersection{wxIcon::GetWidth}\label{wxicongetwidth}
225
226 \constfunc{int}{GetWidth}{\void}
227
228 Gets the width of the icon in pixels.
229
230 \wxheading{See also}
231
232 \helpref{wxIcon::GetHeight}{wxicongetheight}
233
234 \membersection{wxIcon::LoadFile}\label{wxiconloadfile}
235
236 \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type}}
237
238 Loads an icon from a file or resource.
239
240 \wxheading{Parameters}
241
242 \docparam{name}{Either a filename or a Windows resource name.
243 The meaning of {\it name} is determined by the {\it type} parameter.}
244
245 \docparam{type}{One of the following values:
246
247 \twocolwidtha{5cm}
248 \begin{twocollist}
249 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file.}
250 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.}
251 \twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.}
252 \twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Load an X bitmap file.}
253 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load an XPM bitmap file.}
254 \end{twocollist}
255
256 The validity of these flags depends on the platform and wxWindows configuration.}
257
258 \wxheading{Return value}
259
260 TRUE if the operation succeeded, FALSE otherwise.
261
262 \wxheading{See also}
263
264 \helpref{wxIcon::wxIcon}{wxiconconstr}
265
266 \membersection{wxIcon::Ok}\label{wxiconok}
267
268 \constfunc{bool}{Ok}{\void}
269
270 Returns TRUE if icon data is present.
271
272 \begin{comment}
273 \membersection{wxIcon::SaveFile}\label{wxiconsavefile}
274
275 \func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}, \param{wxPalette* }{palette = NULL}}
276
277 Saves an icon in the named file.
278
279 \wxheading{Parameters}
280
281 \docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.}
282
283 \docparam{type}{One of the following values:
284
285 \twocolwidtha{5cm}
286 \begin{twocollist}
287 \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a Windows icon file.}
288 %\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Save a GIF icon file.}
289 %\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Save an X bitmap file.}
290 \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save an XPM bitmap file.}
291 \end{twocollist}
292
293 The validity of these flags depends on the platform and wxWindows configuration.}
294
295 \docparam{palette}{An optional palette used for saving the icon. TODO: this parameter should
296 probably be eliminated; instead the app should set the palette before saving.}
297
298 \wxheading{Return value}
299
300 TRUE if the operation succeeded, FALSE otherwise.
301
302 \wxheading{Remarks}
303
304 Depending on how wxWindows has been configured, not all formats may be available.
305
306 \wxheading{See also}
307
308 \helpref{wxIcon::LoadFile}{wxiconloadfile}
309 \end{comment}
310
311 \membersection{wxIcon::SetDepth}\label{wxiconsetdepth}
312
313 \func{void}{SetDepth}{\param{int }{depth}}
314
315 Sets the depth member (does not affect the icon data).
316
317 \wxheading{Parameters}
318
319 \docparam{depth}{Icon depth.}
320
321 \membersection{wxIcon::SetHeight}\label{wxiconsetheight}
322
323 \func{void}{SetHeight}{\param{int }{height}}
324
325 Sets the height member (does not affect the icon data).
326
327 \wxheading{Parameters}
328
329 \docparam{height}{Icon height in pixels.}
330
331 \membersection{wxIcon::SetOk}
332
333 \func{void}{SetOk}{\param{int }{isOk}}
334
335 Sets the validity member (does not affect the icon data).
336
337 \wxheading{Parameters}
338
339 \docparam{isOk}{Validity flag.}
340
341 \membersection{wxIcon::SetWidth}
342
343 \func{void}{SetWidth}{\param{int }{width}}
344
345 Sets the width member (does not affect the icon data).
346
347 \wxheading{Parameters}
348
349 \docparam{width}{Icon width in pixels.}
350
351 \membersection{wxIcon::operator $=$}
352
353 \func{wxIcon\& }{operator $=$}{\param{const wxIcon\& }{icon}}
354
355 Assignment operator. This operator does not copy any data, but instead
356 passes a pointer to the data in {\it icon} and increments a reference
357 counter. It is a fast operation.
358
359 \wxheading{Parameters}
360
361 \docparam{icon}{Icon to assign.}
362
363 \wxheading{Return value}
364
365 Returns 'this' object.
366
367 \membersection{wxIcon::operator $==$}
368
369 \func{bool}{operator $==$}{\param{const wxIcon\& }{icon}}
370
371 Equality operator. This operator tests whether the internal data pointers are
372 equal (a fast test).
373
374 \wxheading{Parameters}
375
376 \docparam{icon}{Icon to compare with 'this'}
377
378 \wxheading{Return value}
379
380 Returns TRUE if the icons were effectively equal, FALSE otherwise.
381
382 \membersection{wxIcon::operator $!=$}
383
384 \func{bool}{operator $!=$}{\param{const wxIcon\& }{icon}}
385
386 Inequality operator. This operator tests whether the internal data pointers are
387 unequal (a fast test).
388
389 \wxheading{Parameters}
390
391 \docparam{icon}{Icon to compare with 'this'}
392
393 \wxheading{Return value}
394
395 Returns TRUE if the icons were unequal, FALSE otherwise.
396
397