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 QTEXTDOCUMENTLAYOUT_P_H
5#define QTEXTDOCUMENTLAYOUT_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 <QtGui/private/qtguiglobal_p.h>
19#include "QtGui/qabstracttextdocumentlayout.h"
20#include "QtGui/qtextoption.h"
21#include "QtGui/qtextobject.h"
22
23QT_BEGIN_NAMESPACE
24
25class QTextListFormat;
26class QTextTableCell;
27class QTextDocumentLayoutPrivate;
28
29class Q_GUI_EXPORT QTextDocumentLayout : public QAbstractTextDocumentLayout
30{
31 Q_DECLARE_PRIVATE(QTextDocumentLayout)
32 Q_OBJECT
33 Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
34 Q_PROPERTY(qreal idealWidth READ idealWidth)
35 Q_PROPERTY(bool contentHasAlignment READ contentHasAlignment)
36public:
37 explicit QTextDocumentLayout(QTextDocument *doc);
38
39 // from the abstract layout
40 void draw(QPainter *painter, const PaintContext &context) override;
41 int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const override;
42
43 int pageCount() const override;
44 QSizeF documentSize() const override;
45
46 void setCursorWidth(int width);
47 int cursorWidth() const;
48
49 // internal, to support the ugly FixedColumnWidth wordwrap mode in QTextEdit
50 void setFixedColumnWidth(int width);
51
52 // internal for QTextEdit's NoWrap mode
53 void setViewport(const QRectF &viewport);
54
55 virtual QRectF frameBoundingRect(QTextFrame *frame) const override;
56 virtual QRectF blockBoundingRect(const QTextBlock &block) const override;
57 QRectF tableBoundingRect(QTextTable *table) const;
58 QRectF tableCellBoundingRect(QTextTable *table, const QTextTableCell &cell) const;
59
60 // ####
61 int layoutStatus() const;
62 int dynamicPageCount() const;
63 QSizeF dynamicDocumentSize() const;
64 void ensureLayouted(qreal);
65
66 qreal idealWidth() const;
67
68 bool contentHasAlignment() const;
69
70protected:
71 void documentChanged(int from, int oldLength, int length) override;
72 void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override;
73 void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) override;
74 void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item,
75 int posInDocument, const QTextFormat &format) override;
76 virtual void timerEvent(QTimerEvent *e) override;
77private:
78 QRectF doLayout(int from, int oldLength, int length);
79 void layoutFinished();
80};
81
82QT_END_NAMESPACE
83
84#endif // QTEXTDOCUMENTLAYOUT_P_H
85

source code of qtbase/src/gui/text/qtextdocumentlayout_p.h