Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qsvggraphics_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
4#ifndef QSVGGRAPHICS_P_H
5#define QSVGGRAPHICS_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 "qsvgnode_p.h"
19#include "qtsvgglobal_p.h"
20
21#include "QtGui/qpainterpath.h"
22#include "QtGui/qimage.h"
23#include "QtGui/qtextlayout.h"
24#include "QtGui/qtextoption.h"
25#include "QtCore/qstack.h"
26
28
29class QTextCharFormat;
30
31class Q_SVG_PRIVATE_EXPORT QSvgAnimation : public QSvgNode
32{
33public:
34 void draw(QPainter *p, QSvgExtraStates &states) override;
35 Type type() const override;
36};
37
38class Q_SVG_PRIVATE_EXPORT QSvgArc : public QSvgNode
39{
40public:
42 void draw(QPainter *p, QSvgExtraStates &states) override;
43 Type type() const override;
45 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
46private:
47 QPainterPath m_path;
48};
49
50class Q_SVG_PRIVATE_EXPORT QSvgEllipse : public QSvgNode
51{
52public:
54 void draw(QPainter *p, QSvgExtraStates &states) override;
55 Type type() const override;
57 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
58private:
59 QRectF m_bounds;
60};
61
62class Q_SVG_PRIVATE_EXPORT QSvgCircle : public QSvgEllipse
63{
64public:
66 Type type() const override;
67};
68
69class Q_SVG_PRIVATE_EXPORT QSvgImage : public QSvgNode
70{
71public:
73 const QRectF &bounds);
74 void draw(QPainter *p, QSvgExtraStates &states) override;
75 Type type() const override;
76 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
77private:
78 QImage m_image;
79 QRectF m_bounds;
80};
81
82class Q_SVG_PRIVATE_EXPORT QSvgLine : public QSvgNode
83{
84public:
86 void draw(QPainter *p, QSvgExtraStates &states) override;
87 Type type() const override;
89 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
90private:
91 QLineF m_line;
92};
93
94class Q_SVG_PRIVATE_EXPORT QSvgPath : public QSvgNode
95{
96public:
97 QSvgPath(QSvgNode *parent, const QPainterPath &qpath);
98 void draw(QPainter *p, QSvgExtraStates &states) override;
99 Type type() const override;
101 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
102
104 return &m_path;
105 }
106private:
107 QPainterPath m_path;
108};
109
110class Q_SVG_PRIVATE_EXPORT QSvgPolygon : public QSvgNode
111{
112public:
113 QSvgPolygon(QSvgNode *parent, const QPolygonF &poly);
114 void draw(QPainter *p, QSvgExtraStates &states) override;
115 Type type() const override;
117 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
118private:
119 QPolygonF m_poly;
120};
121
122class Q_SVG_PRIVATE_EXPORT QSvgPolyline : public QSvgNode
123{
124public:
125 QSvgPolyline(QSvgNode *parent, const QPolygonF &poly);
126 void draw(QPainter *p, QSvgExtraStates &states) override;
127 Type type() const override;
129 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
130private:
131 QPolygonF m_poly;
132};
133
134class Q_SVG_PRIVATE_EXPORT QSvgRect : public QSvgNode
135{
136public:
137 QSvgRect(QSvgNode *paren, const QRectF &rect, int rx=0, int ry=0);
138 Type type() const override;
139 void draw(QPainter *p, QSvgExtraStates &states) override;
141 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
142private:
143 QRectF m_rect;
144 int m_rx, m_ry;
145};
146
147class QSvgTspan;
148
149class Q_SVG_PRIVATE_EXPORT QSvgText : public QSvgNode
150{
151public:
153 {
155 Preserve
156 };
157
159 ~QSvgText();
160 void setTextArea(const QSizeF &size);
161
162 void draw(QPainter *p, QSvgExtraStates &states) override;
163 Type type() const override;
164
165 void addTspan(QSvgTspan *tspan) {m_tspans.append(tspan);}
166 void addText(const QString &text);
167 void addLineBreak() {m_tspans.append(LINEBREAK);}
169
171 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
172
173private:
174 bool precheck(QPainter *p) const;
175 void draw_helper(QPainter *p, QSvgExtraStates &states, QRectF *boundingRect = nullptr) const;
176
177 static QSvgTspan * const LINEBREAK;
178
179 QPointF m_coord;
180
181 // 'm_tspans' is also used to store characters outside tspans and line breaks.
182 // If a 'm_tspan' item is null, it indicates a line break.
183 QList<QSvgTspan *> m_tspans;
184
185 Type m_type;
186 QSizeF m_size;
187 WhitespaceMode m_mode;
188};
189
190class Q_SVG_PRIVATE_EXPORT QSvgTspan : public QSvgNode
191{
192public:
193 // tspans are also used to store normal text, so the 'isProperTspan' is used to separate text from tspan.
194 QSvgTspan(QSvgNode *parent, bool isProperTspan = true)
195 : QSvgNode(parent), m_mode(QSvgText::Default), m_isTspan(isProperTspan)
196 {
197 }
199 Type type() const override { return TSPAN; }
200 void draw(QPainter *, QSvgExtraStates &) override { Q_ASSERT(!"Tspans should be drawn through QSvgText::draw()."); }
201 void addText(const QString &text) {m_text += text;}
202 const QString &text() const {return m_text;}
203 bool isTspan() const {return m_isTspan;}
206private:
207 QString m_text;
209 bool m_isTspan;
210};
211
212class QSvgUse : public QSvgNode
213{
214public:
215 QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *link);
218 { m_linkId = linkId; }
219 void draw(QPainter *p, QSvgExtraStates &states) override;
220 Type type() const override;
221 QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
222 bool isResolved() const { return m_link != nullptr; }
223 QString linkId() const { return m_linkId; }
224 void setLink(QSvgNode *link) { m_link = link; }
225
226private:
227 QSvgNode *m_link;
228 QPointF m_start;
229 QString m_linkId;
230 mutable bool m_recursing;
231};
232
233class QSvgVideo : public QSvgNode
234{
235public:
236 void draw(QPainter *p, QSvgExtraStates &states) override;
237 Type type() const override;
238};
239
241
242#endif // QSVGGRAPHICS_P_H
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qline.h:182
Definition qlist.h:74
\inmodule QtGui
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qpoint.h:214
The QPolygonF class provides a list of points using floating point precision.
Definition qpolygon.h:96
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore
Definition qsize.h:207
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QSvgCircle(QSvgNode *parent, const QRectF &rect)
virtual QRectF bounds(QPainter *p, QSvgExtraStates &states) const
Definition qsvgnode.cpp:185
QSvgNode * parent() const
Definition qsvgnode_p.h:148
virtual void draw(QPainter *p, QSvgExtraStates &states)=0
virtual QRectF fastBounds(QPainter *p, QSvgExtraStates &states) const
Definition qsvgnode.cpp:180
virtual Type type() const =0
QPainterPath * qpath()
void setWhitespaceMode(WhitespaceMode mode)
void addTspan(QSvgTspan *tspan)
void addLineBreak()
QSvgTspan(QSvgNode *parent, bool isProperTspan=true)
bool isTspan() const
const QString & text() const
void draw(QPainter *, QSvgExtraStates &) override
void setWhitespaceMode(QSvgText::WhitespaceMode mode)
Type type() const override
void addText(const QString &text)
QSvgText::WhitespaceMode whitespaceMode() const
QString linkId() const
void draw(QPainter *p, QSvgExtraStates &states) override
void setLink(QSvgNode *link)
bool isResolved() const
QSvgUse(const QPointF &start, QSvgNode *parent, const QString &linkId)
Type type() const override
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override
Type type() const override
void draw(QPainter *p, QSvgExtraStates &states) override
QString text
rect
[4]
Combined button and popup list for selecting options.
Definition image.cpp:4
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint start
GLuint coord
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
GLuint * states
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE const uint Default
Definition qsplitter_p.h:25
QObject::connect nullptr
p ry()++
p rx()++
scene addText("Hello, world!")
Definition moc.h:24
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent