1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
|
<HTML>
<head><title>wxIcon</title></head>
<BODY BGCOLOR=#FFFFFF>
<A NAME="wxicon"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx113.htm#wxidleevent"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx115.htm#wximage"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>
<H2>wxIcon</H2>
<P>
An icon is a small rectangular bitmap usually used for denoting a
minimized application. It differs from a wxBitmap in always
having a mask associated with it for transparent drawing. On some platforms,
icons and bitmaps are implemented identically, since there is no real distinction between
a wxBitmap with a mask and an icon; and there is no specific icon format on
some platforms (X-based applications usually standardize on XPMs for small bitmaps
and icons). However, some platforms (such as Windows) make the distinction, so
a separate class is provided.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx32.htm#wxbitmap">wxBitmap</A><BR>
<A HREF="wx107.htm#wxgdiobject">wxGDIObject</A><BR>
<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
<wx/icon.h><P>
<B><FONT COLOR="#FF0000">Predefined objects</FONT></B><P>
Objects:<P>
<B>wxNullIcon</B><P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
It is usually desirable to associate a pertinent icon with a frame. Icons
can also be used for other purposes, for example with <A HREF="wx250.htm#wxtreectrl">wxTreeCtrl</A>
and <A HREF="wx129.htm#wxlistctrl">wxListCtrl</A>.<P>
Icons have different formats on different platforms.
Therefore, separate icons will usually be created for the different
environments. Platform-specific methods for creating a <B>wxIcon</B>
structure are catered for, and this is an occasion where conditional
compilation will probably be required.<P>
Note that a new icon must be created for every time the icon is to be
used for a new window. In Windows, the icon will not be
reloaded if it has already been used. An icon allocated to a frame will
be deleted when the frame is deleted.<P>
For more information please see <A HREF="wx284.htm#wxbitmapoverview">Bitmap and icon overview</A>.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx284.htm#wxbitmapoverview">Bitmap and icon overview</A>, <A HREF="wx284.htm#supportedbitmapformats">supported bitmap file formats</A>,
<A HREF="wx65.htm#wxdcdrawicon">wxDC::DrawIcon</A>, <A HREF="wx59.htm#wxcursor">wxCursor</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#wxiconconstr">wxIcon::wxIcon</A><BR>
<A HREF="#topic441">wxIcon::~wxIcon</A><BR>
<A HREF="#topic442">wxIcon::GetDepth</A><BR>
<A HREF="#wxicongetheight">wxIcon::GetHeight</A><BR>
<A HREF="#wxicongetwidth">wxIcon::GetWidth</A><BR>
<A HREF="#wxiconloadfile">wxIcon::LoadFile</A><BR>
<A HREF="#wxiconok">wxIcon::Ok</A><BR>
<A HREF="#wxiconsetdepth">wxIcon::SetDepth</A><BR>
<A HREF="#wxiconsetheight">wxIcon::SetHeight</A><BR>
<A HREF="#topic443">wxIcon::SetOk</A><BR>
<A HREF="#topic444">wxIcon::SetWidth</A><BR>
<A HREF="#topic445">wxIcon::operator =</A><BR>
<A HREF="#topic446">wxIcon::operator ==</A><BR>
<A HREF="#topic447">wxIcon::operator !=</A><BR>
<P>
<HR>
<A NAME="wxiconconstr"></A>
<H3>wxIcon::wxIcon</H3>
<P>
<B></B> <B>wxIcon</B>()<P>
Default constructor.<P>
<B></B> <B>wxIcon</B>(<B>const wxIcon& </B><I>icon</I>)<P>
Copy constructor.<P>
<B></B> <B>wxIcon</B>(<B>void*</B><I> data</I>, <B>int</B><I> type</I>, <B>int</B><I> width</I>, <B>int</B><I> height</I>, <B>int</B><I> depth = -1</I>)<P>
Creates an icon from the given data, which can be of arbitrary type.<P>
<B></B> <B>wxIcon</B>(<B>const char</B><I> bits[]</I>, <B>int</B><I> width</I>, <B>int</B><I> height</I><BR>
<B>int</B><I> depth = 1</I>)<P>
Creates an icon from an array of bits.<P>
<B></B> <B>wxIcon</B>(<B>int</B><I> width</I>, <B>int</B><I> height</I>, <B>int</B><I> depth = -1</I>)<P>
Creates a new icon.<P>
<B></B> <B>wxIcon</B>(<B>const char**</B><I> bits</I>)<P>
Creates an icon from XPM data.<P>
<B></B> <B>wxIcon</B>(<B>const wxString& </B><I>name</I>, <B>long</B><I> type</I>,
<B>int</B><I> desiredWidth = -1</I>, <B>int</B><I> desiredHeight = -1</I>)<P>
Loads an icon from a file or resource.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>bits</I><UL><UL>
Specifies an array of pixel values.</UL></UL>
<P>
<I>width</I><UL><UL>
Specifies the width of the icon.</UL></UL>
<P>
<I>height</I><UL><UL>
Specifies the height of the icon.</UL></UL>
<P>
<I>desiredWidth</I><UL><UL>
Specifies the desired width of the icon. This
parameter only has an effect in Windows (32-bit) where icon resources can contain
several icons of different sizes.</UL></UL>
<P>
<I>desiredWidth</I><UL><UL>
Specifies the desired height of the icon. This
parameter only has an effect in Windows (32-bit) where icon resources can contain
several icons of different sizes.</UL></UL>
<P>
<I>depth</I><UL><UL>
Specifies the depth of the icon. If this is omitted, the display depth of the
screen is used.</UL></UL>
<P>
<I>name</I><UL><UL>
This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
Its meaning is determined by the <I>flags</I> parameter.</UL></UL>
<P>
<I>type</I><UL><UL>
May be one of the following:<P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_ICO</B>
</TD>
<TD VALIGN=TOP>
Load a Windows icon file.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_ICO_RESOURCE</B>
</TD>
<TD VALIGN=TOP>
Load a Windows icon from the resource database.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_GIF</B>
</TD>
<TD VALIGN=TOP>
Load a GIF bitmap file.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_XBM</B>
</TD>
<TD VALIGN=TOP>
Load an X bitmap file.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_XPM</B>
</TD>
<TD VALIGN=TOP>
Load an XPM bitmap file.
</TD></TR>
</TABLE>
<P>
The validity of these flags depends on the platform and wxWindows configuration.
If all possible wxWindows settings are used, the Windows platform supports ICO file, ICO resource,
XPM data, and XPM file. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Remarks</FONT></B><P>
The first form constructs an icon object with no data; an assignment or another member function such as Create
or LoadFile must be called subsequently.<P>
The second and third forms provide copy constructors. Note that these do not copy the
icon data, but instead a pointer to the data, keeping a reference count. They are therefore
very efficient operations.<P>
The fourth form constructs an icon from data whose type and value depends on
the value of the <I>type</I> argument.<P>
The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
X and Windows.<P>
The sixth form constructs a new icon.<P>
The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
to incorporate this feature.<P>
To use this constructor, you must first include an XPM file. For
example, assuming that the file <TT>mybitmap.xpm</TT> contains an XPM array
of character pointers called mybitmap:<P>
<PRE>
#include "mybitmap.xpm"
...
wxIcon *icon = new wxIcon(mybitmap);
</PRE>
A macro, wxICON, is available which creates an icon using an XPM
on the appropriate platform, or an icon resource on Windows.<P>
<PRE>
wxIcon icon(wxICON(mondrian));
// Equivalent to:
#if defined(__WXGTK__) || defined(__WXMOTIF__)
wxIcon icon(mondrian_xpm);
#endif
#if defined(__WXMSW__)
wxIcon icon("mondrian");
#endif
</PRE>
The eighth form constructs an icon from a file or resource. <I>name</I> can refer
to a resource name under MS Windows, or a filename under MS Windows and X.<P>
Under Windows, <I>type</I> defaults to wxBITMAP_TYPE_ICO_RESOURCE.
Under X, <I>type</I> defaults to wxBITMAP_TYPE_XPM.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx114.htm#wxiconloadfile">wxIcon::LoadFile</A><P>
<HR>
<A NAME="topic441"></A>
<H3>wxIcon::~wxIcon</H3>
<P>
<B></B> <B>~wxIcon</B>()<P>
Destroys the wxIcon object and possibly the underlying icon data.
Because reference counting is used, the icon may not actually be
destroyed at this point - only when the reference count is zero will the
data be deleted.<P>
If the application omits to delete the icon explicitly, the icon will be
destroyed automatically by wxWindows when the application exits.<P>
Do not delete an icon that is selected into a memory device context.<P>
<HR>
<A NAME="topic442"></A>
<H3>wxIcon::GetDepth</H3>
<P>
<B>int</B> <B>GetDepth</B>() <B>const</B><P>
Gets the colour depth of the icon. A value of 1 indicates a
monochrome icon.<P>
<HR>
<A NAME="wxicongetheight"></A>
<H3>wxIcon::GetHeight</H3>
<P>
<B>int</B> <B>GetHeight</B>() <B>const</B><P>
Gets the height of the icon in pixels.<P>
<HR>
<A NAME="wxicongetwidth"></A>
<H3>wxIcon::GetWidth</H3>
<P>
<B>int</B> <B>GetWidth</B>() <B>const</B><P>
Gets the width of the icon in pixels.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx114.htm#wxicongetheight">wxIcon::GetHeight</A><P>
<HR>
<A NAME="wxiconloadfile"></A>
<H3>wxIcon::LoadFile</H3>
<P>
<B>bool</B> <B>LoadFile</B>(<B>const wxString&</B><I> name</I>, <B>long</B><I> type</I>)<P>
Loads an icon from a file or resource.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>name</I><UL><UL>
Either a filename or a Windows resource name.
The meaning of <I>name</I> is determined by the <I>type</I> parameter.</UL></UL>
<P>
<I>type</I><UL><UL>
One of the following values:<P>
<TABLE>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_ICO</B>
</TD>
<TD VALIGN=TOP>
Load a Windows icon file.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_ICO_RESOURCE</B>
</TD>
<TD VALIGN=TOP>
Load a Windows icon from the resource database.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_GIF</B>
</TD>
<TD VALIGN=TOP>
Load a GIF bitmap file.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_XBM</B>
</TD>
<TD VALIGN=TOP>
Load an X bitmap file.
</TD></TR>
<TR><TD VALIGN=TOP>
<B>wxBITMAP_TYPE_XPM</B>
</TD>
<TD VALIGN=TOP>
Load an XPM bitmap file.
</TD></TR>
</TABLE>
<P>
The validity of these flags depends on the platform and wxWindows configuration.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
TRUE if the operation succeeded, FALSE otherwise.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx114.htm#wxiconconstr">wxIcon::wxIcon</A><P>
<HR>
<A NAME="wxiconok"></A>
<H3>wxIcon::Ok</H3>
<P>
<B>bool</B> <B>Ok</B>() <B>const</B><P>
Returns TRUE if icon data is present.<P>
<HR>
<A NAME="wxiconsetdepth"></A>
<H3>wxIcon::SetDepth</H3>
<P>
<B>void</B> <B>SetDepth</B>(<B>int </B><I>depth</I>)<P>
Sets the depth member (does not affect the icon data).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>depth</I><UL><UL>
Icon depth.</UL></UL>
<P>
<HR>
<A NAME="wxiconsetheight"></A>
<H3>wxIcon::SetHeight</H3>
<P>
<B>void</B> <B>SetHeight</B>(<B>int </B><I>height</I>)<P>
Sets the height member (does not affect the icon data).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>height</I><UL><UL>
Icon height in pixels.</UL></UL>
<P>
<HR>
<A NAME="topic443"></A>
<H3>wxIcon::SetOk</H3>
<P>
<B>void</B> <B>SetOk</B>(<B>int </B><I>isOk</I>)<P>
Sets the validity member (does not affect the icon data).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>isOk</I><UL><UL>
Validity flag.</UL></UL>
<P>
<HR>
<A NAME="topic444"></A>
<H3>wxIcon::SetWidth</H3>
<P>
<B>void</B> <B>SetWidth</B>(<B>int </B><I>width</I>)<P>
Sets the width member (does not affect the icon data).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>width</I><UL><UL>
Icon width in pixels.</UL></UL>
<P>
<HR>
<A NAME="topic445"></A>
<H3>wxIcon::operator =</H3>
<P>
<B>wxIcon& </B> <B>operator =</B>(<B>const wxIcon& </B><I>icon</I>)<P>
Assignment operator. This operator does not copy any data, but instead
passes a pointer to the data in <I>icon</I> and increments a reference
counter. It is a fast operation.<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>icon</I><UL><UL>
Icon to assign.</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Returns 'this' object.<P>
<HR>
<A NAME="topic446"></A>
<H3>wxIcon::operator ==</H3>
<P>
<B>bool</B> <B>operator ==</B>(<B>const wxIcon& </B><I>icon</I>)<P>
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>icon</I><UL><UL>
Icon to compare with 'this'</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Returns TRUE if the icons were effectively equal, FALSE otherwise.<P>
<HR>
<A NAME="topic447"></A>
<H3>wxIcon::operator !=</H3>
<P>
<B>bool</B> <B>operator !=</B>(<B>const wxIcon& </B><I>icon</I>)<P>
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).<P>
<B><FONT COLOR="#FF0000">Parameters</FONT></B><P>
<I>icon</I><UL><UL>
Icon to compare with 'this'</UL></UL>
<P>
<B><FONT COLOR="#FF0000">Return value</FONT></B><P>
Returns TRUE if the icons were unequal, FALSE otherwise.<P>
</BODY></HTML>
|