57 class QGraphicsItem; |
58 class QGraphicsItem; |
58 class QStyleOption; |
59 class QStyleOption; |
59 class QPainter; |
60 class QPainter; |
60 class QPixmap; |
61 class QPixmap; |
61 |
62 |
62 class QGraphicsEffectSourcePrivate; |
63 class QGraphicsEffectSource; |
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 |
64 |
95 class QGraphicsEffectPrivate; |
65 class QGraphicsEffectPrivate; |
96 class Q_GUI_EXPORT QGraphicsEffect : public QObject |
66 class Q_GUI_EXPORT QGraphicsEffect : public QObject |
97 { |
67 { |
98 Q_OBJECT |
68 Q_OBJECT |
105 SourceBoundingRectChanged = 0x4, |
75 SourceBoundingRectChanged = 0x4, |
106 SourceInvalidated = 0x8 |
76 SourceInvalidated = 0x8 |
107 }; |
77 }; |
108 Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) |
78 Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) |
109 |
79 |
|
80 enum PixmapPadMode { |
|
81 NoPad, |
|
82 PadToTransparentBorder, |
|
83 PadToEffectiveBoundingRect |
|
84 }; |
|
85 |
110 QGraphicsEffect(QObject *parent = 0); |
86 QGraphicsEffect(QObject *parent = 0); |
111 virtual ~QGraphicsEffect(); |
87 virtual ~QGraphicsEffect(); |
112 |
88 |
113 virtual QRectF boundingRectFor(const QRectF &rect) const; |
89 virtual QRectF boundingRectFor(const QRectF &sourceRect) const; |
114 QRectF boundingRect() const; |
90 QRectF boundingRect() const; |
115 |
|
116 QGraphicsEffectSource *source() const; |
|
117 |
91 |
118 bool isEnabled() const; |
92 bool isEnabled() const; |
119 |
93 |
120 public Q_SLOTS: |
94 public Q_SLOTS: |
121 void setEnabled(bool enable); |
95 void setEnabled(bool enable); |
124 Q_SIGNALS: |
98 Q_SIGNALS: |
125 void enabledChanged(bool enabled); |
99 void enabledChanged(bool enabled); |
126 |
100 |
127 protected: |
101 protected: |
128 QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0); |
102 QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = 0); |
129 virtual void draw(QPainter *painter, QGraphicsEffectSource *source) = 0; |
103 virtual void draw(QPainter *painter) = 0; |
130 virtual void sourceChanged(ChangeFlags flags); |
104 virtual void sourceChanged(ChangeFlags flags); |
131 void updateBoundingRect(); |
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; |
132 |
113 |
133 private: |
114 private: |
134 Q_DECLARE_PRIVATE(QGraphicsEffect) |
115 Q_DECLARE_PRIVATE(QGraphicsEffect) |
135 Q_DISABLE_COPY(QGraphicsEffect) |
116 Q_DISABLE_COPY(QGraphicsEffect) |
136 friend class QGraphicsItem; |
117 friend class QGraphicsItem; |
137 friend class QGraphicsItemPrivate; |
118 friend class QGraphicsItemPrivate; |
138 friend class QGraphicsScenePrivate; |
119 friend class QGraphicsScenePrivate; |
139 friend class QWidget; |
120 friend class QWidget; |
140 friend class QWidgetPrivate; |
121 friend class QWidgetPrivate; |
|
122 |
|
123 public: |
|
124 QGraphicsEffectSource *source() const; // internal |
|
125 |
141 }; |
126 }; |
142 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags) |
127 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 |
128 |
169 class QGraphicsColorizeEffectPrivate; |
129 class QGraphicsColorizeEffectPrivate; |
170 class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect |
130 class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect |
171 { |
131 { |
172 Q_OBJECT |
132 Q_OBJECT |
186 Q_SIGNALS: |
146 Q_SIGNALS: |
187 void colorChanged(const QColor &color); |
147 void colorChanged(const QColor &color); |
188 void strengthChanged(qreal strength); |
148 void strengthChanged(qreal strength); |
189 |
149 |
190 protected: |
150 protected: |
191 void draw(QPainter *painter, QGraphicsEffectSource *source); |
151 void draw(QPainter *painter); |
192 |
152 |
193 private: |
153 private: |
194 Q_DECLARE_PRIVATE(QGraphicsColorizeEffect) |
154 Q_DECLARE_PRIVATE(QGraphicsColorizeEffect) |
195 Q_DISABLE_COPY(QGraphicsColorizeEffect) |
155 Q_DISABLE_COPY(QGraphicsColorizeEffect) |
196 }; |
156 }; |
197 |
157 |
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; |
158 class QGraphicsBlurEffectPrivate; |
224 class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect |
159 class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect |
225 { |
160 { |
226 Q_OBJECT |
161 Q_OBJECT |
227 Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
162 Q_FLAGS(BlurHint BlurHints) |
228 Q_PROPERTY(Qt::RenderHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) |
163 Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
229 public: |
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 |
230 QGraphicsBlurEffect(QObject *parent = 0); |
173 QGraphicsBlurEffect(QObject *parent = 0); |
231 ~QGraphicsBlurEffect(); |
174 ~QGraphicsBlurEffect(); |
232 |
175 |
233 QRectF boundingRectFor(const QRectF &rect) const; |
176 QRectF boundingRectFor(const QRectF &rect) const; |
234 int blurRadius() const; |
177 qreal blurRadius() const; |
235 Qt::RenderHint blurHint() const; |
178 BlurHints blurHints() const; |
236 |
179 |
237 public Q_SLOTS: |
180 public Q_SLOTS: |
238 void setBlurRadius(int blurRadius); |
181 void setBlurRadius(qreal blurRadius); |
239 void setBlurHint(Qt::RenderHint hint); |
182 void setBlurHints(BlurHints hints); |
240 |
183 |
241 Q_SIGNALS: |
184 Q_SIGNALS: |
242 void blurRadiusChanged(int blurRadius); |
185 void blurRadiusChanged(qreal blurRadius); |
243 void blurHintChanged(Qt::RenderHint hint); |
186 void blurHintsChanged(BlurHints hints); |
244 |
187 |
245 protected: |
188 protected: |
246 void draw(QPainter *painter, QGraphicsEffectSource *source); |
189 void draw(QPainter *painter); |
247 |
190 |
248 private: |
191 private: |
249 Q_DECLARE_PRIVATE(QGraphicsBlurEffect) |
192 Q_DECLARE_PRIVATE(QGraphicsBlurEffect) |
250 Q_DISABLE_COPY(QGraphicsBlurEffect) |
193 Q_DISABLE_COPY(QGraphicsBlurEffect) |
251 }; |
194 }; |
|
195 |
|
196 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsBlurEffect::BlurHints) |
252 |
197 |
253 class QGraphicsDropShadowEffectPrivate; |
198 class QGraphicsDropShadowEffectPrivate; |
254 class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect |
199 class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect |
255 { |
200 { |
256 Q_OBJECT |
201 Q_OBJECT |
257 Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) |
202 Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged) |
258 Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) |
203 Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) |
259 Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) |
204 Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) |
260 Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
205 Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) |
261 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
206 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) |
262 public: |
207 public: |
263 QGraphicsDropShadowEffect(QObject *parent = 0); |
208 QGraphicsDropShadowEffect(QObject *parent = 0); |
264 ~QGraphicsDropShadowEffect(); |
209 ~QGraphicsDropShadowEffect(); |
265 |
210 |
288 { setOffset(QPointF(dx, yOffset())); } |
233 { setOffset(QPointF(dx, yOffset())); } |
289 |
234 |
290 inline void setYOffset(qreal dy) |
235 inline void setYOffset(qreal dy) |
291 { setOffset(QPointF(xOffset(), dy)); } |
236 { setOffset(QPointF(xOffset(), dy)); } |
292 |
237 |
293 void setBlurRadius(int blurRadius); |
238 void setBlurRadius(qreal blurRadius); |
294 void setColor(const QColor &color); |
239 void setColor(const QColor &color); |
295 |
240 |
296 Q_SIGNALS: |
241 Q_SIGNALS: |
297 void offsetChanged(const QPointF &offset); |
242 void offsetChanged(const QPointF &offset); |
298 void blurRadiusChanged(int blurRadius); |
243 void blurRadiusChanged(qreal blurRadius); |
299 void colorChanged(const QColor &color); |
244 void colorChanged(const QColor &color); |
300 |
245 |
301 protected: |
246 protected: |
302 void draw(QPainter *painter, QGraphicsEffectSource *source); |
247 void draw(QPainter *painter); |
303 |
248 |
304 private: |
249 private: |
305 Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect) |
250 Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect) |
306 Q_DISABLE_COPY(QGraphicsDropShadowEffect) |
251 Q_DISABLE_COPY(QGraphicsDropShadowEffect) |
307 }; |
252 }; |
326 Q_SIGNALS: |
271 Q_SIGNALS: |
327 void opacityChanged(qreal opacity); |
272 void opacityChanged(qreal opacity); |
328 void opacityMaskChanged(const QBrush &mask); |
273 void opacityMaskChanged(const QBrush &mask); |
329 |
274 |
330 protected: |
275 protected: |
331 void draw(QPainter *painter, QGraphicsEffectSource *source); |
276 void draw(QPainter *painter); |
332 |
277 |
333 private: |
278 private: |
334 Q_DECLARE_PRIVATE(QGraphicsOpacityEffect) |
279 Q_DECLARE_PRIVATE(QGraphicsOpacityEffect) |
335 Q_DISABLE_COPY(QGraphicsOpacityEffect) |
280 Q_DISABLE_COPY(QGraphicsOpacityEffect) |
336 }; |
281 }; |
337 |
282 |
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 |
283 QT_END_NAMESPACE |
377 |
284 |
378 QT_END_HEADER |
285 QT_END_HEADER |
|
286 #endif //QT_NO_GRAPHICSEFFECT |
379 |
287 |
380 #endif // QGRAPHICSEFFECT_H |
288 #endif // QGRAPHICSEFFECT_H |
381 |
289 |