A TQIconSet 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 TQIconSet 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:
Using whichever pixmaps you specify as a base, TQIconSet 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.
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 TQIconSet will provide the "Off" pixmaps. You may specify icons for both states in you wish.
When you retrieve a pixmap using pixmap(Size, Mode, State), TQIconSet will return the icon that has been set or previously generated for that size, mode and state combination. If none is available, TQIconSet will ask the icon factory. If the icon factory cannot provide any (the default), TQIconSet generates a pixmap based on the pixmaps it has been given and returns it.
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.
When scaling icons, TQIconSet 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.
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.
The isGenerated() function returns TRUE if an icon was generated by TQIconSet or by a factory; clearGenerated() clears all cached pixmaps.
.SH "Making Classes that Use TQIconSet"
If you write your own widgets that have an option to set a small pixmap, consider allowing a TQIconSet to be set for that pixmap. The TQt class QToolButton is an example of such a widget.
Provide a method to set a TQIconSet, 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.
\fCTQIconSet::Normal\fR - Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available.
\fCTQIconSet::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.
If a Small pixmap is not set by TQIconSet::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().
The default for \fIsize\fR is Automatic, which means that TQIconSet 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.
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.
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.
The \fIsize\fR can be one of Automatic, Large or Small. If Automatic is used, TQIconSet will determine if 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.
.PP
This function does nothing if \fIpixmap\fR is a null pixmap.