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.
12 \wxheading{Derived from
}
14 \helpref{wxBitmap
}{wxbitmap
}\\
15 \helpref{wxGDIObject
}{wxgdiobject
}\\
16 \helpref{wxObject
}{wxobject
}
18 \wxheading{Include files
}
24 \helpref{wxCore
}{librarieslist
}
26 \wxheading{Predefined objects
}
34 It is usually desirable to associate a pertinent icon with a frame. Icons
35 can also be used for other purposes, for example with
\helpref{wxTreeCtrl
}{wxtreectrl
}
36 and
\helpref{wxListCtrl
}{wxlistctrl
}.
38 Icons have different formats on different platforms.
39 Therefore, separate icons will usually be created for the different
40 environments. Platform-specific methods for creating a
{\bf wxIcon
}\rtfsp
41 structure are catered for, and this is an occasion where conditional
42 compilation will probably be required.
44 Note that a new icon must be created for every time the icon is to be
45 used for a new window. In Windows, the icon will not be
46 reloaded if it has already been used. An icon allocated to a frame will
47 be deleted when the frame is deleted.
49 For more information please see
\helpref{Bitmap and icon overview
}{wxbitmapoverview
}.
53 \helpref{Bitmap and icon overview
}{wxbitmapoverview
},
\helpref{supported bitmap file formats
}{supportedbitmapformats
},
54 \helpref{wxDC::DrawIcon
}{wxdcdrawicon
},
\helpref{wxCursor
}{wxcursor
}
56 \latexignore{\rtfignore{\wxheading{Members
}}}
58 \membersection{wxIcon::wxIcon
}\label{wxiconctor
}
60 \func{}{wxIcon
}{\void}
64 \func{}{wxIcon
}{\param{const wxIcon\&
}{icon
}}
68 \func{}{wxIcon
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
70 Creates an icon from the given data, which can be of arbitrary type.
72 \func{}{wxIcon
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
73 \param{int
}{ depth =
1}}
75 Creates an icon from an array of bits.
77 \func{}{wxIcon
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
81 \func{}{wxIcon
}{\param{char**
}{ bits
}}
83 \func{}{wxIcon
}{\param{const char**
}{ bits
}}
85 Creates an icon from XPM data.
87 \func{}{wxIcon
}{\param{const wxString\&
}{name
},
\param{wxBitmapType
}{ type
},
88 \param{int
}{ desiredWidth = -
1},
\param{int
}{ desiredHeight = -
1}}
90 Loads an icon from a file or resource.
92 \func{}{wxIcon
}{\param{const wxIconLocation\&
}{loc
}}
94 Loads an icon from the specified
\helpref{location
}{wxiconlocation
}.
96 \wxheading{Parameters
}
98 \docparam{bits
}{Specifies an array of pixel values.
}
100 \docparam{width
}{Specifies the width of the icon.
}
102 \docparam{height
}{Specifies the height of the icon.
}
104 \docparam{desiredWidth
}{Specifies the desired width of the icon. This
105 parameter only has an effect in Windows (
32-bit) where icon resources can contain
106 several icons of different sizes.
}
108 \docparam{desiredWidth
}{Specifies the desired height of the icon. This
109 parameter only has an effect in Windows (
32-bit) where icon resources can contain
110 several icons of different sizes.
}
112 \docparam{depth
}{Specifies the depth of the icon. If this is omitted, the display depth of the
115 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
116 Its meaning is determined by the
{\it flags
} parameter.
}
118 \docparam{loc
}{The object describing the location of the native icon, see
119 \helpref{wxIconLocation
}{wxiconlocation
}.
}
121 \docparam{type
}{May be one of the following:
125 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file.
}
126 \twocolitem{\indexit{wxBITMAP
\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.
}
127 \twocolitem{\indexit{wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
128 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
129 \twocolitem{\indexit{wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
130 %\twocolitem{\indexit{wxBITMAP\_TYPE\_RESOURCE}}{Load a Windows resource name.}
133 The validity of these flags depends on the platform and wxWidgets configuration.
134 If all possible wxWidgets settings are used, the Windows platform supports ICO file, ICO resource,
135 XPM data, and XPM file. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
136 Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
}
140 The first form constructs an icon object with no data; an assignment or another member function such as Create
141 or LoadFile must be called subsequently.
143 The second and third forms provide copy constructors. Note that these do not copy the
144 icon data, but instead a pointer to the data, keeping a reference count. They are therefore
145 very efficient operations.
147 The fourth form constructs an icon from data whose type and value depends on
148 the value of the
{\it type
} argument.
150 The fifth form constructs a (usually monochrome) icon from an array of pixel values, under both
153 The sixth form constructs a new icon.
155 The seventh form constructs an icon from pixmap (XPM) data, if wxWidgets has been configured
156 to incorporate this feature.
158 To use this constructor, you must first include an XPM file. For
159 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
160 of character pointers called mybitmap:
163 #include "mybitmap.xpm"
167 wxIcon *icon = new wxIcon(mybitmap);
170 A macro, wxICON, is available which creates an icon using an XPM
171 on the appropriate platform, or an icon resource on Windows.
174 wxIcon icon(wxICON(mondrian));
178 #if defined(__WXGTK__) || defined(__WXMOTIF__)
179 wxIcon icon(mondrian_xpm);
182 #if defined(__WXMSW__)
183 wxIcon icon("mondrian");
187 The eighth form constructs an icon from a file or resource.
{\it name
} can refer
188 to a resource name under MS Windows, or a filename under MS Windows and X.
190 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_ICO\_RESOURCE.
191 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XPM.
196 \membersection{wxIcon::CopyFromBitmap
}\label{wxiconcopyfrombitmap
}
198 \func{void
}{CopyFromBitmap
}{\param{const wxBitmap\&
}{ bmp
}}
200 Copies
{\it bmp
} bitmap to this icon. Under MS Windows the bitmap
201 must have mask colour set.
204 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
206 \perlnote{Constructors supported by wxPerl are:
\par
208 \item{Wx::Icon->new( width, height, depth = -
1 )
}
209 \item{Wx::Icon->new( name, type, desiredWidth = -
1, desiredHeight = -
1 )
}
210 \item{Wx::Icon->newFromBits( bits, width, height, depth =
1 )
}
211 \item{Wx::Icon->newFromXPM( data )
}
215 \membersection{wxIcon::
\destruct{wxIcon
}}\label{wxicondtor
}
217 \func{}{\destruct{wxIcon
}}{\void}
220 See
\helpref{reference-counted object destruction
}{refcountdestruct
} for more info.
222 If the application omits to delete the icon explicitly, the icon will be
223 destroyed automatically by wxWidgets when the application exits.
225 Do not delete an icon that is selected into a memory device context.
227 \membersection{wxIcon::GetDepth
}\label{wxicongetdepth
}
229 \constfunc{int
}{GetDepth
}{\void}
231 Gets the colour depth of the icon. A value of
1 indicates a
234 \membersection{wxIcon::GetHeight
}\label{wxicongetheight
}
236 \constfunc{int
}{GetHeight
}{\void}
238 Gets the height of the icon in pixels.
240 \membersection{wxIcon::GetWidth
}\label{wxicongetwidth
}
242 \constfunc{int
}{GetWidth
}{\void}
244 Gets the width of the icon in pixels.
248 \helpref{wxIcon::GetHeight
}{wxicongetheight
}
250 \membersection{wxIcon::LoadFile
}\label{wxiconloadfile
}
252 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{wxBitmapType
}{ type
}}
254 Loads an icon from a file or resource.
256 \wxheading{Parameters
}
258 \docparam{name
}{Either a filename or a Windows resource name.
259 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
261 \docparam{type
}{One of the following values:
265 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file.
}
266 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.
}
267 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
268 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
269 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
272 The validity of these flags depends on the platform and wxWidgets configuration.
}
274 \wxheading{Return value
}
276 true if the operation succeeded, false otherwise.
280 \helpref{wxIcon::wxIcon
}{wxiconctor
}
282 \membersection{wxIcon::IsOk
}\label{wxiconisok
}
284 \constfunc{bool
}{IsOk
}{\void}
286 Returns true if icon data is present.
289 \membersection{wxIcon::SaveFile
}\label{wxiconsavefile
}
291 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{wxBitmapType
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
293 Saves an icon in the named file.
295 \wxheading{Parameters
}
297 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
299 \docparam{type
}{One of the following values:
303 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Save a Windows icon file.
}
304 %\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Save a GIF icon file.}
305 %\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Save an X bitmap file.}
306 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
309 The validity of these flags depends on the platform and wxWidgets configuration.
}
311 \docparam{palette
}{An optional palette used for saving the icon.
}
313 \wxheading{Return value
}
315 true if the operation succeeded, false otherwise.
319 Depending on how wxWidgets has been configured, not all formats may be available.
323 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
326 \membersection{wxIcon::SetDepth
}\label{wxiconsetdepth
}
328 \func{void
}{SetDepth
}{\param{int
}{depth
}}
330 Sets the depth member (does not affect the icon data).
332 \wxheading{Parameters
}
334 \docparam{depth
}{Icon depth.
}
336 \membersection{wxIcon::SetHeight
}\label{wxiconsetheight
}
338 \func{void
}{SetHeight
}{\param{int
}{height
}}
340 Sets the height member (does not affect the icon data).
342 \wxheading{Parameters
}
344 \docparam{height
}{Icon height in pixels.
}
346 \membersection{wxIcon::SetWidth
}\label{wxiconsetwidth
}
348 \func{void
}{SetWidth
}{\param{int
}{width
}}
350 Sets the width member (does not affect the icon data).
352 \wxheading{Parameters
}
354 \docparam{width
}{Icon width in pixels.
}
356 \membersection{wxIcon::operator $=$
}\label{wxiconassign
}
358 \func{wxIcon\&
}{operator $=$
}{\param{const wxIcon\&
}{icon
}}
360 Assignment operator, using
\helpref{reference counting
}{trefcount
}.
362 \wxheading{Parameters
}
364 \docparam{icon
}{Icon to assign.
}
366 \wxheading{Return value
}
368 Returns 'this' object.