00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QICON_H
00043 #define QICON_H
00044
00045 #include <QtCore/qglobal.h>
00046 #include <QtCore/qsize.h>
00047 #include <QtCore/qlist.h>
00048 #include <QtGui/qpixmap.h>
00049
00050 QT_BEGIN_HEADER
00051
00052 QT_BEGIN_NAMESPACE
00053
00054 QT_MODULE(Gui)
00055
00056 class QIconPrivate;
00057 class QIconEngine;
00058 class QIconEngineV2;
00059
00060 class Q_GUI_EXPORT QIcon
00061 {
00062 public:
00063 enum Mode { Normal, Disabled, Active, Selected };
00064 enum State { On, Off };
00065
00066 QIcon();
00067 QIcon(const QPixmap &pixmap);
00068 QIcon(const QIcon &other);
00069 explicit QIcon(const QString &fileName);
00070 explicit QIcon(QIconEngine *engine);
00071 explicit QIcon(QIconEngineV2 *engine);
00072 ~QIcon();
00073 QIcon &operator=(const QIcon &other);
00074 operator QVariant() const;
00075
00076 QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
00077 inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const
00078 { return pixmap(QSize(w, h), mode, state); }
00079 inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const
00080 { return pixmap(QSize(extent, extent), mode, state); }
00081
00082 QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
00083
00084 QString name() const;
00085
00086 void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
00087 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
00088 { paint(painter, QRect(x, y, w, h), alignment, mode, state); }
00089
00090 bool isNull() const;
00091 bool isDetached() const;
00092 void detach();
00093
00094 int serialNumber() const;
00095 qint64 cacheKey() const;
00096
00097 void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off);
00098 void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off);
00099
00100 QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const;
00101
00102 static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon());
00103 static bool hasThemeIcon(const QString &name);
00104
00105 static QStringList themeSearchPaths();
00106 static void setThemeSearchPaths(const QStringList &searchpath);
00107
00108 static QString themeName();
00109 static void setThemeName(const QString &path);
00110
00111
00112 #ifdef QT3_SUPPORT
00113 enum Size { Small, Large, Automatic = Small };
00114 static QT3_SUPPORT void setPixmapSize(Size which, const QSize &size);
00115 static QT3_SUPPORT QSize pixmapSize(Size which);
00116 inline QT3_SUPPORT void reset(const QPixmap &pixmap, Size ) { *this = QIcon(pixmap); }
00117 inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap, Size, Mode mode = Normal, State state = Off)
00118 { addPixmap(pixmap, mode, state); }
00119 inline QT3_SUPPORT void setPixmap(const QString &fileName, Size, Mode mode = Normal, State state = Off)
00120 { addPixmap(QPixmap(fileName), mode, state); }
00121 QT3_SUPPORT QPixmap pixmap(Size size, Mode mode, State state = Off) const;
00122 QT3_SUPPORT QPixmap pixmap(Size size, bool enabled, State state = Off) const;
00123 QT3_SUPPORT QPixmap pixmap() const;
00124 #endif
00125
00126 Q_DUMMY_COMPARISON_OPERATOR(QIcon)
00127
00128 private:
00129 QIconPrivate *d;
00130 #if !defined(QT_NO_DATASTREAM)
00131 friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
00132 friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
00133 #endif
00134
00135 public:
00136 typedef QIconPrivate * DataPtr;
00137 inline DataPtr &data_ptr() { return d; }
00138 };
00139
00140 Q_DECLARE_SHARED(QIcon)
00141 Q_DECLARE_TYPEINFO(QIcon, Q_MOVABLE_TYPE);
00142
00143 #if !defined(QT_NO_DATASTREAM)
00144 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
00145 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
00146 #endif
00147
00148 #ifdef QT3_SUPPORT
00149 typedef QIcon QIconSet;
00150 #endif
00151
00152 QT_END_NAMESPACE
00153
00154 QT_END_HEADER
00155
00156 #endif // QICON_H