Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsginternaltextnode_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QSGINTERNALTEXTNODE_P_H
6#define QSGINTERNALTEXTNODE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qsgtextnode.h"
20#include "qquicktext_p.h"
21#include <qglyphrun.h>
22
23#include <QtGui/qcolor.h>
24#include <QtGui/qtextlayout.h>
25#include <QtCore/qvarlengtharray.h>
26#include <QtCore/qscopedpointer.h>
27
28QT_BEGIN_NAMESPACE
29
30class QSGGlyphNode;
31class QTextBlock;
32class QColor;
33class QTextDocument;
34class QSGContext;
35class QRawFont;
36class QSGInternalRectangleNode;
37class QSGClipNode;
38class QSGTexture;
39class QSGRenderContext;
40
42
43class Q_QUICK_EXPORT QSGInternalTextNode : public QSGTextNode
44{
45public:
46 QSGInternalTextNode(QSGRenderContext *renderContext);
47 ~QSGInternalTextNode();
48
49 static bool isComplexRichText(QTextDocument *);
50
51 void setColor(QColor color) override
52 {
53 m_color = color;
54 }
55
56 QColor color() const override
57 {
58 return m_color;
59 }
60
61 void setTextStyle(TextStyle textStyle) override
62 {
63 m_textStyle = textStyle;
64 }
65
66 TextStyle textStyle() override
67 {
68 return m_textStyle;
69 }
70
71 void setStyleColor(QColor styleColor) override
72 {
73 m_styleColor = styleColor;
74 }
75
76 QColor styleColor() const override
77 {
78 return m_styleColor;
79 }
80
81 void setLinkColor(QColor linkColor) override
82 {
83 m_linkColor = linkColor;
84 }
85
86 QColor linkColor() const override
87 {
88 return m_linkColor;
89 }
90
91 void setSelectionColor(QColor selectionColor) override
92 {
93 m_selectionColor = selectionColor;
94 }
95
96 QColor selectionColor() const override
97 {
98 return m_selectionColor;
99 }
100
101 void setSelectionTextColor(QColor selectionTextColor) override
102 {
103 m_selectionTextColor = selectionTextColor;
104 }
105
106 QColor selectionTextColor() const override
107 {
108 return m_selectionTextColor;
109 }
110
111 void setRenderTypeQuality(int renderTypeQuality) override
112 {
113 m_renderTypeQuality = renderTypeQuality;
114 }
115 int renderTypeQuality() const override
116 {
117 return m_renderTypeQuality;
118 }
119
120 void setRenderType(RenderType renderType) override
121 {
122 m_renderType = renderType;
123 }
124
125 RenderType renderType() const override
126 {
127 return m_renderType;
128 }
129
130 bool containsUnscalableGlyphs() const
131 {
132 return m_containsUnscalableGlyphs;
133 }
134
135 void setFiltering(QSGTexture::Filtering filtering) override
136 {
137 m_filtering = filtering;
138 }
139
140 QSGTexture::Filtering filtering() const override
141 {
142 return m_filtering;
143 }
144
145 void setViewport(const QRectF &viewport) override
146 {
147 m_viewport = viewport;
148 }
149
150 QRectF viewport() const override
151 {
152 return m_viewport;
153 }
154
155 void setDevicePixelRatio(qreal dpr)
156 {
157 m_devicePixelRatio = dpr;
158 }
159
160 void setCursor(const QRectF &rect, const QColor &color);
161 void clearCursor();
162
163 void addRectangleNode(const QRectF &rect, const QColor &color);
164 virtual void addDecorationNode(const QRectF &rect, const QColor &color);
165 void addImage(const QRectF &rect, const QImage &image);
166 void clear() override;
167 QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
168 QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(),
169 QSGNode *parentNode = 0);
170
171 QSGInternalRectangleNode *cursorNode() const { return m_cursorNode; }
172 std::pair<int, int> renderedLineRange() const { return { m_firstLineInViewport, m_firstLinePastViewport }; }
173
174protected:
175 void doAddTextLayout(QPointF position,
176 QTextLayout *textLayout,
177 int selectionStart,
178 int selectionEnd,
179 int lineStart,
180 int lineCount) override;
181
182 void doAddTextDocument(QPointF position,
183 QTextDocument *textDocument,
184 int selectionStart,
185 int selectionEnd) override;
186
187private:
188 QSGInternalRectangleNode *m_cursorNode = nullptr;
189 QList<QSGTexture *> m_textures;
190 QSGRenderContext *m_renderContext = nullptr;
191 RenderType m_renderType = QtRendering;
192 TextStyle m_textStyle = Normal;
193 QRectF m_viewport;
194 QColor m_color = QColor(0, 0, 0);
195 QColor m_styleColor = QColor(0, 0, 0);
196 QColor m_linkColor = QColor(0, 0, 255);
197 QColor m_selectionColor = QColor(0, 0, 128);
198 QColor m_selectionTextColor = QColor(255, 255, 255);
199 QSGTexture::Filtering m_filtering = QSGTexture::Nearest;
200 int m_renderTypeQuality = -1;
201 int m_firstLineInViewport = -1;
202 int m_firstLinePastViewport = -1;
203 bool m_containsUnscalableGlyphs = false;
204 qreal m_devicePixelRatio = 1.0;
205
206 friend class QQuickTextEdit;
207 friend class QQuickTextEditPrivate;
208};
209
210QT_END_NAMESPACE
211
212#endif // QSGINTERNALTEXTNODE_P_H
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
#define QQUICKTEXT_LARGETEXT_THRESHOLD
static void getLinks_helper(const QTextLayout *layout, QVector< QQuickTextPrivate::LinkDesc > *links)