1 \section{\class{wxIcon
}}\label{wxicon
}
3 An icon is a small rectangular bitmap usually used for denoting a
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.
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.
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.
33 wxIcon *icon = new wxIcon("aiai");
36 wxIcon *icon = new wxIcon(aiai_bits, aiai_width, aiai_height);
40 \wxheading{Derived from
}
42 \helpref{wxBitmap
}{wxbitmap
}\\
43 \helpref{wxGDIObject
}{wxgdiobject
}\\
44 \helpref{wxObject
}{wxobject
}
48 \helpref{wxIcon overview
}{wxiconoverview
},
\helpref{wxDC::DrawIcon
}{wxdcdrawicon
},
\helpref{wxCursor
}{wxcursor
}
50 \latexignore{\rtfignore{\wxheading{Members
}}}
52 \membersection{wxIcon::wxIcon
}\label{wxiconconstr
}
54 \func{}{wxIcon
}{\void}
58 \func{}{wxIcon
}{\param{const wxIcon\&
}{icon
}}
62 \func{}{wxIcon
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
64 Creates an icon from the given data, which can be of arbitrary type.
66 \func{}{wxIcon
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
67 \param{int
}{ depth =
1}}
69 Creates an icon from an array of bits.
71 \func{}{wxIcon
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
75 \func{}{wxIcon
}{\param{const char**
}{ bits
}}
77 Creates an icon from XPM data.
79 \func{}{wxIcon
}{\param{const wxString\&
}{name
},
\param{long
}{ type
},
80 \param{int
}{ desiredWidth = -
1},
\param{int
}{ desiredHeight = -
1}}
82 Loads an icon from a file or resource.
84 \wxheading{Parameters
}
86 \docparam{bits
}{Specifies an array of pixel values.
}
88 \docparam{width
}{Specifies the width of the icon.
}
90 \docparam{height
}{Specifies the height of the icon.
}
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.
}
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.
}
100 \docparam{depth
}{Specifies the depth of the icon. If this is omitted, the display depth of the
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.
}
106 \docparam{type
}{May be one of the following:
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.}
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.
}
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.
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.
131 The fourth form constructs an icon from data whose type and value depends on
132 the value of the
{\it type
} argument.
134 The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
137 The sixth form constructs a new icon.
139 The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
140 to incorporate this feature.
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:
147 #include "mybitmap.xpm"
151 wxIcon *icon = new wxIcon(mybitmap);
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.
157 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_ICO\_RESOURCE.
158 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XBM.
162 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
164 \membersection{wxIcon::
\destruct{wxIcon
}}
166 \func{}{\destruct{wxIcon
}}{\void}
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
173 If the application omits to delete the icon explicitly, the icon will be
174 destroyed automatically by wxWindows when the application exits.
176 Do not delete an icon that is selected into a memory device context.
179 \membersection{wxIcon::Create
}\label{wxiconcreate
}
181 \func{virtual bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
183 Creates a fresh icon. If the final argument is omitted, the display depth of
186 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
188 Creates an icon from the given data, which can be of arbitrary type.
190 \wxheading{Parameters
}
192 \docparam{width
}{The width of the icon in pixels.
}
194 \docparam{height
}{The height of the icon in pixels.
}
196 \docparam{depth
}{The depth of the icon in pixels. If this is -
1, the screen depth is used.
}
198 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
200 \docparam{type
}{An icon type identifier - see
\helpref{wxIcon::wxIcon
}{wxiconconstr
} for a list
203 \wxheading{Return value
}
205 TRUE if the call succeeded, FALSE otherwise.
209 The first form works on all platforms. The portability of the second form depends on the
214 \helpref{wxIcon::wxIcon
}{wxiconconstr
}
218 \membersection{wxIcon::GetDepth
}
220 \constfunc{int
}{GetDepth
}{\void}
222 Gets the colour depth of the icon. A value of
1 indicates a
225 \membersection{wxIcon::GetHeight
}\label{wxicongetheight
}
227 \constfunc{int
}{GetHeight
}{\void}
229 Gets the height of the icon in pixels.
231 \membersection{wxIcon::GetWidth
}\label{wxicongetwidth
}
233 \constfunc{int
}{GetWidth
}{\void}
235 Gets the width of the icon in pixels.
239 \helpref{wxIcon::GetHeight
}{wxicongetheight
}
241 \membersection{wxIcon::LoadFile
}\label{wxiconloadfile
}
243 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
245 Loads an icon from a file or resource.
247 \wxheading{Parameters
}
249 \docparam{name
}{Either a filename or a Windows resource name.
250 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
252 \docparam{type
}{One of the following values:
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.
}
263 The validity of these flags depends on the platform and wxWindows configuration.
}
265 \wxheading{Return value
}
267 TRUE if the operation succeeded, FALSE otherwise.
271 \helpref{wxIcon::wxIcon
}{wxiconconstr
}
273 \membersection{wxIcon::Ok
}\label{wxiconok
}
275 \constfunc{bool
}{Ok
}{\void}
277 Returns TRUE if icon data is present.
280 \membersection{wxIcon::SaveFile
}\label{wxiconsavefile
}
282 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
284 Saves an icon in the named file.
286 \wxheading{Parameters
}
288 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
290 \docparam{type
}{One of the following values:
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.
}
300 The validity of these flags depends on the platform and wxWindows configuration.
}
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.
}
305 \wxheading{Return value
}
307 TRUE if the operation succeeded, FALSE otherwise.
311 Depending on how wxWindows has been configured, not all formats may be available.
315 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
318 \membersection{wxIcon::SetDepth
}\label{wxiconsetdepth
}
320 \func{void
}{SetDepth
}{\param{int
}{depth
}}
322 Sets the depth member (does not affect the icon data).
324 \wxheading{Parameters
}
326 \docparam{depth
}{Icon depth.
}
328 \membersection{wxIcon::SetHeight
}\label{wxiconsetheight
}
330 \func{void
}{SetHeight
}{\param{int
}{height
}}
332 Sets the height member (does not affect the icon data).
334 \wxheading{Parameters
}
336 \docparam{height
}{Icon height in pixels.
}
338 \membersection{wxIcon::SetOk
}
340 \func{void
}{SetOk
}{\param{int
}{isOk
}}
342 Sets the validity member (does not affect the icon data).
344 \wxheading{Parameters
}
346 \docparam{isOk
}{Validity flag.
}
348 \membersection{wxIcon::SetWidth
}
350 \func{void
}{SetWidth
}{\param{int
}{width
}}
352 Sets the width member (does not affect the icon data).
354 \wxheading{Parameters
}
356 \docparam{width
}{Icon width in pixels.
}
358 \membersection{wxIcon::operator $=$
}
360 \func{wxIcon\&
}{operator $=$
}{\param{const wxIcon\&
}{icon
}}
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.
366 \wxheading{Parameters
}
368 \docparam{icon
}{Icon to assign.
}
370 \wxheading{Return value
}
372 Returns 'this' object.
374 \membersection{wxIcon::operator $==$
}
376 \func{bool
}{operator $==$
}{\param{const wxIcon\&
}{icon
}}
378 Equality operator. This operator tests whether the internal data pointers are
381 \wxheading{Parameters
}
383 \docparam{icon
}{Icon to compare with 'this'
}
385 \wxheading{Return value
}
387 Returns TRUE if the icons were effectively equal, FALSE otherwise.
389 \membersection{wxIcon::operator $!=$
}
391 \func{bool
}{operator $!=$
}{\param{const wxIcon\&
}{icon
}}
393 Inequality operator. This operator tests whether the internal data pointers are
394 unequal (a fast test).
396 \wxheading{Parameters
}
398 \docparam{icon
}{Icon to compare with 'this'
}
400 \wxheading{Return value
}
402 Returns TRUE if the icons were unequal, FALSE otherwise.