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
}
37 \wxheading{Include files
}
43 \helpref{Bitmap and icon overview
}{wxbitmapoverview
},
\helpref{supported bitmap file formats
}{supportedbitmapformats
},
44 \helpref{wxDC::DrawIcon
}{wxdcdrawicon
},
\helpref{wxCursor
}{wxcursor
}
46 \latexignore{\rtfignore{\wxheading{Members
}}}
48 \membersection{wxIcon::wxIcon
}\label{wxiconconstr
}
50 \func{}{wxIcon
}{\void}
54 \func{}{wxIcon
}{\param{const wxIcon\&
}{icon
}}
58 \func{}{wxIcon
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
60 Creates an icon from the given data, which can be of arbitrary type.
62 \func{}{wxIcon
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
63 \param{int
}{ depth =
1}}
65 Creates an icon from an array of bits.
67 \func{}{wxIcon
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
71 \func{}{wxIcon
}{\param{const char**
}{ bits
}}
73 Creates an icon from XPM data.
75 \func{}{wxIcon
}{\param{const wxString\&
}{name
},
\param{long
}{ type
},
76 \param{int
}{ desiredWidth = -
1},
\param{int
}{ desiredHeight = -
1}}
78 Loads an icon from a file or resource.
80 \wxheading{Parameters
}
82 \docparam{bits
}{Specifies an array of pixel values.
}
84 \docparam{width
}{Specifies the width of the icon.
}
86 \docparam{height
}{Specifies the height of the icon.
}
88 \docparam{desiredWidth
}{Specifies the desired width 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{desiredWidth
}{Specifies the desired height 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{depth
}{Specifies the depth of the icon. If this is omitted, the display depth of the
99 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
100 Its meaning is determined by the
{\it flags
} parameter.
}
102 \docparam{type
}{May be one of the following:
106 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ICO}}}{Load a Windows icon file.
}
107 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ICO\_RESOURCE}}}{Load a Windows icon from the resource database.
}
108 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
109 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
110 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
111 %\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_RESOURCE}}}{Load a Windows resource name.}
114 The validity of these flags depends on the platform and wxWindows configuration.
115 If all possible wxWindows settings are used, the Windows platform supports ICO file, ICO resource,
116 XPM data, and XPM file. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
117 Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
}
121 The first form constructs an icon object with no data; an assignment or another member function such as Create
122 or LoadFile must be called subsequently.
124 The second and third forms provide copy constructors. Note that these do not copy the
125 icon data, but instead a pointer to the data, keeping a reference count. They are therefore
126 very efficient operations.
128 The fourth form constructs an icon from data whose type and value depends on
129 the value of the
{\it type
} argument.
131 The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
134 The sixth form constructs a new icon.
136 The seventh form constructs an icon from pixmap (XPM) data, if wxWindows has been configured
137 to incorporate this feature.
139 To use this constructor, you must first include an XPM file. For
140 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
141 of character pointers called mybitmap:
144 #include "mybitmap.xpm"
148 wxIcon *icon = new wxIcon(mybitmap);
151 A macro, wxICON, is available which creates an icon using an XPM
152 on the appropriate platform, or an icon resource on Windows.
155 wxIcon icon(wxICON(mondrian));
159 #if defined(__WXGTK__) || defined(__WXMOTIF__)
160 wxIcon icon(mondrian_xpm);
163 #if defined(__WXMSW__)
164 wxIcon icon("mondrian");
168 The eighth form constructs an icon from a file or resource.
{\it name
} can refer
169 to a resource name under MS Windows, or a filename under MS Windows and X.
171 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_ICO\_RESOURCE.
172 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XPM.
176 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
178 \membersection{wxIcon::
\destruct{wxIcon
}}
180 \func{}{\destruct{wxIcon
}}{\void}
182 Destroys the wxIcon object and possibly the underlying icon data.
183 Because reference counting is used, the icon may not actually be
184 destroyed at this point - only when the reference count is zero will the
187 If the application omits to delete the icon explicitly, the icon will be
188 destroyed automatically by wxWindows when the application exits.
190 Do not delete an icon that is selected into a memory device context.
192 \membersection{wxIcon::GetDepth
}
194 \constfunc{int
}{GetDepth
}{\void}
196 Gets the colour depth of the icon. A value of
1 indicates a
199 \membersection{wxIcon::GetHeight
}\label{wxicongetheight
}
201 \constfunc{int
}{GetHeight
}{\void}
203 Gets the height of the icon in pixels.
205 \membersection{wxIcon::GetWidth
}\label{wxicongetwidth
}
207 \constfunc{int
}{GetWidth
}{\void}
209 Gets the width of the icon in pixels.
213 \helpref{wxIcon::GetHeight
}{wxicongetheight
}
215 \membersection{wxIcon::LoadFile
}\label{wxiconloadfile
}
217 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
219 Loads an icon from a file or resource.
221 \wxheading{Parameters
}
223 \docparam{name
}{Either a filename or a Windows resource name.
224 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
226 \docparam{type
}{One of the following values:
230 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file.
}
231 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.
}
232 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
233 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
234 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
237 The validity of these flags depends on the platform and wxWindows configuration.
}
239 \wxheading{Return value
}
241 TRUE if the operation succeeded, FALSE otherwise.
245 \helpref{wxIcon::wxIcon
}{wxiconconstr
}
247 \membersection{wxIcon::Ok
}\label{wxiconok
}
249 \constfunc{bool
}{Ok
}{\void}
251 Returns TRUE if icon data is present.
254 \membersection{wxIcon::SaveFile
}\label{wxiconsavefile
}
256 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
258 Saves an icon in the named file.
260 \wxheading{Parameters
}
262 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
264 \docparam{type
}{One of the following values:
268 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Save a Windows icon file.
}
269 %\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Save a GIF icon file.}
270 %\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Save an X bitmap file.}
271 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
274 The validity of these flags depends on the platform and wxWindows configuration.
}
276 \docparam{palette
}{An optional palette used for saving the icon.
}
278 \wxheading{Return value
}
280 TRUE if the operation succeeded, FALSE otherwise.
284 Depending on how wxWindows has been configured, not all formats may be available.
288 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
291 \membersection{wxIcon::SetDepth
}\label{wxiconsetdepth
}
293 \func{void
}{SetDepth
}{\param{int
}{depth
}}
295 Sets the depth member (does not affect the icon data).
297 \wxheading{Parameters
}
299 \docparam{depth
}{Icon depth.
}
301 \membersection{wxIcon::SetHeight
}\label{wxiconsetheight
}
303 \func{void
}{SetHeight
}{\param{int
}{height
}}
305 Sets the height member (does not affect the icon data).
307 \wxheading{Parameters
}
309 \docparam{height
}{Icon height in pixels.
}
311 \membersection{wxIcon::SetOk
}
313 \func{void
}{SetOk
}{\param{int
}{isOk
}}
315 Sets the validity member (does not affect the icon data).
317 \wxheading{Parameters
}
319 \docparam{isOk
}{Validity flag.
}
321 \membersection{wxIcon::SetWidth
}
323 \func{void
}{SetWidth
}{\param{int
}{width
}}
325 Sets the width member (does not affect the icon data).
327 \wxheading{Parameters
}
329 \docparam{width
}{Icon width in pixels.
}
331 \membersection{wxIcon::operator $=$
}
333 \func{wxIcon\&
}{operator $=$
}{\param{const wxIcon\&
}{icon
}}
335 Assignment operator. This operator does not copy any data, but instead
336 passes a pointer to the data in
{\it icon
} and increments a reference
337 counter. It is a fast operation.
339 \wxheading{Parameters
}
341 \docparam{icon
}{Icon to assign.
}
343 \wxheading{Return value
}
345 Returns 'this' object.
347 \membersection{wxIcon::operator $==$
}
349 \func{bool
}{operator $==$
}{\param{const wxIcon\&
}{icon
}}
351 Equality operator. This operator tests whether the internal data pointers are
354 \wxheading{Parameters
}
356 \docparam{icon
}{Icon to compare with 'this'
}
358 \wxheading{Return value
}
360 Returns TRUE if the icons were effectively equal, FALSE otherwise.
362 \membersection{wxIcon::operator $!=$
}
364 \func{bool
}{operator $!=$
}{\param{const wxIcon\&
}{icon
}}
366 Inequality operator. This operator tests whether the internal data pointers are
367 unequal (a fast test).
369 \wxheading{Parameters
}
371 \docparam{icon
}{Icon to compare with 'this'
}
373 \wxheading{Return value
}
375 Returns TRUE if the icons were unequal, FALSE otherwise.