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

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