Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1393

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qiconset.cpp:96 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QIconSet Class</title>
<style type="text/css"><!--
h3.fn,span.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&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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 &lt;<a href="qiconset-h.html">qiconset.h</a>&gt;</tt>
<p><a href="qiconset-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn>enum <a href="#Size-enum"><b>Size</b></a> { Automatic, Small, Large }</div></li>
<li><div class=fn>enum <a href="#Mode-enum"><b>Mode</b></a> { Normal, Disabled, Active }</div></li>
<li><div class=fn>enum <a href="#State-enum"><b>State</b></a> { On, Off }</div></li>
<li><div class=fn><a href="#QIconSet"><b>QIconSet</b></a> ()</div></li>
<li><div class=fn><a href="#QIconSet-2"><b>QIconSet</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, Size&nbsp;size = Automatic )</div></li>
<li><div class=fn><a href="#QIconSet-3"><b>QIconSet</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;smallPix, const&nbsp;QPixmap&nbsp;&amp;&nbsp;largePix )</div></li>
<li><div class=fn><a href="#QIconSet-4"><b>QIconSet</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;other )</div></li>
<li><div class=fn>virtual <a href="#~QIconSet"><b>~QIconSet</b></a> ()</div></li>
<li><div class=fn>void <a href="#reset"><b>reset</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pm, Size&nbsp;size )</div></li>
<li><div class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pm, Size&nbsp;size, Mode&nbsp;mode = Normal, State&nbsp;state = Off )</div></li>
<li><div class=fn>virtual void <a href="#setPixmap-2"><b>setPixmap</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fileName, Size&nbsp;size, Mode&nbsp;mode = Normal, State&nbsp;state = Off )</div></li>
<li><div class=fn>QPixmap <a href="#pixmap"><b>pixmap</b></a> ( Size&nbsp;size, Mode&nbsp;mode, State&nbsp;state = Off ) const</div></li>
<li><div class=fn>QPixmap <a href="#pixmap-2"><b>pixmap</b></a> ( Size&nbsp;size, bool&nbsp;enabled, State&nbsp;state = Off ) const</div></li>
<li><div class=fn>QPixmap <a href="#pixmap-3"><b>pixmap</b></a> () const</div></li>
<li><div class=fn>bool <a href="#isGenerated"><b>isGenerated</b></a> ( Size&nbsp;size, Mode&nbsp;mode, State&nbsp;state = Off ) const</div></li>
<li><div class=fn>void <a href="#clearGenerated"><b>clearGenerated</b></a> ()</div></li>
<li><div class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</div></li>
<li><div class=fn>void <a href="#detach"><b>detach</b></a> ()</div></li>
<li><div class=fn>QIconSet &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;other )</div></li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class=fn>void <a href="#setIconSize"><b>setIconSize</b></a> ( Size&nbsp;s, const&nbsp;QSize&nbsp;&amp;&nbsp;size )</div></li>
<li><div class=fn>const QSize &amp; <a href="#iconSize"><b>iconSize</b></a> ( Size&nbsp;s )</div></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> *tb = new <a href="qtoolbutton.html">QToolButton</a>( <a href="#QIconSet">QIconSet</a>( QPixmap("open.xpm") ), ... );
  </pre>
 
<p> Using whichever <a href="#pixmap">pixmap</a>(s) 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>:
<ul>
<li> <em>Small Normal</em> - can only be calculated from Large Normal.
<li> <em>Small Disabled</em> - calculated from Large Disabled or Small Normal.
<li> <em>Small Active</em> - same as Small Normal unless you set it.
<li> <em>Large Normal</em> - can only be calculated from Small Normal.
<li> <em>Large Disabled</em> - calculated from Small Disabled or Large Normal.
<li> <em>Large Active</em> - same as Large Normal unless you set it.
</ul>
<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. For best results for
calculated pixmaps, you should supply a 22 x 22 pixel pixmap.
<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 no pixmap has been set or
previously generated for the combination QIconSet will generate a
pixmap based on the pixmap(s) it has been given, cache the generated
pixmap for later use, and return it. The <a href="#isGenerated">isGenerated</a>() function
returns TRUE if an icon was generated by QIconSet.
<p> The <a href="#Mode-enum">Disabled</a> appearance is computed using a "shadow" algorithm
that produces results very similar to those used in Microsoft
Windows 95.
<p> 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
22x22 (compatible with Qt 2.x), while the default large size
is 32x32. Please note that these sizes only affect generated icons.
<p> QIconSet provides a function, <a href="#isGenerated">isGenerated</a>(), that indicates whether
an icon was set by the application programmer or computed by
QIconSet itself.
<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-&gt;<a href="qpainter.html#drawPixmap">drawPixmap</a>( pos, icons-&gt;pixmap(QIconSet::<a href="#Size-enum">Small</a>, isEnabled()) );
  }
  </pre>
 
