1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QSVGNODE_P_H |
5 | #define QSVGNODE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include "qsvgstyle_p.h" |
19 | #include "qtsvgglobal_p.h" |
20 | |
21 | #include "QtCore/qstring.h" |
22 | #include "QtCore/qhash.h" |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QPainter; |
27 | class QSvgTinyDocument; |
28 | |
29 | class Q_SVG_PRIVATE_EXPORT QSvgNode |
30 | { |
31 | public: |
32 | enum Type |
33 | { |
34 | DOC, |
35 | G, |
36 | DEFS, |
37 | SWITCH, |
38 | ANIMATION, |
39 | ARC, |
40 | CIRCLE, |
41 | ELLIPSE, |
42 | IMAGE, |
43 | LINE, |
44 | PATH, |
45 | POLYGON, |
46 | POLYLINE, |
47 | RECT, |
48 | TEXT, |
49 | TEXTAREA, |
50 | TSPAN, |
51 | USE, |
52 | VIDEO |
53 | }; |
54 | enum DisplayMode { |
55 | InlineMode, |
56 | BlockMode, |
57 | ListItemMode, |
58 | RunInMode, |
59 | CompactMode, |
60 | MarkerMode, |
61 | TableMode, |
62 | InlineTableMode, |
63 | TableRowGroupMode, |
64 | , |
65 | , |
66 | TableRowMode, |
67 | TableColumnGroupMode, |
68 | TableColumnMode, |
69 | TableCellMode, |
70 | TableCaptionMode, |
71 | NoneMode, |
72 | InheritMode |
73 | }; |
74 | public: |
75 | QSvgNode(QSvgNode *parent=0); |
76 | virtual ~QSvgNode(); |
77 | virtual void (QPainter *p, QSvgExtraStates &states) =0; |
78 | |
79 | QSvgNode *parent() const; |
80 | bool isDescendantOf(const QSvgNode *parent) const; |
81 | |
82 | void appendStyleProperty(QSvgStyleProperty *prop, const QString &id); |
83 | void (QPainter *p, QSvgExtraStates &states) const; |
84 | void (QPainter *p, QSvgExtraStates &states) const; |
85 | QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const; |
86 | QSvgFillStyleProperty *styleProperty(const QString &id) const; |
87 | |
88 | QSvgTinyDocument *document() const; |
89 | |
90 | virtual Type type() const =0; |
91 | virtual QRectF (QPainter *p, QSvgExtraStates &states) const; |
92 | virtual QRectF (QPainter *p, QSvgExtraStates &states) const; |
93 | virtual QRectF (QPainter *p, QSvgExtraStates &states) const; |
94 | QRectF transformedBounds() const; |
95 | |
96 | void setRequiredFeatures(const QStringList &lst); |
97 | const QStringList & requiredFeatures() const; |
98 | |
99 | void setRequiredExtensions(const QStringList &lst); |
100 | const QStringList & requiredExtensions() const; |
101 | |
102 | void setRequiredLanguages(const QStringList &lst); |
103 | const QStringList & requiredLanguages() const; |
104 | |
105 | void setRequiredFormats(const QStringList &lst); |
106 | const QStringList & requiredFormats() const; |
107 | |
108 | void setRequiredFonts(const QStringList &lst); |
109 | const QStringList & requiredFonts() const; |
110 | |
111 | void setVisible(bool visible); |
112 | bool isVisible() const; |
113 | |
114 | void setDisplayMode(DisplayMode display); |
115 | DisplayMode displayMode() const; |
116 | |
117 | QString nodeId() const; |
118 | void setNodeId(const QString &i); |
119 | |
120 | QString xmlClass() const; |
121 | void setXmlClass(const QString &str); |
122 | |
123 | bool (QPainter *p, QSvgExtraStates &states) const; |
124 | protected: |
125 | mutable QSvgStyle m_style; |
126 | |
127 | static qreal strokeWidth(QPainter *p); |
128 | private: |
129 | QSvgNode *m_parent; |
130 | |
131 | QStringList m_requiredFeatures; |
132 | QStringList m_requiredExtensions; |
133 | QStringList m_requiredLanguages; |
134 | QStringList m_requiredFormats; |
135 | QStringList m_requiredFonts; |
136 | |
137 | bool m_visible; |
138 | |
139 | QString m_id; |
140 | QString m_class; |
141 | |
142 | DisplayMode m_displayMode; |
143 | mutable QRectF m_cachedBounds; |
144 | |
145 | friend class QSvgTinyDocument; |
146 | }; |
147 | |
148 | inline QSvgNode *QSvgNode::parent() const |
149 | { |
150 | return m_parent; |
151 | } |
152 | |
153 | inline bool QSvgNode::isVisible() const |
154 | { |
155 | return m_visible; |
156 | } |
157 | |
158 | inline QString QSvgNode::nodeId() const |
159 | { |
160 | return m_id; |
161 | } |
162 | |
163 | inline QString QSvgNode::xmlClass() const |
164 | { |
165 | return m_class; |
166 | } |
167 | |
168 | QT_END_NAMESPACE |
169 | |
170 | #endif // QSVGNODE_P_H |
171 | |