Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsvgpaintserver_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
QSVGPAINTSERVER_P_H
7
#
define
QSVGPAINTSERVER_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
<
memory
>
21
#
include
<
QtSvg
/
private
/
qtsvgglobal_p
.
h
>
22
#
include
<
QtCore
/
qrect
.
h
>
23
#
include
<
QtCore
/
qset
.
h
>
24
#
include
<
QtCore
/
qstring
.
h
>
25
#
include
<
QtGui
/
qcolor
.
h
>
26
#
include
<
QtGui
/
qbrush
.
h
>
27
#
include
<
QtGui
/
qpainter
.
h
>
28
#
include
<
QtGui
/
qpen
.
h
>
29
#
include
<
QtGui
/
qtransform
.
h
>
30
31
QT_BEGIN_NAMESPACE
32
33
class
QSvgNode;
34
class
QSvgDocument;
35
class
QSvgPattern;
36
struct
QSvgExtraStates;
37
38
class
Q_SVG_EXPORT
QSvgPaintServer
39
{
40
Q_DISABLE_COPY_MOVE(QSvgPaintServer)
41
public
:
42
enum
class
Type : qint8 {
43
SolidColor,
44
Gradient,
45
Pattern,
46
};
47
public
:
48
QSvgPaintServer() =
default
;
49
virtual
~QSvgPaintServer();
50
virtual
QBrush
brush
(QPainter *p,
const
QSvgNode *node, QSvgExtraStates &states) = 0;
51
virtual
Type
type
()
const
= 0;
52
};
53
54
class
Q_SVG_EXPORT
QSvgSolidColorPaint
:
public
QSvgPaintServer
55
{
56
public
:
57
QSvgSolidColorPaint(
const
QColor &color);
58
~QSvgSolidColorPaint() override;
59
Type type()
const
override;
60
61
const
QColor & qcolor()
const
;
62
63
QBrush brush(QPainter *,
const
QSvgNode *, QSvgExtraStates &) override;
64
65
private
:
66
// solid-color v x 'inherit' | <SVGColor.datatype>
67
// solid-opacity v x 'inherit' | <OpacityValue.datatype>
68
QColor m_solidColor;
69
70
QBrush m_oldFill;
71
QPen m_oldStroke;
72
};
73
74
inline
QSvgPaintServer::Type QSvgSolidColorPaint::type()
const
75
{
76
return
Type::SolidColor;
77
}
78
79
inline
const
QColor &QSvgSolidColorPaint::qcolor()
const
80
{
81
return
m_solidColor;
82
}
83
84
inline
QBrush QSvgSolidColorPaint::brush(QPainter *,
const
QSvgNode *, QSvgExtraStates &)
85
{
86
return
m_solidColor;
87
}
88
89
90
class
Q_SVG_EXPORT
QSvgGradientPaint
:
public
QSvgPaintServer
91
{
92
public
:
93
QSvgGradientPaint(std::unique_ptr<QGradient> grad);
94
~QSvgGradientPaint() override;
95
Type type()
const
override;
96
97
void
setStopLink(
const
QString &link, QSvgDocument *doc);
98
QString stopLink()
const
;
99
100
void
setTransform(
const
QTransform &transform);
101
QTransform qtransform()
const
;
102
103
QGradient *qgradient();
104
105
bool
gradientStopsSet()
const
;
106
107
void
setGradientStopsSet(
bool
set);
108
109
QBrush brush(QPainter *,
const
QSvgNode *, QSvgExtraStates &) override;
110
private
:
111
void
resolveStops();
112
void
resolveStops_helper(QSet<QString> &visited);
113
private
:
114
std::unique_ptr<QGradient> m_gradient;
115
QTransform m_transform;
116
117
QSvgDocument *m_doc{
nullptr
};
118
QString m_link;
119
bool
m_gradientStopsSet{
false
};
120
};
121
122
inline
QSvgPaintServer::Type QSvgGradientPaint::type()
const
123
{
124
return
Type::Gradient;
125
}
126
127
inline
void
QSvgGradientPaint::setStopLink(
const
QString &link, QSvgDocument *doc)
128
{
129
m_link = link;
130
m_doc = doc;
131
}
132
133
inline
QString QSvgGradientPaint::stopLink()
const
134
{
135
return
m_link;
136
}
137
138
inline
void
QSvgGradientPaint::setTransform(
const
QTransform &transform)
139
{
140
m_transform = transform;
141
}
142
143
inline
QTransform QSvgGradientPaint::qtransform()
const
144
{
145
return
m_transform;
146
}
147
148
inline
QGradient *QSvgGradientPaint::qgradient()
149
{
150
return
m_gradient.get();
151
}
152
153
inline
void
QSvgGradientPaint::setGradientStopsSet(
bool
set)
154
{
155
m_gradientStopsSet = set;
156
}
157
158
inline
bool
QSvgGradientPaint::gradientStopsSet()
const
159
{
160
return
m_gradientStopsSet;
161
}
162
163
class
Q_SVG_EXPORT
QSvgPatternPaint
:
public
QSvgPaintServer
164
{
165
public
:
166
QSvgPatternPaint(QSvgPattern *pattern);
167
~QSvgPatternPaint() override;
168
Type type()
const
override;
169
170
QBrush brush(QPainter *,
const
QSvgNode *, QSvgExtraStates &) override;
171
QSvgPattern *patternNode();
172
private
:
173
QSvgPattern *m_pattern;
174
QRectF m_parentBound;
175
};
176
177
inline
QSvgPaintServer::Type QSvgPatternPaint::type()
const
178
{
179
return
Type::Pattern;
180
}
181
182
inline
QSvgPattern *QSvgPatternPaint::patternNode()
183
{
184
return
m_pattern;
185
}
186
187
using
QSvgPaintServerSharedPtr = std::shared_ptr<QSvgPaintServer>;
188
using
QSvgGradientPaintSharedPtr = std::shared_ptr<QSvgGradientPaint>;
189
190
QT_END_NAMESPACE
191
192
#
endif
// QSVGPAINTSERVER_P_H
QPaintEngine::type
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
QSvgGradientPaint
Definition
qsvgpaintserver_p.h:91
QSvgPaintServer
Definition
qsvgpaintserver_p.h:39
QSvgPaintServer::brush
virtual QBrush brush(QPainter *p, const QSvgNode *node, QSvgExtraStates &states)=0
QSvgPatternPaint
Definition
qsvgpaintserver_p.h:164
QSvgSolidColorPaint
Definition
qsvgpaintserver_p.h:55
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtsvg
src
svg
qsvgpaintserver_p.h
Generated on
for Qt by
1.18.0