|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
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 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
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 QT_BEGIN_HEADER |
|
52 |
|
53 QT_BEGIN_NAMESPACE |
|
54 |
|
55 QT_MODULE(Gui) |
|
56 |
|
57 class QGraphicsItem; |
|
58 class QStyleOption; |
|
59 class QPainter; |
|
60 class QPixmap; |
|
61 |
|
62 class QGraphicsEffectSourcePrivate; |
|
63 class Q_GUI_EXPORT QGraphicsEffectSource : public QObject |
|
64 { |
|
65 Q_OBJECT |
|
66 public: |
|
67 ~QGraphicsEffectSource(); |
|
68 const QGraphicsItem *graphicsItem() const; |
|
69 const QWidget *widget() const; |
|
70 const QStyleOption *styleOption() const; |
|
71 |
|
72 bool isPixmap() const; |
|
73 void draw(QPainter *painter); |
|
74 void update(); |
|
75 |
|
76 QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; |
|
77 QRect deviceRect() const; |
|
78 QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, QPoint *offset = 0) const; |
|
79 |
|
80 protected: |
|
81 QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); |
|
82 |
|
83 private: |
|
84 Q_DECLARE_PRIVATE(QGraphicsEffectSource) |
|
85 Q_DISABLE_COPY(QGraphicsEffectSource) |
|
86 friend class QGraphicsEffect; |
|
87 friend class QGraphicsEffectPrivate; |
|
88 friend class QGraphicsScenePrivate; |
|
89 friend class QGraphicsItem; |
|
90 friend class QGraphicsItemPrivate; |
|
91 friend class QWidget; |
|
92 friend class QWidgetPrivate; |
|
93 }; |
|
94 |
|
95 class QGraphicsEffectPrivate; |
|
96 class Q_GUI_EXPORT QGraphicsEffect : public QObject |
|
97 { |
|
98 Q_OBJECT |
|
99 Q_FLAGS(ChangeFlags) |
|
100 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) |
|
101 public: |
|
102 enum ChangeFlag { |
|
103 SourceAttached = 0x1, |
|
104 SourceDetached = 0x2, |
|
105 SourceBoundingRectChanged = 0x4, |
|
106 SourceInvalidated = 0x8 |
|
107 }; |
|
108 Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) |
|
109 |
|
110 QGraphicsEffect(QObject *parent = 0); |
|
111 virtual ~QGraphicsEffect(); |
|
112 |
|
113 virtual QRectF boundingRectFor(const QRectF &rect) const; |
|
114 QRectF boundingRect() const; |
|
115 |
|
116 QGraphicsEffectSource *source() const; |
|
117 |
|
118 bool isEnabled() const; |
|
119 |
|
120 public Q_SLOTS: |
|
121 void setEnabled(bool enable); |
|
122 void update(); |
|
123 |
|
124 Q_SIGNALS: |
|
125 void enabledChanged(bool enabled); |
|
126 |
|
127 protected: |
|
128 QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0); |
|
129 virtual void draw(QPainter *painter, QGraphicsEffectSource *source) = 0; |
|
130 virtual void sourceChanged(ChangeFlags flags); |
|
131 void updateBoundingRect(); |
|
132 |
|
133 private: |
|
134 Q_DECLARE_PRIVATE(QGraphicsEffect) |
|
135 Q_DISABLE_COPY(QGraphicsEffect) |
|
136 friend class QGraphicsItem; |
|
137 friend class QGraphicsItemPrivate; |
|
138 friend class QGraphicsScenePrivate; |
|
139 friend class QWidget; |
|
140 friend class QWidgetPrivate; |
|
141 }; |
|
142 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags) |
|
143 |
|
144 class QGraphicsGrayscaleEffectPrivate; |
|
145 class Q_GUI_EXPORT QGraphicsGrayscaleEffect: public QGraphicsEffect |
|
146 { |
|
147 Q_OBJECT |
|
148 Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged) |
|
149 public: |
|
150 QGraphicsGrayscaleEffect(QObject *parent = 0); |
|
151 ~QGraphicsGrayscaleEffect(); |
|
152 |
|
153 qreal strength() const; |
|
154 |
|
155 protected: |
|
156 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
157 |
|
158 public Q_SLOTS: |
|
159 void setStrength(qreal strength); |
|
160 |
|
161 Q_SIGNALS: |
|
162 void strengthChanged(qreal strength); |
|
163 |
|
164 private: |
|
165 Q_DECLARE_PRIVATE(QGraphicsGrayscaleEffect) |
|
166 Q_DISABLE_COPY(QGraphicsGrayscaleEffect) |
|
167 }; |
|
168 |
|
169 class QGraphicsColorizeEffectPrivate; |
|
170 class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect |
|
171 { |
|
172 Q_OBJECT |
|
173 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
174 Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged) |
|
175 public: |
|
176 QGraphicsColorizeEffect(QObject *parent = 0); |
|
177 ~QGraphicsColorizeEffect(); |
|
178 |
|
179 QColor color() const; |
|
180 qreal strength() const; |
|
181 |
|
182 public Q_SLOTS: |
|
183 void setColor(const QColor &c); |
|
184 void setStrength(qreal strength); |
|
185 |
|
186 Q_SIGNALS: |
|
187 void colorChanged(const QColor &color); |
|
188 void strengthChanged(qreal strength); |
|
189 |
|
190 protected: |
|
191 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
192 |
|
193 private: |
|
194 Q_DECLARE_PRIVATE(QGraphicsColorizeEffect) |
|
195 Q_DISABLE_COPY(QGraphicsColorizeEffect) |
|
196 }; |
|
197 |
|
198 class QGraphicsPixelizeEffectPrivate; |
|
199 class Q_GUI_EXPORT QGraphicsPixelizeEffect: public QGraphicsEffect |
|
200 { |
|
201 Q_OBJECT |
|
202 Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize NOTIFY pixelSizeChanged) |
|
203 public: |
|
204 QGraphicsPixelizeEffect(QObject *parent = 0); |
|
205 ~QGraphicsPixelizeEffect(); |
|
206 |
|
207 int pixelSize() const; |
|
208 |
|
209 public Q_SLOTS: |
|
210 void setPixelSize(int pixelSize); |
|
211 |
|
212 Q_SIGNALS: |
|
213 void pixelSizeChanged(int pixelSize); |
|
214 |
|
215 protected: |
|
216 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
217 |
|
218 private: |
|
219 Q_DECLARE_PRIVATE(QGraphicsPixelizeEffect) |
|
220 Q_DISABLE_COPY(QGraphicsPixelizeEffect) |
|
221 }; |
|
222 |
|
223 class QGraphicsBlurEffectPrivate; |
|
224 class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect |
|
225 { |
|
226 Q_OBJECT |
|
227 Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
|
228 Q_PROPERTY(Qt::RenderHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) |
|
229 public: |
|
230 QGraphicsBlurEffect(QObject *parent = 0); |
|
231 ~QGraphicsBlurEffect(); |
|
232 |
|
233 QRectF boundingRectFor(const QRectF &rect) const; |
|
234 int blurRadius() const; |
|
235 Qt::RenderHint blurHint() const; |
|
236 |
|
237 public Q_SLOTS: |
|
238 void setBlurRadius(int blurRadius); |
|
239 void setBlurHint(Qt::RenderHint hint); |
|
240 |
|
241 Q_SIGNALS: |
|
242 void blurRadiusChanged(int blurRadius); |
|
243 void blurHintChanged(Qt::RenderHint hint); |
|
244 |
|
245 protected: |
|
246 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
247 |
|
248 private: |
|
249 Q_DECLARE_PRIVATE(QGraphicsBlurEffect) |
|
250 Q_DISABLE_COPY(QGraphicsBlurEffect) |
|
251 }; |
|
252 |
|
253 class QGraphicsDropShadowEffectPrivate; |
|
254 class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect |
|
255 { |
|
256 Q_OBJECT |
|
257 Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) |
|
258 Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) |
|
259 Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) |
|
260 Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
|
261 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
|
262 public: |
|
263 QGraphicsDropShadowEffect(QObject *parent = 0); |
|
264 ~QGraphicsDropShadowEffect(); |
|
265 |
|
266 QRectF boundingRectFor(const QRectF &rect) const; |
|
267 QPointF offset() const; |
|
268 |
|
269 inline qreal xOffset() const |
|
270 { return offset().x(); } |
|
271 |
|
272 inline qreal yOffset() const |
|
273 { return offset().y(); } |
|
274 |
|
275 int blurRadius() const; |
|
276 QColor color() const; |
|
277 |
|
278 public Q_SLOTS: |
|
279 void setOffset(const QPointF &ofs); |
|
280 |
|
281 inline void setOffset(qreal dx, qreal dy) |
|
282 { setOffset(QPointF(dx, dy)); } |
|
283 |
|
284 inline void setOffset(qreal d) |
|
285 { setOffset(QPointF(d, d)); } |
|
286 |
|
287 inline void setXOffset(qreal dx) |
|
288 { setOffset(QPointF(dx, yOffset())); } |
|
289 |
|
290 inline void setYOffset(qreal dy) |
|
291 { setOffset(QPointF(xOffset(), dy)); } |
|
292 |
|
293 void setBlurRadius(int blurRadius); |
|
294 void setColor(const QColor &color); |
|
295 |
|
296 Q_SIGNALS: |
|
297 void offsetChanged(const QPointF &offset); |
|
298 void blurRadiusChanged(int blurRadius); |
|
299 void colorChanged(const QColor &color); |
|
300 |
|
301 protected: |
|
302 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
303 |
|
304 private: |
|
305 Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect) |
|
306 Q_DISABLE_COPY(QGraphicsDropShadowEffect) |
|
307 }; |
|
308 |
|
309 class QGraphicsOpacityEffectPrivate; |
|
310 class Q_GUI_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect |
|
311 { |
|
312 Q_OBJECT |
|
313 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) |
|
314 Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged) |
|
315 public: |
|
316 QGraphicsOpacityEffect(QObject *parent = 0); |
|
317 ~QGraphicsOpacityEffect(); |
|
318 |
|
319 qreal opacity() const; |
|
320 QBrush opacityMask() const; |
|
321 |
|
322 public Q_SLOTS: |
|
323 void setOpacity(qreal opacity); |
|
324 void setOpacityMask(const QBrush &mask); |
|
325 |
|
326 Q_SIGNALS: |
|
327 void opacityChanged(qreal opacity); |
|
328 void opacityMaskChanged(const QBrush &mask); |
|
329 |
|
330 protected: |
|
331 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
332 |
|
333 private: |
|
334 Q_DECLARE_PRIVATE(QGraphicsOpacityEffect) |
|
335 Q_DISABLE_COPY(QGraphicsOpacityEffect) |
|
336 }; |
|
337 |
|
338 class QGraphicsBloomEffectPrivate; |
|
339 class Q_GUI_EXPORT QGraphicsBloomEffect: public QGraphicsEffect |
|
340 { |
|
341 Q_OBJECT |
|
342 Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
|
343 Q_PROPERTY(Qt::RenderHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) |
|
344 Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) |
|
345 Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged) |
|
346 public: |
|
347 QGraphicsBloomEffect(QObject *parent = 0); |
|
348 ~QGraphicsBloomEffect(); |
|
349 |
|
350 QRectF boundingRectFor(const QRectF &rect) const; |
|
351 int blurRadius() const; |
|
352 Qt::RenderHint blurHint() const; |
|
353 int brightness() const; |
|
354 qreal strength() const; |
|
355 |
|
356 public Q_SLOTS: |
|
357 void setBlurRadius(int blurRadius); |
|
358 void setBlurHint(Qt::RenderHint hint); |
|
359 void setBrightness(int brightness); |
|
360 void setStrength(qreal strength); |
|
361 |
|
362 Q_SIGNALS: |
|
363 void blurRadiusChanged(int blurRadius); |
|
364 void blurHintChanged(Qt::RenderHint hint); |
|
365 void brightnessChanged(int brightness); |
|
366 void strengthChanged(qreal strength); |
|
367 |
|
368 protected: |
|
369 void draw(QPainter *painter, QGraphicsEffectSource *source); |
|
370 |
|
371 private: |
|
372 Q_DECLARE_PRIVATE(QGraphicsBloomEffect) |
|
373 Q_DISABLE_COPY(QGraphicsBloomEffect) |
|
374 }; |
|
375 |
|
376 QT_END_NAMESPACE |
|
377 |
|
378 QT_END_HEADER |
|
379 |
|
380 #endif // QGRAPHICSEFFECT_H |
|
381 |