1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QICON_H
|
---|
43 | #define QICON_H
|
---|
44 |
|
---|
45 | #include <QtCore/qglobal.h>
|
---|
46 | #include <QtCore/qsize.h>
|
---|
47 | #include <QtCore/qlist.h>
|
---|
48 | #include <QtGui/qpixmap.h>
|
---|
49 |
|
---|
50 | QT_BEGIN_HEADER
|
---|
51 |
|
---|
52 | QT_BEGIN_NAMESPACE
|
---|
53 |
|
---|
54 | QT_MODULE(Gui)
|
---|
55 |
|
---|
56 | class QIconPrivate;
|
---|
57 | class QIconEngine;
|
---|
58 | class QIconEngineV2;
|
---|
59 |
|
---|
60 | class Q_GUI_EXPORT QIcon
|
---|
61 | {
|
---|
62 | public:
|
---|
63 | enum Mode { Normal, Disabled, Active, Selected };
|
---|
64 | enum State { On, Off };
|
---|
65 |
|
---|
66 | QIcon();
|
---|
67 | QIcon(const QPixmap &pixmap);
|
---|
68 | QIcon(const QIcon &other);
|
---|
69 | explicit QIcon(const QString &fileName); // file or resource name
|
---|
70 | explicit QIcon(QIconEngine *engine);
|
---|
71 | explicit QIcon(QIconEngineV2 *engine);
|
---|
72 | ~QIcon();
|
---|
73 | QIcon &operator=(const QIcon &other);
|
---|
74 | operator QVariant() const;
|
---|
75 |
|
---|
76 | QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
|
---|
77 | inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const
|
---|
78 | { return pixmap(QSize(w, h), mode, state); }
|
---|
79 | inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const
|
---|
80 | { return pixmap(QSize(extent, extent), mode, state); }
|
---|
81 |
|
---|
82 | QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
|
---|
83 |
|
---|
84 | void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
|
---|
85 | inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const
|
---|
86 | { paint(painter, QRect(x, y, w, h), alignment, mode, state); }
|
---|
87 |
|
---|
88 | bool isNull() const;
|
---|
89 | bool isDetached() const;
|
---|
90 | void detach();
|
---|
91 |
|
---|
92 | int serialNumber() const;
|
---|
93 | qint64 cacheKey() const;
|
---|
94 |
|
---|
95 | void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off);
|
---|
96 | void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off);
|
---|
97 |
|
---|
98 | QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const;
|
---|
99 |
|
---|
100 | static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon());
|
---|
101 | static bool hasThemeIcon(const QString &name);
|
---|
102 |
|
---|
103 | static QStringList themeSearchPaths();
|
---|
104 | static void setThemeSearchPaths(const QStringList &searchpath);
|
---|
105 |
|
---|
106 | static QString themeName();
|
---|
107 | static void setThemeName(const QString &path);
|
---|
108 |
|
---|
109 |
|
---|
110 | #ifdef QT3_SUPPORT
|
---|
111 | enum Size { Small, Large, Automatic = Small };
|
---|
112 | static QT3_SUPPORT void setPixmapSize(Size which, const QSize &size);
|
---|
113 | static QT3_SUPPORT QSize pixmapSize(Size which);
|
---|
114 | inline QT3_SUPPORT void reset(const QPixmap &pixmap, Size /*size*/) { *this = QIcon(pixmap); }
|
---|
115 | inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap, Size, Mode mode = Normal, State state = Off)
|
---|
116 | { addPixmap(pixmap, mode, state); }
|
---|
117 | inline QT3_SUPPORT void setPixmap(const QString &fileName, Size, Mode mode = Normal, State state = Off)
|
---|
118 | { addPixmap(QPixmap(fileName), mode, state); }
|
---|
119 | QT3_SUPPORT QPixmap pixmap(Size size, Mode mode, State state = Off) const;
|
---|
120 | QT3_SUPPORT QPixmap pixmap(Size size, bool enabled, State state = Off) const;
|
---|
121 | QT3_SUPPORT QPixmap pixmap() const;
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | Q_DUMMY_COMPARISON_OPERATOR(QIcon)
|
---|
125 |
|
---|
126 | private:
|
---|
127 | QIconPrivate *d;
|
---|
128 | #if !defined(QT_NO_DATASTREAM)
|
---|
129 | friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
|
---|
130 | friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | public:
|
---|
134 | typedef QIconPrivate * DataPtr;
|
---|
135 | inline DataPtr &data_ptr() { return d; }
|
---|
136 | };
|
---|
137 |
|
---|
138 | Q_DECLARE_SHARED(QIcon)
|
---|
139 | Q_DECLARE_TYPEINFO(QIcon, Q_MOVABLE_TYPE);
|
---|
140 |
|
---|
141 | #if !defined(QT_NO_DATASTREAM)
|
---|
142 | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
|
---|
143 | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | #ifdef QT3_SUPPORT
|
---|
147 | typedef QIcon QIconSet;
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | QT_END_NAMESPACE
|
---|
151 |
|
---|
152 | QT_END_HEADER
|
---|
153 |
|
---|
154 | #endif // QICON_H
|
---|