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 QTEXTEDIT_P_H |
5 | #define QTEXTEDIT_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 <QtWidgets/private/qtwidgetsglobal_p.h> |
19 | #include "private/qabstractscrollarea_p.h" |
20 | #include "QtGui/qtextdocumentfragment.h" |
21 | #if QT_CONFIG(scrollbar) |
22 | #include "QtWidgets/qscrollbar.h" |
23 | #endif |
24 | #include "QtGui/qtextcursor.h" |
25 | #include "QtGui/qtextformat.h" |
26 | #if QT_CONFIG(menu) |
27 | #include "QtWidgets/qmenu.h" |
28 | #endif |
29 | #include "QtGui/qabstracttextdocumentlayout.h" |
30 | #include "QtCore/qbasictimer.h" |
31 | #include "QtCore/qurl.h" |
32 | #include "qtextedit.h" |
33 | |
34 | #include "private/qwidgettextcontrol_p.h" |
35 | |
36 | QT_REQUIRE_CONFIG(textedit); |
37 | |
38 | QT_BEGIN_NAMESPACE |
39 | |
40 | class QMimeData; |
41 | class QTextEditPrivate : public QAbstractScrollAreaPrivate |
42 | { |
43 | Q_DECLARE_PUBLIC(QTextEdit) |
44 | public: |
45 | QTextEditPrivate(); |
46 | |
47 | void init(const QString &html = QString()); |
48 | void paint(QPainter *p, QPaintEvent *e); |
49 | void _q_repaintContents(const QRectF &contentsRect); |
50 | |
51 | inline QPoint mapToContents(const QPoint &point) const |
52 | { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); } |
53 | |
54 | void _q_adjustScrollbars(); |
55 | void _q_ensureVisible(const QRectF &rect); |
56 | void relayoutDocument(); |
57 | |
58 | void createAutoBulletList(); |
59 | void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode); |
60 | |
61 | inline int horizontalOffset() const |
62 | { return q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value(); } |
63 | inline int verticalOffset() const |
64 | { return vbar->value(); } |
65 | |
66 | inline void sendControlEvent(QEvent *e) |
67 | { control->processEvent(e, coordinateOffset: QPointF(horizontalOffset(), verticalOffset()), contextWidget: viewport); } |
68 | |
69 | void _q_currentCharFormatChanged(const QTextCharFormat &format); |
70 | void _q_cursorPositionChanged(); |
71 | void _q_hoveredBlockWithMarkerChanged(const QTextBlock &block); |
72 | |
73 | void updateDefaultTextOption(); |
74 | |
75 | // re-implemented by QTextBrowser, called by QTextDocument::loadResource |
76 | virtual QUrl resolveUrl(const QUrl &url) const |
77 | { return url; } |
78 | |
79 | QWidgetTextControl *control; |
80 | |
81 | QTextEdit::AutoFormatting autoFormatting; |
82 | bool tabChangesFocus; |
83 | |
84 | QBasicTimer autoScrollTimer; |
85 | QPoint autoScrollDragPos; |
86 | |
87 | QTextEdit::LineWrapMode lineWrap; |
88 | int lineWrapColumnOrWidth; |
89 | QTextOption::WrapMode wordWrap; |
90 | |
91 | uint ignoreAutomaticScrollbarAdjustment : 1; |
92 | uint preferRichText : 1; |
93 | uint showCursorOnInitialShow : 1; |
94 | uint inDrag : 1; |
95 | uint clickCausedFocus : 1; |
96 | |
97 | // Qt3 COMPAT only, for setText |
98 | Qt::TextFormat textFormat; |
99 | |
100 | QString anchorToScrollToWhenVisible; |
101 | |
102 | QString placeholderText; |
103 | |
104 | Qt::CursorShape cursorToRestoreAfterHover = Qt::IBeamCursor; |
105 | |
106 | #ifdef QT_KEYPAD_NAVIGATION |
107 | QBasicTimer deleteAllTimer; |
108 | #endif |
109 | }; |
110 | |
111 | QT_END_NAMESPACE |
112 | |
113 | #endif // QTEXTEDIT_P_H |
114 | |