1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt SVG module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QSVGRENDERER_H
41#define QSVGRENDERER_H
42
43#include <QtGui/qmatrix.h>
44
45#ifndef QT_NO_SVGRENDERER
46
47#include <QtCore/qobject.h>
48#include <QtCore/qsize.h>
49#include <QtCore/qrect.h>
50#include <QtCore/qxmlstream.h>
51#include <QtSvg/qtsvgglobal.h>
52
53QT_BEGIN_NAMESPACE
54
55
56class QSvgRendererPrivate;
57class QPainter;
58class QByteArray;
59class QTransform;
60
61class Q_SVG_EXPORT QSvgRenderer : public QObject
62{
63 Q_OBJECT
64
65 Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
66 Q_PROPERTY(int framesPerSecond READ framesPerSecond WRITE setFramesPerSecond)
67 Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame)
68 Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode)
69public:
70 QSvgRenderer(QObject *parent = nullptr);
71 QSvgRenderer(const QString &filename, QObject *parent = nullptr);
72 QSvgRenderer(const QByteArray &contents, QObject *parent = nullptr);
73 QSvgRenderer(QXmlStreamReader *contents, QObject *parent = nullptr);
74 ~QSvgRenderer();
75
76 bool isValid() const;
77
78 QSize defaultSize() const;
79
80 QRect viewBox() const;
81 QRectF viewBoxF() const;
82 void setViewBox(const QRect &viewbox);
83 void setViewBox(const QRectF &viewbox);
84
85 Qt::AspectRatioMode aspectRatioMode() const;
86 void setAspectRatioMode(Qt::AspectRatioMode mode);
87
88 bool animated() const;
89 int framesPerSecond() const;
90 void setFramesPerSecond(int num);
91 int currentFrame() const;
92 void setCurrentFrame(int);
93 int animationDuration() const;//in seconds
94
95 QRectF boundsOnElement(const QString &id) const;
96 bool elementExists(const QString &id) const;
97#if QT_DEPRECATED_SINCE(5, 15)
98 QT_DEPRECATED_X("Use transformForElement()")
99 QMatrix matrixForElement(const QString &id) const;
100#endif // QT_DEPRECATED_SINCE(5, 15)
101 QTransform transformForElement(const QString &id) const;
102
103public Q_SLOTS:
104 bool load(const QString &filename);
105 bool load(const QByteArray &contents);
106 bool load(QXmlStreamReader *contents);
107 void render(QPainter *p);
108 void render(QPainter *p, const QRectF &bounds);
109
110 void render(QPainter *p, const QString &elementId,
111 const QRectF &bounds=QRectF());
112
113Q_SIGNALS:
114 void repaintNeeded();
115
116private:
117 Q_DECLARE_PRIVATE(QSvgRenderer)
118};
119
120QT_END_NAMESPACE
121
122#endif // QT_NO_SVGRENDERER
123#endif // QSVGRENDERER_H
124

source code of qtsvg/src/svg/qsvgrenderer.h