1// Copyright (C) 2017 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 QQUICKTEXTAREA_P_P_H
5#define QQUICKTEXTAREA_P_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 <QtQml/private/qlazilyallocated_p.h>
19#include <QtQuick/private/qquicktextedit_p_p.h>
20#include <QtQuick/private/qquickitemchangelistener_p.h>
21#include <QtQuickTemplates2/private/qquickpresshandler_p_p.h>
22#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h>
23#include <QtQuickTemplates2/private/qquicktheme_p.h>
24
25#include <QtQuickTemplates2/private/qquicktextarea_p.h>
26
27#if QT_CONFIG(accessibility)
28#include <QtGui/qaccessible.h>
29#endif
30
31QT_BEGIN_NAMESPACE
32
33class QQuickFlickable;
34
35class QQuickTextAreaPrivate : public QQuickTextEditPrivate, public QQuickItemChangeListener
36#if QT_CONFIG(accessibility)
37 , public QAccessible::ActivationObserver
38#endif
39{
40public:
41 Q_DECLARE_PUBLIC(QQuickTextArea)
42
43 QQuickTextAreaPrivate();
44 ~QQuickTextAreaPrivate();
45
46 static QQuickTextAreaPrivate *get(QQuickTextArea *item)
47 {
48 return static_cast<QQuickTextAreaPrivate *>(QObjectPrivate::get(o: item));
49 }
50
51 inline QMarginsF getInset() const { return QMarginsF(getLeftInset(), getTopInset(), getRightInset(), getBottomInset()); }
52 inline qreal getTopInset() const { return extra.isAllocated() ? extra->topInset : 0; }
53 inline qreal getLeftInset() const { return extra.isAllocated() ? extra->leftInset : 0; }
54 inline qreal getRightInset() const { return extra.isAllocated() ? extra->rightInset : 0; }
55 inline qreal getBottomInset() const { return extra.isAllocated() ? extra->bottomInset : 0; }
56
57 void setTopInset(qreal value, bool reset = false);
58 void setLeftInset(qreal value, bool reset = false);
59 void setRightInset(qreal value, bool reset = false);
60 void setBottomInset(qreal value, bool reset = false);
61
62 void resizeBackground();
63
64 void resolveFont();
65 void inheritFont(const QFont &font);
66 void updateFont(const QFont &font);
67 inline void setFont_helper(const QFont &font) {
68 if (sourceFont.resolveMask() == font.resolveMask() && sourceFont == font)
69 return;
70 updateFont(font);
71 }
72
73#if QT_CONFIG(quicktemplates2_hover)
74 void updateHoverEnabled(bool h, bool e);
75#endif
76
77 void attachFlickable(QQuickFlickable *flickable);
78 void detachFlickable();
79 void ensureCursorVisible();
80 void resizeFlickableControl();
81 void resizeFlickableContent();
82
83 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
84
85 qreal getImplicitWidth() const override;
86 qreal getImplicitHeight() const override;
87
88 void implicitWidthChanged() override;
89 void implicitHeightChanged() override;
90
91 void readOnlyChanged(bool isReadOnly);
92
93#if QT_CONFIG(accessibility)
94 void accessibilityActiveChanged(bool active) override;
95 QAccessible::Role accessibleRole() const override;
96#endif
97
98 void cancelBackground();
99 void executeBackground(bool complete = false);
100
101 void itemImplicitWidthChanged(QQuickItem *item) override;
102 void itemImplicitHeightChanged(QQuickItem *item) override;
103 void itemDestroyed(QQuickItem *item) override;
104
105 QPalette defaultPalette() const override;
106
107#if QT_CONFIG(quicktemplates2_hover)
108 bool hovered = false;
109 bool explicitHoverEnabled = false;
110#endif
111
112 struct ExtraData {
113 bool hasTopInset = false;
114 bool hasLeftInset = false;
115 bool hasRightInset = false;
116 bool hasBottomInset = false;
117 bool hasBackgroundWidth = false;
118 bool hasBackgroundHeight = false;
119 qreal topInset = 0;
120 qreal leftInset = 0;
121 qreal rightInset = 0;
122 qreal bottomInset = 0;
123 QFont requestedFont;
124 QPalette requestedPalette;
125 };
126 QLazilyAllocated<ExtraData> extra;
127
128 bool resizingBackground = false;
129 QPalette resolvedPalette;
130 QQuickDeferredPointer<QQuickItem> background;
131 QString placeholder;
132 QColor placeholderColor;
133 Qt::FocusReason focusReason = Qt::OtherFocusReason;
134 QQuickPressHandler pressHandler;
135 QQuickFlickable *flickable = nullptr;
136};
137
138QT_END_NAMESPACE
139
140#endif // QQUICKTEXTAREA_P_P_H
141

source code of qtdeclarative/src/quicktemplates/qquicktextarea_p_p.h