1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QQUICKTEXTAREA_P_P_H
38#define QQUICKTEXTAREA_P_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <QtQml/private/qlazilyallocated_p.h>
52#include <QtQuick/private/qquicktextedit_p_p.h>
53#include <QtQuick/private/qquickitemchangelistener_p.h>
54#include <QtQuickTemplates2/private/qquickpresshandler_p_p.h>
55#include <QtQuickTemplates2/private/qquickdeferredpointer_p_p.h>
56
57#include <QtQuickTemplates2/private/qquicktextarea_p.h>
58
59#if QT_CONFIG(accessibility)
60#include <QtGui/qaccessible.h>
61#endif
62
63QT_BEGIN_NAMESPACE
64
65class QQuickFlickable;
66
67class QQuickTextAreaPrivate : public QQuickTextEditPrivate, public QQuickItemChangeListener
68#if QT_CONFIG(accessibility)
69 , public QAccessible::ActivationObserver
70#endif
71{
72 Q_DECLARE_PUBLIC(QQuickTextArea)
73
74public:
75 QQuickTextAreaPrivate();
76 ~QQuickTextAreaPrivate();
77
78 static QQuickTextAreaPrivate *get(QQuickTextArea *item)
79 {
80 return static_cast<QQuickTextAreaPrivate *>(QObjectPrivate::get(o: item));
81 }
82
83 inline QMarginsF getInset() const { return QMarginsF(getLeftInset(), getTopInset(), getRightInset(), getBottomInset()); }
84 inline qreal getTopInset() const { return extra.isAllocated() ? extra->topInset : 0; }
85 inline qreal getLeftInset() const { return extra.isAllocated() ? extra->leftInset : 0; }
86 inline qreal getRightInset() const { return extra.isAllocated() ? extra->rightInset : 0; }
87 inline qreal getBottomInset() const { return extra.isAllocated() ? extra->bottomInset : 0; }
88
89 void setTopInset(qreal value, bool reset = false);
90 void setLeftInset(qreal value, bool reset = false);
91 void setRightInset(qreal value, bool reset = false);
92 void setBottomInset(qreal value, bool reset = false);
93
94 void resizeBackground();
95
96 void resolveFont();
97 void inheritFont(const QFont &font);
98 void updateFont(const QFont &font);
99 inline void setFont_helper(const QFont &font) {
100 if (sourceFont.resolve() == font.resolve() && sourceFont == font)
101 return;
102 updateFont(font);
103 }
104
105 void resolvePalette();
106 void inheritPalette(const QPalette &palette);
107 void updatePalette(const QPalette &palette);
108 inline void setPalette_helper(const QPalette &palette) {
109 if (resolvedPalette.resolve() == palette.resolve() && resolvedPalette == palette)
110 return;
111 updatePalette(palette);
112 }
113
114#if QT_CONFIG(quicktemplates2_hover)
115 void updateHoverEnabled(bool h, bool e);
116#endif
117
118 void attachFlickable(QQuickFlickable *flickable);
119 void detachFlickable();
120 void ensureCursorVisible();
121 void resizeFlickableControl();
122 void resizeFlickableContent();
123
124 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
125
126 qreal getImplicitWidth() const override;
127 qreal getImplicitHeight() const override;
128
129 void implicitWidthChanged() override;
130 void implicitHeightChanged() override;
131
132 void readOnlyChanged(bool isReadOnly);
133
134#if QT_CONFIG(accessibility)
135 void accessibilityActiveChanged(bool active) override;
136 QAccessible::Role accessibleRole() const override;
137#endif
138
139 void cancelBackground();
140 void executeBackground(bool complete = false);
141
142 void itemImplicitWidthChanged(QQuickItem *item) override;
143 void itemImplicitHeightChanged(QQuickItem *item) override;
144 void itemDestroyed(QQuickItem *item) override;
145
146#if QT_CONFIG(quicktemplates2_hover)
147 bool hovered = false;
148 bool explicitHoverEnabled = false;
149#endif
150
151 struct ExtraData {
152 bool hasTopInset = false;
153 bool hasLeftInset = false;
154 bool hasRightInset = false;
155 bool hasBottomInset = false;
156 bool hasBackgroundWidth = false;
157 bool hasBackgroundHeight = false;
158 qreal topInset = 0;
159 qreal leftInset = 0;
160 qreal rightInset = 0;
161 qreal bottomInset = 0;
162 QFont requestedFont;
163 QPalette requestedPalette;
164 };
165 QLazilyAllocated<ExtraData> extra;
166
167 bool resizingBackground = false;
168 QPalette resolvedPalette;
169 QQuickDeferredPointer<QQuickItem> background;
170 QString placeholder;
171 QColor placeholderColor;
172 Qt::FocusReason focusReason = Qt::OtherFocusReason;
173 QQuickPressHandler pressHandler;
174 QQuickFlickable *flickable = nullptr;
175};
176
177QT_END_NAMESPACE
178
179#endif // QQUICKTEXTAREA_P_P_H
180

source code of qtquickcontrols2/src/quicktemplates2/qquicktextarea_p_p.h