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 QSGINTERNALTEXTNODE_P_H |
5 | #define QSGINTERNALTEXTNODE_P_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 "qsgtextnode.h" |
19 | #include "qquicktext_p.h" |
20 | #include <qglyphrun.h> |
21 | |
22 | #include <QtGui/qcolor.h> |
23 | #include <QtGui/qtextlayout.h> |
24 | #include <QtCore/qvarlengtharray.h> |
25 | #include <QtCore/qscopedpointer.h> |
26 | |
27 | QT_BEGIN_NAMESPACE |
28 | |
29 | class QSGGlyphNode; |
30 | class QTextBlock; |
31 | class QColor; |
32 | class QTextDocument; |
33 | class QSGContext; |
34 | class QRawFont; |
35 | class QSGInternalRectangleNode; |
36 | class QSGClipNode; |
37 | class QSGTexture; |
38 | class QSGRenderContext; |
39 | |
40 | class QQuickTextNodeEngine; |
41 | |
42 | class Q_QUICK_EXPORT QSGInternalTextNode : public QSGTextNode |
43 | { |
44 | public: |
45 | QSGInternalTextNode(QSGRenderContext *renderContext); |
46 | ~QSGInternalTextNode(); |
47 | |
48 | static bool isComplexRichText(QTextDocument *); |
49 | |
50 | void setColor(QColor color) override |
51 | { |
52 | m_color = color; |
53 | } |
54 | |
55 | QColor color() const override |
56 | { |
57 | return m_color; |
58 | } |
59 | |
60 | void setTextStyle(TextStyle textStyle) override |
61 | { |
62 | m_textStyle = textStyle; |
63 | } |
64 | |
65 | TextStyle textStyle() override |
66 | { |
67 | return m_textStyle; |
68 | } |
69 | |
70 | void setStyleColor(QColor styleColor) override |
71 | { |
72 | m_styleColor = styleColor; |
73 | } |
74 | |
75 | QColor styleColor() const override |
76 | { |
77 | return m_styleColor; |
78 | } |
79 | |
80 | void setLinkColor(QColor linkColor) override |
81 | { |
82 | m_linkColor = linkColor; |
83 | } |
84 | |
85 | QColor linkColor() const override |
86 | { |
87 | return m_linkColor; |
88 | } |
89 | |
90 | void setSelectionColor(QColor selectionColor) override |
91 | { |
92 | m_selectionColor = selectionColor; |
93 | } |
94 | |
95 | QColor selectionColor() const override |
96 | { |
97 | return m_selectionColor; |
98 | } |
99 | |
100 | void setSelectionTextColor(QColor selectionTextColor) override |
101 | { |
102 | m_selectionTextColor = selectionTextColor; |
103 | } |
104 | |
105 | QColor selectionTextColor() const override |
106 | { |
107 | return m_selectionTextColor; |
108 | } |
109 | |
110 | void setRenderTypeQuality(int renderTypeQuality) override |
111 | { |
112 | m_renderTypeQuality = renderTypeQuality; |
113 | } |
114 | int renderTypeQuality() const override |
115 | { |
116 | return m_renderTypeQuality; |
117 | } |
118 | |
119 | void setRenderType(RenderType renderType) override |
120 | { |
121 | m_renderType = renderType; |
122 | } |
123 | |
124 | RenderType renderType() const override |
125 | { |
126 | return m_renderType; |
127 | } |
128 | |
129 | bool containsUnscalableGlyphs() const |
130 | { |
131 | return m_containsUnscalableGlyphs; |
132 | } |
133 | |
134 | void setFiltering(QSGTexture::Filtering filtering) override |
135 | { |
136 | m_filtering = filtering; |
137 | } |
138 | |
139 | QSGTexture::Filtering filtering() const override |
140 | { |
141 | return m_filtering; |
142 | } |
143 | |
144 | void setViewport(const QRectF &viewport) override |
145 | { |
146 | m_viewport = viewport; |
147 | } |
148 | |
149 | QRectF viewport() const override |
150 | { |
151 | return m_viewport; |
152 | } |
153 | |
154 | void setCursor(const QRectF &rect, const QColor &color); |
155 | void clearCursor(); |
156 | |
157 | void addRectangleNode(const QRectF &rect, const QColor &color); |
158 | virtual void addDecorationNode(const QRectF &rect, const QColor &color); |
159 | void addImage(const QRectF &rect, const QImage &image); |
160 | void clear() override; |
161 | QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color, |
162 | QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(), |
163 | QSGNode *parentNode = 0); |
164 | |
165 | QSGInternalRectangleNode *cursorNode() const { return m_cursorNode; } |
166 | QPair<int, int> renderedLineRange() const { return { m_firstLineInViewport, m_firstLinePastViewport }; } |
167 | |
168 | protected: |
169 | void doAddTextLayout(QPointF position, |
170 | QTextLayout *textLayout, |
171 | int selectionStart, |
172 | int selectionEnd, |
173 | int lineStart, |
174 | int lineCount) override; |
175 | |
176 | void doAddTextDocument(QPointF position, |
177 | QTextDocument *textDocument, |
178 | int selectionStart, |
179 | int selectionEnd) override; |
180 | |
181 | private: |
182 | QSGInternalRectangleNode *m_cursorNode = nullptr; |
183 | QList<QSGTexture *> m_textures; |
184 | QSGRenderContext *m_renderContext = nullptr; |
185 | RenderType m_renderType = QtRendering; |
186 | TextStyle m_textStyle = Normal; |
187 | QRectF m_viewport; |
188 | QColor m_color = QColor(0, 0, 0); |
189 | QColor m_styleColor = QColor(0, 0, 0); |
190 | QColor m_linkColor = QColor(0, 0, 255); |
191 | QColor m_selectionColor = QColor(0, 0, 128); |
192 | QColor m_selectionTextColor = QColor(255, 255, 255); |
193 | QSGTexture::Filtering m_filtering = QSGTexture::Nearest; |
194 | int m_renderTypeQuality = -1; |
195 | int m_firstLineInViewport = -1; |
196 | int m_firstLinePastViewport = -1; |
197 | bool m_containsUnscalableGlyphs = false; |
198 | |
199 | friend class QQuickTextEdit; |
200 | friend class QQuickTextEditPrivate; |
201 | }; |
202 | |
203 | QT_END_NAMESPACE |
204 | |
205 | #endif // QSGINTERNALTEXTNODE_P_H |
206 |
Definitions
- QSGInternalTextNode
- setColor
- color
- setTextStyle
- textStyle
- setStyleColor
- styleColor
- setLinkColor
- linkColor
- setSelectionColor
- selectionColor
- setSelectionTextColor
- selectionTextColor
- setRenderTypeQuality
- renderTypeQuality
- setRenderType
- renderType
- containsUnscalableGlyphs
- setFiltering
- filtering
- setViewport
- viewport
- cursorNode
Learn to use CMake with our Intro Training
Find out more