[556] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[556] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
| 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 qt-info@nokia.com.
|
---|
| 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QGRAPHICSEFFECT_H
|
---|
| 43 | #define QGRAPHICSEFFECT_H
|
---|
| 44 |
|
---|
| 45 | #include <QtCore/qobject.h>
|
---|
| 46 | #include <QtCore/qpoint.h>
|
---|
| 47 | #include <QtCore/qrect.h>
|
---|
| 48 | #include <QtGui/qcolor.h>
|
---|
| 49 | #include <QtGui/qbrush.h>
|
---|
| 50 |
|
---|
| 51 | #ifndef QT_NO_GRAPHICSEFFECT
|
---|
| 52 | QT_BEGIN_HEADER
|
---|
| 53 |
|
---|
| 54 | QT_BEGIN_NAMESPACE
|
---|
| 55 |
|
---|
| 56 | QT_MODULE(Gui)
|
---|
| 57 |
|
---|
| 58 | class QGraphicsItem;
|
---|
| 59 | class QStyleOption;
|
---|
| 60 | class QPainter;
|
---|
| 61 | class QPixmap;
|
---|
| 62 |
|
---|
| 63 | class QGraphicsEffectSource;
|
---|
| 64 |
|
---|
| 65 | class QGraphicsEffectPrivate;
|
---|
| 66 | class Q_GUI_EXPORT QGraphicsEffect : public QObject
|
---|
| 67 | {
|
---|
| 68 | Q_OBJECT
|
---|
| 69 | Q_FLAGS(ChangeFlags)
|
---|
| 70 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
|
---|
| 71 | public:
|
---|
| 72 | enum ChangeFlag {
|
---|
| 73 | SourceAttached = 0x1,
|
---|
| 74 | SourceDetached = 0x2,
|
---|
| 75 | SourceBoundingRectChanged = 0x4,
|
---|
| 76 | SourceInvalidated = 0x8
|
---|
| 77 | };
|
---|
| 78 | Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
|
---|
| 79 |
|
---|
| 80 | enum PixmapPadMode {
|
---|
| 81 | NoPad,
|
---|
| 82 | PadToTransparentBorder,
|
---|
| 83 | PadToEffectiveBoundingRect
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 | QGraphicsEffect(QObject *parent = 0);
|
---|
| 87 | virtual ~QGraphicsEffect();
|
---|
| 88 |
|
---|
| 89 | virtual QRectF boundingRectFor(const QRectF &sourceRect) const;
|
---|
| 90 | QRectF boundingRect() const;
|
---|
| 91 |
|
---|
| 92 | bool isEnabled() const;
|
---|
| 93 |
|
---|
| 94 | public Q_SLOTS:
|
---|
| 95 | void setEnabled(bool enable);
|
---|
| 96 | void update();
|
---|
| 97 |
|
---|
| 98 | Q_SIGNALS:
|
---|
| 99 | void enabledChanged(bool enabled);
|
---|
| 100 |
|
---|
| 101 | protected:
|
---|
| 102 | QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0);
|
---|
| 103 | virtual void draw(QPainter *painter) = 0;
|
---|
| 104 | virtual void sourceChanged(ChangeFlags flags);
|
---|
| 105 | void updateBoundingRect();
|
---|
| 106 |
|
---|
| 107 | bool sourceIsPixmap() const;
|
---|
| 108 | QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const;
|
---|
| 109 | void drawSource(QPainter *painter);
|
---|
| 110 | QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
|
---|
| 111 | QPoint *offset = 0,
|
---|
| 112 | PixmapPadMode mode = PadToEffectiveBoundingRect) const;
|
---|
| 113 |
|
---|
| 114 | private:
|
---|
| 115 | Q_DECLARE_PRIVATE(QGraphicsEffect)
|
---|
| 116 | Q_DISABLE_COPY(QGraphicsEffect)
|
---|
| 117 | friend class QGraphicsItem;
|
---|
| 118 | friend class QGraphicsItemPrivate;
|
---|
| 119 | friend class QGraphicsScenePrivate;
|
---|
| 120 | friend class QWidget;
|
---|
| 121 | friend class QWidgetPrivate;
|
---|
| 122 |
|
---|
| 123 | public:
|
---|
| 124 | QGraphicsEffectSource *source() const; // internal
|
---|
| 125 |
|
---|
| 126 | };
|
---|
| 127 | Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags)
|
---|
| 128 |
|
---|
| 129 | class QGraphicsColorizeEffectPrivate;
|
---|
| 130 | class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect
|
---|
| 131 | {
|
---|
| 132 | Q_OBJECT
|
---|
| 133 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
---|
| 134 | Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
|
---|
| 135 | public:
|
---|
| 136 | QGraphicsColorizeEffect(QObject *parent = 0);
|
---|
| 137 | ~QGraphicsColorizeEffect();
|
---|
| 138 |
|
---|
| 139 | QColor color() const;
|
---|
| 140 | qreal strength() const;
|
---|
| 141 |
|
---|
| 142 | public Q_SLOTS:
|
---|
| 143 | void setColor(const QColor &c);
|
---|
| 144 | void setStrength(qreal strength);
|
---|
| 145 |
|
---|
| 146 | Q_SIGNALS:
|
---|
| 147 | void colorChanged(const QColor &color);
|
---|
| 148 | void strengthChanged(qreal strength);
|
---|
| 149 |
|
---|
| 150 | protected:
|
---|
| 151 | void draw(QPainter *painter);
|
---|
| 152 |
|
---|
| 153 | private:
|
---|
| 154 | Q_DECLARE_PRIVATE(QGraphicsColorizeEffect)
|
---|
| 155 | Q_DISABLE_COPY(QGraphicsColorizeEffect)
|
---|
| 156 | };
|
---|
| 157 |
|
---|
| 158 | class QGraphicsBlurEffectPrivate;
|
---|
| 159 | class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect
|
---|
| 160 | {
|
---|
| 161 | Q_OBJECT
|
---|
| 162 | Q_FLAGS(BlurHint BlurHints)
|
---|
| 163 | Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
|
---|
| 164 | Q_PROPERTY(BlurHints blurHints READ blurHints WRITE setBlurHints NOTIFY blurHintsChanged)
|
---|
| 165 | public:
|
---|
| 166 | enum BlurHint {
|
---|
| 167 | PerformanceHint = 0x00,
|
---|
| 168 | QualityHint = 0x01,
|
---|
| 169 | AnimationHint = 0x02
|
---|
| 170 | };
|
---|
| 171 | Q_DECLARE_FLAGS(BlurHints, BlurHint)
|
---|
| 172 |
|
---|
| 173 | QGraphicsBlurEffect(QObject *parent = 0);
|
---|
| 174 | ~QGraphicsBlurEffect();
|
---|
| 175 |
|
---|
| 176 | QRectF boundingRectFor(const QRectF &rect) const;
|
---|
| 177 | qreal blurRadius() const;
|
---|
| 178 | BlurHints blurHints() const;
|
---|
| 179 |
|
---|
| 180 | public Q_SLOTS:
|
---|
| 181 | void setBlurRadius(qreal blurRadius);
|
---|
| 182 | void setBlurHints(BlurHints hints);
|
---|
| 183 |
|
---|
| 184 | Q_SIGNALS:
|
---|
| 185 | void blurRadiusChanged(qreal blurRadius);
|
---|
| 186 | void blurHintsChanged(BlurHints hints);
|
---|
| 187 |
|
---|
| 188 | protected:
|
---|
| 189 | void draw(QPainter *painter);
|
---|
| 190 |
|
---|
| 191 | private:
|
---|
| 192 | Q_DECLARE_PRIVATE(QGraphicsBlurEffect)
|
---|
| 193 | Q_DISABLE_COPY(QGraphicsBlurEffect)
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 | Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints)
|
---|
| 197 |
|
---|
| 198 | class QGraphicsDropShadowEffectPrivate;
|
---|
| 199 | class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
|
---|
| 200 | {
|
---|
| 201 | Q_OBJECT
|
---|
| 202 | Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged)
|
---|
| 203 | Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
|
---|
| 204 | Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
|
---|
| 205 | Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
|
---|
| 206 | Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
---|
| 207 | public:
|
---|
| 208 | QGraphicsDropShadowEffect(QObject *parent = 0);
|
---|
| 209 | ~QGraphicsDropShadowEffect();
|
---|
| 210 |
|
---|
| 211 | QRectF boundingRectFor(const QRectF &rect) const;
|
---|
| 212 | QPointF offset() const;
|
---|
| 213 |
|
---|
| 214 | inline qreal xOffset() const
|
---|
| 215 | { return offset().x(); }
|
---|
| 216 |
|
---|
| 217 | inline qreal yOffset() const
|
---|
| 218 | { return offset().y(); }
|
---|
| 219 |
|
---|
| 220 | qreal blurRadius() const;
|
---|
| 221 | QColor color() const;
|
---|
| 222 |
|
---|
| 223 | public Q_SLOTS:
|
---|
| 224 | void setOffset(const QPointF &ofs);
|
---|
| 225 |
|
---|
| 226 | inline void setOffset(qreal dx, qreal dy)
|
---|
| 227 | { setOffset(QPointF(dx, dy)); }
|
---|
| 228 |
|
---|
| 229 | inline void setOffset(qreal d)
|
---|
| 230 | { setOffset(QPointF(d, d)); }
|
---|
| 231 |
|
---|
| 232 | inline void setXOffset(qreal dx)
|
---|
| 233 | { setOffset(QPointF(dx, yOffset())); }
|
---|
| 234 |
|
---|
| 235 | inline void setYOffset(qreal dy)
|
---|
| 236 | { setOffset(QPointF(xOffset(), dy)); }
|
---|
| 237 |
|
---|
| 238 | void setBlurRadius(qreal blurRadius);
|
---|
| 239 | void setColor(const QColor &color);
|
---|
| 240 |
|
---|
| 241 | Q_SIGNALS:
|
---|
| 242 | void offsetChanged(const QPointF &offset);
|
---|
| 243 | void blurRadiusChanged(qreal blurRadius);
|
---|
| 244 | void colorChanged(const QColor &color);
|
---|
| 245 |
|
---|
| 246 | protected:
|
---|
| 247 | void draw(QPainter *painter);
|
---|
| 248 |
|
---|
| 249 | private:
|
---|
| 250 | Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect)
|
---|
| 251 | Q_DISABLE_COPY(QGraphicsDropShadowEffect)
|
---|
| 252 | };
|
---|
| 253 |
|
---|
| 254 | class QGraphicsOpacityEffectPrivate;
|
---|
| 255 | class Q_GUI_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect
|
---|
| 256 | {
|
---|
| 257 | Q_OBJECT
|
---|
| 258 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
|
---|
| 259 | Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
|
---|
| 260 | public:
|
---|
| 261 | QGraphicsOpacityEffect(QObject *parent = 0);
|
---|
| 262 | ~QGraphicsOpacityEffect();
|
---|
| 263 |
|
---|
| 264 | qreal opacity() const;
|
---|
| 265 | QBrush opacityMask() const;
|
---|
| 266 |
|
---|
| 267 | public Q_SLOTS:
|
---|
| 268 | void setOpacity(qreal opacity);
|
---|
| 269 | void setOpacityMask(const QBrush &mask);
|
---|
| 270 |
|
---|
| 271 | Q_SIGNALS:
|
---|
| 272 | void opacityChanged(qreal opacity);
|
---|
| 273 | void opacityMaskChanged(const QBrush &mask);
|
---|
| 274 |
|
---|
| 275 | protected:
|
---|
| 276 | void draw(QPainter *painter);
|
---|
| 277 |
|
---|
| 278 | private:
|
---|
| 279 | Q_DECLARE_PRIVATE(QGraphicsOpacityEffect)
|
---|
| 280 | Q_DISABLE_COPY(QGraphicsOpacityEffect)
|
---|
| 281 | };
|
---|
| 282 |
|
---|
| 283 | QT_END_NAMESPACE
|
---|
| 284 |
|
---|
| 285 | QT_END_HEADER
|
---|
| 286 | #endif //QT_NO_GRAPHICSEFFECT
|
---|
| 287 |
|
---|
| 288 | #endif // QGRAPHICSEFFECT_H
|
---|
| 289 |
|
---|