Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qgraphicseffect.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QGRAPHICSEFFECT_H
0005 #define QGRAPHICSEFFECT_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtCore/qobject.h>
0009 #include <QtCore/qpoint.h>
0010 #include <QtCore/qrect.h>
0011 #include <QtGui/qcolor.h>
0012 #include <QtGui/qbrush.h>
0013 
0014 QT_REQUIRE_CONFIG(graphicseffect);
0015 
0016 QT_BEGIN_NAMESPACE
0017 
0018 class QGraphicsItem;
0019 class QStyleOption;
0020 class QPainter;
0021 class QPixmap;
0022 
0023 class QGraphicsEffectSource;
0024 
0025 class QGraphicsEffectPrivate;
0026 class Q_WIDGETS_EXPORT QGraphicsEffect : public QObject
0027 {
0028     Q_OBJECT
0029     Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
0030 public:
0031     enum ChangeFlag {
0032         SourceAttached = 0x1,
0033         SourceDetached = 0x2,
0034         SourceBoundingRectChanged = 0x4,
0035         SourceInvalidated = 0x8
0036     };
0037     Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
0038     Q_FLAG(ChangeFlags)
0039 
0040     enum PixmapPadMode {
0041         NoPad,
0042         PadToTransparentBorder,
0043         PadToEffectiveBoundingRect
0044     };
0045 
0046     QGraphicsEffect(QObject *parent = nullptr);
0047     virtual ~QGraphicsEffect();
0048 
0049     virtual QRectF boundingRectFor(const QRectF &sourceRect) const;
0050     QRectF boundingRect() const;
0051 
0052     bool isEnabled() const;
0053 
0054 public Q_SLOTS:
0055     void setEnabled(bool enable);
0056     void update();
0057 
0058 Q_SIGNALS:
0059     void enabledChanged(bool enabled);
0060 
0061 protected:
0062     QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = nullptr);
0063     virtual void draw(QPainter *painter) = 0;
0064     virtual void sourceChanged(ChangeFlags flags);
0065     void updateBoundingRect();
0066 
0067     bool sourceIsPixmap() const;
0068     QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const;
0069     void drawSource(QPainter *painter);
0070     QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
0071                          QPoint *offset = nullptr,
0072                          PixmapPadMode mode = PadToEffectiveBoundingRect) const;
0073 
0074 private:
0075     Q_DECLARE_PRIVATE(QGraphicsEffect)
0076     Q_DISABLE_COPY(QGraphicsEffect)
0077     friend class QGraphicsItem;
0078     friend class QGraphicsItemPrivate;
0079     friend class QGraphicsScenePrivate;
0080     friend class QWidget;
0081     friend class QWidgetPrivate;
0082 
0083 public:
0084     QGraphicsEffectSource *source() const; // internal
0085 
0086 };
0087 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags)
0088 
0089 class QGraphicsColorizeEffectPrivate;
0090 class Q_WIDGETS_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect
0091 {
0092     Q_OBJECT
0093     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
0094     Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
0095 public:
0096     QGraphicsColorizeEffect(QObject *parent = nullptr);
0097     ~QGraphicsColorizeEffect();
0098 
0099     QColor color() const;
0100     qreal strength() const;
0101 
0102 public Q_SLOTS:
0103     void setColor(const QColor &c);
0104     void setStrength(qreal strength);
0105 
0106 Q_SIGNALS:
0107     void colorChanged(const QColor &color);
0108     void strengthChanged(qreal strength);
0109 
0110 protected:
0111     void draw(QPainter *painter) override;
0112 
0113 private:
0114     Q_DECLARE_PRIVATE(QGraphicsColorizeEffect)
0115     Q_DISABLE_COPY(QGraphicsColorizeEffect)
0116 };
0117 
0118 class QGraphicsBlurEffectPrivate;
0119 class Q_WIDGETS_EXPORT QGraphicsBlurEffect: public QGraphicsEffect
0120 {
0121     Q_OBJECT
0122     Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
0123     Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged)
0124 public:
0125     enum BlurHint {
0126         PerformanceHint = 0x00,
0127         QualityHint = 0x01,
0128         AnimationHint = 0x02
0129     };
0130     Q_ENUM(BlurHint)
0131     Q_DECLARE_FLAGS(BlurHints, BlurHint)
0132     Q_FLAG(BlurHints)
0133 
0134     QGraphicsBlurEffect(QObject *parent = nullptr);
0135     ~QGraphicsBlurEffect();
0136 
0137     QRectF boundingRectFor(const QRectF &rect) const override;
0138     qreal blurRadius() const;
0139     BlurHints blurHints() const;
0140 
0141 public Q_SLOTS:
0142     void setBlurRadius(qreal blurRadius);
0143     void setBlurHints(BlurHints hints);
0144 
0145 Q_SIGNALS:
0146     void blurRadiusChanged(qreal blurRadius);
0147     void blurHintsChanged(BlurHints hints);
0148 
0149 protected:
0150     void draw(QPainter *painter) override;
0151 
0152 private:
0153     Q_DECLARE_PRIVATE(QGraphicsBlurEffect)
0154     Q_DISABLE_COPY(QGraphicsBlurEffect)
0155 };
0156 
0157 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints)
0158 
0159 class QGraphicsDropShadowEffectPrivate;
0160 class Q_WIDGETS_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
0161 {
0162     Q_OBJECT
0163     Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged)
0164     Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
0165     Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
0166     Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
0167     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
0168 public:
0169     QGraphicsDropShadowEffect(QObject *parent = nullptr);
0170     ~QGraphicsDropShadowEffect();
0171 
0172     QRectF boundingRectFor(const QRectF &rect) const override;
0173     QPointF offset() const;
0174 
0175     inline qreal xOffset() const
0176     { return offset().x(); }
0177 
0178     inline qreal yOffset() const
0179     { return offset().y(); }
0180 
0181     qreal blurRadius() const;
0182     QColor color() const;
0183 
0184 public Q_SLOTS:
0185     void setOffset(const QPointF &ofs);
0186 
0187     inline void setOffset(qreal dx, qreal dy)
0188     { setOffset(QPointF(dx, dy)); }
0189 
0190     inline void setOffset(qreal d)
0191     { setOffset(QPointF(d, d)); }
0192 
0193     inline void setXOffset(qreal dx)
0194     { setOffset(QPointF(dx, yOffset())); }
0195 
0196     inline void setYOffset(qreal dy)
0197     { setOffset(QPointF(xOffset(), dy)); }
0198 
0199     void setBlurRadius(qreal blurRadius);
0200     void setColor(const QColor &color);
0201 
0202 Q_SIGNALS:
0203     void offsetChanged(const QPointF &offset);
0204     void blurRadiusChanged(qreal blurRadius);
0205     void colorChanged(const QColor &color);
0206 
0207 protected:
0208     void draw(QPainter *painter) override;
0209 
0210 private:
0211     Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect)
0212     Q_DISABLE_COPY(QGraphicsDropShadowEffect)
0213 };
0214 
0215 class QGraphicsOpacityEffectPrivate;
0216 class Q_WIDGETS_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect
0217 {
0218     Q_OBJECT
0219     Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
0220     Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
0221 public:
0222     QGraphicsOpacityEffect(QObject *parent = nullptr);
0223     ~QGraphicsOpacityEffect();
0224 
0225     qreal opacity() const;
0226     QBrush opacityMask() const;
0227 
0228 public Q_SLOTS:
0229     void setOpacity(qreal opacity);
0230     void setOpacityMask(const QBrush &mask);
0231 
0232 Q_SIGNALS:
0233     void opacityChanged(qreal opacity);
0234     void opacityMaskChanged(const QBrush &mask);
0235 
0236 protected:
0237     void draw(QPainter *painter) override;
0238 
0239 private:
0240     Q_DECLARE_PRIVATE(QGraphicsOpacityEffect)
0241     Q_DISABLE_COPY(QGraphicsOpacityEffect)
0242 };
0243 
0244 QT_END_NAMESPACE
0245 
0246 #endif // QGRAPHICSEFFECT_H
0247