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 QSVGNODE_P_H
43#define QSVGNODE_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 "qsvgstyle_p.h"
57
58#ifndef QT_NO_SVG
59
60#include "QtCore/qstring.h"
61#include "QtCore/qhash.h"
62
63QT_BEGIN_NAMESPACE
64
65class QPainter;
66class QSvgTinyDocument;
67
68class QSvgNode
69{
70public:
71 enum Type
72 {
73 DOC,
74 G,
75 DEFS,
76 SWITCH,
77 ANIMATION,
78 ARC,
79 CIRCLE,
80 ELLIPSE,
81 IMAGE,
82 LINE,
83 PATH,
84 POLYGON,
85 POLYLINE,
86 RECT,
87 TEXT,
88 TEXTAREA,
89 TSPAN,
90 USE,
91 VIDEO
92 };
93 enum DisplayMode {
94 InlineMode,
95 BlockMode,
96 ListItemMode,
97 RunInMode,
98 CompactMode,
99 MarkerMode,
100 TableMode,
101 InlineTableMode,
102 TableRowGroupMode,
103 TableHeaderGroupMode,
104 TableFooterGroupMode,
105 TableRowMode,
106 TableColumnGroupMode,
107 TableColumnMode,
108 TableCellMode,
109 TableCaptionMode,
110 NoneMode,
111 InheritMode
112 };
113public:
114 QSvgNode(QSvgNode *parent=0);
115 virtual ~QSvgNode();
116 virtual void draw(QPainter *p, QSvgExtraStates &states) =0;
117
118 QSvgNode *parent() const;
119
120 void appendStyleProperty(QSvgStyleProperty *prop, const QString &id);
121 void applyStyle(QPainter *p, QSvgExtraStates &states) const;
122 void revertStyle(QPainter *p, QSvgExtraStates &states) const;
123 QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
124 QSvgFillStyleProperty *styleProperty(const QString &id) const;
125
126 QSvgTinyDocument *document() const;
127
128 virtual Type type() const =0;
129 virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
130 virtual QRectF transformedBounds(QPainter *p, QSvgExtraStates &states) const;
131 QRectF transformedBounds() const;
132
133 void setRequiredFeatures(const QStringList &lst);
134 const QStringList & requiredFeatures() const;
135
136 void setRequiredExtensions(const QStringList &lst);
137 const QStringList & requiredExtensions() const;
138
139 void setRequiredLanguages(const QStringList &lst);
140 const QStringList & requiredLanguages() const;
141
142 void setRequiredFormats(const QStringList &lst);
143 const QStringList & requiredFormats() const;
144
145 void setRequiredFonts(const QStringList &lst);
146 const QStringList & requiredFonts() const;
147
148 void setVisible(bool visible);
149 bool isVisible() const;
150
151 void setDisplayMode(DisplayMode display);
152 DisplayMode displayMode() const;
153
154 QString nodeId() const;
155 void setNodeId(const QString &i);
156
157 QString xmlClass() const;
158 void setXmlClass(const QString &str);
159protected:
160 mutable QSvgStyle m_style;
161
162 static qreal strokeWidth(QPainter *p);
163private:
164 QSvgNode *m_parent;
165
166 QStringList m_requiredFeatures;
167 QStringList m_requiredExtensions;
168 QStringList m_requiredLanguages;
169 QStringList m_requiredFormats;
170 QStringList m_requiredFonts;
171
172 bool m_visible;
173
174 QString m_id;
175 QString m_class;
176
177 DisplayMode m_displayMode;
178 mutable QRectF m_cachedBounds;
179
180 friend class QSvgTinyDocument;
181};
182
183inline QSvgNode *QSvgNode::parent() const
184{
185 return m_parent;
186}
187
188inline bool QSvgNode::isVisible() const
189{
190 return m_visible;
191}
192
193inline QString QSvgNode::nodeId() const
194{
195 return m_id;
196}
197
198inline QString QSvgNode::xmlClass() const
199{
200 return m_class;
201}
202
203QT_END_NAMESPACE
204
205#endif // QT_NO_SVG
206#endif // QSVGNODE_P_H
207