1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtSvg module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
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 | USE,
|
---|
90 | VIDEO
|
---|
91 | };
|
---|
92 | enum DisplayMode {
|
---|
93 | InlineMode,
|
---|
94 | BlockMode,
|
---|
95 | ListItemMode,
|
---|
96 | RunInMode,
|
---|
97 | CompactMode,
|
---|
98 | MarkerMode,
|
---|
99 | TableMode,
|
---|
100 | InlineTableMode,
|
---|
101 | TableRowGroupMode,
|
---|
102 | TableHeaderGroupMode,
|
---|
103 | TableFooterGroupMode,
|
---|
104 | TableRowMode,
|
---|
105 | TableColumnGroupMode,
|
---|
106 | TableColumnMode,
|
---|
107 | TableCellMode,
|
---|
108 | TableCaptionMode,
|
---|
109 | NoneMode,
|
---|
110 | InheritMode
|
---|
111 | };
|
---|
112 | public:
|
---|
113 | QSvgNode(QSvgNode *parent=0);
|
---|
114 | virtual ~QSvgNode();
|
---|
115 | virtual void draw(QPainter *p, QSvgExtraStates &states) =0;
|
---|
116 |
|
---|
117 | QSvgNode *parent() const;
|
---|
118 |
|
---|
119 | void appendStyleProperty(QSvgStyleProperty *prop, const QString &id,
|
---|
120 | bool justLink=false);
|
---|
121 | void applyStyle(QPainter *p, QSvgExtraStates &states);
|
---|
122 | void revertStyle(QPainter *p, QSvgExtraStates &states);
|
---|
123 | QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
|
---|
124 | QSvgStyleProperty *styleProperty(const QString &id) const;
|
---|
125 |
|
---|
126 | QSvgTinyDocument *document() const;
|
---|
127 |
|
---|
128 | virtual Type type() const =0;
|
---|
129 | virtual QRectF bounds() const;
|
---|
130 | virtual QRectF transformedBounds(const QTransform &transform) const;
|
---|
131 |
|
---|
132 | void setRequiredFeatures(const QStringList &lst);
|
---|
133 | const QStringList & requiredFeatures() const;
|
---|
134 |
|
---|
135 | void setRequiredExtensions(const QStringList &lst);
|
---|
136 | const QStringList & requiredExtensions() const;
|
---|
137 |
|
---|
138 | void setRequiredLanguages(const QStringList &lst);
|
---|
139 | const QStringList & requiredLanguages() const;
|
---|
140 |
|
---|
141 | void setRequiredFormats(const QStringList &lst);
|
---|
142 | const QStringList & requiredFormats() const;
|
---|
143 |
|
---|
144 | void setRequiredFonts(const QStringList &lst);
|
---|
145 | const QStringList & requiredFonts() const;
|
---|
146 |
|
---|
147 | void setVisible(bool visible);
|
---|
148 | bool isVisible() const;
|
---|
149 |
|
---|
150 | void setDisplayMode(DisplayMode display);
|
---|
151 | DisplayMode displayMode() const;
|
---|
152 |
|
---|
153 | QString nodeId() const;
|
---|
154 | void setNodeId(const QString &i);
|
---|
155 |
|
---|
156 | QString xmlClass() const;
|
---|
157 | void setXmlClass(const QString &str);
|
---|
158 | protected:
|
---|
159 | QSvgStyle m_style;
|
---|
160 |
|
---|
161 | qreal strokeWidth() const;
|
---|
162 | private:
|
---|
163 | QSvgNode *m_parent;
|
---|
164 | QHash<QString, QSvgRefCounter<QSvgStyleProperty> > m_styles;
|
---|
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 |
|
---|
179 | friend class QSvgTinyDocument;
|
---|
180 | };
|
---|
181 |
|
---|
182 | inline QSvgNode *QSvgNode::parent() const
|
---|
183 | {
|
---|
184 | return m_parent;
|
---|
185 | }
|
---|
186 |
|
---|
187 | inline bool QSvgNode::isVisible() const
|
---|
188 | {
|
---|
189 | return m_visible;
|
---|
190 | }
|
---|
191 |
|
---|
192 | inline QString QSvgNode::nodeId() const
|
---|
193 | {
|
---|
194 | return m_id;
|
---|
195 | }
|
---|
196 |
|
---|
197 | inline QString QSvgNode::xmlClass() const
|
---|
198 | {
|
---|
199 | return m_class;
|
---|
200 | }
|
---|
201 |
|
---|
202 | QT_END_NAMESPACE
|
---|
203 |
|
---|
204 | #endif // QT_NO_SVG
|
---|
205 | #endif // QSVGNODE_P_H
|
---|