The QIconSet class provides a set of icons with different styles and sizes.
.PP
A QIconSet can generate smaller, larger, active, and disabled pixmaps from the set of icons it is given. Such pixmaps are used by QToolButton, QHeader, QPopupMenu, etc. to show an icon representing a particular action.
The simplest use of QIconSet is to create one from a QPixmap and then use it, allowing TQt to work out all the required icon styles and sizes. For example:
QToolButton *but = new QToolButton( QIconSet( QPixmap("open.xpm") ), ... );
.br
.fi
.PP
Using whichever pixmaps you specify as a base, QIconSet provides a set of six icons, each with a Size and a Mode: Small Normal, Small Disabled, Small Active, Large Normal, Large Disabled, and Large Active.
.PP
An additional set of six icons can be provided for widgets that have an "On" or "Off" state, like checkable menu items or toggleable toolbuttons. If you provide pixmaps for the "On" state, but not for the "Off" state, the QIconSet will provide the "Off" pixmaps. You may specify icons for both states in you wish.
.PP
You can set any of the icons using setPixmap().
.PP
When you retrieve a pixmap using pixmap(Size, Mode, State), QIconSet will return the icon that has been set or previously generated for that size, mode and state combination. If none is available, QIconSet will ask the icon factory. If the icon factory cannot provide any (the default), QIconSet generates a pixmap based on the pixmaps it has been given and returns it.
.PP
The Disabled appearance is computed using an algorithm that produces results very similar to those used in Microsoft Windows 95. The Active appearance is identical to the Normal appearance unless you use setPixmap() to set it to something special.
.PP
When scaling icons, QIconSet uses smooth scaling, which can partially blend the color component of pixmaps. If the results look poor, the best solution is to supply pixmaps in both large and small sizes.
.PP
You can use the static function setIconSize() to set the preferred size of the generated large/small icons. The default small size is 22 x 22, while the default large size is 32 x 32. These sizes only affect generated icons.
.PP
The isGenerated() function returns TRUE if an icon was generated by QIconSet or by a factory; clearGenerated() clears all cached pixmaps.
If you write your own widgets that have an option to set a small pixmap, consider allowing a QIconSet to be set for that pixmap. The TQt class QToolButton is an example of such a widget.
Provide a method to set a QIconSet, and when you draw the icon, choose whichever icon is appropriate for the current state of your widget. For example:
You might also make use of the Active mode, perhaps making your widget Active when the mouse is over the widget (see TQWidget::enterEvent()), while the mouse is pressed pending the release that will activate the function, or when it is the currently selected item. If the widget can be toggled, the "On" mode might be used to draw a different icon.
See also QIconFactory, QPixmap, QMainWindow::usesBigPixmaps, GUI Design Handbook: Iconic Label, Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.
.SS "Member Type Documentation"
.SH "QIconSet::Mode"
This enum type describes the mode for which a pixmap is intended to be used. The currently defined modes are:
.TP
\fCQIconSet::Normal\fR - Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available.
.TP
\fCQIconSet::Disabled\fR - Display the pixmap when the functionality represented by the icon is not available.
.TP
\fCQIconSet::Active\fR - Display the pixmap when the functionality represented by the icon is available and the user is interacting with the icon, for example, moving the mouse over it or clicking it.
.SH "QIconSet::Size"
This enum type describes the size at which a pixmap is intended to be used. The currently defined sizes are:
.TP
\fCQIconSet::Automatic\fR - The size of the pixmap is determined from its pixel size. This is a useful default.
.TP
\fCQIconSet::Small\fR - The pixmap is the smaller of two.
.TP
\fCQIconSet::Large\fR - The pixmap is the larger of two.
If a Small pixmap is not set by QIconSet::setPixmap(), the Large pixmap will be automatically scaled down to the size of a small pixmap to generate the Small pixmap when required. Similarly, a Small pixmap will be automatically scaled up to generate a Large pixmap. The preferred sizes for large/small generated icons can be set using setIconSize().
Constructs an icon set for which the Normal pixmap is \fIpixmap\fR, which is assumed to be of size \fIsize\fR.
.PP
The default for \fIsize\fR is Automatic, which means that QIconSet will determine whether the pixmap is Small or Large from its pixel size. Pixmaps less than the width of a small generated icon are considered to be Small. You can use setIconSize() to set the preferred size of a generated icon.
Creates an iconset which uses the pixmap \fIsmallPix\fR for for displaying a small icon, and the pixmap \fIlargePix\fR for displaying a large icon.
.SH "QIconSet::QIconSet ( const QIconSet & other )"
Constructs a copy of \fIother\fR. This is very fast.
.SH "QIconSet::~QIconSet ()\fC [virtual]\fR"
Destroys the icon set and frees any allocated resources.
.SH "void QIconSet::clearGenerated ()"
Clears all cached pixmaps, including those obtained from an eventual QIconFactory.
.SH "void QIconSet::detach ()"
Detaches this icon set from others with which it may share data.
.PP
You will never need to call this function; other QIconSet functions call it as necessary.
.SH "const QSize & QIconSet::iconSize ( Size which )\fC [static]\fR"
If \fIwhich\fR is Small, returns the preferred size of a small generated icon; if \fIwhich\fR is Large, returns the preferred size of a large generated icon.
Set the preferred size for all small or large icons that are generated after this call. If \fIwhich\fR is Small, sets the preferred size of small generated icons to \fIsize\fR. Similarly, if \fIwhich\fR is Large, sets the preferred size of large generated icons to \fIsize\fR.
.PP
Note that cached icons will not be regenerated, so it is recommended that you set the preferred icon sizes before generating any icon sets. Also note that the preferred icon sizes will be ignored for icon sets that have been created using both small and large pixmaps.
.PP
See also iconSize().
.SH "void QIconSet::setPixmap ( const QPixmap & pixmap, Size size, Mode mode = Normal, State state = Off )\fC [virtual]\fR"
Sets this icon set to provide pixmap \fIpixmap\fR for size \fIsize\fR, mode \fImode\fR and state \fIstate\fR. The icon set may also use \fIpixmap\fR for generating other pixmaps if they are not explicitly set.
.PP
The \fIsize\fR can be one of Automatic, Large or Small. If Automatic is used, QIconSet will determine if the pixmap is Small or Large from its pixel size.
.PP
Pixmaps less than the width of a small generated icon are considered to be Small. You can use setIconSize() to set the preferred size of a generated icon.
.PP
This function does nothing if \fIpixmap\fR is a null pixmap.