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 QSVGGENERATOR_H
5#define QSVGGENERATOR_H
6
7#include <QtGui/qpaintdevice.h>
8
9#ifndef QT_NO_SVGGENERATOR
10
11#include <QtCore/qnamespace.h>
12#include <QtCore/qiodevice.h>
13#include <QtCore/qobjectdefs.h>
14#include <QtCore/qscopedpointer.h>
15#include <QtSvg/qtsvgglobal.h>
16
17QT_BEGIN_NAMESPACE
18
19
20class QSvgGeneratorPrivate;
21
22class Q_SVG_EXPORT QSvgGenerator : public QPaintDevice
23{
24 Q_DECLARE_PRIVATE(QSvgGenerator)
25
26 // Not a QObject; just a hack to get documentation from qdoc
27 Q_PROPERTY(QSize size READ size WRITE setSize)
28 Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
29 Q_PROPERTY(QString title READ title WRITE setTitle)
30 Q_PROPERTY(QString description READ description WRITE setDescription)
31 Q_PROPERTY(QString fileName READ fileName WRITE setFileName)
32 Q_PROPERTY(QIODevice* outputDevice READ outputDevice WRITE setOutputDevice)
33 Q_PROPERTY(int resolution READ resolution WRITE setResolution)
34public:
35 enum class SvgVersion {
36 SvgTiny12,
37 Svg11,
38 };
39
40 QSvgGenerator();
41 explicit QSvgGenerator(SvgVersion version);
42 ~QSvgGenerator();
43
44 QString title() const;
45 void setTitle(const QString &title);
46
47 QString description() const;
48 void setDescription(const QString &description);
49
50 QSize size() const;
51 void setSize(const QSize &size);
52
53 QRect viewBox() const;
54 QRectF viewBoxF() const;
55 void setViewBox(const QRect &viewBox);
56 void setViewBox(const QRectF &viewBox);
57
58 QString fileName() const;
59 void setFileName(const QString &fileName);
60
61 QIODevice *outputDevice() const;
62 void setOutputDevice(QIODevice *outputDevice);
63
64 void setResolution(int dpi);
65 int resolution() const;
66
67 SvgVersion svgVersion() const;
68protected:
69 QPaintEngine *paintEngine() const override;
70 int metric(QPaintDevice::PaintDeviceMetric metric) const override;
71
72private:
73 QScopedPointer<QSvgGeneratorPrivate> d_ptr;
74};
75
76QT_END_NAMESPACE
77
78#endif // QT_NO_SVGGENERATOR
79#endif // QSVGGENERATOR_H
80

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