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
qsvghelper_p.h
Go to the documentation of this file.
1
// Copyright (C) 2023 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
QSVGHELPER_P_H
7
#
define
QSVGHELPER_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
"qtsvgglobal_p.h"
21
#
include
<
QtCore
/
qdebug
.
h
>
22
#
include
<
QRectF
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
Q_SVG_EXPORT
QSvgRectF
:
public
QRectF
27
{
28
public
:
29
QSvgRectF(
const
QRectF &r = QRectF(),
30
QtSvg::UnitTypes unitX = QtSvg::UnitTypes::userSpaceOnUse,
31
QtSvg::UnitTypes unitY = QtSvg::UnitTypes::userSpaceOnUse,
32
QtSvg::UnitTypes unitW = QtSvg::UnitTypes::userSpaceOnUse,
33
QtSvg::UnitTypes unitH = QtSvg::UnitTypes::userSpaceOnUse)
34
: QRectF(r)
35
, m_unitX(unitX)
36
, m_unitY(unitY)
37
, m_unitW(unitW)
38
, m_unitH(unitH)
39
{}
40
41
QPointF translationRelativeToBoundingBox(
const
QRectF &boundingBox)
const
{
42
QPointF result;
43
44
if
(m_unitX == QtSvg::UnitTypes::objectBoundingBox)
45
result.setX(x() * boundingBox.width());
46
else
47
result.setX(x());
48
if
(m_unitY == QtSvg::UnitTypes::objectBoundingBox)
49
result.setY(y() * boundingBox.height());
50
else
51
result.setY(y());
52
return
result;
53
}
54
55
QRectF resolveRelativeLengths(
const
QRectF &localRect)
const
{
56
QRectF result;
57
if
(m_unitX == QtSvg::UnitTypes::objectBoundingBox)
58
result.setX(localRect.x() + x() * localRect.width());
59
else
60
result.setX(x());
61
if
(m_unitY == QtSvg::UnitTypes::objectBoundingBox)
62
result.setY(localRect.y() + y() * localRect.height());
63
else
64
result.setY(y());
65
if
(m_unitW == QtSvg::UnitTypes::objectBoundingBox)
66
result.setWidth(localRect.width() * width());
67
else
68
result.setWidth(width());
69
if
(m_unitH == QtSvg::UnitTypes::objectBoundingBox)
70
result.setHeight(localRect.height() * height());
71
else
72
result.setHeight(height());
73
return
result;
74
}
75
76
QRectF resolveRelativeLengths(
const
QRectF &localRect, QtSvg::UnitTypes units)
const
{
77
QRectF result;
78
if
(units == QtSvg::UnitTypes::objectBoundingBox ||
79
m_unitX == QtSvg::UnitTypes::objectBoundingBox)
80
result.setX(localRect.x() + x() * localRect.width());
81
else
82
result.setX(x());
83
if
(units == QtSvg::UnitTypes::objectBoundingBox ||
84
m_unitY == QtSvg::UnitTypes::objectBoundingBox)
85
result.setY(localRect.y() + y() * localRect.height());
86
else
87
result.setY(y());
88
if
(units == QtSvg::UnitTypes::objectBoundingBox ||
89
m_unitW == QtSvg::UnitTypes::objectBoundingBox)
90
result.setWidth(localRect.width() * width());
91
else
92
result.setWidth(width());
93
if
(units == QtSvg::UnitTypes::objectBoundingBox ||
94
m_unitH == QtSvg::UnitTypes::objectBoundingBox)
95
result.setHeight(localRect.height() * height());
96
else
97
result.setHeight(height());
98
99
return
result;
100
}
101
102
QtSvg::UnitTypes unitX()
const
{
return
m_unitX;}
103
QtSvg::UnitTypes unitY()
const
{
return
m_unitY;}
104
QtSvg::UnitTypes unitW()
const
{
return
m_unitW;}
105
QtSvg::UnitTypes unitH()
const
{
return
m_unitH;}
106
107
void
setUnitX(QtSvg::UnitTypes unit) {m_unitX = unit;}
108
void
setUnitY(QtSvg::UnitTypes unit) {m_unitY = unit;}
109
void
setUnitW(QtSvg::UnitTypes unit) {m_unitW = unit;}
110
void
setUnitH(QtSvg::UnitTypes unit) {m_unitH = unit;}
111
112
113
#
ifndef
QT_NO_DEBUG_STREAM
114
friend
QDebug operator<<(QDebug debug,
const
QSvgRectF &r)
115
{
116
debug.space();
117
debug.nospace() <<
"QSvgRectF("
<< r.x()
118
<< (r.unitX() == QtSvg::UnitTypes::unknown ?
"(?)"
:
119
(r.unitX() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)"
:
""
))
120
<<
","
<< r.y()
121
<< (r.unitY() == QtSvg::UnitTypes::unknown ?
"(?)"
:
122
(r.unitY() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)"
:
""
))
123
<<
" "
<< r.width()
124
<< (r.unitW() == QtSvg::UnitTypes::unknown ?
"(?)"
:
125
(r.unitW() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)"
:
""
))
126
<<
"x"
<< r.height()
127
<< (r.unitH() == QtSvg::UnitTypes::unknown ?
"(?)"
:
128
(r.unitH() == QtSvg::UnitTypes::objectBoundingBox ?
"(%)"
:
""
))
129
<<
")"
;
130
return
debug;
131
}
132
#
endif
133
134
protected
:
135
QtSvg::UnitTypes m_unitX,
136
m_unitY,
137
m_unitW,
138
m_unitH;
139
};
140
141
QT_END_NAMESPACE
142
143
#
endif
// QSVGHELPER_P_H
QSvgRectF
Definition
qsvghelper_p.h:27
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtsvg
src
svg
qsvghelper_p.h
Generated on
for Qt by
1.18.0