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 QQUICKTEXTNODE_P_H
5#define QQUICKTEXTNODE_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 <QtQuick/qsgnode.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
27QT_BEGIN_NAMESPACE
28
29class QSGGlyphNode;
30class QTextBlock;
31class QColor;
32class QTextDocument;
33class QSGContext;
34class QRawFont;
35class QSGInternalRectangleNode;
36class QSGClipNode;
37class QSGTexture;
38
39class QQuickTextNodeEngine;
40
41class Q_QUICK_PRIVATE_EXPORT QQuickTextNode : public QSGTransformNode
42{
43public:
44 QQuickTextNode(QQuickItem *ownerElement);
45 ~QQuickTextNode();
46
47 static bool isComplexRichText(QTextDocument *);
48
49 void deleteContent();
50 void addTextLayout(const QPointF &position, QTextLayout *textLayout, const QColor &color = QColor(),
51 QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(),
52 const QColor &anchorColor = QColor(),
53 const QColor &selectionColor = QColor(), const QColor &selectedTextColor = QColor(),
54 int selectionStart = -1, int selectionEnd = -1,
55 int lineStart = 0, int lineCount = -1);
56 void addTextDocument(const QPointF &position, QTextDocument *textDocument, const QColor &color = QColor(),
57 QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(),
58 const QColor &anchorColor = QColor(),
59 const QColor &selectionColor = QColor(), const QColor &selectedTextColor = QColor(),
60 int selectionStart = -1, int selectionEnd = -1);
61
62 void setCursor(const QRectF &rect, const QColor &color);
63 void clearCursor();
64 QSGInternalRectangleNode *cursorNode() const { return m_cursorNode; }
65
66 QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color,
67 QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor(),
68 QSGNode *parentNode = 0);
69 void addImage(const QRectF &rect, const QImage &image);
70 void addRectangleNode(const QRectF &rect, const QColor &color);
71
72 bool useNativeRenderer() const { return m_useNativeRenderer; }
73 void setUseNativeRenderer(bool on) { m_useNativeRenderer = on; }
74
75 void setRenderTypeQuality(int renderTypeQuality) { m_renderTypeQuality = renderTypeQuality; }
76 int renderTypeQuality() const { return m_renderTypeQuality; }
77
78 QPair<int, int> renderedLineRange() const { return { m_firstLineInViewport, m_firstLinePastViewport }; }
79
80private:
81 QSGInternalRectangleNode *m_cursorNode;
82 QList<QSGTexture *> m_textures;
83 QQuickItem *m_ownerElement;
84 bool m_useNativeRenderer;
85 int m_renderTypeQuality;
86 int m_firstLineInViewport = -1;
87 int m_firstLinePastViewport = -1;
88
89 friend class QQuickTextEdit;
90 friend class QQuickTextEditPrivate;
91};
92
93QT_END_NAMESPACE
94
95#endif // QQUICKTEXTNODE_P_H
96

source code of qtdeclarative/src/quick/items/qquicktextnode_p.h