Qt 4.8
qgraphicseffect_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QGRAPHICSEFFECT_P_H
43 #define QGRAPHICSEFFECT_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists for the convenience
50 // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
51 // file may change from version to version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "qgraphicseffect.h"
57 
58 #include <QPixmapCache>
59 
60 #include <private/qobject_p.h>
61 #include <private/qpixmapfilter_p.h>
62 
63 #ifndef QT_NO_GRAPHICSEFFECT
65 
68 {
69  Q_OBJECT
70 public:
72  const QGraphicsItem *graphicsItem() const;
73  const QWidget *widget() const;
74  const QStyleOption *styleOption() const;
75 
76  bool isPixmap() const;
77  void draw(QPainter *painter);
78  void update();
79 
81  QRect deviceRect() const;
83  QPoint *offset = 0,
85 
86 protected:
88 
89 private:
97  friend class QWidget;
99 };
100 
102 {
104 public:
106  : QObjectPrivate()
107  , m_cachedSystem(Qt::DeviceCoordinates)
108  , m_cachedMode(QGraphicsEffect::PadToTransparentBorder)
109  {}
110 
112  {
115  SourceChanged
116  };
117 
118  virtual ~QGraphicsEffectSourcePrivate();
119  virtual void detach() = 0;
120  virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0;
121  virtual QRect deviceRect() const = 0;
122  virtual const QGraphicsItem *graphicsItem() const = 0;
123  virtual const QWidget *widget() const = 0;
124  virtual const QStyleOption *styleOption() const = 0;
125  virtual void draw(QPainter *p) = 0;
126  virtual void update() = 0;
127  virtual bool isPixmap() const = 0;
128  virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0,
130  virtual void effectBoundingRectChanged() = 0;
131 
132  void setCachedOffset(const QPoint &offset);
133  void invalidateCache(InvalidateReason reason = SourceChanged) const;
134  Qt::CoordinateSystem currentCachedSystem() const { return m_cachedSystem; }
135  QGraphicsEffect::PixmapPadMode currentCachedMode() const { return m_cachedMode; }
136 
137  friend class QGraphicsScenePrivate;
138  friend class QGraphicsItem;
139  friend class QGraphicsItemPrivate;
140 
141 private:
146 };
147 
149 {
151 public:
152  QGraphicsEffectPrivate() : source(0), isEnabled(1) {}
153 
155  {
156  QGraphicsEffect::ChangeFlags flags;
157  if (source) {
159  source->d_func()->invalidateCache();
160  source->d_func()->detach();
161  delete source;
162  }
163  source = newSource;
164  if (newSource)
166  q_func()->sourceChanged(flags);
167  }
168 
172  quint32 padding : 31; // feel free to use
173 };
174 
175 
177 {
179 public:
181  : opaque(true)
182  {
184  }
186 
190 };
191 
193 {
195 public:
198 
200 };
201 
203 {
205 public:
208 
210 };
211 
213 {
215 public:
217  : opacity(qreal(0.7)), isFullyTransparent(0), isFullyOpaque(0), hasOpacityMask(0) {}
219 
225 };
226 
228 
229 #endif //QT_NO_GRAPHICSEFFECT
230 #endif // QGRAPHICSEFFECT_P_H
231 
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
CoordinateSystem
Definition: qnamespace.h:1733
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on...
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
The QGraphicsDropShadowEffect class provides a drop shadow effect.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QGraphicsBlurEffect class provides a blur effect.
Qt::CoordinateSystem currentCachedSystem() const
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QGraphicsColorizeEffect class provides a colorize effect.
The QPixmapColorizeFilter class provides colorizing filtering for pixmaps.
The QStyleOption class stores the parameters used by QStyle functions.
Definition: qstyleoption.h:67
The QPixmapBlurFilter class provides blur filtering for pixmaps.
unsigned int uint
Definition: qglobal.h:996
QPixmapDropShadowFilter * filter
PixmapPadMode
This enum describes how the pixmap returned from sourcePixmap should be padded.
QGraphicsEffectSource * source
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QGraphicsOpacityEffect class provides an opacity effect.
The QPixmapCache::Key class can be used for efficient access to the QPixmapCache. ...
Definition: qpixmapcache.h:61
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
unsigned int quint32
Definition: qglobal.h:938
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows...
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
Qt::CoordinateSystem m_cachedSystem
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QPixmapBlurFilter * filter
QGraphicsEffect::PixmapPadMode currentCachedMode() const
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
void setGraphicsEffectSource(QGraphicsEffectSource *newSource)
QGraphicsEffect::PixmapPadMode m_cachedMode
#define class
QPixmapColorizeFilter * filter
The QGraphicsEffect class is the base class for all graphics effects.