42 static QSvgTinyDocument *load(
const QString &file, QtSvg::Options options = {},
43 QtSvg::AnimatorType type = QtSvg::AnimatorType::Automatic);
44 static QSvgTinyDocument *load(
const QByteArray &contents, QtSvg::Options options = {},
45 QtSvg::AnimatorType type = QtSvg::AnimatorType::Automatic);
46 static QSvgTinyDocument *load(QXmlStreamReader *contents, QtSvg::Options options = {},
47 QtSvg::AnimatorType type = QtSvg::AnimatorType::Automatic);
48 static bool isLikelySvg(QIODevice *device,
bool *isCompressed =
nullptr);
50 QSvgTinyDocument(QtSvg::Options options, QtSvg::AnimatorType type);
52 Type type()
const override;
54 inline QSize size()
const;
55 void setWidth(
int len,
bool percent);
56 void setHeight(
int len,
bool percent);
57 inline int width()
const;
58 inline int height()
const;
59 inline bool widthPercent()
const;
60 inline bool heightPercent()
const;
62 inline bool preserveAspectRatio()
const;
63 void setPreserveAspectRatio(
bool on);
65 inline QRectF viewBox()
const;
66 void setViewBox(
const QRectF &rect);
67 bool isCalculatingImplicitViewBox() {
return m_calculatingImplicitViewBox; }
69 QtSvg::Options options()
const;
71 void drawCommand(QPainter *, QSvgExtraStates &) override;
73 void draw(QPainter *p);
74 void draw(QPainter *p,
const QRectF &bounds);
75 void draw(QPainter *p,
const QString &id,
76 const QRectF &bounds=QRectF());
78 QTransform transformForElement(
const QString &id)
const;
79 QRectF boundsOnElement(
const QString &id)
const;
80 bool elementExists(
const QString &id)
const;
82 void addSvgFont(QSvgFont *);
83 QSvgFont *svgFont(
const QString &family)
const;
84 void addNamedNode(
const QString &id, QSvgNode *node);
85 QSvgNode *namedNode(
const QString &id)
const;
86 void addNamedStyle(
const QString &id, QSvgPaintStyleProperty *style);
87 QSvgPaintStyleProperty *namedStyle(
const QString &id)
const;
89 void restartAnimation();
90 inline qint64 currentElapsed()
const;
91 bool animated()
const;
92 void setAnimated(
bool a);
93 inline int animationDuration()
const;
94 int currentFrame()
const;
95 void setCurrentFrame(
int);
96 void setFramesPerSecond(
int num);
98 QSharedPointer<QSvgAbstractAnimator> animator()
const;
101 void mapSourceToTarget(QPainter *p,
const QRectF &targetRect,
const QRectF &sourceRect = QRectF());
105 bool m_heightPercent;
107 mutable bool m_calculatingImplicitViewBox =
false;
108 mutable bool m_implicitViewBox =
true;
109 mutable QRectF m_viewBox;
110 bool m_preserveAspectRatio =
false;
112 QHash<QString, QSvgRefCounter<QSvgFont> > m_fonts;
113 QHash<QString, QSvgNode *> m_namedNodes;
114 QHash<QString, QSvgRefCounter<QSvgPaintStyleProperty> > m_namedStyles;
119 QSvgExtraStates m_states;
121 const QtSvg::Options m_options;
122 QSharedPointer<QSvgAbstractAnimator> m_animator;
127inline QSize QSvgTinyDocument::size()
const
129 if (m_size.isEmpty())
130 return viewBox().size().toSize();
131 if (m_widthPercent || m_heightPercent) {
132 const int width = m_widthPercent ? qRound(0.01 * m_size.width() * viewBox().size().width()) : m_size.width();
133 const int height = m_heightPercent ? qRound(0.01 * m_size.height() * viewBox().size().height()) : m_size.height();
134 return QSize(width, height);