File: qiconset.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (222 lines) | stat: -rw-r--r-- 14,208 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - 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: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QIconSet Class Reference</h1><br clear="all">
<p>
The QIconSet class provides a set of differently styled and sized icons.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qiconset-h.html">qiconset.h</a>&gt;</code>
<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"><b>Size</b></a>{Automatic, Small, Large}</div>
<li><div class="fn">enum<a href="#Mode"><b>Mode</b></a>{Normal, Disabled, Active}</div>
<li><div class="fn"><a href="#c42106"><b>QIconSet</b></a>()</div>
<li><div class="fn"><a href="#66c1d6"><b>QIconSet</b></a>(constQPixmap&amp;, Size=Automatic)</div>
<li><div class="fn"><a href="#fea340"><b>QIconSet</b></a>(constQPixmap&amp;smallPix, constQPixmap&amp;largePix)</div>
<li><div class="fn"><a href="#13449a"><b>QIconSet</b></a>(constQIconSet&amp;)</div>
<li><div class="fn">virtual<a href="#c5dd08"><b>~QIconSet</b></a>()</div>
<li><div class="fn">void<a href="#631e1e"><b>reset</b></a>(constQPixmap&amp;, Size)</div>
<li><div class="fn">virtualvoid<a href="#50bce3"><b>setPixmap</b></a>(constQPixmap&amp;, Size, Mode=Normal)</div>
<li><div class="fn">virtualvoid<a href="#f0362d"><b>setPixmap</b></a>(constQString&amp;, Size, Mode=Normal)</div>
<li><div class="fn">QPixmap<a href="#61e136"><b>pixmap</b></a>(Size, Mode)const</div>
<li><div class="fn">QPixmap<a href="#7159de"><b>pixmap</b></a>(Sizes, boolenabled)const</div>
<li><div class="fn">QPixmap<a href="#c88c17"><b>pixmap</b></a>()const</div>
<li><div class="fn">bool<a href="#fe29dd"><b>isGenerated</b></a>(Size, Mode)const</div>
<li><div class="fn">bool<a href="#90228e"><b>isNull</b></a>()const</div>
<li><div class="fn">void<a href="#5f0cae"><b>detach</b></a>()</div>
<li><div class="fn">QIconSet&amp;<a href="#f4830c"><b>operator=</b></a>(constQIconSet&amp;)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QIconSet class provides a set of differently styled and sized icons.
<p>
Once a QIconSet is fed some pixmaps,
it can generate smaller, larger, active and disabled pixmaps.
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 piece of functionality.
<p>The simplest usage of QIconSet is to create one from a <a href="qpixmap.html">QPixmap</a> then
use it, allowing Qt to work out all the required icon sizes. For example:
<p><pre>  <a href="qtoolbutton.html">QToolButton</a> *tb = new <a href="qtoolbutton.html">QToolButton</a>( <a href="qiconset.html">QIconSet</a>( <a href="qpixmap.html">QPixmap</a>("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">Size</a> and
a <a href="#Mode">Mode</a>:
<ul>
<li> <i>Small Normal</i> - can only be calculated from Large Normal.
<li> <i>Small Disabled</i> - calculated from Large Disabled or Small Normal.
<li> <i>Small Active</i> - same as Small Normal unless you set it.
<li> <i>Large Normal</i> - can only be calculated from Small Normal.
<li> <i>Large Disabled</i> - calculated from Small Disabled or Large Normal.
<li> <i>Large Active</i> - same as Large Normal unless you set it.
</ul>
<p>You can set any of the icons using <a href="#50bce3">setPixmap</a>() and when you retrieve
one using <a href="#61e136">pixmap</a>(<a href="#Size">Size</a>,<a href="#Mode">Mode</a>), QIconSet will compute it from the
closest other icon and cache it for later.
<p>The <code>Disabled</code> appearance is computed using a "shadow" algorithm
which produces results very similar to that used in Microsoft
Windows 95.
<p>The <code>Active</code> appearance is identical to the <code>Normal</code> appearance
unless you use setPixmap() to set it to something special.
<p>When scaling icons, QIconSet uses <a href="qimage.html#239910">smooth scaling</a>, 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.
<p>QIconSet provides a function, <a href="#fe29dd">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>
<p>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.
<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 YourWidget::drawIcon( <a href="qpainter.html">QPainter</a>* p, QPoint pos )
  {
      p-&gt;<a href="qpainter.html#c64b89">drawPixmap</a>( pos, icons-&gt;pixmap(isEnabled(), QIconSet::Small) );
  }
</pre>
<p>You might also make use of the Active mode, perhaps making your widget
Active when the mouse in inside the widget (see <a href="qwidget.html#5d1d18">QWidget::enterEvent</a>),
while the mouse is pressed pending the release that will activate
the function, or when it is the currently selected item.
<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>, QIconViewItem::setViewMode(), <a href="qmainwindow.html#5f2c62">QMainWindow::setUsesBigPixmaps</a>(), <a href="guibooks.html#fowler">GUI Design Handbook: Iconic Label</a> and <a href="http://cgl.microsoft.com/clipgallerylive/cgl30/eula.asp?nInterface=0">Microsoft Icon Gallery.</a>

<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="Mode">QIconSet::Mode</a></h3>
This enum type describes the mode for which a pixmap is intended to be
provided.
The currently defined modes are:
<p><ul>
<li> <code>Normal</code>
- the pixmap to be displayed when the user is
not interacting with the icon, but when the
functionality represented by the icon is available.
<li> <code>Disabled</code>
- the pixmap to be displayed when the
functionality represented by the icon is not available.
<li> <code>Active</code>
- the pixmap to be displayed when the
functionality represented by the icon is available and
the user is interacting with the icon, such as by pointing
at it or by invoking it.
</ul>
<h3 class="fn"><a name="Size">QIconSet::Size</a></h3>
This enum type describes the size for which a pixmap is intended to be
provided.
The currently defined sizes are:
<p><ul>
<li> <code>Automatic</code> - the size of the pixmap is determined from its
pixel size. This is a useful default.
<li> <code>Small</code> - the pixmap is the smaller of two.
<li> <code>Large</code> - the pixmap is the larger of two
</ul>
<p>If a Small pixmap is not set by <a href="#50bce3">QIconSet::setPixmap</a>(), 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.
<p>See also  <a href="#50bce3">setPixmap</a>(), <a href="#61e136">pixmap</a>(), QIconViewItem::setViewMode() and <a href="qmainwindow.html#5f2c62">QMainWindow::setUsesBigPixmaps</a>().
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="c42106"></a>QIconSet::QIconSet()</h3>
<p>Constructs an icon set of <a href="qpixmap.html#7803c4">null</a> pixmaps.
Use <a href="#50bce3">setPixmap</a>(), <a href="#631e1e">reset</a>(), or <a href="#f4830c">operator=</a>() to set some pixmaps.
<p>See also  <a href="#631e1e">reset</a>().
<h3 class="fn"><a name="66c1d6"></a>QIconSet::QIconSet(const<a href="qpixmap.html">QPixmap</a>&amp;pixmap, <a href="qiconset.html#Size">Size</a>size=Automatic)</h3>
<p>Constructs an icon set for which the Normal pixmap is
<em>pixmap,</em> which is assumed to be the given <em>size.</em>
<p>The default for <em>size</em> is <code>Automatic,</code> 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.
<p>See also  <a href="#631e1e">reset</a>().
<h3 class="fn"><a name="fea340"></a>QIconSet::QIconSet(const<a href="qpixmap.html">QPixmap</a>&amp;smallPix, const<a href="qpixmap.html">QPixmap</a>&amp;largePix)</h3>
<p>Creates an iconset which uses the pixmap <em>smallPix</em> for for
displaying small a small icon, and <em>largePix</em> for displaying a large
one.
<h3 class="fn"><a name="13449a"></a>QIconSet::QIconSet(constQIconSet&amp;other)</h3>
<p>Constructs a copy of <em>other.</em>  This is very fast.
<h3 class="fn"><a name="c5dd08"></a>QIconSet::~QIconSet() <code>[virtual]</code></h3>
<p>Destructs the icon set and frees any allocated resources.
<h3 class="fn">void<a name="5f0cae"></a>QIconSet::detach()</h3>
<p>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">bool<a name="fe29dd"></a>QIconSet::isGenerated(<a href="qiconset.html#Size">Size</a>s, <a href="qiconset.html#Mode">Mode</a>m)const</h3>
<p>Returns TRUE if the variant with size <em>s</em> and mode <em>m</em> was
automatically generated, and FALSE if it was not. This mainly
useful for development purposes.
<h3 class="fn">bool<a name="90228e"></a>QIconSet::isNull()const</h3>
<p>Returns TRUE if the icon set is empty. Currently, a QIconSet
is never empty (although it may contain null pixmaps).
<h3 class="fn">QIconSet&amp;<a name="f4830c"></a>QIconSet::operator=(constQIconSet&amp;other)</h3>
<p>Assigns <em>other</em> to this icon set and returns a reference to this
icon set.
<p>This is very fast.
<p>See also  <a href="#5f0cae">detach</a>().
<h3 class="fn"><a href="qpixmap.html">QPixmap</a><a name="c88c17"></a>QIconSet::pixmap()const</h3>
<p>Returns the pixmap originally provided to the constructor or
to <a href="#631e1e">reset</a>().  This is the Normal pixmap of unspecified <a href="#Size">Size</a>.
<p>See also  <a href="#631e1e">reset</a>().
<h3 class="fn"><a href="qpixmap.html">QPixmap</a><a name="61e136"></a>QIconSet::pixmap(<a href="qiconset.html#Size">Size</a>s, <a href="qiconset.html#Mode">Mode</a>m)const</h3>
<p>Returns a pixmap with size <em>s</em> and mode <em>m,</em> generating one if
needed. Generated pixmaps are cached.
<h3 class="fn"><a href="qpixmap.html">QPixmap</a><a name="7159de"></a>QIconSet::pixmap(<a href="qiconset.html#Size">Size</a>s, boolenabled)const</h3>
<p>Returns a pixmap with size <em>s,</em> and <a href="#Mode">Mode</a> either Normal or Disabled,
depending on the value of <em>enabled.</em>
<h3 class="fn">void<a name="631e1e"></a>QIconSet::reset(const<a href="qpixmap.html">QPixmap</a>&amp;pm, <a href="qiconset.html#Size">Size</a>s)</h3>
<p>Sets this icon set to provide <em>pm</em> for the Normal pixmap,
assuming it to be of size <em>s.</em>
<p>This is equivalent to assigning QIconSet(pm,s) to this icon set.
<h3 class="fn">void<a name="50bce3"></a>QIconSet::setPixmap(const<a href="qpixmap.html">QPixmap</a>&amp;pm, <a href="qiconset.html#Size">Size</a>size, <a href="qiconset.html#Mode">Mode</a>mode=Normal)</h3>
<p>Sets this icon set to provide <em>pm</em> for a <em>size</em> and <em>mode.</em>
It may also use <em>pm</em> for deriving some other varieties if those
are not 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 23 pixels wide are considered to be Small.
<p>See also  <a href="#631e1e">reset</a>().
<h3 class="fn">void<a name="f0362d"></a>QIconSet::setPixmap(const<a href="qstring.html">QString</a>&amp;fileName, <a href="qiconset.html#Size">Size</a>s, <a href="qiconset.html#Mode">Mode</a>m=Normal)</h3>
<p>Sets this icon set to load <em>fileName</em> as a pixmap and provide it
for size <em>s</em> and mode <em>m.</em>
It may also use the pixmap for deriving some other varieties if those
are not 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 23 pixels wide are considered to be Small.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><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  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>