author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 15 Mar 2010 12:43:09 +0200 | |
branch | RCL_3 |
changeset 6 | dee5afe5301f |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtSvg 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 QSVGGRAPHICS_P_H |
|
43 |
#define QSVGGRAPHICS_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 "qsvgnode_p.h" |
|
57 |
||
58 |
#ifndef QT_NO_SVG |
|
59 |
||
60 |
#include "QtGui/qpainterpath.h" |
|
61 |
#include "QtGui/qimage.h" |
|
62 |
#include "QtGui/qtextlayout.h" |
|
63 |
#include "QtGui/qtextoption.h" |
|
64 |
#include "QtCore/qstack.h" |
|
65 |
||
66 |
QT_BEGIN_NAMESPACE |
|
67 |
||
68 |
class QTextCharFormat; |
|
69 |
||
70 |
class QSvgAnimation : public QSvgNode |
|
71 |
{ |
|
72 |
public: |
|
73 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
74 |
virtual Type type() const; |
|
75 |
}; |
|
76 |
||
77 |
class QSvgArc : public QSvgNode |
|
78 |
{ |
|
79 |
public: |
|
80 |
QSvgArc(QSvgNode *parent, const QPainterPath &path); |
|
81 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
82 |
virtual Type type() const; |
|
83 |
virtual QRectF bounds() const; |
|
84 |
private: |
|
85 |
QPainterPath cubic; |
|
86 |
QRectF m_cachedBounds; |
|
87 |
}; |
|
88 |
||
89 |
class QSvgCircle : public QSvgNode |
|
90 |
{ |
|
91 |
public: |
|
92 |
QSvgCircle(QSvgNode *parent, const QRectF &rect); |
|
93 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
94 |
virtual Type type() const; |
|
95 |
virtual QRectF bounds() const; |
|
96 |
private: |
|
97 |
QRectF m_bounds; |
|
98 |
}; |
|
99 |
||
100 |
class QSvgEllipse : public QSvgNode |
|
101 |
{ |
|
102 |
public: |
|
103 |
QSvgEllipse(QSvgNode *parent, const QRectF &rect); |
|
104 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
105 |
virtual Type type() const; |
|
106 |
virtual QRectF bounds() const; |
|
107 |
private: |
|
108 |
QRectF m_bounds; |
|
109 |
}; |
|
110 |
||
111 |
class QSvgImage : public QSvgNode |
|
112 |
{ |
|
113 |
public: |
|
114 |
QSvgImage(QSvgNode *parent, const QImage &image, |
|
115 |
const QRect &bounds); |
|
116 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
117 |
virtual Type type() const; |
|
118 |
virtual QRectF bounds() const; |
|
119 |
private: |
|
120 |
QImage m_image; |
|
121 |
QRect m_bounds; |
|
122 |
}; |
|
123 |
||
124 |
class QSvgLine : public QSvgNode |
|
125 |
{ |
|
126 |
public: |
|
127 |
QSvgLine(QSvgNode *parent, const QLineF &line); |
|
128 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
129 |
virtual Type type() const; |
|
130 |
virtual QRectF bounds() const; |
|
131 |
private: |
|
132 |
QLineF m_bounds; |
|
133 |
}; |
|
134 |
||
135 |
class QSvgPath : public QSvgNode |
|
136 |
{ |
|
137 |
public: |
|
138 |
QSvgPath(QSvgNode *parent, const QPainterPath &qpath); |
|
139 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
140 |
virtual Type type() const; |
|
141 |
virtual QRectF bounds() const; |
|
142 |
||
143 |
QPainterPath *qpath() { |
|
144 |
return &m_path; |
|
145 |
} |
|
146 |
private: |
|
147 |
QPainterPath m_path; |
|
148 |
mutable QRectF m_cachedBounds; |
|
149 |
}; |
|
150 |
||
151 |
class QSvgPolygon : public QSvgNode |
|
152 |
{ |
|
153 |
public: |
|
154 |
QSvgPolygon(QSvgNode *parent, const QPolygonF &poly); |
|
155 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
156 |
virtual Type type() const; |
|
157 |
virtual QRectF bounds() const; |
|
158 |
private: |
|
159 |
QPolygonF m_poly; |
|
160 |
}; |
|
161 |
||
162 |
class QSvgPolyline : public QSvgNode |
|
163 |
{ |
|
164 |
public: |
|
165 |
QSvgPolyline(QSvgNode *parent, const QPolygonF &poly); |
|
166 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
167 |
virtual Type type() const; |
|
168 |
virtual QRectF bounds() const; |
|
169 |
private: |
|
170 |
QPolygonF m_poly; |
|
171 |
}; |
|
172 |
||
173 |
class QSvgRect : public QSvgNode |
|
174 |
{ |
|
175 |
public: |
|
176 |
QSvgRect(QSvgNode *paren, const QRectF &rect, int rx=0, int ry=0); |
|
177 |
virtual Type type() const; |
|
178 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
179 |
virtual QRectF bounds() const; |
|
180 |
private: |
|
181 |
QRectF m_rect; |
|
182 |
int m_rx, m_ry; |
|
183 |
}; |
|
184 |
||
185 |
class QSvgTspan; |
|
186 |
||
187 |
class QSvgText : public QSvgNode |
|
188 |
{ |
|
189 |
public: |
|
190 |
enum WhitespaceMode |
|
191 |
{ |
|
192 |
Default, |
|
193 |
Preserve |
|
194 |
}; |
|
195 |
||
196 |
QSvgText(QSvgNode *parent, const QPointF &coord); |
|
197 |
~QSvgText(); |
|
198 |
void setTextArea(const QSizeF &size); |
|
199 |
||
200 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
201 |
virtual Type type() const; |
|
202 |
||
203 |
void addTspan(QSvgTspan *tspan) {m_tspans.append(tspan);} |
|
204 |
void addText(const QString &text); |
|
205 |
void addLineBreak() {m_tspans.append(LINEBREAK);} |
|
206 |
void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;} |
|
207 |
||
208 |
//virtual QRectF bounds() const; |
|
209 |
private: |
|
210 |
static QSvgTspan * const LINEBREAK; |
|
211 |
||
212 |
QPointF m_coord; |
|
213 |
||
214 |
// 'm_tspans' is also used to store characters outside tspans and line breaks. |
|
215 |
// If a 'm_tspan' item is null, it indicates a line break. |
|
216 |
QVector<QSvgTspan *> m_tspans; |
|
217 |
||
218 |
Type m_type; |
|
219 |
QSizeF m_size; |
|
220 |
WhitespaceMode m_mode; |
|
221 |
}; |
|
222 |
||
223 |
class QSvgTspan : public QSvgNode |
|
224 |
{ |
|
225 |
public: |
|
226 |
// tspans are also used to store normal text, so the 'isProperTspan' is used to separate text from tspan. |
|
227 |
QSvgTspan(QSvgNode *parent, bool isProperTspan = true) |
|
228 |
: QSvgNode(parent), m_mode(QSvgText::Default), m_isTspan(isProperTspan) |
|
229 |
{ |
|
230 |
} |
|
231 |
~QSvgTspan() { }; |
|
232 |
virtual Type type() const {return TSPAN;} |
|
233 |
virtual void draw(QPainter *, QSvgExtraStates &) {Q_ASSERT(!"Tspans should be drawn through QSvgText::draw().");} |
|
234 |
void addText(const QString &text) {m_text += text;} |
|
235 |
const QString &text() const {return m_text;} |
|
236 |
bool isTspan() const {return m_isTspan;} |
|
237 |
void setWhitespaceMode(QSvgText::WhitespaceMode mode) {m_mode = mode;} |
|
238 |
QSvgText::WhitespaceMode whitespaceMode() const {return m_mode;} |
|
239 |
private: |
|
240 |
QString m_text; |
|
241 |
QSvgText::WhitespaceMode m_mode; |
|
242 |
bool m_isTspan; |
|
243 |
}; |
|
244 |
||
245 |
class QSvgUse : public QSvgNode |
|
246 |
{ |
|
247 |
public: |
|
248 |
QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link); |
|
249 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
250 |
virtual Type type() const; |
|
251 |
virtual QRectF bounds() const; |
|
252 |
virtual QRectF transformedBounds(const QTransform &transform) const; |
|
253 |
||
254 |
private: |
|
255 |
QSvgNode *m_link; |
|
256 |
QPointF m_start; |
|
257 |
mutable QRectF m_bounds; |
|
258 |
}; |
|
259 |
||
260 |
class QSvgVideo : public QSvgNode |
|
261 |
{ |
|
262 |
public: |
|
263 |
virtual void draw(QPainter *p, QSvgExtraStates &states); |
|
264 |
virtual Type type() const; |
|
265 |
}; |
|
266 |
||
267 |
QT_END_NAMESPACE |
|
268 |
||
269 |
#endif // QT_NO_SVG |
|
270 |
#endif // QSVGGRAPHICS_P_H |