source: trunk/src/svg/qsvggraphics_p.h@ 561

Last change on this file since 561 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 7.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtSvg module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** 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 have questions regarding the use of this file, please contact
37** Nokia 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
66QT_BEGIN_NAMESPACE
67
68class QTextCharFormat;
69
70class QSvgAnimation : public QSvgNode
71{
72public:
73 virtual void draw(QPainter *p, QSvgExtraStates &states);
74 virtual Type type() const;
75};
76
77class QSvgArc : public QSvgNode
78{
79public:
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;
84private:
85 QPainterPath cubic;
86 QRectF m_cachedBounds;
87};
88
89class QSvgCircle : public QSvgNode
90{
91public:
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;
96private:
97 QRectF m_bounds;
98};
99
100class QSvgEllipse : public QSvgNode
101{
102public:
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;
107private:
108 QRectF m_bounds;
109};
110
111class QSvgImage : public QSvgNode
112{
113public:
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;
119private:
120 QImage m_image;
121 QRect m_bounds;
122};
123
124class QSvgLine : public QSvgNode
125{
126public:
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;
131private:
132 QLineF m_bounds;
133};
134
135class QSvgPath : public QSvgNode
136{
137public:
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 }
146private:
147 QPainterPath m_path;
148 mutable QRectF m_cachedBounds;
149};
150
151class QSvgPolygon : public QSvgNode
152{
153public:
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;
158private:
159 QPolygonF m_poly;
160};
161
162class QSvgPolyline : public QSvgNode
163{
164public:
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;
169private:
170 QPolygonF m_poly;
171};
172
173class QSvgRect : public QSvgNode
174{
175public:
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;
180private:
181 QRectF m_rect;
182 int m_rx, m_ry;
183};
184
185class QSvgTspan;
186
187class QSvgText : public QSvgNode
188{
189public:
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;
209private:
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
223class QSvgTspan : public QSvgNode
224{
225public:
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;}
239private:
240 QString m_text;
241 QSvgText::WhitespaceMode m_mode;
242 bool m_isTspan;
243};
244
245class QSvgUse : public QSvgNode
246{
247public:
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
254private:
255 QSvgNode *m_link;
256 QPointF m_start;
257 mutable QRectF m_bounds;
258};
259
260class QSvgVideo : public QSvgNode
261{
262public:
263 virtual void draw(QPainter *p, QSvgExtraStates &states);
264 virtual Type type() const;
265};
266
267QT_END_NAMESPACE
268
269#endif // QT_NO_SVG
270#endif // QSVGGRAPHICS_P_H
Note: See TracBrowser for help on using the repository browser.