1 \section{\class{wxIcon
}}\label{wxicon
}
3 An icon is a small rectangular bitmap usually used for denoting a
4 minimized application. It differs from a wxBitmap in always
5 having a mask associated with it for transparent drawing. On some platforms,
6 icons and bitmaps are implemented identically, since there is no real distinction between
7 a wxBitmap with a mask and an icon; and there is no specific icon format on
8 some platforms (X-based applications usually standardize on XPMs for small bitmaps
9 and icons). However, some platforms (such as Windows) make the distinction, so
10 a separate class is provided.
14 It is usually desirable to associate a pertinent icon with a frame. Icons
15 can also be used for other purposes, for example with
\helpref{wxTreeCtrl
}{wxtreectrl
}
16 and
\helpref{wxListCtrl
}{wxlistctrl
}.
18 Icons have different formats on different platforms.
19 Therefore, separate icons will usually be created for the different
20 environments. Platform-specific methods for creating a
{\bf wxIcon
}\rtfsp
21 structure are catered for, and this is an occasion where conditional
22 compilation will probably be required.
24 Note that a new icon must be created for every time the icon is to be
25 used for a new window. In Windows, the icon will not be
26 reloaded if it has already been used. An icon allocated to a frame will
27 be deleted when the frame is deleted.
29 For more information please see
\helpref{Bitmap and icon overview
}{wxbitmapoverview
}.
31 \wxheading{Derived from
}
33 \helpref{wxBitmap
}{wxbitmap
}\\
34 \helpref{wxGDIObject
}{wxgdiobject
}\\
35 \helpref{wxObject
}{wxobject
}
39 \helpref{Bitmap and icon overview
}{wxbitmapoverview
},
\helpref{supported bitmap file formats
}{supportedbitmapformats
},
40 \helpref{wxDC::DrawIcon
}{wxdcdrawicon
},
\helpref{wxCursor
}{wxcursor
}
42 \latexignore{\rtfignore{\wxheading{Members
}}}
44 \membersection{wxIcon::wxIcon
}\label{wxiconconstr
}
46 \func{}{wxIcon
}{\void}
50 \func{}{wxIcon
}{\param{const wxIcon\&
}{icon
}}
54 \func{}{wxIcon
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
56 Creates an icon from the given data, which can be of arbitrary type.
58 \func{}{wxIcon
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
59 \param{int
}{ depth =
1}}
61 Creates an icon from an array of bits.
63 \func{}{wxIcon
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
67 \func{}{wxIcon
}{\param{const char**
}{ bits
}}
69 Creates an icon from XPM data.
71 \func{}{wxIcon
}{\param{const wxString\&
}{name
},
\param{long
}{ type
},
72 \param{int
}{ desiredWidth = -
1},
\param{int
}{ desiredHeight = -
1}}
74 Loads an icon from a file or resource.
76 \wxheading{Parameters
}
78 \docparam{bits
}{Specifies an array of pixel values.
}
80 \docparam{width
}{Specifies the width of the icon.
}
82 \docparam{height
}{Specifies the height of the icon.
}
84 \docparam{desiredWidth
}{Specifies the desired width of the icon. This
85 parameter only has an effect in Windows (
32-bit) where icon resources can contain
86 several icons of different sizes.
}
88 \docparam{desiredWidth
}{Specifies the desired height of the icon. This
89 parameter only has an effect in Windows (
32-bit) where icon resources can contain
90 several icons of different sizes.
}
92 \docparam{depth
}{Specifies the depth of the icon. If this is omitted, the display depth of the
95 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
96 Its meaning is determined by the
{\it flags
} parameter.
}
98 \docparam{type
}{May be one of the following:
102 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ICO}}}{Load a Windows icon file.
}
103 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ICO\_RESOURCE}}}{Load a Windows icon from the resource database.
}
104 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
105 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
106 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
107 %\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_RESOURCE}}}{Load a Windows resource name.}
110 The validity of these flags depends on the platform and wxWindows configuration.
111 If all possible wxWindows settings are used, the Windows platform supports ICO file, ICO resource,
112 XPM data, and XPM file. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
113 Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
}
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.
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.
124 The fourth form constructs an icon from data whose type and value depends on
125 the value of the
{\it type
} argument.
127 The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
130 The sixth form constructs a new icon.
132 The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
133 to incorporate this feature.
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:
140 #include "mybitmap.xpm"
144 wxIcon *icon = new wxIcon(mybitmap);
147 A macro, wxICON, is available which creates an icon using an XPM
148 on the appropriate platform, or an icon resource on Windows.
151 wxIcon icon(wxICON(mondrian));
155 #if defined(__WXGTK__) || defined(__WXMOTIF__)
156 wxIcon icon(mondrian_xpm);
159 #if defined(__WXMSW__)
160 wxIcon icon("mondrian");
164 The eighth form constructs an icon from a file or resource.
{\it name
} can refer
165 to a resource name under MS Windows, or a filename under MS Windows and X.
167 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_ICO\_RESOURCE.
168 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XPM.
172 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
174 \membersection{wxIcon::
\destruct{wxIcon
}}
176 \func{}{\destruct{wxIcon
}}{\void}
178 Destroys the wxIcon object and possibly the underlying icon data.
179 Because reference counting is used, the icon may not actually be
180 destroyed at this point - only when the reference count is zero will the
183 If the application omits to delete the icon explicitly, the icon will be
184 destroyed automatically by wxWindows when the application exits.
186 Do not delete an icon that is selected into a memory device context.
188 \membersection{wxIcon::GetDepth
}
190 \constfunc{int
}{GetDepth
}{\void}
192 Gets the colour depth of the icon. A value of
1 indicates a
195 \membersection{wxIcon::GetHeight
}\label{wxicongetheight
}
197 \constfunc{int
}{GetHeight
}{\void}
199 Gets the height of the icon in pixels.
201 \membersection{wxIcon::GetWidth
}\label{wxicongetwidth
}
203 \constfunc{int
}{GetWidth
}{\void}
205 Gets the width of the icon in pixels.
209 \helpref{wxIcon::GetHeight
}{wxicongetheight
}
211 \membersection{wxIcon::LoadFile
}\label{wxiconloadfile
}
213 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
215 Loads an icon from a file or resource.
217 \wxheading{Parameters
}
219 \docparam{name
}{Either a filename or a Windows resource name.
220 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
222 \docparam{type
}{One of the following values:
226 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file.
}
227 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.
}
228 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
229 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
230 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
233 The validity of these flags depends on the platform and wxWindows configuration.
}
235 \wxheading{Return value
}
237 TRUE if the operation succeeded, FALSE otherwise.
241 \helpref{wxIcon::wxIcon
}{wxiconconstr
}
243 \membersection{wxIcon::Ok
}\label{wxiconok
}
245 \constfunc{bool
}{Ok
}{\void}
247 Returns TRUE if icon data is present.
250 \membersection{wxIcon::SaveFile
}\label{wxiconsavefile
}
252 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
254 Saves an icon in the named file.
256 \wxheading{Parameters
}
258 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
260 \docparam{type
}{One of the following values:
264 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Save a Windows icon file.
}
265 %\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Save a GIF icon file.}
266 %\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Save an X bitmap file.}
267 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
270 The validity of these flags depends on the platform and wxWindows configuration.
}
272 \docparam{palette
}{An optional palette used for saving the icon. TODO: this parameter should
273 probably be eliminated; instead the app should set the palette before saving.
}
275 \wxheading{Return value
}
277 TRUE if the operation succeeded, FALSE otherwise.
281 Depending on how wxWindows has been configured, not all formats may be available.
285 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
288 \membersection{wxIcon::SetDepth
}\label{wxiconsetdepth
}
290 \func{void
}{SetDepth
}{\param{int
}{depth
}}
292 Sets the depth member (does not affect the icon data).
294 \wxheading{Parameters
}
296 \docparam{depth
}{Icon depth.
}
298 \membersection{wxIcon::SetHeight
}\label{wxiconsetheight
}
300 \func{void
}{SetHeight
}{\param{int
}{height
}}
302 Sets the height member (does not affect the icon data).
304 \wxheading{Parameters
}
306 \docparam{height
}{Icon height in pixels.
}
308 \membersection{wxIcon::SetOk
}
310 \func{void
}{SetOk
}{\param{int
}{isOk
}}
312 Sets the validity member (does not affect the icon data).
314 \wxheading{Parameters
}
316 \docparam{isOk
}{Validity flag.
}
318 \membersection{wxIcon::SetWidth
}
320 \func{void
}{SetWidth
}{\param{int
}{width
}}
322 Sets the width member (does not affect the icon data).
324 \wxheading{Parameters
}
326 \docparam{width
}{Icon width in pixels.
}
328 \membersection{wxIcon::operator $=$
}
330 \func{wxIcon\&
}{operator $=$
}{\param{const wxIcon\&
}{icon
}}
332 Assignment operator. This operator does not copy any data, but instead
333 passes a pointer to the data in
{\it icon
} and increments a reference
334 counter. It is a fast operation.
336 \wxheading{Parameters
}
338 \docparam{icon
}{Icon to assign.
}
340 \wxheading{Return value
}
342 Returns 'this' object.
344 \membersection{wxIcon::operator $==$
}
346 \func{bool
}{operator $==$
}{\param{const wxIcon\&
}{icon
}}
348 Equality operator. This operator tests whether the internal data pointers are
351 \wxheading{Parameters
}
353 \docparam{icon
}{Icon to compare with 'this'
}
355 \wxheading{Return value
}
357 Returns TRUE if the icons were effectively equal, FALSE otherwise.
359 \membersection{wxIcon::operator $!=$
}
361 \func{bool
}{operator $!=$
}{\param{const wxIcon\&
}{icon
}}
363 Inequality operator. This operator tests whether the internal data pointers are
364 unequal (a fast test).
366 \wxheading{Parameters
}
368 \docparam{icon
}{Icon to compare with 'this'
}
370 \wxheading{Return value
}
372 Returns TRUE if the icons were unequal, FALSE otherwise.