Qt 4.8
qsvggraphics_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 QtSvg 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 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 
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(QPainter *p, QSvgExtraStates &states) const;
84 private:
86 };
87 
88 class QSvgEllipse : public QSvgNode
89 {
90 public:
91  QSvgEllipse(QSvgNode *parent, const QRectF &rect);
92  virtual void draw(QPainter *p, QSvgExtraStates &states);
93  virtual Type type() const;
94  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
95 private:
97 };
98 
99 class QSvgCircle : public QSvgEllipse
100 {
101 public:
102  QSvgCircle(QSvgNode *parent, const QRectF &rect) : QSvgEllipse(parent, rect) { }
103  virtual Type type() const;
104 };
105 
106 class QSvgImage : public QSvgNode
107 {
108 public:
109  QSvgImage(QSvgNode *parent, const QImage &image,
110  const QRect &bounds);
111  virtual void draw(QPainter *p, QSvgExtraStates &states);
112  virtual Type type() const;
113  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
114 private:
117 };
118 
119 class QSvgLine : public QSvgNode
120 {
121 public:
122  QSvgLine(QSvgNode *parent, const QLineF &line);
123  virtual void draw(QPainter *p, QSvgExtraStates &states);
124  virtual Type type() const;
125  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
126 private:
128 };
129 
130 class QSvgPath : public QSvgNode
131 {
132 public:
133  QSvgPath(QSvgNode *parent, const QPainterPath &qpath);
134  virtual void draw(QPainter *p, QSvgExtraStates &states);
135  virtual Type type() const;
136  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
137 
139  return &m_path;
140  }
141 private:
143 };
144 
145 class QSvgPolygon : public QSvgNode
146 {
147 public:
148  QSvgPolygon(QSvgNode *parent, const QPolygonF &poly);
149  virtual void draw(QPainter *p, QSvgExtraStates &states);
150  virtual Type type() const;
151  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
152 private:
154 };
155 
156 class QSvgPolyline : public QSvgNode
157 {
158 public:
159  QSvgPolyline(QSvgNode *parent, const QPolygonF &poly);
160  virtual void draw(QPainter *p, QSvgExtraStates &states);
161  virtual Type type() const;
162  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
163 private:
165 };
166 
167 class QSvgRect : public QSvgNode
168 {
169 public:
170  QSvgRect(QSvgNode *paren, const QRectF &rect, int rx=0, int ry=0);
171  virtual Type type() const;
172  virtual void draw(QPainter *p, QSvgExtraStates &states);
173  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
174 private:
176  int m_rx, m_ry;
177 };
178 
179 class QSvgTspan;
180 
181 class QSvgText : public QSvgNode
182 {
183 public:
185  {
187  Preserve
188  };
189 
190  QSvgText(QSvgNode *parent, const QPointF &coord);
191  ~QSvgText();
192  void setTextArea(const QSizeF &size);
193 
194  virtual void draw(QPainter *p, QSvgExtraStates &states);
195  virtual Type type() const;
196 
197  void addTspan(QSvgTspan *tspan) {m_tspans.append(tspan);}
198  void addText(const QString &text);
199  void addLineBreak() {m_tspans.append(LINEBREAK);}
200  void setWhitespaceMode(WhitespaceMode mode) {m_mode = mode;}
201 
202  //virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
203 private:
204  static QSvgTspan * const LINEBREAK;
205 
207 
208  // 'm_tspans' is also used to store characters outside tspans and line breaks.
209  // If a 'm_tspan' item is null, it indicates a line break.
211 
215 };
216 
217 class QSvgTspan : public QSvgNode
218 {
219 public:
220  // tspans are also used to store normal text, so the 'isProperTspan' is used to separate text from tspan.
221  QSvgTspan(QSvgNode *parent, bool isProperTspan = true)
222  : QSvgNode(parent), m_mode(QSvgText::Default), m_isTspan(isProperTspan)
223  {
224  }
225  ~QSvgTspan() { };
226  virtual Type type() const {return TSPAN;}
227  virtual void draw(QPainter *, QSvgExtraStates &) {Q_ASSERT(!"Tspans should be drawn through QSvgText::draw().");}
228  void addText(const QString &text) {m_text += text;}
229  const QString &text() const {return m_text;}
230  bool isTspan() const {return m_isTspan;}
231  void setWhitespaceMode(QSvgText::WhitespaceMode mode) {m_mode = mode;}
232  QSvgText::WhitespaceMode whitespaceMode() const {return m_mode;}
233 private:
236  bool m_isTspan;
237 };
238 
239 class QSvgUse : public QSvgNode
240 {
241 public:
242  QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link);
243  virtual void draw(QPainter *p, QSvgExtraStates &states);
244  virtual Type type() const;
245  virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
246 
247 private:
250 };
251 
252 class QSvgVideo : public QSvgNode
253 {
254 public:
255  virtual void draw(QPainter *p, QSvgExtraStates &states);
256  virtual Type type() const;
257 };
258 
260 
261 #endif // QT_NO_SVG
262 #endif // QSVGGRAPHICS_P_H
QPolygonF m_poly
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void addText(const QString &text)
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
virtual Type type() const
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void addTspan(QSvgTspan *tspan)
QSvgNode * m_link
QLineF m_line
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
void setWhitespaceMode(WhitespaceMode mode)
QPolygonF m_poly
QPainterPath m_path
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual Type type() const
QSvgText::WhitespaceMode m_mode
QSvgNode * parent() const
Definition: qsvgnode_p.h:183
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
QSvgCircle(QSvgNode *parent, const QRectF &rect)
QString m_text
virtual void draw(QPainter *, QSvgExtraStates &)
void addLineBreak()
static const uint Default
Definition: qsplitter_p.h:61
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:212
virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:199
QVector< QSvgTspan * > m_tspans
#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
QImage m_image
bool isTspan() const
QSizeF m_size
The QPolygonF class provides a vector of points using floating point precision.
Definition: qpolygon.h:134
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
QPointF m_start
virtual void draw(QPainter *p, QSvgExtraStates &states)
WhitespaceMode m_mode
QRect m_bounds
QRectF m_rect
QPointF m_coord
const QString & text() const
QSvgText::WhitespaceMode whitespaceMode() const
QPainterPath * qpath()
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
static QSvgTspan *const LINEBREAK
QSvgTspan(QSvgNode *parent, bool isProperTspan=true)
QRectF m_bounds
QPainterPath m_path
#define text
Definition: qobjectdefs.h:80
void setWhitespaceMode(QSvgText::WhitespaceMode mode)