1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt SVG 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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QSVGNODE_P_H
41#define QSVGNODE_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include "qsvgstyle_p.h"
55#include "qtsvgglobal_p.h"
56
57#include "QtCore/qstring.h"
58#include "QtCore/qhash.h"
59
60QT_BEGIN_NAMESPACE
61
62class QPainter;
63class QSvgTinyDocument;
64
65class Q_SVG_PRIVATE_EXPORT QSvgNode
66{
67public:
68 enum Type
69 {
70 DOC,
71 G,
72 DEFS,
73 SWITCH,
74 ANIMATION,
75 ARC,
76 CIRCLE,
77 ELLIPSE,
78 IMAGE,
79 LINE,
80 PATH,
81 POLYGON,
82 POLYLINE,
83 RECT,
84 TEXT,
85 TEXTAREA,
86 TSPAN,
87 USE,
88 VIDEO
89 };
90 enum DisplayMode {
91 InlineMode,
92 BlockMode,
93 ListItemMode,
94 RunInMode,
95 CompactMode,
96 MarkerMode,
97 TableMode,
98 InlineTableMode,
99 TableRowGroupMode,
100 TableHeaderGroupMode,
101 TableFooterGroupMode,
102 TableRowMode,
103 TableColumnGroupMode,
104 TableColumnMode,
105 TableCellMode,
106 TableCaptionMode,
107 NoneMode,
108 InheritMode
109 };
110public:
111 QSvgNode(QSvgNode *parent=0);
112 virtual ~QSvgNode();
113 virtual void draw(QPainter *p, QSvgExtraStates &states) =0;
114
115 QSvgNode *parent() const;
116 bool isDescendantOf(const QSvgNode *parent) const;
117
118 void appendStyleProperty(QSvgStyleProperty *prop, const QString &id);
119 void applyStyle(QPainter *p, QSvgExtraStates &states) const;
120 void revertStyle(QPainter *p, QSvgExtraStates &states) const;
121 QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
122 QSvgFillStyleProperty *styleProperty(const QString &id) const;
123
124 QSvgTinyDocument *document() const;
125
126 virtual Type type() const =0;
127 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
128 virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const;
129 QRectF transformedBounds() const;
130
131 void setRequiredFeatures(const QStringList &lst);
132 const QStringList & requiredFeatures() const;
133
134 void setRequiredExtensions(const QStringList &lst);
135 const QStringList & requiredExtensions() const;
136
137 void setRequiredLanguages(const QStringList &lst);
138 const QStringList & requiredLanguages() const;
139
140 void setRequiredFormats(const QStringList &lst);
141 const QStringList & requiredFormats() const;
142
143 void setRequiredFonts(const QStringList &lst);
144 const QStringList & requiredFonts() const;
145
146 void setVisible(bool visible);
147 bool isVisible() const;
148
149 void setDisplayMode(DisplayMode display);
150 DisplayMode displayMode() const;
151
152 QString nodeId() const;
153 void setNodeId(const QString &i);
154
155 QString xmlClass() const;
156 void setXmlClass(const QString &str);
157protected:
158 mutable QSvgStyle m_style;
159
160 static qreal strokeWidth(QPainter *p);
161private:
162 QSvgNode *m_parent;
163
164 QStringList m_requiredFeatures;
165 QStringList m_requiredExtensions;
166 QStringList m_requiredLanguages;
167 QStringList m_requiredFormats;
168 QStringList m_requiredFonts;
169
170 bool m_visible;
171
172 QString m_id;
173 QString m_class;
174
175 DisplayMode m_displayMode;
176 mutable QRectF m_cachedBounds;
177
178 friend class QSvgTinyDocument;
179};
180
181inline QSvgNode *QSvgNode::parent() const
182{
183 return m_parent;
184}
185
186inline bool QSvgNode::isVisible() const
187{
188 return m_visible;
189}
190
191inline QString QSvgNode::nodeId() const
192{
193 return m_id;
194}
195
196inline QString QSvgNode::xmlClass() const
197{
198 return m_class;
199}
200
201QT_END_NAMESPACE
202
203#endif // QSVGNODE_P_H
204

source code of qtsvg/src/svg/qsvgnode_p.h