summaryrefslogtreecommitdiffstats
path: root/doc/html/qiconset.html
blob: eefb380f1648077d90c9fcc5dc1c97151d110849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!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&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 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&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, Size&nbsp;size = Automatic )</li>
<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>
<li class=fn><a href="#QIconSet-4"><b>QIconSet</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;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&nbsp;QPixmap&nbsp;&amp;&nbsp;pixmap, Size&nbsp;size )</li>
<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>
<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>
<li class=fn>QPixmap <a href="#pixmap"><b>pixmap</b></a> ( Size&nbsp;size, Mode&nbsp;mode, State&nbsp;state = Off ) const</li>
<li class=fn>QPixmap pixmap ( Size&nbsp;size, bool&nbsp;enabled, State&nbsp;state = Off ) const &nbsp;<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&nbsp;size, Mode&nbsp;mode, State&nbsp;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&nbsp;*&nbsp;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 &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QIconSet&nbsp;&amp;&nbsp;other )</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>void <a href="#setIconSize"><b>setIconSize</b></a> ( Size&nbsp;which, const&nbsp;QSize&nbsp;&amp;&nbsp;size )</li>
<li class=fn>const QSize &amp; <a href="#iconSize"><b>iconSize</b></a> ( Size&nbsp;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-&gt;<a href="qpainter.html#drawPixmap">drawPixmap</a>( pos, icons-&gt;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&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 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&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>
</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>&nbsp;*&nbsp;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>&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> 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>&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> <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> <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&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pixmap, <a href="qiconset.html#Size-enum">Size</a>&nbsp;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>&nbsp;which, 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>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&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>
</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&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> 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 &copy; 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 &copy; 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>