You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/man/man3/tqiconset.3qt

285 lines
14 KiB

'\" t
.TH QIconSet 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QIconSet \- Set of icons with different styles and sizes
.SH SYNOPSIS
\fC#include <ntqiconset.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "enum \fBSize\fR { Automatic, Small, Large }"
.br
.ti -1c
.BI "enum \fBMode\fR { Normal, Disabled, Active }"
.br
.ti -1c
.BI "enum \fBState\fR { On, Off }"
.br
.ti -1c
.BI "\fBQIconSet\fR ()"
.br
.ti -1c
.BI "\fBQIconSet\fR ( const QPixmap & pixmap, Size size = Automatic )"
.br
.ti -1c
.BI "\fBQIconSet\fR ( const QPixmap & smallPix, const QPixmap & largePix )"
.br
.ti -1c
.BI "\fBQIconSet\fR ( const QIconSet & other )"
.br
.ti -1c
.BI "virtual \fB~QIconSet\fR ()"
.br
.ti -1c
.BI "void \fBreset\fR ( const QPixmap & pixmap, Size size )"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( const QPixmap & pixmap, Size size, Mode mode = Normal, State state = Off )"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( const QString & fileName, Size size, Mode mode = Normal, State state = Off )"
.br
.ti -1c
.BI "QPixmap \fBpixmap\fR ( Size size, Mode mode, State state = Off ) const"
.br
.ti -1c
.BI "QPixmap pixmap ( Size size, bool enabled, State state = Off ) const \fI(obsolete)\fR"
.br
.ti -1c
.BI "QPixmap \fBpixmap\fR () const"
.br
.ti -1c
.BI "bool \fBisGenerated\fR ( Size size, Mode mode, State state = Off ) const"
.br
.ti -1c
.BI "void \fBclearGenerated\fR ()"
.br
.ti -1c
.BI "void \fBinstallIconFactory\fR ( QIconFactory * factory )"
.br
.ti -1c
.BI "bool \fBisNull\fR () const"
.br
.ti -1c
.BI "void \fBdetach\fR ()"
.br
.ti -1c
.BI "QIconSet & \fBoperator=\fR ( const QIconSet & other )"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "void \fBsetIconSize\fR ( Size which, const QSize & size )"
.br
.ti -1c
.BI "const QSize & \fBiconSize\fR ( Size which )"
.br
.in -1c
.SH DESCRIPTION
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.
.PP
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:
.PP
.nf
.br
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.
.SH "Making Classes that Use QIconSet"
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.
.PP
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:
.PP
.nf
.br
void MyWidget::drawIcon( QPainter* p, QPoint pos )
.br
{
.br
p->drawPixmap( pos, icons->pixmap(
.br
QIconSet::Small,
.br
isEnabled() ? QIconSet::Normal :
.br
QIconSet::Disabled,
.br
isEnabled() ? QIconSet::On :
.br
QIconSet::Off));
.br
}
.br
.fi
.PP
You might also make use of the Active mode, perhaps making your widget Active when the mouse is over the widget (see QWidget::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.
.PP
<center>
.ce 1
.B "[Image Omitted]"
.PP
</center>
.PP
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.
.PP
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().
.PP
See also setIconSize(), iconSize(), setPixmap(), pixmap(), and QMainWindow::usesBigPixmaps.
.SH "QIconSet::State"
This enum describes the state for which a pixmap is intended to be used. The \fIstate\fR can be:
.TP
\fCQIconSet::Off\fR - Display the pixmap when the widget is in an "off" state
.TP
\fCQIconSet::On\fR - Display the pixmap when the widget is in an "on" state
.PP
See also setPixmap() and pixmap().
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QIconSet::QIconSet ()"
Constructs a null icon set.
.PP
See also setPixmap() and reset().
.SH "QIconSet::QIconSet ( const QPixmap & pixmap, Size size = Automatic )"
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.
.PP
See also setIconSize() and reset().
.SH "QIconSet::QIconSet ( const QPixmap & smallPix, const QPixmap & largePix )"
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.
.PP
See also setIconSize().
.SH "void QIconSet::installIconFactory ( QIconFactory * factory )"
Installs \fIfactory\fR as the icon factory for this iconset. The icon factory is used to generates pixmaps not set by the user.
.PP
If no icon factory is installed, QIconFactory::defaultFactory() is used.
.SH "bool QIconSet::isGenerated ( Size size, Mode mode, State state = Off ) const"
Returns TRUE if the pixmap with size \fIsize\fR, mode \fImode\fR and state \fIstate\fR is generated from other pixmaps; otherwise returns FALSE.
.PP
A pixmap obtained from a QIconFactory is considered non-generated.
.SH "bool QIconSet::isNull () const"
Returns TRUE if the icon set is empty; otherwise returns FALSE.
.SH "QIconSet & QIconSet::operator= ( const QIconSet & other )"
Assigns \fIother\fR to this icon set and returns a reference to this icon set.
.PP
See also detach().
.SH "QPixmap QIconSet::pixmap ( Size size, Mode mode, State state = Off ) const"
Returns a pixmap with size \fIsize\fR, mode \fImode\fR and state \fIstate\fR, generating one if necessary. Generated pixmaps are cached.
.SH "QPixmap QIconSet::pixmap ( Size size, bool enabled, State state = Off ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This is the same as pixmap(\fIsize\fR, \fIenabled\fR, \fIstate\fR).
.SH "QPixmap QIconSet::pixmap () const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the pixmap originally provided to the constructor or to reset(). This is the Normal pixmap of unspecified Size.
.PP
See also reset().
.SH "void QIconSet::reset ( const QPixmap & pixmap, Size size )"
Sets this icon set to use pixmap \fIpixmap\fR for the Normal pixmap, assuming it to be of size \fIsize\fR.
.PP
This is equivalent to assigning QIconSet(\fIpixmap\fR, \fIsize\fR) to this icon set.
.PP
This function does nothing if \fIpixmap\fR is a null pixmap.
.SH "void QIconSet::setIconSize ( Size which, const QSize & size )\fC [static]\fR"
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.
.PP
See also reset().
.SH "void QIconSet::setPixmap ( const QString & fileName, Size size, Mode mode = Normal, State state = Off )\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
The pixmap is loaded from \fIfileName\fR when it becomes necessary.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqiconset.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqiconset.3qt) and the Qt
version (3.3.8).