Go to the
documentation of this file.
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 QGRAPHICSEFFECT_H
00043 #define QGRAPHICSEFFECT_H
00044
00045 #include <QtCore/qobject.h>
00046 #include <QtCore/qpoint.h>
00047 #include <QtCore/qrect.h>
00048 #include <QtGui/qcolor.h>
00049 #include <QtGui/qbrush.h>
00050
00051 #ifndef QT_NO_GRAPHICSEFFECT
00052 QT_BEGIN_HEADER
00053
00054 QT_BEGIN_NAMESPACE
00055
00056 QT_MODULE(Gui)
00057
00058 class QGraphicsItem;
00059 class QStyleOption;
00060 class QPainter;
00061 class QPixmap;
00062
00063 class QGraphicsEffectSource;
00064
00065 class QGraphicsEffectPrivate;
00066 class Q_GUI_EXPORT QGraphicsEffect : public QObject
00067 {
00068 Q_OBJECT
00069 Q_FLAGS(ChangeFlags)
00070 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
00071 public:
00072 enum ChangeFlag {
00073 SourceAttached = 0x1,
00074 SourceDetached = 0x2,
00075 SourceBoundingRectChanged = 0x4,
00076 SourceInvalidated = 0x8
00077 };
00078 Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
00079
00080 enum PixmapPadMode {
00081 NoPad,
00082 PadToTransparentBorder,
00083 PadToEffectiveBoundingRect
00084 };
00085
00086 QGraphicsEffect(QObject *parent = 0);
00087 virtual ~QGraphicsEffect();
00088
00089 virtual QRectF boundingRectFor(const QRectF &sourceRect) const;
00090 QRectF boundingRect() const;
00091
00092 bool isEnabled() const;
00093
00094 public Q_SLOTS:
00095 void setEnabled(bool enable);
00096 void update();
00097
00098 Q_SIGNALS:
00099 void enabledChanged(bool enabled);
00100
00101 protected:
00102 QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0);
00103 virtual void draw(QPainter *painter) = 0;
00104 virtual void sourceChanged(ChangeFlags flags);
00105 void updateBoundingRect();
00106
00107 bool sourceIsPixmap() const;
00108 QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const;
00109 void drawSource(QPainter *painter);
00110 QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
00111 QPoint *offset = 0,
00112 PixmapPadMode mode = PadToEffectiveBoundingRect) const;
00113
00114 private:
00115 Q_DECLARE_PRIVATE(QGraphicsEffect)
00116 Q_DISABLE_COPY(QGraphicsEffect)
00117 friend class QGraphicsItem;
00118 friend class QGraphicsItemPrivate;
00119 friend class QGraphicsScenePrivate;
00120 friend class QWidget;
00121 friend class QWidgetPrivate;
00122
00123 public:
00124 QGraphicsEffectSource *source() const;
00125
00126 };
00127 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags)
00128
00129 class QGraphicsColorizeEffectPrivate;
00130 class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect
00131 {
00132 Q_OBJECT
00133 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
00134 Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
00135 public:
00136 QGraphicsColorizeEffect(QObject *parent = 0);
00137 ~QGraphicsColorizeEffect();
00138
00139 QColor color() const;
00140 qreal strength() const;
00141
00142 public Q_SLOTS:
00143 void setColor(const QColor &c);
00144 void setStrength(qreal strength);
00145
00146 Q_SIGNALS:
00147 void colorChanged(const QColor &color);
00148 void strengthChanged(qreal strength);
00149
00150 protected:
00151 void draw(QPainter *painter);
00152
00153 private:
00154 Q_DECLARE_PRIVATE(QGraphicsColorizeEffect)
00155 Q_DISABLE_COPY(QGraphicsColorizeEffect)
00156 };
00157
00158 class QGraphicsBlurEffectPrivate;
00159 class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect
00160 {
00161 Q_OBJECT
00162 Q_FLAGS(BlurHint BlurHints)
00163 Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
00164 Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged)
00165 public:
00166 enum BlurHint {
00167 PerformanceHint = 0x00,
00168 QualityHint = 0x01,
00169 AnimationHint = 0x02
00170 };
00171 Q_DECLARE_FLAGS(BlurHints, BlurHint)
00172
00173 QGraphicsBlurEffect(QObject *parent = 0);
00174 ~QGraphicsBlurEffect();
00175
00176 QRectF boundingRectFor(const QRectF &rect) const;
00177 qreal blurRadius() const;
00178 BlurHints blurHints() const;
00179
00180 public Q_SLOTS:
00181 void setBlurRadius(qreal blurRadius);
00182 void setBlurHints(BlurHints hints);
00183
00184 Q_SIGNALS:
00185 void blurRadiusChanged(qreal blurRadius);
00186 void blurHintsChanged(BlurHints hints);
00187
00188 protected:
00189 void draw(QPainter *painter);
00190
00191 private:
00192 Q_DECLARE_PRIVATE(QGraphicsBlurEffect)
00193 Q_DISABLE_COPY(QGraphicsBlurEffect)
00194 };
00195
00196 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints)
00197
00198 class QGraphicsDropShadowEffectPrivate;
00199 class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
00200 {
00201 Q_OBJECT
00202 Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged)
00203 Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
00204 Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
00205 Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
00206 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
00207 public:
00208 QGraphicsDropShadowEffect(QObject *parent = 0);
00209 ~QGraphicsDropShadowEffect();
00210
00211 QRectF boundingRectFor(const QRectF &rect) const;
00212 QPointF offset() const;
00213
00214 inline qreal xOffset() const
00215 { return offset().x(); }
00216
00217 inline qreal yOffset() const
00218 { return offset().y(); }
00219
00220 qreal blurRadius() const;
00221 QColor color() const;
00222
00223 public Q_SLOTS:
00224 void setOffset(const QPointF &ofs);
00225
00226 inline void setOffset(qreal dx, qreal dy)
00227 { setOffset(QPointF(dx, dy)); }
00228
00229 inline void setOffset(qreal d)
00230 { setOffset(QPointF(d, d)); }
00231
00232 inline void setXOffset(qreal dx)
00233 { setOffset(QPointF(dx, yOffset())); }
00234
00235 inline void setYOffset(qreal dy)
00236 { setOffset(QPointF(xOffset(), dy)); }
00237
00238 void setBlurRadius(qreal blurRadius);
00239 void setColor(const QColor &color);
00240
00241 Q_SIGNALS:
00242 void offsetChanged(const QPointF &offset);
00243 void blurRadiusChanged(qreal blurRadius);
00244 void colorChanged(const QColor &color);
00245
00246 protected:
00247 void draw(QPainter *painter);
00248
00249 private:
00250 Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect)
00251 Q_DISABLE_COPY(QGraphicsDropShadowEffect)
00252 };
00253
00254 class QGraphicsOpacityEffectPrivate;
00255 class Q_GUI_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect
00256 {
00257 Q_OBJECT
00258 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
00259 Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
00260 public:
00261 QGraphicsOpacityEffect(QObject *parent = 0);
00262 ~QGraphicsOpacityEffect();
00263
00264 qreal opacity() const;
00265 QBrush opacityMask() const;
00266
00267 public Q_SLOTS:
00268 void setOpacity(qreal opacity);
00269 void setOpacityMask(const QBrush &mask);
00270
00271 Q_SIGNALS:
00272 void opacityChanged(qreal opacity);
00273 void opacityMaskChanged(const QBrush &mask);
00274
00275 protected:
00276 void draw(QPainter *painter);
00277
00278 private:
00279 Q_DECLARE_PRIVATE(QGraphicsOpacityEffect)
00280 Q_DISABLE_COPY(QGraphicsOpacityEffect)
00281 };
00282
00283 QT_END_NAMESPACE
00284
00285 QT_END_HEADER
00286 #endif //QT_NO_GRAPHICSEFFECT
00287
00288 #endif // QGRAPHICSEFFECT_H
00289