summaryrefslogtreecommitdiffstats
path: root/tests/manual/qglyphruns/view.h
blob: a8c3c1aed99a8ab19ac2cbf85fa5887a57a7288e (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef VIEW_H
#define VIEW_H

#include <QWidget>
#include <QTextOption>

class QTextLayout;
class View : public QWidget
{
    Q_OBJECT
public:
    explicit View(QWidget *parent = nullptr);
    ~View() override;

    void updateLayout(const QString &sourceString,
                      float width,
                      QTextOption::WrapMode mode,
                      const QFont &font);

    QSize sizeHint() const override;

    QTextLayout *layout() const { return m_layout; }

public slots:
    void setVisualizedBounds(const QRegion &region)
    {
        m_bounds = region;
        update();
    }

protected:
    void paintEvent(QPaintEvent *e) override;

private:
    QTextLayout *m_layout = nullptr;
    QRegion m_bounds;
};

#endif // VIEW_H