source: trunk/doc/html/qiconset.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 19.6 KB
RevLine 
[190]1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qiconset.cpp:204 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QIconSet Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<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>
33
34<p>The QIconSet class provides a set of icons with different
35styles and sizes.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qiconset-h.html">qiconset.h</a>&gt;</tt>
38<p><a href="qiconset-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn>enum <a href="#Size-enum"><b>Size</b></a> { Automatic, Small, Large }</li>
42<li class=fn>enum <a href="#Mode-enum"><b>Mode</b></a> { Normal, Disabled, Active }</li>
43<li class=fn>enum <a href="#State-enum"><b>State</b></a> { On, Off }</li>
44<li class=fn><a href="#QIconSet"><b>QIconSet</b></a> ()</li>
45<li class=fn><a href="#QIconSet-2"><b>QIconSet</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, Size&nbsp;size = Automatic )</li>
46<li class=fn><a href="#QIconSet-3"><b>QIconSet</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;smallPix, const&nbsp;QPixmap&nbsp;&amp;&nbsp;largePix )</li>
47<li class=fn><a href="#QIconSet-4"><b>QIconSet</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;other )</li>
48<li class=fn>virtual <a href="#~QIconSet"><b>~QIconSet</b></a> ()</li>
49<li class=fn>void <a href="#reset"><b>reset</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, Size&nbsp;size )</li>
50<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, Size&nbsp;size, Mode&nbsp;mode = Normal, State&nbsp;state = Off )</li>
51<li 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 )</li>
52<li class=fn>QPixmap <a href="#pixmap"><b>pixmap</b></a> ( Size&nbsp;size, Mode&nbsp;mode, State&nbsp;state = Off ) const</li>
53<li class=fn>QPixmap pixmap ( Size&nbsp;size, bool&nbsp;enabled, State&nbsp;state = Off ) const &nbsp;<em>(obsolete)</em></li>
54<li class=fn>QPixmap <a href="#pixmap-3"><b>pixmap</b></a> () const</li>
55<li class=fn>bool <a href="#isGenerated"><b>isGenerated</b></a> ( Size&nbsp;size, Mode&nbsp;mode, State&nbsp;state = Off ) const</li>
56<li class=fn>void <a href="#clearGenerated"><b>clearGenerated</b></a> ()</li>
57<li class=fn>void <a href="#installIconFactory"><b>installIconFactory</b></a> ( QIconFactory&nbsp;*&nbsp;factory )</li>
58<li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li>
59<li class=fn>void <a href="#detach"><b>detach</b></a> ()</li>
60<li class=fn>QIconSet &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;other )</li>
61</ul>
62<h2>Static Public Members</h2>
63<ul>
64<li class=fn>void <a href="#setIconSize"><b>setIconSize</b></a> ( Size&nbsp;which, const&nbsp;QSize&nbsp;&amp;&nbsp;size )</li>
65<li class=fn>const QSize &amp; <a href="#iconSize"><b>iconSize</b></a> ( Size&nbsp;which )</li>
66</ul>
67<hr><a name="details"></a><h2>Detailed Description</h2>
68
69<p> The QIconSet class provides a set of icons with different
70styles and sizes.
71<p>
72
73
74
75<p> A QIconSet can generate smaller, larger, active, and disabled pixmaps
76from the set of icons it is given. Such pixmaps are used by
77<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
78particular action.
79<p> The simplest use of QIconSet is to create one from a <a href="qpixmap.html">QPixmap</a> and then
80use it, allowing Qt to work out all the required icon styles and
81sizes. For example:
82<p> <pre>
83 <a href="qtoolbutton.html">QToolButton</a> *but = new <a href="qtoolbutton.html">QToolButton</a>( <a href="#QIconSet">QIconSet</a>( QPixmap("open.xpm") ), ... );
84 </pre>
85
86<p> Using whichever pixmaps you specify as a base, QIconSet provides a
87set of six icons, each with a <a href="#Size-enum">Size</a> and a <a href="#Mode-enum">Mode</a>: Small Normal,
88Small Disabled, Small Active, Large Normal, Large Disabled, and
89Large Active.
90<p> An additional set of six icons can be provided for widgets that have
91an "On" or "Off" state, like checkable menu items or toggleable
92toolbuttons. If you provide pixmaps for the "On" state, but not for
93the "Off" state, the QIconSet will provide the "Off" pixmaps. You may
94specify icons for both states in you wish.
95<p> You can set any of the icons using <a href="#setPixmap">setPixmap</a>().
96<p> When you retrieve a pixmap using <a href="#pixmap">pixmap</a>(Size, Mode, State),
97QIconSet will return the icon that has been set or previously
98generated for that size, mode and state combination. If none is
99available, QIconSet will ask the icon factory. If the icon factory
100cannot provide any (the default), QIconSet generates a pixmap based
101on the pixmaps it has been given and returns it.
102<p> The <a href="#Mode-enum">Disabled</a> appearance is computed using an algorithm that
103produces results very similar to those used in Microsoft Windows
10495. The <a href="#Mode-enum">Active</a> appearance is identical to the <a href="#Mode-enum">Normal</a>
105appearance unless you use setPixmap() to set it to something
106special.
107<p> When scaling icons, QIconSet uses <a href="qimage.html#smoothScale">smooth scaling</a>, which can partially blend the color component
108of pixmaps. If the results look poor, the best solution
109is to supply pixmaps in both large and small sizes.
110<p> You can use the static function <a href="#setIconSize">setIconSize</a>() to set the preferred
111size of the generated large/small icons. The default small size is
11222 x 22, while the default large size is 32 x 32. These sizes only
113affect generated icons.
114<p> The <a href="#isGenerated">isGenerated</a>() function returns TRUE if an icon was generated by
115QIconSet or by a factory; <a href="#clearGenerated">clearGenerated</a>() clears all cached
116pixmaps.
117<p> <h3> Making Classes that Use QIconSet
118</h3>
119<a name="1"></a><p> If you write your own widgets that have an option to set a small
120pixmap, consider allowing a QIconSet to be set for that pixmap. The
121Qt class <a href="qtoolbutton.html">QToolButton</a> is an example of such a widget.
122<p> Provide a method to set a QIconSet, and when you draw the icon, choose
123whichever icon is appropriate for the current state of your widget.
124For example:
125<pre>
126 void MyWidget::drawIcon( <a href="qpainter.html">QPainter</a>* p, QPoint pos )
127 {
128 p-&gt;<a href="qpainter.html#drawPixmap">drawPixmap</a>( pos, icons-&gt;pixmap(
129 QIconSet::<a href="#Size-enum">Small</a>,
130 isEnabled() ? QIconSet::<a href="#Mode-enum">Normal</a> :
131 QIconSet::<a href="#Mode-enum">Disabled</a>,
132 isEnabled() ? QIconSet::<a href="#State-enum">On</a> :
133 QIconSet::<a href="#State-enum">Off</a>));
134 }
135 </pre>
136
137<p> You might also make use of the <a href="#Mode-enum">Active</a> mode, perhaps making your
138widget <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
139release that will activate the function, or when it is the currently
140selected item. If the widget can be toggled, the "On" mode might be
141used to draw a different icon.
142<p> <center><img src="iconset.png" alt="QIconSet"></center>
143<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>.
144
145<hr><h2>Member Type Documentation</h2>
146<h3 class=fn><a name="Mode-enum"></a>QIconSet::Mode</h3>
147
148<p> This enum type describes the mode for which a pixmap is intended to be
149used.
150The currently defined modes are:
151<ul>
152<li><tt>QIconSet::Normal</tt> -
153Display the pixmap when the user is
154not interacting with the icon, but the
155functionality represented by the icon is available.
156<li><tt>QIconSet::Disabled</tt> -
157Display the pixmap when the
158functionality represented by the icon is not available.
159<li><tt>QIconSet::Active</tt> -
160Display the pixmap when the
161functionality represented by the icon is available and
162the user is interacting with the icon, for example, moving the
163mouse over it or clicking it.
164</ul>
165<h3 class=fn><a name="Size-enum"></a>QIconSet::Size</h3>
166
167<p> This enum type describes the size at which a pixmap is intended to be
168used.
169The currently defined sizes are:
170<ul>
171<li><tt>QIconSet::Automatic</tt> - The size of the pixmap is determined from its
172pixel size. This is a useful default.
173<li><tt>QIconSet::Small</tt> - The pixmap is the smaller of two.
174<li><tt>QIconSet::Large</tt> - The pixmap is the larger of two.
175</ul><p> If a Small pixmap is not set by <a href="#setPixmap">QIconSet::setPixmap</a>(), the Large
176pixmap will be automatically scaled down to the size of a small pixmap
177to generate the Small pixmap when required. Similarly, a Small pixmap
178will be automatically scaled up to generate a Large pixmap. The
179preferred sizes for large/small generated icons can be set using
180<a href="#setIconSize">setIconSize</a>().
181<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>.
182
183<h3 class=fn><a name="State-enum"></a>QIconSet::State</h3>
184
185<p> This enum describes the state for which a pixmap is intended to be
186used. The <em>state</em> can be:
187<ul>
188<li><tt>QIconSet::Off</tt> - Display the pixmap when the widget is in an "off" state
189<li><tt>QIconSet::On</tt> - Display the pixmap when the widget is in an "on" state
190</ul><p> <p>See also <a href="#setPixmap">setPixmap</a>() and <a href="#pixmap">pixmap</a>().
191
192<hr><h2>Member Function Documentation</h2>
193<h3 class=fn><a name="QIconSet"></a>QIconSet::QIconSet ()
194</h3>
195Constructs a null icon set.
196<p> <p>See also <a href="#setPixmap">setPixmap</a>() and <a href="#reset">reset</a>().
197
198<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 )
199</h3>
200Constructs an icon set for which the Normal pixmap is <em>pixmap</em>,
201which is assumed to be of size <em>size</em>.
202<p> The default for <em>size</em> is <a href="#Size-enum">Automatic</a>, which means that QIconSet
203will determine whether the pixmap is Small or Large from its pixel
204size. Pixmaps less than the width of a small generated icon are
205considered to be Small. You can use <a href="#setIconSize">setIconSize</a>() to set the
206preferred size of a generated icon.
207<p> <p>See also <a href="#setIconSize">setIconSize</a>() and <a href="#reset">reset</a>().
208
209<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 )
210</h3> Creates an iconset which uses the pixmap <em>smallPix</em> for for
211displaying a small icon, and the pixmap <em>largePix</em> for displaying a
212large icon.
213
214<h3 class=fn><a name="QIconSet-4"></a>QIconSet::QIconSet ( const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;other )
215</h3>
216Constructs a copy of <em>other</em>. This is very fast.
217
218<h3 class=fn><a name="~QIconSet"></a>QIconSet::~QIconSet ()<tt> [virtual]</tt>
219</h3>
220Destroys the icon set and frees any allocated resources.
221
222<h3 class=fn>void <a name="clearGenerated"></a>QIconSet::clearGenerated ()
223</h3>
224Clears all cached pixmaps, including those obtained from an
225eventual <a href="qiconfactory.html">QIconFactory</a>.
226
227<h3 class=fn>void <a name="detach"></a>QIconSet::detach ()
228</h3>
229Detaches this icon set from others with which it may share data.
230<p> You will never need to call this function; other QIconSet functions
231call it as necessary.
232
233<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;which )<tt> [static]</tt>
234</h3>
235If <em>which</em> is Small, returns the preferred size of a small
236generated icon; if <em>which</em> is Large, returns the preferred size
237of a large generated icon.
238<p> <p>See also <a href="#setIconSize">setIconSize</a>().
239
240<h3 class=fn>void <a name="installIconFactory"></a>QIconSet::installIconFactory ( <a href="qiconfactory.html">QIconFactory</a>&nbsp;*&nbsp;factory )
241</h3>
242Installs <em>factory</em> as the icon factory for this iconset. The
243icon factory is used to generates pixmaps not set by the user.
244<p> If no icon factory is installed, <a href="qiconfactory.html#defaultFactory">QIconFactory::defaultFactory</a>()
245is used.
246
247<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
248</h3>
249Returns TRUE if the pixmap with size <em>size</em>, mode <em>mode</em> and
250state <em>state</em> is generated from other pixmaps; otherwise returns
251FALSE.
252<p> A pixmap obtained from a <a href="qiconfactory.html">QIconFactory</a> is considered non-generated.
253
254<h3 class=fn>bool <a name="isNull"></a>QIconSet::isNull () const
255</h3>
256Returns TRUE if the icon set is empty; otherwise returns FALSE.
257
258<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 )
259</h3>
260Assigns <em>other</em> to this icon set and returns a reference to this
261icon set.
262<p> <p>See also <a href="#detach">detach</a>().
263
264<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
265</h3>
266Returns a pixmap with size <em>size</em>, mode <em>mode</em> and state <em>state</em>, generating one if necessary. Generated pixmaps are cached.
267
268<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
269</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
270<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
271<p> This is the same as <a href="#pixmap">pixmap</a>(<em>size</em>, <em>enabled</em>, <em>state</em>).
272
273<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap-3"></a>QIconSet::pixmap () const
274</h3>
275This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
276<p> Returns the pixmap originally provided to the constructor or to
277<a href="#reset">reset</a>(). This is the Normal pixmap of unspecified Size.
278<p> <p>See also <a href="#reset">reset</a>().
279
280<h3 class=fn>void <a name="reset"></a>QIconSet::reset ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, <a href="qiconset.html#Size-enum">Size</a>&nbsp;size )
281</h3>
282Sets this icon set to use pixmap <em>pixmap</em> for the Normal pixmap,
283assuming it to be of size <em>size</em>.
284<p> This is equivalent to assigning QIconSet(<em>pixmap</em>, <em>size</em>) to this
285icon set.
286<p> This function does nothing if <em>pixmap</em> is a null pixmap.
287
288<h3 class=fn>void <a name="setIconSize"></a>QIconSet::setIconSize ( <a href="qiconset.html#Size-enum">Size</a>&nbsp;which, const&nbsp;<a href="qsize.html">QSize</a>&nbsp;&amp;&nbsp;size )<tt> [static]</tt>
289</h3>
290Set the preferred size for all small or large icons that are
291generated after this call. If <em>which</em> is Small, sets the preferred
292size of small generated icons to <em>size</em>. Similarly, if <em>which</em> is
293Large, sets the preferred size of large generated icons to <em>size</em>.
294<p> Note that cached icons will not be regenerated, so it is recommended
295that you set the preferred icon sizes before generating any icon sets.
296Also note that the preferred icon sizes will be ignored for icon sets
297that have been created using both small and large pixmaps.
298<p> <p>See also <a href="#iconSize">iconSize</a>().
299
300<h3 class=fn>void <a name="setPixmap"></a>QIconSet::setPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, <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>
301</h3>
302Sets 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
303generating other pixmaps if they are not explicitly set.
304<p> The <em>size</em> can be one of Automatic, Large or Small. If Automatic is
305used, QIconSet will determine if the pixmap is Small or Large from its
306pixel size.
307<p> Pixmaps less than the width of a small generated icon are
308considered to be Small. You can use <a href="#setIconSize">setIconSize</a>() to set the preferred
309size of a generated icon.
310<p> This function does nothing if <em>pixmap</em> is a null pixmap.
311<p> <p>See also <a href="#reset">reset</a>().
312
313<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>
314</h3>
315This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
316<p> The pixmap is loaded from <em>fileName</em> when it becomes necessary.
317
318<!-- eof -->
319<hr><p>
320This file is part of the <a href="index.html">Qt toolkit</a>.
321Copyright &copy; 1995-2007
322<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
323<table width=100% cellspacing=0 border=0><tr>
324<td>Copyright &copy; 2007
325<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
326<td align=right><div align=right>Qt 3.3.8</div>
327</table></div></address></body>
328</html>
Note: See TracBrowser for help on using the repository browser.