Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsvgnode_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5
6#ifndef QSVGNODE_P_H
7#define QSVGNODE_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include "qsvgstyle_p.h"
21#include <QtCore/qstring.h>
22
24
25class QPainter;
26class QSvgDocument;
27
28class Q_SVG_EXPORT QSvgNode
29{
30public:
31 enum Type
32 {
33 Doc,
34 Group,
35 Defs,
36 Switch,
37 AnimateColor,
38 AnimateTransform,
39 Circle,
40 Ellipse,
41 Image,
42 Line,
43 Path,
44 Polygon,
45 Polyline,
46 Rect,
47 Text,
48 Textarea,
49 Tspan,
50 Use,
51 Video,
52 Mask,
53 Symbol,
54 Marker,
55 Pattern,
56 Filter,
57 FeMerge,
58 FeMergenode,
59 FeColormatrix,
60 FeGaussianblur,
61 FeOffset,
62 FeComposite,
63 FeFlood,
64 FeBlend,
65 FeUnsupported
66 };
67 enum DisplayMode {
68 InlineMode,
69 BlockMode,
70 ListItemMode,
71 RunInMode,
72 CompactMode,
73 MarkerMode,
74 TableMode,
75 InlineTableMode,
76 TableRowGroupMode,
77 TableHeaderGroupMode,
78 TableFooterGroupMode,
79 TableRowMode,
80 TableColumnGroupMode,
81 TableColumnMode,
82 TableCellMode,
83 TableCaptionMode,
84 NoneMode,
85 InheritMode
86 };
87
88public:
89 QSvgNode(QSvgNode *parent=0);
90 virtual ~QSvgNode();
91 void draw(QPainter *p, QSvgExtraStates &states);
92 virtual bool separateFillStroke(const QSvgExtraStates &) const {return false;}
93 virtual void drawCommand(QPainter *p, QSvgExtraStates &states) = 0;
94 void fillThenStroke(QPainter *p, QSvgExtraStates &states);
95 QImage drawIntoBuffer(QPainter *p, QSvgExtraStates &states, const QRect &boundsRect);
96 void applyMaskToBuffer(QImage *proxy, QImage mask) const;
97 void drawWithMask(QPainter *p, QSvgExtraStates &states, const QImage &mask, const QRect &boundsRect);
98 void applyBufferToCanvas(QPainter *p, QImage proxy) const;
99
100 QSvgNode *parent() const;
101 bool isDescendantOf(const QSvgNode *parent) const;
102
103 void appendStyleProperty(QSvgStyleProperty *prop, const QString &id);
104 void applyStyle(QPainter *p, QSvgExtraStates &states) const;
105 void applyStyleRecursive(QPainter *p, QSvgExtraStates &states) const;
106 void revertStyle(QPainter *p, QSvgExtraStates &states) const;
107 void revertStyleRecursive(QPainter *p, QSvgExtraStates &states) const;
108 void applyAnimatedStyle(QPainter *p, QSvgExtraStates &states) const;
109 void revertAnimatedStyle(QPainter *p, QSvgExtraStates &states) const;
110 QSvgStyleProperty *styleProperty(QSvgStyleProperty::Type type) const;
111 QSvgPaintStyleProperty *styleProperty(QStringView id) const;
112
113 QSvgDocument *document() const;
114
115 virtual Type type() const = 0;
116 QString typeName() const;
117 virtual QRectF internalFastBounds(QPainter *p, QSvgExtraStates &states) const;
118 virtual QRectF internalBounds(QPainter *p, QSvgExtraStates &states) const;
119 QRectF bounds(QPainter *p, QSvgExtraStates &states) const;
120 QRectF bounds() const;
121 virtual QRectF decoratedInternalBounds(QPainter *p, QSvgExtraStates &states) const;
122 virtual QRectF decoratedBounds(QPainter *p, QSvgExtraStates &states) const;
123
124 void setRequiredFeatures(const QStringList &lst);
125 const QStringList & requiredFeatures() const;
126
127 void setRequiredExtensions(const QStringList &lst);
128 const QStringList & requiredExtensions() const;
129
130 void setRequiredLanguages(const QStringList &lst);
131 const QStringList & requiredLanguages() const;
132
133 void setRequiredFormats(const QStringList &lst);
134 const QStringList & requiredFormats() const;
135
136 void setRequiredFonts(const QStringList &lst);
137 const QStringList & requiredFonts() const;
138
139 void setVisible(bool visible);
140 bool isVisible() const;
141
142 void setDisplayMode(DisplayMode display);
143 DisplayMode displayMode() const;
144
145 QString nodeId() const;
146 void setNodeId(const QString &i);
147
148 QString xmlClass() const;
149 void setXmlClass(const QString &str);
150
151 QString maskId() const;
152 void setMaskId(const QString &str);
153 bool hasMask() const;
154
155 QString filterId() const;
156 void setFilterId(const QString &str);
157 bool hasFilter() const;
158
159 QString markerStartId() const;
160 void setMarkerStartId(const QString &str);
161 bool hasMarkerStart() const;
162
163 QString markerMidId() const;
164 void setMarkerMidId(const QString &str);
165 bool hasMarkerMid() const;
166
167 QString markerEndId() const;
168 void setMarkerEndId(const QString &str);
169 bool hasMarkerEnd() const;
170
171 bool hasAnyMarker() const;
172
173 virtual bool requiresGroupRendering() const;
174
175 virtual bool shouldDrawNode(QPainter *p, QSvgExtraStates &states) const;
176 const QSvgStaticStyle &style() const { return m_style; }
177protected:
178 mutable QSvgStaticStyle m_style;
179 mutable QSvgAnimatedStyle m_animatedStyle;
180
181 QRectF filterRegion(QRectF bounds) const;
182
183 static qreal strokeWidth(QPainter *p);
184 static void initPainter(QPainter *p);
185
186 enum BoundsMode {
187 Simplistic,
188 IncludeMiterLimit
189 };
190 static QRectF boundsOnStroke(QPainter *p, const QPainterPath &path,
191 qreal width, BoundsMode mode);
192
193private:
194 QSvgNode *m_parent;
195
196 QStringList m_requiredFeatures;
197 QStringList m_requiredExtensions;
198 QStringList m_requiredLanguages;
199 QStringList m_requiredFormats;
200 QStringList m_requiredFonts;
201
202 QString m_id;
203 QString m_class;
204 QString m_maskId;
205 QString m_filterId;
206 QString m_markerStartId;
207 QString m_markerMidId;
208 QString m_markerEndId;
209
210 mutable QRectF m_cachedBounds;
211 DisplayMode m_displayMode;
212 bool m_visible;
213
214 friend class QSvgDocument;
215};
216
217inline QSvgNode *QSvgNode::parent() const
218{
219 return m_parent;
220}
221
222inline bool QSvgNode::isVisible() const
223{
224 return m_visible;
225}
226
227inline QString QSvgNode::nodeId() const
228{
229 return m_id;
230}
231
232inline QString QSvgNode::xmlClass() const
233{
234 return m_class;
235}
236
237QT_END_NAMESPACE
238
239#endif // QSVGNODE_P_H
friend class QPainter
Combined button and popup list for selecting options.