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 QtSvg 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 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 | 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 QSvgText : public QSvgNode
|
---|
186 | {
|
---|
187 | public:
|
---|
188 | enum WhitespaceMode
|
---|
189 | {
|
---|
190 | Default,
|
---|
191 | Preserve
|
---|
192 | };
|
---|
193 |
|
---|
194 | QSvgText(QSvgNode *parent, const QPointF &coord);
|
---|
195 | ~QSvgText();
|
---|
196 | void setTextArea(const QSizeF &size);
|
---|
197 |
|
---|
198 | virtual void draw(QPainter *p, QSvgExtraStates &states);
|
---|
199 | virtual Type type() const;
|
---|
200 | void insertText(const QString &text, WhitespaceMode mode);
|
---|
201 | void insertFormat(const QTextCharFormat &format);
|
---|
202 | void insertLineBreak();
|
---|
203 | void popFormat();
|
---|
204 | void setTextAlignment(const Qt::Alignment &alignment);
|
---|
205 | const QTextCharFormat &topFormat() const;
|
---|
206 | qreal scale() const;
|
---|
207 | void setScale(qreal scale);
|
---|
208 | //virtual QRectF bounds() const;
|
---|
209 | private:
|
---|
210 | QPointF m_coord;
|
---|
211 |
|
---|
212 | QVector<QString> m_paragraphs;
|
---|
213 | QStack<QTextCharFormat> m_formats;
|
---|
214 | Qt::Alignment m_textAlignment;
|
---|
215 | QVector<QList<QTextLayout::FormatRange> > m_formatRanges;
|
---|
216 | qreal m_scale;
|
---|
217 | bool m_appendSpace;
|
---|
218 | Type m_type;
|
---|
219 | QSizeF m_size;
|
---|
220 | };
|
---|
221 |
|
---|
222 | class QSvgUse : public QSvgNode
|
---|
223 | {
|
---|
224 | public:
|
---|
225 | QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link);
|
---|
226 | virtual void draw(QPainter *p, QSvgExtraStates &states);
|
---|
227 | virtual Type type() const;
|
---|
228 | virtual QRectF bounds() const;
|
---|
229 | virtual QRectF transformedBounds(const QTransform &transform) const;
|
---|
230 |
|
---|
231 | private:
|
---|
232 | QSvgNode *m_link;
|
---|
233 | QPointF m_start;
|
---|
234 | mutable QRectF m_bounds;
|
---|
235 | };
|
---|
236 |
|
---|
237 | class QSvgVideo : public QSvgNode
|
---|
238 | {
|
---|
239 | public:
|
---|
240 | virtual void draw(QPainter *p, QSvgExtraStates &states);
|
---|
241 | virtual Type type() const;
|
---|
242 | };
|
---|
243 |
|
---|
244 | QT_END_NAMESPACE
|
---|
245 |
|
---|
246 | #endif // QT_NO_SVG
|
---|
247 | #endif // QSVGGRAPHICS_P_H
|
---|