| 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 <QScopedPointer> |
| 23 | #include <QtQuick/private/qquickpixmap_p.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QQuickStyledTextImgTag; |
| 28 | class QQuickStyledTextPrivate; |
| 29 | class QString; |
| 30 | class QQmlContext; |
| 31 | |
| 32 | class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag |
| 33 | { |
| 34 | public: |
| 35 | QQuickStyledTextImgTag() = default; |
| 36 | ~QQuickStyledTextImgTag() = default; |
| 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 | QScopedPointer<QQuickPixmap> pix; |
| 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 | |