1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QPAINTENGINEEX_P_H
|
---|
43 | #define QPAINTENGINEEX_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 purely as an
|
---|
50 | // implementation detail. This header file may change from version to
|
---|
51 | // version without notice, or even be removed.
|
---|
52 | //
|
---|
53 | // We mean it.
|
---|
54 | //
|
---|
55 |
|
---|
56 | #include <QtGui/qpaintengine.h>
|
---|
57 |
|
---|
58 | #include "qpaintengine_p.h"
|
---|
59 | #include "qstroker_p.h"
|
---|
60 | #include "qpainter_p.h"
|
---|
61 | #include "qvectorpath_p.h"
|
---|
62 |
|
---|
63 |
|
---|
64 | QT_BEGIN_HEADER
|
---|
65 |
|
---|
66 | QT_BEGIN_NAMESPACE
|
---|
67 |
|
---|
68 | QT_MODULE(Gui)
|
---|
69 |
|
---|
70 | class QPainterState;
|
---|
71 | class QPaintEngineExPrivate;
|
---|
72 | struct StrokeHandler;
|
---|
73 |
|
---|
74 |
|
---|
75 | struct QIntRect {
|
---|
76 | int x1, y1, x2, y2;
|
---|
77 | inline void set(const QRect &r) {
|
---|
78 | x1 = r.x();
|
---|
79 | y1 = r.y();
|
---|
80 | x2 = r.right() + 1;
|
---|
81 | y2 = r.bottom() + 1;
|
---|
82 | // We will assume normalized for later...
|
---|
83 | Q_ASSERT(x2 >= x1);
|
---|
84 | Q_ASSERT(y2 >= y1);
|
---|
85 | }
|
---|
86 | };
|
---|
87 |
|
---|
88 | class QRectVectorPath : public QVectorPath {
|
---|
89 | public:
|
---|
90 | inline void set(const QRect &r) {
|
---|
91 | qreal left = r.x();
|
---|
92 | qreal right = r.x() + r.width();
|
---|
93 | qreal top = r.y();
|
---|
94 | qreal bottom = r.y() + r.height();
|
---|
95 | pts[0] = left;
|
---|
96 | pts[1] = top;
|
---|
97 | pts[2] = right;
|
---|
98 | pts[3] = top;
|
---|
99 | pts[4] = right;
|
---|
100 | pts[5] = bottom;
|
---|
101 | pts[6] = left;
|
---|
102 | pts[7] = bottom;
|
---|
103 | }
|
---|
104 |
|
---|
105 | inline void set(const QRectF &r) {
|
---|
106 | qreal left = r.x();
|
---|
107 | qreal right = r.x() + r.width();
|
---|
108 | qreal top = r.y();
|
---|
109 | qreal bottom = r.y() + r.height();
|
---|
110 | pts[0] = left;
|
---|
111 | pts[1] = top;
|
---|
112 | pts[2] = right;
|
---|
113 | pts[3] = top;
|
---|
114 | pts[4] = right;
|
---|
115 | pts[5] = bottom;
|
---|
116 | pts[6] = left;
|
---|
117 | pts[7] = bottom;
|
---|
118 | }
|
---|
119 | inline QRectVectorPath(const QRect &r)
|
---|
120 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
|
---|
121 | {
|
---|
122 | set(r);
|
---|
123 | }
|
---|
124 | inline QRectVectorPath(const QRectF &r)
|
---|
125 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
|
---|
126 | {
|
---|
127 | set(r);
|
---|
128 | }
|
---|
129 | inline QRectVectorPath()
|
---|
130 | : QVectorPath(pts, 4, 0, QVectorPath::RectangleHint | QVectorPath::ImplicitClose)
|
---|
131 | { }
|
---|
132 |
|
---|
133 | qreal pts[8];
|
---|
134 | };
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | #ifndef QT_NO_DEBUG_STREAM
|
---|
139 | QDebug Q_GUI_EXPORT &operator<<(QDebug &, const QVectorPath &path);
|
---|
140 | #endif
|
---|
141 |
|
---|
142 | class Q_GUI_EXPORT QPaintEngineExPrivate : public QPaintEnginePrivate
|
---|
143 | {
|
---|
144 | public:
|
---|
145 | QPaintEngineExPrivate();
|
---|
146 | ~QPaintEngineExPrivate();
|
---|
147 |
|
---|
148 | QStroker stroker;
|
---|
149 | QDashStroker dasher;
|
---|
150 | StrokeHandler *strokeHandler;
|
---|
151 | QStrokerOps *activeStroker;
|
---|
152 | QPen strokerPen;
|
---|
153 | };
|
---|
154 |
|
---|
155 | class QPixmapFilter;
|
---|
156 |
|
---|
157 | class Q_GUI_EXPORT QPaintEngineEx : public QPaintEngine
|
---|
158 | {
|
---|
159 | Q_DECLARE_PRIVATE(QPaintEngineEx)
|
---|
160 | public:
|
---|
161 | inline QPaintEngineEx()
|
---|
162 | : QPaintEngine(*new QPaintEngineExPrivate, AllFeatures) { extended = true; }
|
---|
163 |
|
---|
164 | virtual QPainterState *createState(QPainterState *orig) const;
|
---|
165 |
|
---|
166 | virtual void draw(const QVectorPath &path);
|
---|
167 | virtual void fill(const QVectorPath &path, const QBrush &brush) = 0;
|
---|
168 | virtual void stroke(const QVectorPath &path, const QPen &pen);
|
---|
169 |
|
---|
170 | virtual void clip(const QVectorPath &path, Qt::ClipOperation op) = 0;
|
---|
171 | virtual void clip(const QRect &rect, Qt::ClipOperation op);
|
---|
172 | virtual void clip(const QRegion ®ion, Qt::ClipOperation op);
|
---|
173 | virtual void clip(const QPainterPath &path, Qt::ClipOperation op);
|
---|
174 |
|
---|
175 | virtual void clipEnabledChanged() = 0;
|
---|
176 | virtual void penChanged() = 0;
|
---|
177 | virtual void brushChanged() = 0;
|
---|
178 | virtual void brushOriginChanged() = 0;
|
---|
179 | virtual void opacityChanged() = 0;
|
---|
180 | virtual void compositionModeChanged() = 0;
|
---|
181 | virtual void renderHintsChanged() = 0;
|
---|
182 | virtual void transformChanged() = 0;
|
---|
183 |
|
---|
184 | virtual void fillRect(const QRectF &rect, const QBrush &brush);
|
---|
185 | virtual void fillRect(const QRectF &rect, const QColor &color);
|
---|
186 |
|
---|
187 | virtual void drawRects(const QRect *rects, int rectCount);
|
---|
188 | virtual void drawRects(const QRectF *rects, int rectCount);
|
---|
189 |
|
---|
190 | virtual void drawLines(const QLine *lines, int lineCount);
|
---|
191 | virtual void drawLines(const QLineF *lines, int lineCount);
|
---|
192 |
|
---|
193 | virtual void drawEllipse(const QRectF &r);
|
---|
194 | virtual void drawEllipse(const QRect &r);
|
---|
195 |
|
---|
196 | virtual void drawPath(const QPainterPath &path);
|
---|
197 |
|
---|
198 | virtual void drawPoints(const QPointF *points, int pointCount);
|
---|
199 | virtual void drawPoints(const QPoint *points, int pointCount);
|
---|
200 |
|
---|
201 | virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
---|
202 | virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
|
---|
203 |
|
---|
204 | virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) = 0;
|
---|
205 | virtual void drawPixmap(const QPointF &pos, const QPixmap &pm);
|
---|
206 |
|
---|
207 | virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
|
---|
208 | Qt::ImageConversionFlags flags = Qt::AutoColor) = 0;
|
---|
209 | virtual void drawImage(const QPointF &pos, const QImage &image);
|
---|
210 |
|
---|
211 | virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
|
---|
212 |
|
---|
213 | virtual void updateState(const QPaintEngineState &state);
|
---|
214 |
|
---|
215 | virtual void setState(QPainterState *s);
|
---|
216 | inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
|
---|
217 | inline const QPainterState *state() const { return static_cast<const QPainterState *>(QPaintEngine::state); }
|
---|
218 |
|
---|
219 | virtual QPixmapFilter *createPixmapFilter(int /*type*/) const { return 0; }
|
---|
220 |
|
---|
221 | protected:
|
---|
222 | QPaintEngineEx(QPaintEngineExPrivate &data);
|
---|
223 | };
|
---|
224 |
|
---|
225 |
|
---|
226 | inline uint QVectorPath::polygonFlags(QPaintEngine::PolygonDrawMode mode) {
|
---|
227 | switch (mode) {
|
---|
228 | case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose;
|
---|
229 | case QPaintEngine::OddEvenMode: return NonCurvedShapeHint | OddEvenFill | ImplicitClose;
|
---|
230 | case QPaintEngine::WindingMode: return NonCurvedShapeHint | WindingFill | ImplicitClose;
|
---|
231 | case QPaintEngine::PolylineMode: return NonCurvedShapeHint;
|
---|
232 | default: return 0;
|
---|
233 | }
|
---|
234 | }
|
---|
235 |
|
---|
236 | QT_END_NAMESPACE
|
---|
237 |
|
---|
238 | QT_END_HEADER
|
---|
239 |
|
---|
240 | #endif
|
---|