summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqiconset.3qt
blob: 347960cc3af4f7bdd2f87dd50dfd0a704574892b (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
'\" t
.TH TQIconSet 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQIconSet \- Set of icons with different styles and sizes
.SH SYNOPSIS
\fC#include <tqiconset.h>\fR
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "enum \fBSize\fR { Automatic, Small, Large }"
.br
.ti -1c
.BI "enum \fBMode\fR { Normal, Disabled, Active }"
.br
.ti -1c
.BI "enum \fBState\fR { On, Off }"
.br
.ti -1c
.BI "\fBTQIconSet\fR ()"
.br
.ti -1c
.BI "\fBTQIconSet\fR ( const QPixmap & pixmap, Size size = Automatic )"
.br
.ti -1c
.BI "\fBTQIconSet\fR ( const QPixmap & smallPix, const QPixmap & largePix )"
.br
.ti -1c
.BI "\fBTQIconSet\fR ( const TQIconSet & other )"
.br
.ti -1c
.BI "virtual \fB~TQIconSet\fR ()"
.br
.ti -1c
.BI "void \fBreset\fR ( const QPixmap & pixmap, Size size )"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( const QPixmap & pixmap, Size size, Mode mode = Normal, State state = Off )"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( const TQString & fileName, Size size, Mode mode = Normal, State state = Off )"
.br
.ti -1c
.BI "QPixmap \fBpixmap\fR ( Size size, Mode mode, State state = Off ) const"
.br
.ti -1c
.BI "QPixmap pixmap ( Size size, bool enabled, State state = Off ) const  \fI(obsolete)\fR"
.br
.ti -1c
.BI "QPixmap \fBpixmap\fR () const"
.br
.ti -1c
.BI "bool \fBisGenerated\fR ( Size size, Mode mode, State state = Off ) const"
.br
.ti -1c
.BI "void \fBclearGenerated\fR ()"
.br
.ti -1c
.BI "void \fBinstallIconFactory\fR ( TQIconFactory * factory )"
.br
.ti -1c
.BI "bool \fBisNull\fR () const"
.br
.ti -1c
.BI "void \fBdetach\fR ()"
.br
.ti -1c
.BI "TQIconSet & \fBoperator=\fR ( const TQIconSet & other )"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "void \fBsetIconSize\fR ( Size which, const TQSize & size )"
.br
.ti -1c
.BI "const TQSize & \fBiconSize\fR ( Size which )"
.br
.in -1c
.SH DESCRIPTION
The TQIconSet class provides a set of icons with different styles and sizes.
.PP
A TQIconSet can generate smaller, larger, active, and disabled pixmaps from the set of icons it is given. Such pixmaps are used by TQToolButton, QHeader, TQPopupMenu, etc. to show an icon representing a particular action.
.PP
The simplest use of TQIconSet is to create one from a QPixmap and then use it, allowing TQt to work out all the required icon styles and sizes. For example:
.PP
.nf
.br
    TQToolButton *but = new TQToolButton( TQIconSet( QPixmap("open.xpm") ), ... );
.br
.fi
.PP
Using whichever pixmaps you specify as a base, TQIconSet provides a set of six icons, each with a Size and a Mode: Small Normal, Small Disabled, Small Active, Large Normal, Large Disabled, and Large Active.
.PP
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 TQIconSet will provide the "Off" pixmaps. You may specify icons for both states in you wish.
.PP
You can set any of the icons using setPixmap().
.PP
When you retrieve a pixmap using pixmap(Size, Mode, State), TQIconSet will return the icon that has been set or previously generated for that size, mode and state combination. If none is available, TQIconSet will ask the icon factory. If the icon factory cannot provide any (the default), TQIconSet generates a pixmap based on the pixmaps it has been given and returns it.
.PP
The Disabled appearance is computed using an algorithm that produces results very similar to those used in Microsoft Windows 95. The Active appearance is identical to the Normal appearance unless you use setPixmap() to set it to something special.
.PP
When scaling icons, TQIconSet uses smooth scaling, 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.
.PP
You can use the static function setIconSize() 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.
.PP
The isGenerated() function returns TRUE if an icon was generated by TQIconSet or by a factory; clearGenerated() clears all cached pixmaps.
.SH "Making Classes that Use TQIconSet"
If you write your own widgets that have an option to set a small pixmap, consider allowing a TQIconSet to be set for that pixmap. The TQt class TQToolButton is an example of such a widget.
.PP
Provide a method to set a TQIconSet, and when you draw the icon, choose whichever icon is appropriate for the current state of your widget. For example:
.PP
.nf
.br
    void MyWidget::drawIcon( QPainter* p, QPoint pos )
.br
    {
.br
        p->drawPixmap( pos, icons->pixmap(
.br
                                TQIconSet::Small,
.br
                                isEnabled() ? TQIconSet::Normal :
.br
                                              TQIconSet::Disabled,
.br
                                isEnabled() ? TQIconSet::On :
.br
                                              TQIconSet::Off));
.br
    }
.br
.fi
.PP
You might also make use of the Active mode, perhaps making your widget Active when the mouse is over the widget (see TQWidget::enterEvent()), 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.
.PP
<center>
.ce 1
.B "[Image Omitted]"
.PP
</center>
.PP
See also TQIconFactory, QPixmap, TQMainWindow::usesBigPixmaps, GUI Design Handbook: Iconic Label, Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.
.SS "Member Type Documentation"
.SH "TQIconSet::Mode"
This enum type describes the mode for which a pixmap is intended to be used. The currently defined modes are:
.TP
\fCTQIconSet::Normal\fR - Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available.
.TP
\fCTQIconSet::Disabled\fR - Display the pixmap when the functionality represented by the icon is not available.
.TP
\fCTQIconSet::Active\fR - 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.
.SH "TQIconSet::Size"
This enum type describes the size at which a pixmap is intended to be used. The currently defined sizes are:
.TP
\fCTQIconSet::Automatic\fR - The size of the pixmap is determined from its pixel size. This is a useful default.
.TP
\fCTQIconSet::Small\fR - The pixmap is the smaller of two.
.TP
\fCTQIconSet::Large\fR - The pixmap is the larger of two.
.PP
If a Small pixmap is not set by TQIconSet::setPixmap(), 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 setIconSize().
.PP
See also setIconSize(), iconSize(), setPixmap(), pixmap(), and TQMainWindow::usesBigPixmaps.
.SH "TQIconSet::State"
This enum describes the state for which a pixmap is intended to be used. The \fIstate\fR can be:
.TP
\fCTQIconSet::Off\fR - Display the pixmap when the widget is in an "off" state
.TP
\fCTQIconSet::On\fR - Display the pixmap when the widget is in an "on" state
.PP
See also setPixmap() and pixmap().
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQIconSet::TQIconSet ()"
Constructs a null icon set.
.PP
See also setPixmap() and reset().
.SH "TQIconSet::TQIconSet ( const QPixmap & pixmap, Size size = Automatic )"
Constructs an icon set for which the Normal pixmap is \fIpixmap\fR, which is assumed to be of size \fIsize\fR.
.PP
The default for \fIsize\fR is Automatic, which means that TQIconSet 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 setIconSize() to set the preferred size of a generated icon.
.PP
See also setIconSize() and reset().
.SH "TQIconSet::TQIconSet ( const QPixmap & smallPix, const QPixmap & largePix )"
Creates an iconset which uses the pixmap \fIsmallPix\fR for for displaying a small icon, and the pixmap \fIlargePix\fR for displaying a large icon.
.SH "TQIconSet::TQIconSet ( const TQIconSet & other )"
Constructs a copy of \fIother\fR. This is very fast.
.SH "TQIconSet::~TQIconSet ()\fC [virtual]\fR"
Destroys the icon set and frees any allocated resources.
.SH "void TQIconSet::clearGenerated ()"
Clears all cached pixmaps, including those obtained from an eventual TQIconFactory.
.SH "void TQIconSet::detach ()"
Detaches this icon set from others with which it may share data.
.PP
You will never need to call this function; other TQIconSet functions call it as necessary.
.SH "const TQSize & TQIconSet::iconSize ( Size which )\fC [static]\fR"
If \fIwhich\fR is Small, returns the preferred size of a small generated icon; if \fIwhich\fR is Large, returns the preferred size of a large generated icon.
.PP
See also setIconSize().
.SH "void TQIconSet::installIconFactory ( TQIconFactory * factory )"
Installs \fIfactory\fR as the icon factory for this iconset. The icon factory is used to generates pixmaps not set by the user.
.PP
If no icon factory is installed, TQIconFactory::defaultFactory() is used.
.SH "bool TQIconSet::isGenerated ( Size size, Mode mode, State state = Off ) const"
Returns TRUE if the pixmap with size \fIsize\fR, mode \fImode\fR and state \fIstate\fR is generated from other pixmaps; otherwise returns FALSE.
.PP
A pixmap obtained from a TQIconFactory is considered non-generated.
.SH "bool TQIconSet::isNull () const"
Returns TRUE if the icon set is empty; otherwise returns FALSE.
.SH "TQIconSet & TQIconSet::operator= ( const TQIconSet & other )"
Assigns \fIother\fR to this icon set and returns a reference to this icon set.
.PP
See also detach().
.SH "QPixmap TQIconSet::pixmap ( Size size, Mode mode, State state = Off ) const"
Returns a pixmap with size \fIsize\fR, mode \fImode\fR and state \fIstate\fR, generating one if necessary. Generated pixmaps are cached.
.SH "QPixmap TQIconSet::pixmap ( Size size, bool enabled, State state = Off ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
This is the same as pixmap(\fIsize\fR, \fIenabled\fR, \fIstate\fR).
.SH "QPixmap TQIconSet::pixmap () const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the pixmap originally provided to the constructor or to reset(). This is the Normal pixmap of unspecified Size.
.PP
See also reset().
.SH "void TQIconSet::reset ( const QPixmap & pixmap, Size size )"
Sets this icon set to use pixmap \fIpixmap\fR for the Normal pixmap, assuming it to be of size \fIsize\fR.
.PP
This is equivalent to assigning TQIconSet(\fIpixmap\fR, \fIsize\fR) to this icon set.
.PP
This function does nothing if \fIpixmap\fR is a null pixmap.
.SH "void TQIconSet::setIconSize ( Size which, const TQSize & size )\fC [static]\fR"
Set the preferred size for all small or large icons that are generated after this call. If \fIwhich\fR is Small, sets the preferred size of small generated icons to \fIsize\fR. Similarly, if \fIwhich\fR is Large, sets the preferred size of large generated icons to \fIsize\fR.
.PP
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.
.PP
See also iconSize().
.SH "void TQIconSet::setPixmap ( const QPixmap & pixmap, Size size, Mode mode = Normal, State state = Off )\fC [virtual]\fR"
Sets this icon set to provide pixmap \fIpixmap\fR for size \fIsize\fR, mode \fImode\fR and state \fIstate\fR. The icon set may also use \fIpixmap\fR for generating other pixmaps if they are not explicitly set.
.PP
The \fIsize\fR can be one of Automatic, Large or Small. If Automatic is used, TQIconSet will determine if the pixmap is Small or Large from its pixel size.
.PP
Pixmaps less than the width of a small generated icon are considered to be Small. You can use setIconSize() to set the preferred size of a generated icon.
.PP
This function does nothing if \fIpixmap\fR is a null pixmap.
.PP
See also reset().
.SH "void TQIconSet::setPixmap ( const TQString & fileName, Size size, Mode mode = Normal, State state = Off )\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
The pixmap is loaded from \fIfileName\fR when it becomes necessary.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqiconset.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqiconset.3qt) and the Qt
version (3.3.8).