<p> You might also make use of the Active mode, perhaps making your widget
Active 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> <p>See also <a href="qpixmap.html">QPixmap</a>, <a href="qlabel.html">QLabel</a>, <a href="qtoolbutton.html">QToolButton</a>, <a href="qpopupmenu.html">QPopupMenu</a>, <a href="qmainwindow.html#usesBigPixmaps-prop">QMainWindow::usesBigPixmaps</a>, <a href="guibooks.html#fowler">GUI Design Handbook: Iconic Label</a>, <a href="http://cgl.microsoft.com/clipgallerylive/cgl30/eula.asp?nInterface=0
	">Microsoft Icon Gallery</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.
Use <a href="#setPixmap">setPixmap</a>(), <a href="#reset">reset</a>(), or <a href="#operator-eq">operator=</a>() to set some pixmaps.
<p> <p>See also <a href="#reset">reset</a>().

<h3 class=fn><a name="QIconSet-2"></a>QIconSet::QIconSet ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, <a href="qiconset.html#Size-enum">Size</a>&nbsp;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&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;smallPix, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;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&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;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 generated pixmaps.

<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&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp; <a name="iconSize"></a>QIconSet::iconSize ( <a href="qiconset.html#Size-enum">Size</a>&nbsp;s )<tt> [static]</tt>
</h3>
If <em>s</em> is Small, returns the preferred size of a small generated
icon; if <em>s</em> is Large, returns the preferred size of a large
generated icon.
<p> <p>See also <a href="#setIconSize">setIconSize</a>().

<h3 class=fn>bool <a name="isGenerated"></a>QIconSet::isGenerated ( <a href="qiconset.html#Size-enum">Size</a>&nbsp;size, <a href="qiconset.html#Mode-enum">Mode</a>&nbsp;mode, <a href="qiconset.html#State-enum">State</a>&nbsp;state = Off ) const
</h3>
Returns TRUE if the pixmap with size <em>size</em>, mode <em>mode</em> and state
<em>state</em> has been generated; otherwise returns FALSE.

<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>&nbsp;&amp; <a name="operator-eq"></a>QIconSet::operator= ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;other )
</h3>
Assigns <em>other</em> to this icon set and returns a reference to this
icon set.
<p> This is very fast.
<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>&nbsp;size, <a href="qiconset.html#Mode-enum">Mode</a>&nbsp;mode, <a href="qiconset.html#State-enum">State</a>&nbsp;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>&nbsp;size, bool&nbsp;enabled, <a href="qiconset.html#State-enum">State</a>&nbsp;state = Off ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a pixmap with size <em>size</em>, state <em>state</em> and a Mode which is
Normal if <em>enabled</em> is TRUE, or Disabled if <em>enabled</em> is FALSE.

<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&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pm, <a href="qiconset.html#Size-enum">Size</a>&nbsp;size )
</h3>
Sets this icon set to use pixmap <em>pm</em> for the Normal pixmap,
assuming it to be of size <em>size</em>.
<p> This is equivalent to assigning QIconSet(<em>pm</em>, <em>size</em>) to this
icon set.
<p> This function does nothing if <em>pm</em> is a null pixmap.

<h3 class=fn>void <a name="setIconSize"></a>QIconSet::setIconSize ( <a href="qiconset.html#Size-enum">Size</a>&nbsp;s, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;size )<tt> [static]</tt>
</h3>
Set the preferred size for all small or large icons that are generated
after this call. If <em>s</em> is Small, sets the preferred size of small
generated icons to <em>size</em>. Similarly, if <em>s</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.
<p> <p>See also <a href="#iconSize">iconSize</a>().

<h3 class=fn>void <a name="setPixmap"></a>QIconSet::setPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pm, <a href="qiconset.html#Size-enum">Size</a>&nbsp;size, <a href="qiconset.html#Mode-enum">Mode</a>&nbsp;mode = Normal, <a href="qiconset.html#State-enum">State</a>&nbsp;state = Off )<tt> [virtual]</tt>
</h3>
Sets this icon set to provide pixmap <em>pm</em> for size <em>size</em>, mode <em>mode</em> and state <em>state</em>. The icon set may also use <em>pm</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>pm</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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fileName, <a href="qiconset.html#Size-enum">Size</a>&nbsp;size, <a href="qiconset.html#Mode-enum">Mode</a>&nbsp;mode = Normal, <a href="qiconset.html#State-enum">State</a>&nbsp;state = Off )<tt> [virtual]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Sets this icon set to load the file called <em>fileName</em> as a pixmap and
use it for size <em>size</em>, mode <em>mode</em> and state <em>state</em>. The icon set
may also use this pixmap 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.
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.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<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 &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>