aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/util/qsgtextnode.h
blob: 47431929af69e96e6f32761599c0c343963888b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QSGTEXTNODE_H
#define QSGTEXTNODE_H

#include <QtGui/qtextlayout.h>
#include <QtQuick/qsgnode.h>
#include <QtQuick/qsgtexture.h>

QT_BEGIN_NAMESPACE

class Q_QUICK_EXPORT QSGTextNode : public QSGTransformNode
{
public:
    ~QSGTextNode() override;

    // Should match the TextStyle in qquicktext_p.h
    enum TextStyle : quint8
    {
        Normal,
        Outline,
        Raised,
        Sunken
    };

    // Should match the RenderType in qquicktext_p.h
    enum RenderType: quint8
    {
        QtRendering,
        NativeRendering,
        CurveRendering
    };

    virtual void setColor(QColor color) = 0;
    virtual QColor color() const = 0;

    virtual void setTextStyle(TextStyle textStyle) = 0;
    virtual TextStyle textStyle() = 0;

    virtual void setStyleColor(QColor styleColor) = 0;
    virtual QColor styleColor() const = 0;

    virtual void setLinkColor(QColor linkColor) = 0;
    virtual QColor linkColor() const = 0;

    virtual void setSelectionColor(QColor selectionColor) = 0;
    virtual QColor selectionColor() const = 0;

    virtual void setSelectionTextColor(QColor selectionTextColor) = 0;
    virtual QColor selectionTextColor() const = 0;

    virtual void setRenderType(RenderType renderType) = 0;
    virtual RenderType renderType() const = 0;

    virtual void setRenderTypeQuality(int renderTypeQuality) = 0;
    virtual int renderTypeQuality() const = 0;

    virtual void setFiltering(QSGTexture::Filtering) = 0;
    virtual QSGTexture::Filtering filtering() const = 0;

    virtual void clear() = 0;

    virtual void setViewport(const QRectF &viewport) = 0;
    virtual QRectF viewport() const = 0;

    void addTextLayout(QPointF position,
                       QTextLayout *layout,
                       int selectionStart = -1,
                       int selectionCount = -1,
                       int lineStart = 0,
                       int lineCount = -1)
    {
        doAddTextLayout(position, layout, selectionStart, selectionCount, lineStart, lineCount);
    }

    void addTextDocument(QPointF position,
                         QTextDocument *document,
                         int selectionStart = -1,
                         int selectionCount = -1)
    {
        doAddTextDocument(position, document, selectionStart, selectionCount);
    }

private:
    virtual void doAddTextLayout(QPointF position,
                                 QTextLayout *layout,
                                 int selectionStart,
                                 int selectionCount,
                                 int lineStart,
                                 int lineCount) = 0;
    virtual void doAddTextDocument(QPointF position,
                                   QTextDocument *document,
                                   int selectionStart,
                                   int selectionCount) = 0;

};

QT_END_NAMESPACE

#endif // QSGTEXTNODE_H