Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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
28
29class QSGGlyphNode;
30class QTextBlock;
31class QColor;
32class QTextDocument;
33class QSGContext;
34class QRawFont;
36class QSGClipNode;
37class QSGTexture;
39
41
42class Q_QUICK_EXPORT QSGInternalTextNode : public QSGTextNode
43{
44public:
47
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
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 void setFiltering(QSGTexture::Filtering filtering) override
130 {
131 m_filtering = filtering;
132 }
133
135 {
136 return m_filtering;
137 }
138
139 void setViewport(const QRectF &viewport) override
140 {
141 m_viewport = viewport;
142 }
143
144 QRectF viewport() const override
145 {
146 return m_viewport;
147 }
148
149 void setCursor(const QRectF &rect, const QColor &color);
150 void clearCursor();
151
152 void addRectangleNode(const QRectF &rect, const QColor &color);
153 virtual void addDecorationNode(const QRectF &rect, const QColor &color);
154 void addImage(const QRectF &rect, const QImage &image);
155 void clear() override;
156 QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
157 QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(),
158 QSGNode *parentNode = 0);
159
160 QSGInternalRectangleNode *cursorNode() const { return m_cursorNode; }
161 QPair<int, int> renderedLineRange() const { return { m_firstLineInViewport, m_firstLinePastViewport }; }
162
163protected:
164 void doAddTextLayout(QPointF position,
165 QTextLayout *textLayout,
166 int selectionStart,
167 int selectionEnd,
168 int lineStart,
169 int lineCount) override;
170
171 void doAddTextDocument(QPointF position,
172 QTextDocument *textDocument,
173 int selectionStart,
174 int selectionEnd) override;
175
176private:
177 QSGInternalRectangleNode *m_cursorNode = nullptr;
178 QList<QSGTexture *> m_textures;
179 QSGRenderContext *m_renderContext = nullptr;
180 RenderType m_renderType = QtRendering;
181 TextStyle m_textStyle = Normal;
182 QRectF m_viewport;
183 QColor m_color = QColor(0, 0, 0);
184 QColor m_styleColor = QColor(0, 0, 0);
185 QColor m_linkColor = QColor(0, 0, 255);
186 QColor m_selectionColor = QColor(0, 0, 128);
187 QColor m_selectionTextColor = QColor(255, 255, 255);
189 int m_renderTypeQuality = -1;
190 int m_firstLineInViewport = -1;
191 int m_firstLinePastViewport = -1;
192
193 friend class QQuickTextEdit;
195};
196
198
199#endif // QSGINTERNALTEXTNODE_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
The QGlyphRun class provides direct access to the internal glyphs in a font.
Definition qglyphrun.h:20
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QRawFont class provides access to a single physical instance of a font.
Definition qrawfont.h:24
\inmodule QtCore\reentrant
Definition qrect.h:484
The QSGClipNode class implements the clipping functionality in the scene graph.
Definition qsgnode.h:221
The QSGContext holds the scene graph entry points for one QML engine.
QColor linkColor() const override
Returns the color of hyperlinks in the text.
void setSelectionTextColor(QColor selectionTextColor) override
Sets the color of the selection text to selectionTextColor when any part of the text is marked as sel...
void setTextStyle(TextStyle textStyle) override
Sets the style of the rendered text to textStyle.
QColor selectionColor() const override
Returns the color of the selection background when any part of the text is marked as selected.
QPair< int, int > renderedLineRange() const
RenderType renderType() const override
Returns the type of glyph node used for rendering the text.
void setLinkColor(QColor linkColor) override
Sets the color of or hyperlinks to linkColor in the text.
QSGInternalRectangleNode * cursorNode() const
TextStyle textStyle() override
Returns the style of the rendered text.
void setFiltering(QSGTexture::Filtering filtering) override
Sets the sampling mode used when scaling images that are part of the displayed text to filtering.
void setRenderType(RenderType renderType) override
Sets the type of glyph node in use to renderType.
QSGTexture::Filtering filtering() const override
Returns the sampling mode used when scaling images that are part of the displayed text.
static bool isComplexRichText(QTextDocument *)
void setRenderTypeQuality(int renderTypeQuality) override
If the \l renderType() in use supports it, set the quality to use when rendering the text.
int renderTypeQuality() const override
Returns the render type quality of the node.
QRectF viewport() const override
Returns the current viewport set for this QSGTextNode.
QColor selectionTextColor() const override
Returns the color of the selection text when any part of the text is marked as selected.
void setStyleColor(QColor styleColor) override
Sets the style color to use when rendering the text to styleColor.
void setColor(QColor color) override
Sets the main color to use when rendering the text to color.
void setViewport(const QRectF &viewport) override
Sets the bounding rect of the viewport where the text is displayed to viewport.
void setSelectionColor(QColor selectionColor) override
Sets the color of the selection background to color when any part of the text is marked as selected.
QColor color() const override
Returns the main color used when rendering the text.
QColor styleColor() const override
Returns the style color used when rendering the text.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
The QSGTextNode class is a class for drawing text layouts and text documents in the Qt Quick scene gr...
Definition qsgtextnode.h:14
RenderType
This enum type describes type of glyph node used for rendering the text.
Definition qsgtextnode.h:29
TextStyle
This enum type describes styles that can be applied to text rendering.
Definition qsgtextnode.h:20
\inmodule QtQuick
Definition qsgtexture.h:20
Filtering
Specifies how sampling of texels should filter when texture coordinates are not pixel aligned.
Definition qsgtexture.h:34
\reentrant
\reentrant \inmodule QtGui
\reentrant
Definition qtextlayout.h:70
b clear()
rect
[4]
Combined button and popup list for selecting options.
Definition image.cpp:4
GLuint color
[2]
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
item setCursor(Qt::IBeamCursor)
[1]
view viewport() -> scroll(dx, dy, deviceRect)