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
}}
60 \func{}{wxIcon
}{\param{const wxIcon*
}{icon
}}
64 \func{}{wxIcon
}{\param{void*
}{ data
},
\param{const int
}{ type
},
\param{const int
}{ width
},
\param{const int
}{ height
},
\param{const int
}{ depth = -
1}}
66 Creates an icon from the given data, which can be of arbitrary type.
68 \func{}{wxIcon
}{\param{const char
}{ bits
[]},
\param{const int
}{ width
},
\param{const int
}{ height
}\\
69 \param{const int
}{ depth =
1}}
71 Creates an icon from an array of bits.
73 \func{}{wxIcon
}{\param{const int
}{ width
},
\param{const int
}{ height
},
\param{const int
}{ depth = -
1}}
77 \func{}{wxIcon
}{\param{const char**
}{ bits
}}
79 Creates an icon from XPM data.
81 \func{}{wxIcon
}{\param{const wxString\&
}{name
},
\param{const long
}{ type
}}
83 Loads an icon from a file or resource.
85 \wxheading{Parameters
}
87 \docparam{bits
}{Specifies an array of pixel values.
}
89 \docparam{width
}{Specifies the width of the icon.
}
91 \docparam{height
}{Specifies the height of the icon.
}
93 \docparam{depth
}{Specifies the depth of the icon. If this is omitted, the display depth of the
96 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
97 Its meaning is determined by the
{\it flags
} parameter.
}
99 \docparam{type
}{May be one of the following:
103 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ICO}}}{Load a Windows icon file.
}
104 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_ICO\_RESOURCE}}}{Load a Windows icon from the resource database.
}
105 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
106 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
107 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
108 %\twocolitem{{\bf \indexit{wxBITMAP\_TYPE\_RESOURCE}}}{Load a Windows resource name.}
111 The validity of these flags depends on the platform and wxWindows configuration.
112 If all possible wxWindows settings are used, the Windows platform supports ICO, ICO
\_RESOURCE,
113 XPM
\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.
}
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 The eighth form constructs an icon from a file or resource.
{\it name
} can refer
148 to a resource name under MS Windows, or a filename under MS Windows and X.
150 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_ICO\_RESOURCE.
151 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XBM.
155 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
157 \membersection{wxIcon::
\destruct{wxIcon
}}
159 \func{}{\destruct{wxIcon
}}{\void}
161 Destroys the wxIcon object and possibly the underlying icon data.
162 Because reference counting is used, the icon may not actually be
163 destroyed at this point - only when the reference count is zero will the
166 If the application omits to delete the icon explicitly, the icon will be
167 destroyed automatically by wxWindows when the application exits.
169 Do not delete an icon that is selected into a memory device context.
172 \membersection{wxIcon::Create
}\label{wxiconcreate
}
174 \func{virtual bool
}{Create
}{\param{const int
}{ width
},
\param{const int
}{ height
},
\param{const int
}{ depth = -
1}}
176 Creates a fresh icon. If the final argument is omitted, the display depth of
179 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{const int
}{ type
},
\param{const int
}{ width
},
\param{const int
}{ height
},
\param{const int
}{ depth = -
1}}
181 Creates an icon from the given data, which can be of arbitrary type.
183 \wxheading{Parameters
}
185 \docparam{width
}{The width of the icon in pixels.
}
187 \docparam{height
}{The height of the icon in pixels.
}
189 \docparam{depth
}{The depth of the icon in pixels. If this is -
1, the screen depth is used.
}
191 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
193 \docparam{type
}{An icon type identifier - see
\helpref{wxIcon::wxIcon
}{wxiconconstr
} for a list
196 \wxheading{Return value
}
198 TRUE if the call succeeded, FALSE otherwise.
202 The first form works on all platforms. The portability of the second form depends on the
207 \helpref{wxIcon::wxIcon
}{wxiconconstr
}
211 \membersection{wxIcon::GetDepth
}
213 \constfunc{int
}{GetDepth
}{\void}
215 Gets the colour depth of the icon. A value of
1 indicates a
218 \membersection{wxIcon::GetHeight
}\label{wxicongetheight
}
220 \constfunc{int
}{GetHeight
}{\void}
222 Gets the height of the icon in pixels.
224 \membersection{wxIcon::GetWidth
}\label{wxicongetwidth
}
226 \constfunc{int
}{GetWidth
}{\void}
228 Gets the width of the icon in pixels.
232 \helpref{wxIcon::GetHeight
}{wxicongetheight
}
234 \membersection{wxIcon::LoadFile
}\label{wxiconloadfile
}
236 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{const long
}{ type
}}
238 Loads an icon from a file or resource.
240 \wxheading{Parameters
}
242 \docparam{name
}{Either a filename or a Windows resource name.
243 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
245 \docparam{type
}{One of the following values:
249 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Load a Windows icon file.
}
250 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO\_RESOURCE}}{Load a Windows icon from the resource database.
}
251 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
252 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
253 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
256 The validity of these flags depends on the platform and wxWindows configuration.
}
258 \wxheading{Return value
}
260 TRUE if the operation succeeded, FALSE otherwise.
264 \helpref{wxIcon::wxIcon
}{wxiconconstr
}
266 \membersection{wxIcon::Ok
}\label{wxiconok
}
268 \constfunc{bool
}{Ok
}{\void}
270 Returns TRUE if icon data is present.
273 \membersection{wxIcon::SaveFile
}\label{wxiconsavefile
}
275 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
277 Saves an icon in the named file.
279 \wxheading{Parameters
}
281 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
283 \docparam{type
}{One of the following values:
287 \twocolitem{{\bf wxBITMAP
\_TYPE\_ICO}}{Save a Windows icon file.
}
288 %\twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Save a GIF icon file.}
289 %\twocolitem{{\bf wxBITMAP\_TYPE\_XBM}}{Save an X bitmap file.}
290 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
293 The validity of these flags depends on the platform and wxWindows configuration.
}
295 \docparam{palette
}{An optional palette used for saving the icon. TODO: this parameter should
296 probably be eliminated; instead the app should set the palette before saving.
}
298 \wxheading{Return value
}
300 TRUE if the operation succeeded, FALSE otherwise.
304 Depending on how wxWindows has been configured, not all formats may be available.
308 \helpref{wxIcon::LoadFile
}{wxiconloadfile
}
311 \membersection{wxIcon::SetDepth
}\label{wxiconsetdepth
}
313 \func{void
}{SetDepth
}{\param{int
}{depth
}}
315 Sets the depth member (does not affect the icon data).
317 \wxheading{Parameters
}
319 \docparam{depth
}{Icon depth.
}
321 \membersection{wxIcon::SetHeight
}\label{wxiconsetheight
}
323 \func{void
}{SetHeight
}{\param{int
}{height
}}
325 Sets the height member (does not affect the icon data).
327 \wxheading{Parameters
}
329 \docparam{height
}{Icon height in pixels.
}
331 \membersection{wxIcon::SetOk
}
333 \func{void
}{SetOk
}{\param{int
}{isOk
}}
335 Sets the validity member (does not affect the icon data).
337 \wxheading{Parameters
}
339 \docparam{isOk
}{Validity flag.
}
341 \membersection{wxIcon::SetWidth
}
343 \func{void
}{SetWidth
}{\param{int
}{width
}}
345 Sets the width member (does not affect the icon data).
347 \wxheading{Parameters
}
349 \docparam{width
}{Icon width in pixels.
}
351 \membersection{wxIcon::operator $=$
}
353 \func{wxIcon\&
}{operator $=$
}{\param{const wxIcon\&
}{icon
}}
355 Assignment operator. This operator does not copy any data, but instead
356 passes a pointer to the data in
{\it icon
} and increments a reference
357 counter. It is a fast operation.
359 \wxheading{Parameters
}
361 \docparam{icon
}{Icon to assign.
}
363 \wxheading{Return value
}
365 Returns 'this' object.
367 \membersection{wxIcon::operator $==$
}
369 \func{bool
}{operator $==$
}{\param{const wxIcon\&
}{icon
}}
371 Equality operator. This operator tests whether the internal data pointers are
374 \wxheading{Parameters
}
376 \docparam{icon
}{Icon to compare with 'this'
}
378 \wxheading{Return value
}
380 Returns TRUE if the icons were effectively equal, FALSE otherwise.
382 \membersection{wxIcon::operator $!=$
}
384 \func{bool
}{operator $!=$
}{\param{const wxIcon\&
}{icon
}}
386 Inequality operator. This operator tests whether the internal data pointers are
387 unequal (a fast test).
389 \wxheading{Parameters
}
391 \docparam{icon
}{Icon to compare with 'this'
}
393 \wxheading{Return value
}
395 Returns TRUE if the icons were unequal, FALSE otherwise.