Qtopia Home - Classes - Hierachy - Annotated - Functions - Licenses - Reference |
|
The QIconSet class provides a set of differently styled and sized icons. More...
#include <qiconset.h>
The QIconSet class provides a set of differently styled and sized icons.
Once a QIconSet is fed some pixmaps, it can generate smaller, larger, active and disabled pixmaps. Such pixmaps are used by QToolButton, QHeader, QPopupMenu, etc. to show an icon representing a piece of functionality.
The simplest usage of QIconSet is to create one from a QPixmap then use it, allowing Qt to work out all the required icon sizes. For example:
QToolButton *tb = new QToolButton( QIconSet( QPixmap("open.xpm") ), ... );
Using whichever pixmaps you specify as a base, QIconSet provides a set of six icons each with a Size and a Mode:
You can set any of the icons using setPixmap() and when you retrieve one using pixmap(Size,Mode), QIconSet will compute it from the closest other icon and cache it for later.
The Disabled appearance is computed using a "shadow" algorithm which produces results very similar to that 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, QIconSet uses smooth scaling, which can partially blend the color component of pixmaps. If the results look poor, the best solution is to supply both large and small sizes of pixmap.
QIconSet provides a function, isGenerated(), that indicates whether an icon was set by the application programmer or computed by QIconSet itself.
If you write your own widgets that have an option to set a small pixmap, you should consider instead, or additionally, allowing a QIconSet to be set for that pixmap. The Qt 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:
void YourWidget::drawIcon( QPainter* p, QPoint pos )
{
p->drawPixmap( pos, icons->pixmap(isEnabled(), QIconSet::Small) );
}
You might also make use of the Active mode, perhaps making your widget Active when the mouse in inside 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.
See also QPixmap, QLabel, QToolButton, QPopupMenu, QIconViewItem::setViewMode(), QMainWindow::setUsesBigPixmaps(), and GUI Design Handbook: Iconic Label.
This enum type describes the mode for which a pixmap is intended to be provided. The currently defined modes are:
This enum type describes the size for which a pixmap is intended to be provided. The currently defined sizes are:
If a Small pixmap is not set by QIconSet::setPixmap(), then the Large pixmap may be automatically scaled to two-thirds of its size to generate the Small pixmap. Conversely, a Small pixmap will be automatically scaled up by 50% to create a Large pixmap if needed.
See also setPixmap(), pixmap(), QIconViewItem::setViewMode(), and QMainWindow::setUsesBigPixmaps().
See also reset().
The default for size is Automatic, which means that QIconSet will determine if the pixmap is Small or Large from its pixel size. Pixmaps less than 23 pixels wide are considered to be Small.
See also reset().
You will never need to call this function; other QIconSet functions call it as necessary.
This is very fast.
See also detach().
See also reset().
This is equivalent to assigning QIconSet(pm,s) to this icon set.
The size 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. Pixmaps less than 23 pixels wide are considered to be Small.
See also reset().
The size 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. Pixmaps less than 23 pixels wide are considered to be Small.
This file is part of the Qtopia platform, copyright © 1995-2005 Trolltech, all rights reserved.
| Copyright © 2005 Trolltech | Trademarks | Qtopia version 2.2.0
|