1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
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 qt-info@nokia.com.
|
---|
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 |
|
---|
63 | QT_BEGIN_NAMESPACE
|
---|
64 |
|
---|
65 | class QPainter;
|
---|
66 | class QSvgTinyDocument;
|
---|
67 |
|
---|
68 | class QSvgNode
|
---|
69 | {
|
---|
70 | public:
|
---|
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 | };
|
---|
113 | public:
|
---|
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);
|
---|
159 | protected:
|
---|
160 | mutable QSvgStyle m_style;
|
---|
161 |
|
---|
162 | static qreal strokeWidth(QPainter *p);
|
---|
163 | private:
|
---|
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 |
|
---|
183 | inline QSvgNode *QSvgNode::parent() const
|
---|
184 | {
|
---|
185 | return m_parent;
|
---|
186 | }
|
---|
187 |
|
---|
188 | inline bool QSvgNode::isVisible() const
|
---|
189 | {
|
---|
190 | return m_visible;
|
---|
191 | }
|
---|
192 |
|
---|
193 | inline QString QSvgNode::nodeId() const
|
---|
194 | {
|
---|
195 | return m_id;
|
---|
196 | }
|
---|
197 |
|
---|
198 | inline QString QSvgNode::xmlClass() const
|
---|
199 | {
|
---|
200 | return m_class;
|
---|
201 | }
|
---|
202 |
|
---|
203 | QT_END_NAMESPACE
|
---|
204 |
|
---|
205 | #endif // QT_NO_SVG
|
---|
206 | #endif // QSVGNODE_P_H
|
---|