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_H |
5 | #define QQUICKTEXTAREA_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/qpalette.h> |
19 | #include <QtQuick/private/qquicktextedit_p.h> |
20 | #include <QtQuick/private/qquickevents_p_p.h> |
21 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QQuickText; |
26 | class QQuickTextAreaPrivate; |
27 | class QQuickTextAreaAttached; |
28 | |
29 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextArea : public QQuickTextEdit |
30 | { |
31 | Q_OBJECT |
32 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) // override |
33 | Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged3 FINAL) |
34 | Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged3 FINAL) |
35 | Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) |
36 | Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL) |
37 | Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) |
38 | // 2.1 (Qt 5.8) |
39 | Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL REVISION(2, 1)) |
40 | Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL REVISION(2, 1)) |
41 | // 2.5 (Qt 5.12) |
42 | Q_PROPERTY(QColor placeholderTextColor READ placeholderTextColor WRITE setPlaceholderTextColor NOTIFY placeholderTextColorChanged FINAL REVISION(2, 5)) |
43 | Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY implicitBackgroundWidthChanged FINAL REVISION(2, 5)) |
44 | Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY implicitBackgroundHeightChanged FINAL REVISION(2, 5)) |
45 | Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY topInsetChanged FINAL REVISION(2, 5)) |
46 | Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY leftInsetChanged FINAL REVISION(2, 5)) |
47 | Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY rightInsetChanged FINAL REVISION(2, 5)) |
48 | Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY bottomInsetChanged FINAL REVISION(2, 5)) |
49 | Q_CLASSINFO("DeferredPropertyNames" , "background" ) |
50 | QML_NAMED_ELEMENT(TextArea) |
51 | QML_ATTACHED(QQuickTextAreaAttached) |
52 | QML_ADDED_IN_VERSION(2, 0) |
53 | |
54 | public: |
55 | explicit QQuickTextArea(QQuickItem *parent = nullptr); |
56 | ~QQuickTextArea(); |
57 | |
58 | static QQuickTextAreaAttached *qmlAttachedProperties(QObject *object); |
59 | |
60 | QFont font() const; |
61 | void setFont(const QFont &font); |
62 | |
63 | QQuickItem *background() const; |
64 | void setBackground(QQuickItem *background); |
65 | |
66 | QString placeholderText() const; |
67 | void setPlaceholderText(const QString &text); |
68 | |
69 | Qt::FocusReason focusReason() const; |
70 | void setFocusReason(Qt::FocusReason reason); |
71 | |
72 | bool contains(const QPointF &point) const override; |
73 | |
74 | // 2.1 (Qt 5.8) |
75 | bool isHovered() const; |
76 | void setHovered(bool hovered); |
77 | |
78 | bool isHoverEnabled() const; |
79 | void setHoverEnabled(bool enabled); |
80 | void resetHoverEnabled(); |
81 | |
82 | // 2.5 (Qt 5.12) |
83 | QColor placeholderTextColor() const; |
84 | void setPlaceholderTextColor(const QColor &color); |
85 | |
86 | qreal implicitBackgroundWidth() const; |
87 | qreal implicitBackgroundHeight() const; |
88 | |
89 | qreal topInset() const; |
90 | void setTopInset(qreal inset); |
91 | void resetTopInset(); |
92 | |
93 | qreal leftInset() const; |
94 | void setLeftInset(qreal inset); |
95 | void resetLeftInset(); |
96 | |
97 | qreal rightInset() const; |
98 | void setRightInset(qreal inset); |
99 | void resetRightInset(); |
100 | |
101 | qreal bottomInset() const; |
102 | void setBottomInset(qreal inset); |
103 | void resetBottomInset(); |
104 | |
105 | Q_SIGNALS: |
106 | void fontChanged(); |
107 | void implicitWidthChanged3(); |
108 | void implicitHeightChanged3(); |
109 | void backgroundChanged(); |
110 | void placeholderTextChanged(); |
111 | void focusReasonChanged(); |
112 | void pressAndHold(QQuickMouseEvent *event); |
113 | // 2.1 (Qt 5.8) |
114 | Q_REVISION(2, 1) void pressed(QQuickMouseEvent *event); |
115 | Q_REVISION(2, 1) void released(QQuickMouseEvent *event); |
116 | Q_REVISION(2, 1) void hoveredChanged(); |
117 | Q_REVISION(2, 1) void hoverEnabledChanged(); |
118 | // 2.5 (Qt 5.12) |
119 | Q_REVISION(2, 5) void placeholderTextColorChanged(); |
120 | Q_REVISION(2, 5) void implicitBackgroundWidthChanged(); |
121 | Q_REVISION(2, 5) void implicitBackgroundHeightChanged(); |
122 | Q_REVISION(2, 5) void topInsetChanged(); |
123 | Q_REVISION(2, 5) void leftInsetChanged(); |
124 | Q_REVISION(2, 5) void rightInsetChanged(); |
125 | Q_REVISION(2, 5) void bottomInsetChanged(); |
126 | |
127 | protected: |
128 | friend struct QQuickPressHandler; |
129 | |
130 | void classBegin() override; |
131 | void componentComplete() override; |
132 | |
133 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
134 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
135 | virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset); |
136 | |
137 | QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override; |
138 | |
139 | void focusInEvent(QFocusEvent *event) override; |
140 | void focusOutEvent(QFocusEvent *event) override; |
141 | #if QT_CONFIG(quicktemplates2_hover) |
142 | void hoverEnterEvent(QHoverEvent *event) override; |
143 | void hoverLeaveEvent(QHoverEvent *event) override; |
144 | #endif |
145 | void mousePressEvent(QMouseEvent *event) override; |
146 | void mouseMoveEvent(QMouseEvent *event) override; |
147 | void mouseReleaseEvent(QMouseEvent *event) override; |
148 | void mouseDoubleClickEvent(QMouseEvent *event) override; |
149 | void timerEvent(QTimerEvent *event) override; |
150 | |
151 | private: |
152 | Q_DISABLE_COPY(QQuickTextArea) |
153 | Q_DECLARE_PRIVATE(QQuickTextArea) |
154 | }; |
155 | |
156 | class QQuickTextAreaAttachedPrivate; |
157 | |
158 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTextAreaAttached : public QObject |
159 | { |
160 | Q_OBJECT |
161 | Q_PROPERTY(QQuickTextArea *flickable READ flickable WRITE setFlickable NOTIFY flickableChanged FINAL) |
162 | |
163 | public: |
164 | explicit QQuickTextAreaAttached(QObject *parent); |
165 | |
166 | QQuickTextArea *flickable() const; |
167 | void setFlickable(QQuickTextArea *control); |
168 | |
169 | Q_SIGNALS: |
170 | void flickableChanged(); |
171 | |
172 | private: |
173 | Q_DISABLE_COPY(QQuickTextAreaAttached) |
174 | Q_DECLARE_PRIVATE(QQuickTextAreaAttached) |
175 | }; |
176 | |
177 | QT_END_NAMESPACE |
178 | |
179 | QML_DECLARE_TYPE(QQuickTextArea) |
180 | |
181 | #endif // QQUICKTEXTAREA_P_H |
182 | |