1 | // Copyright (C) 2023 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 QSGTEXTNODE_H |
5 | #define QSGTEXTNODE_H |
6 | |
7 | #include <QtGui/qtextlayout.h> |
8 | #include <QtQuick/qsgnode.h> |
9 | #include <QtQuick/qsgtexture.h> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | class Q_QUICK_EXPORT QSGTextNode : public QSGTransformNode |
14 | { |
15 | public: |
16 | ~QSGTextNode() override; |
17 | |
18 | // Should match the TextStyle in qquicktext_p.h |
19 | enum TextStyle : quint8 |
20 | { |
21 | Normal, |
22 | Outline, |
23 | Raised, |
24 | Sunken |
25 | }; |
26 | |
27 | // Should match the RenderType in qquicktext_p.h |
28 | enum RenderType: quint8 |
29 | { |
30 | QtRendering, |
31 | NativeRendering, |
32 | CurveRendering |
33 | }; |
34 | |
35 | virtual void setColor(QColor color) = 0; |
36 | virtual QColor color() const = 0; |
37 | |
38 | virtual void setTextStyle(TextStyle textStyle) = 0; |
39 | virtual TextStyle textStyle() = 0; |
40 | |
41 | virtual void setStyleColor(QColor styleColor) = 0; |
42 | virtual QColor styleColor() const = 0; |
43 | |
44 | virtual void setLinkColor(QColor linkColor) = 0; |
45 | virtual QColor linkColor() const = 0; |
46 | |
47 | virtual void setSelectionColor(QColor selectionColor) = 0; |
48 | virtual QColor selectionColor() const = 0; |
49 | |
50 | virtual void setSelectionTextColor(QColor selectionTextColor) = 0; |
51 | virtual QColor selectionTextColor() const = 0; |
52 | |
53 | virtual void setRenderType(RenderType renderType) = 0; |
54 | virtual RenderType renderType() const = 0; |
55 | |
56 | virtual void setRenderTypeQuality(int renderTypeQuality) = 0; |
57 | virtual int renderTypeQuality() const = 0; |
58 | |
59 | virtual void setFiltering(QSGTexture::Filtering) = 0; |
60 | virtual QSGTexture::Filtering filtering() const = 0; |
61 | |
62 | virtual void clear() = 0; |
63 | |
64 | virtual void setViewport(const QRectF &viewport) = 0; |
65 | virtual QRectF viewport() const = 0; |
66 | |
67 | void addTextLayout(QPointF position, |
68 | QTextLayout *layout, |
69 | int selectionStart = -1, |
70 | int selectionCount = -1, |
71 | int lineStart = 0, |
72 | int lineCount = -1) |
73 | { |
74 | doAddTextLayout(position, layout, selectionStart, selectionCount, lineStart, lineCount); |
75 | } |
76 | |
77 | void addTextDocument(QPointF position, |
78 | QTextDocument *document, |
79 | int selectionStart = -1, |
80 | int selectionCount = -1) |
81 | { |
82 | doAddTextDocument(position, document, selectionStart, selectionCount); |
83 | } |
84 | |
85 | private: |
86 | virtual void doAddTextLayout(QPointF position, |
87 | QTextLayout *layout, |
88 | int selectionStart, |
89 | int selectionCount, |
90 | int lineStart, |
91 | int lineCount) = 0; |
92 | virtual void doAddTextDocument(QPointF position, |
93 | QTextDocument *document, |
94 | int selectionStart, |
95 | int selectionCount) = 0; |
96 | |
97 | }; |
98 | |
99 | QT_END_NAMESPACE |
100 | |
101 | #endif // QSGTEXTNODE_H |
102 | |