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 QQUICKSTYLEDTEXT_H |
5 | #define QQUICKSTYLEDTEXT_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 <QSize> |
19 | #include <QPointF> |
20 | #include <QList> |
21 | #include <QUrl> |
22 | #include <QtQuick/private/qquickpixmapcache_p.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QQuickStyledTextImgTag; |
27 | class QQuickStyledTextPrivate; |
28 | class QString; |
29 | class QQmlContext; |
30 | |
31 | class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag |
32 | { |
33 | public: |
34 | QQuickStyledTextImgTag() { } |
35 | |
36 | ~QQuickStyledTextImgTag() { delete pix; } |
37 | |
38 | enum Align { |
39 | Bottom, |
40 | Middle, |
41 | Top |
42 | }; |
43 | |
44 | QUrl url; |
45 | QPointF pos; |
46 | QSize size; |
47 | int position = 0; |
48 | qreal offset = 0.0; // this offset allows us to compensate for flooring reserved space |
49 | Align align = QQuickStyledTextImgTag::Bottom; |
50 | QQuickPixmap *pix = nullptr; |
51 | }; |
52 | |
53 | class Q_AUTOTEST_EXPORT QQuickStyledText |
54 | { |
55 | public: |
56 | static void parse(const QString &string, QTextLayout &layout, |
57 | QList<QQuickStyledTextImgTag*> &imgTags, |
58 | const QUrl &baseUrl, |
59 | QQmlContext *context, |
60 | bool preloadImages, |
61 | bool *fontSizeModified); |
62 | |
63 | private: |
64 | QQuickStyledText(const QString &string, QTextLayout &layout, |
65 | QList<QQuickStyledTextImgTag*> &imgTags, |
66 | const QUrl &baseUrl, |
67 | QQmlContext *context, |
68 | bool preloadImages, |
69 | bool *fontSizeModified); |
70 | ~QQuickStyledText(); |
71 | |
72 | QQuickStyledTextPrivate *d; |
73 | }; |
74 | |
75 | QT_END_NAMESPACE |
76 | |
77 | #endif |
78 | |