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.
329 lines
19 KiB
329 lines
19 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qiconset.cpp:204 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>QIconSet Class</title>
|
|
<style type="text/css"><!--
|
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
|
a:link { color: #004faf; text-decoration: none }
|
|
a:visited { color: #672967; text-decoration: none }
|
|
body { background: #ffffff; color: black; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|
<tr bgcolor="#E5E5E5">
|
|
<td valign=center>
|
|
<a href="index.html">
|
|
<font color="#004faf">Home</font></a>
|
|
| <a href="classes.html">
|
|
<font color="#004faf">All Classes</font></a>
|
|
| <a href="mainclasses.html">
|
|
<font color="#004faf">Main Classes</font></a>
|
|
| <a href="annotated.html">
|
|
<font color="#004faf">Annotated</font></a>
|
|
| <a href="groups.html">
|
|
<font color="#004faf">Grouped Classes</font></a>
|
|
| <a href="functions.html">
|
|
<font color="#004faf">Functions</font></a>
|
|
</td>
|
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QIconSet Class Reference</h1>
|
|
|
|
<p>The QIconSet class provides a set of icons with different
|
|
styles and sizes.
|
|
<a href="#details">More...</a>
|
|
<p><tt>#include <<a href="qiconset-h.html">qiconset.h</a>></tt>
|
|
<p><a href="qiconset-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn>enum <a href="#Size-enum"><b>Size</b></a> { Automatic, Small, Large }</li>
|
|
<li class=fn>enum <a href="#Mode-enum"><b>Mode</b></a> { Normal, Disabled, Active }</li>
|
|
<li class=fn>enum <a href="#State-enum"><b>State</b></a> { On, Off }</li>
|
|
<li class=fn><a href="#QIconSet"><b>QIconSet</b></a> ()</li>
|
|
<li class=fn><a href="#QIconSet-2"><b>QIconSet</b></a> ( const QPixmap & pixmap, Size size = Automatic )</li>
|
|
<li class=fn><a href="#QIconSet-3"><b>QIconSet</b></a> ( const QPixmap & smallPix, const QPixmap & largePix )</li>
|
|
<li class=fn><a href="#QIconSet-4"><b>QIconSet</b></a> ( const QIconSet & other )</li>
|
|
<li class=fn>virtual <a href="#~QIconSet"><b>~QIconSet</b></a> ()</li>
|
|
<li class=fn>void <a href="#reset"><b>reset</b></a> ( const QPixmap & pixmap, Size size )</li>
|
|
<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const QPixmap & pixmap, Size size, Mode mode = Normal, State state = Off )</li>
|
|
<li class=fn>virtual void <a href="#setPixmap-2"><b>setPixmap</b></a> ( const QString & fileName, Size size, Mode mode = Normal, State state = Off )</li>
|
|
<li class=fn>QPixmap <a href="#pixmap"><b>pixmap</b></a> ( Size size, Mode mode, State state = Off ) const</li>
|
|
<li class=fn>QPixmap pixmap ( Size size, bool enabled, State state = Off ) const <em>(obsolete)</em></li>
|
|
<li class=fn>QPixmap <a href="#pixmap-3"><b>pixmap</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isGenerated"><b>isGenerated</b></a> ( Size size, Mode mode, State state = Off ) const</li>
|
|
<li class=fn>void <a href="#clearGenerated"><b>clearGenerated</b></a> ()</li>
|
|
<li class=fn>void <a href="#installIconFactory"><b>installIconFactory</b></a> ( QIconFactory * factory )</li>
|
|
<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
|
|
<li class=fn>void <a href="#detach"><b>detach</b></a> ()</li>
|
|
<li class=fn>QIconSet & <a href="#operator-eq"><b>operator=</b></a> ( const QIconSet & other )</li>
|
|
</ul>
|
|
<h2>Static Public Members</h2>
|
|
<ul>
|
|
<li class=fn>void <a href="#setIconSize"><b>setIconSize</b></a> ( Size which, const QSize & size )</li>
|
|
<li class=fn>const QSize & <a href="#iconSize"><b>iconSize</b></a> ( Size which )</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
<p> The QIconSet class provides a set of icons with different
|
|
styles and sizes.
|
|
<p>
|
|
|
|
|
|
|
|
<p> A QIconSet can generate smaller, larger, active, and disabled pixmaps
|
|
from the set of icons it is given. Such pixmaps are used by
|
|
<a href="qtoolbutton.html">QToolButton</a>, <a href="qheader.html">QHeader</a>, <a href="qpopupmenu.html">QPopupMenu</a>, etc. to show an icon representing a
|
|
particular action.
|
|
<p> The simplest use of QIconSet is to create one from a <a href="qpixmap.html">QPixmap</a> and then
|
|
use it, allowing Qt to work out all the required icon styles and
|
|
sizes. For example:
|
|
<p> <pre>
|
|
<a href="qtoolbutton.html">QToolButton</a> *but = new <a href="qtoolbutton.html">QToolButton</a>( <a href="#QIconSet">QIconSet</a>( QPixmap("open.xpm") ), ... );
|
|
</pre>
|
|
|
|
<p> Using whichever pixmaps you specify as a base, QIconSet provides a
|
|
set of six icons, each with a <a href="#Size-enum">Size</a> and a <a href="#Mode-enum">Mode</a>: Small Normal,
|
|
Small Disabled, Small Active, Large Normal, Large Disabled, and
|
|
Large Active.
|
|
<p> 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.
|
|
<p> You can set any of the icons using <a href="#setPixmap">setPixmap</a>().
|
|
<p> When you retrieve a pixmap using <a href="#pixmap">pixmap</a>(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.
|
|
<p> The <a href="#Mode-enum">Disabled</a> appearance is computed using an algorithm that
|
|
produces results very similar to those used in Microsoft Windows
|
|
95. The <a href="#Mode-enum">Active</a> appearance is identical to the <a href="#Mode-enum">Normal</a>
|
|
appearance unless you use setPixmap() to set it to something
|
|
special.
|
|
<p> When scaling icons, QIconSet uses <a href="qimage.html#smoothScale">smooth scaling</a>, 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.
|
|
<p> You can use the static function <a href="#setIconSize">setIconSize</a>() 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.
|
|
<p> The <a href="#isGenerated">isGenerated</a>() function returns TRUE if an icon was generated by
|
|
QIconSet or by a factory; <a href="#clearGenerated">clearGenerated</a>() clears all cached
|
|
pixmaps.
|
|
<p> <h3> Making Classes that Use QIconSet
|
|
</h3>
|
|
<a name="1"></a><p> 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
|
|
Qt class <a href="qtoolbutton.html">QToolButton</a> is an example of such a widget.
|
|
<p> 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:
|
|
<pre>
|
|
void MyWidget::drawIcon( <a href="qpainter.html">QPainter</a>* p, QPoint pos )
|
|
{
|
|
p-><a href="qpainter.html#drawPixmap">drawPixmap</a>( pos, icons->pixmap(
|
|
QIconSet::<a href="#Size-enum">Small</a>,
|
|
isEnabled() ? QIconSet::<a href="#Mode-enum">Normal</a> :
|
|
QIconSet::<a href="#Mode-enum">Disabled</a>,
|
|
isEnabled() ? QIconSet::<a href="#State-enum">On</a> :
|
|
QIconSet::<a href="#State-enum">Off</a>));
|
|
}
|
|
</pre>
|
|
|
|
<p> You might also make use of the <a href="#Mode-enum">Active</a> mode, perhaps making your
|
|
widget <a href="#Mode-enum">Active</a> when the mouse is over the widget (see <a href="qwidget.html#enterEvent">QWidget::enterEvent</a>()), 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.
|
|
<p> <center><img src="iconset.png" alt="QIconSet"></center>
|
|
<p> <p>See also <a href="qiconfactory.html">QIconFactory</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qmainwindow.html#usesBigPixmaps-prop">QMainWindow::usesBigPixmaps</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Iconic Label</a>, <a href="graphics.html">Graphics Classes</a>, <a href="images.html">Image Processing Classes</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
|
|
|
|
<hr><h2>Member Type Documentation</h2>
|
|
<h3 class=fn><a name="Mode-enum"></a>QIconSet::Mode</h3>
|
|
|
|
<p> This enum type describes the mode for which a pixmap is intended to be
|
|
used.
|
|
The currently defined modes are:
|
|
<ul>
|
|
<li><tt>QIconSet::Normal</tt> -
|
|
Display the pixmap when the user is
|
|
not interacting with the icon, but the
|
|
functionality represented by the icon is available.
|
|
<li><tt>QIconSet::Disabled</tt> -
|
|
Display the pixmap when the
|
|
functionality represented by the icon is not available.
|
|
<li><tt>QIconSet::Active</tt> -
|
|
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.
|
|
</ul>
|
|
<h3 class=fn><a name="Size-enum"></a>QIconSet::Size</h3>
|
|
|
|
<p> This enum type describes the size at which a pixmap is intended to be
|
|
used.
|
|
The currently defined sizes are:
|
|
<ul>
|
|
<li><tt>QIconSet::Automatic</tt> - The size of the pixmap is determined from its
|
|
pixel size. This is a useful default.
|
|
<li><tt>QIconSet::Small</tt> - The pixmap is the smaller of two.
|
|
<li><tt>QIconSet::Large</tt> - The pixmap is the larger of two.
|
|
</ul><p> If a Small pixmap is not set by <a href="#setPixmap">QIconSet::setPixmap</a>(), 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
|
|
<a href="#setIconSize">setIconSize</a>().
|
|
<p> <p>See also <a href="#setIconSize">setIconSize</a>(), <a href="#iconSize">iconSize</a>(), <a href="#setPixmap">setPixmap</a>(), <a href="#pixmap">pixmap</a>(), and <a href="qmainwindow.html#usesBigPixmaps-prop">QMainWindow::usesBigPixmaps</a>.
|
|
|
|
<h3 class=fn><a name="State-enum"></a>QIconSet::State</h3>
|
|
|
|
<p> This enum describes the state for which a pixmap is intended to be
|
|
used. The <em>state</em> can be:
|
|
<ul>
|
|
<li><tt>QIconSet::Off</tt> - Display the pixmap when the widget is in an "off" state
|
|
<li><tt>QIconSet::On</tt> - Display the pixmap when the widget is in an "on" state
|
|
</ul><p> <p>See also <a href="#setPixmap">setPixmap</a>() and <a href="#pixmap">pixmap</a>().
|
|
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<h3 class=fn><a name="QIconSet"></a>QIconSet::QIconSet ()
|
|
</h3>
|
|
Constructs a null icon set.
|
|
<p> <p>See also <a href="#setPixmap">setPixmap</a>() and <a href="#reset">reset</a>().
|
|
|
|
<h3 class=fn><a name="QIconSet-2"></a>QIconSet::QIconSet ( const <a href="qpixmap.html">QPixmap</a> & pixmap, <a href="qiconset.html#Size-enum">Size</a> size = Automatic )
|
|
</h3>
|
|
Constructs an icon set for which the Normal pixmap is <em>pixmap</em>,
|
|
which is assumed to be of size <em>size</em>.
|
|
<p> The default for <em>size</em> is <a href="#Size-enum">Automatic</a>, 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 <a href="#setIconSize">setIconSize</a>() to set the
|
|
preferred size of a generated icon.
|
|
<p> <p>See also <a href="#setIconSize">setIconSize</a>() and <a href="#reset">reset</a>().
|
|
|
|
<h3 class=fn><a name="QIconSet-3"></a>QIconSet::QIconSet ( const <a href="qpixmap.html">QPixmap</a> & smallPix, const <a href="qpixmap.html">QPixmap</a> & largePix )
|
|
</h3> Creates an iconset which uses the pixmap <em>smallPix</em> for for
|
|
displaying a small icon, and the pixmap <em>largePix</em> for displaying a
|
|
large icon.
|
|
|
|
<h3 class=fn><a name="QIconSet-4"></a>QIconSet::QIconSet ( const <a href="qiconset.html">QIconSet</a> & other )
|
|
</h3>
|
|
Constructs a copy of <em>other</em>. This is very fast.
|
|
|
|
<h3 class=fn><a name="~QIconSet"></a>QIconSet::~QIconSet ()<tt> [virtual]</tt>
|
|
</h3>
|
|
Destroys the icon set and frees any allocated resources.
|
|
|
|
<h3 class=fn>void <a name="clearGenerated"></a>QIconSet::clearGenerated ()
|
|
</h3>
|
|
Clears all cached pixmaps, including those obtained from an
|
|
eventual <a href="qiconfactory.html">QIconFactory</a>.
|
|
|
|
<h3 class=fn>void <a name="detach"></a>QIconSet::detach ()
|
|
</h3>
|
|
Detaches this icon set from others with which it may share data.
|
|
<p> You will never need to call this function; other QIconSet functions
|
|
call it as necessary.
|
|
|
|
<h3 class=fn>const <a href="qsize.html">QSize</a> & <a name="iconSize"></a>QIconSet::iconSize ( <a href="qiconset.html#Size-enum">Size</a> which )<tt> [static]</tt>
|
|
</h3>
|
|
If <em>which</em> is Small, returns the preferred size of a small
|
|
generated icon; if <em>which</em> is Large, returns the preferred size
|
|
of a large generated icon.
|
|
<p> <p>See also <a href="#setIconSize">setIconSize</a>().
|
|
|
|
<h3 class=fn>void <a name="installIconFactory"></a>QIconSet::installIconFactory ( <a href="qiconfactory.html">QIconFactory</a> * factory )
|
|
</h3>
|
|
Installs <em>factory</em> as the icon factory for this iconset. The
|
|
icon factory is used to generates pixmaps not set by the user.
|
|
<p> If no icon factory is installed, <a href="qiconfactory.html#defaultFactory">QIconFactory::defaultFactory</a>()
|
|
is used.
|
|
|
|
<h3 class=fn>bool <a name="isGenerated"></a>QIconSet::isGenerated ( <a href="qiconset.html#Size-enum">Size</a> size, <a href="qiconset.html#Mode-enum">Mode</a> mode, <a href="qiconset.html#State-enum">State</a> state = Off ) const
|
|
</h3>
|
|
Returns TRUE if the pixmap with size <em>size</em>, mode <em>mode</em> and
|
|
state <em>state</em> is generated from other pixmaps; otherwise returns
|
|
FALSE.
|
|
<p> A pixmap obtained from a <a href="qiconfactory.html">QIconFactory</a> is considered non-generated.
|
|
|
|
<h3 class=fn>bool <a name="isNull"></a>QIconSet::isNull () const
|
|
</h3>
|
|
Returns TRUE if the icon set is empty; otherwise returns FALSE.
|
|
|
|
<h3 class=fn><a href="qiconset.html">QIconSet</a> & <a name="operator-eq"></a>QIconSet::operator= ( const <a href="qiconset.html">QIconSet</a> & other )
|
|
</h3>
|
|
Assigns <em>other</em> to this icon set and returns a reference to this
|
|
icon set.
|
|
<p> <p>See also <a href="#detach">detach</a>().
|
|
|
|
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap"></a>QIconSet::pixmap ( <a href="qiconset.html#Size-enum">Size</a> size, <a href="qiconset.html#Mode-enum">Mode</a> mode, <a href="qiconset.html#State-enum">State</a> state = Off ) const
|
|
</h3>
|
|
Returns a pixmap with size <em>size</em>, mode <em>mode</em> and state <em>state</em>, generating one if necessary. Generated pixmaps are cached.
|
|
|
|
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-2"></a>QIconSet::pixmap ( <a href="qiconset.html#Size-enum">Size</a> size, bool enabled, <a href="qiconset.html#State-enum">State</a> state = Off ) const
|
|
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
|
|
<p> This is the same as <a href="#pixmap">pixmap</a>(<em>size</em>, <em>enabled</em>, <em>state</em>).
|
|
|
|
<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-3"></a>QIconSet::pixmap () const
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns the pixmap originally provided to the constructor or to
|
|
<a href="#reset">reset</a>(). This is the Normal pixmap of unspecified Size.
|
|
<p> <p>See also <a href="#reset">reset</a>().
|
|
|
|
<h3 class=fn>void <a name="reset"></a>QIconSet::reset ( const <a href="qpixmap.html">QPixmap</a> & pixmap, <a href="qiconset.html#Size-enum">Size</a> size )
|
|
</h3>
|
|
Sets this icon set to use pixmap <em>pixmap</em> for the Normal pixmap,
|
|
assuming it to be of size <em>size</em>.
|
|
<p> This is equivalent to assigning QIconSet(<em>pixmap</em>, <em>size</em>) to this
|
|
icon set.
|
|
<p> This function does nothing if <em>pixmap</em> is a null pixmap.
|
|
|
|
<h3 class=fn>void <a name="setIconSize"></a>QIconSet::setIconSize ( <a href="qiconset.html#Size-enum">Size</a> which, const <a href="qsize.html">QSize</a> & size )<tt> [static]</tt>
|
|
</h3>
|
|
Set the preferred size for all small or large icons that are
|
|
generated after this call. If <em>which</em> is Small, sets the preferred
|
|
size of small generated icons to <em>size</em>. Similarly, if <em>which</em> is
|
|
Large, sets the preferred size of large generated icons to <em>size</em>.
|
|
<p> 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.
|
|
<p> <p>See also <a href="#iconSize">iconSize</a>().
|
|
|
|
<h3 class=fn>void <a name="setPixmap"></a>QIconSet::setPixmap ( const <a href="qpixmap.html">QPixmap</a> & pixmap, <a href="qiconset.html#Size-enum">Size</a> size, <a href="qiconset.html#Mode-enum">Mode</a> mode = Normal, <a href="qiconset.html#State-enum">State</a> state = Off )<tt> [virtual]</tt>
|
|
</h3>
|
|
Sets this icon set to provide pixmap <em>pixmap</em> for size <em>size</em>, mode <em>mode</em> and state <em>state</em>. The icon set may also use <em>pixmap</em> for
|
|
generating other pixmaps if they are not explicitly set.
|
|
<p> The <em>size</em> 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.
|
|
<p> Pixmaps less than the width of a small generated icon are
|
|
considered to be Small. You can use <a href="#setIconSize">setIconSize</a>() to set the preferred
|
|
size of a generated icon.
|
|
<p> This function does nothing if <em>pixmap</em> is a null pixmap.
|
|
<p> <p>See also <a href="#reset">reset</a>().
|
|
|
|
<h3 class=fn>void <a name="setPixmap-2"></a>QIconSet::setPixmap ( const <a href="qstring.html">QString</a> & fileName, <a href="qiconset.html#Size-enum">Size</a> size, <a href="qiconset.html#Mode-enum">Mode</a> mode = Normal, <a href="qiconset.html#State-enum">State</a> state = Off )<tt> [virtual]</tt>
|
|
</h3>
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> The pixmap is loaded from <em>fileName</em> when it becomes necessary.
|
|
|
|
<!-- eof -->
|
|
<hr><p>
|
|
This file is part of the <a href="index.html">Qt toolkit</a>.
|
|
Copyright © 1995-2007
|
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
|
<table width=100% cellspacing=0 border=0><tr>
|
|
<td>Copyright © 2007
|
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
|
<td align=right><div align=right>Qt 3.3.8</div>
|
|
</table></div></address></body>
|
|
</html>
|