1
/****************************************************************************
3
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/
6
** This file is part of the QtQml module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** GNU Lesser General Public License Usage
10
** This file may be used under the terms of the GNU Lesser General Public
11
** License version 2.1 as published by the Free Software Foundation and
12
** appearing in the file LICENSE.LGPL included in the packaging of this
13
** file. Please review the following information to ensure the GNU Lesser
14
** General Public License version 2.1 requirements will be met:
15
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17
** In addition, as a special exception, Nokia gives you certain additional
18
** rights. These rights are described in the Nokia Qt LGPL Exception
19
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21
** GNU General Public License Usage
22
** Alternatively, this file may be used under the terms of the GNU General
23
** Public License version 3.0 as published by the Free Software Foundation
24
** and appearing in the file LICENSE.GPL included in the packaging of this
25
** file. Please review the following information to ensure the GNU General
26
** Public License version 3.0 requirements will be met:
27
** http://www.gnu.org/copyleft/gpl.html.
30
** Alternatively, this file may be used in accordance with the terms and
31
** conditions contained in a signed written agreement between you and Nokia.
40
****************************************************************************/
42
#ifndef QQUICKTEXTEDIT_P_H
43
#define QQUICKTEXTEDIT_P_H
45
#include "qquickimplicitsizeitem_p.h"
47
#include <QtGui/qtextoption.h>
53
class QQuickTextEditPrivate;
54
class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
61
Q_ENUMS(SelectionMode)
63
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
64
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
65
Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
66
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
67
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
68
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
69
Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
70
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
71
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
72
Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged)
73
Q_PROPERTY(int length READ length NOTIFY textChanged)
74
Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
75
Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
76
Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged) // Compatibility
77
Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
78
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
79
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
80
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
81
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
82
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
83
Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
84
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
85
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
86
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
87
Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
88
Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
89
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
90
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
91
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
92
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
93
Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
94
Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
95
Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
96
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
97
Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
100
QQuickTextEdit(QQuickItem *parent=0);
103
AlignLeft = Qt::AlignLeft,
104
AlignRight = Qt::AlignRight,
105
AlignHCenter = Qt::AlignHCenter,
106
AlignJustify = Qt::AlignJustify
110
AlignTop = Qt::AlignTop,
111
AlignBottom = Qt::AlignBottom,
112
AlignVCenter = Qt::AlignVCenter
116
PlainText = Qt::PlainText,
117
RichText = Qt::RichText,
118
AutoText = Qt::AutoText
121
enum WrapMode { NoWrap = QTextOption::NoWrap,
122
WordWrap = QTextOption::WordWrap,
123
WrapAnywhere = QTextOption::WrapAnywhere,
124
WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
125
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
133
Q_INVOKABLE void openSoftwareInputPanel();
134
Q_INVOKABLE void closeSoftwareInputPanel();
136
QString text() const;
137
void setText(const QString &);
139
TextFormat textFormat() const;
140
void setTextFormat(TextFormat format);
143
void setFont(const QFont &font);
145
QColor color() const;
146
void setColor(const QColor &c);
148
QColor selectionColor() const;
149
void setSelectionColor(const QColor &c);
151
QColor selectedTextColor() const;
152
void setSelectedTextColor(const QColor &c);
154
HAlignment hAlign() const;
155
void setHAlign(HAlignment align);
157
HAlignment effectiveHAlign() const;
159
VAlignment vAlign() const;
160
void setVAlign(VAlignment align);
162
WrapMode wrapMode() const;
163
void setWrapMode(WrapMode w);
165
int lineCount() const;
169
bool isCursorVisible() const;
170
void setCursorVisible(bool on);
172
int cursorPosition() const;
173
void setCursorPosition(int pos);
175
QQmlComponent* cursorDelegate() const;
176
void setCursorDelegate(QQmlComponent*);
178
int selectionStart() const;
179
int selectionEnd() const;
181
QString selectedText() const;
183
bool focusOnPress() const;
184
void setFocusOnPress(bool on);
186
bool persistentSelection() const;
187
void setPersistentSelection(bool on);
189
qreal textMargin() const;
190
void setTextMargin(qreal margin);
192
Qt::InputMethodHints inputMethodHints() const;
193
void setInputMethodHints(Qt::InputMethodHints hints);
195
bool selectByMouse() const;
196
void setSelectByMouse(bool);
198
SelectionMode mouseSelectionMode() const;
199
void setMouseSelectionMode(SelectionMode mode);
201
bool canPaste() const;
203
bool canUndo() const;
204
bool canRedo() const;
206
virtual void componentComplete();
209
void setReadOnly(bool);
210
bool isReadOnly() const;
212
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
213
Qt::TextInteractionFlags textInteractionFlags() const;
215
QRectF cursorRectangle() const;
217
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
219
qreal contentWidth() const;
220
qreal contentHeight() const;
222
QUrl baseUrl() const;
223
void setBaseUrl(const QUrl &url);
226
Q_INVOKABLE QRectF positionToRectangle(int) const;
227
Q_INVOKABLE int positionAt(qreal x, qreal y) const;
228
Q_INVOKABLE void moveCursorSelection(int pos);
229
Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
231
QRectF boundingRect() const;
233
bool isInputMethodComposing() const;
235
Q_INVOKABLE QString getText(int start, int end) const;
236
Q_INVOKABLE QString getFormattedText(int start, int end) const;
240
void contentSizeChanged();
241
void cursorPositionChanged();
242
void cursorRectangleChanged();
243
void selectionStartChanged();
244
void selectionEndChanged();
245
void selectionChanged();
246
void colorChanged(const QColor &color);
247
void selectionColorChanged(const QColor &color);
248
void selectedTextColorChanged(const QColor &color);
249
void fontChanged(const QFont &font);
250
void horizontalAlignmentChanged(HAlignment alignment);
251
void verticalAlignmentChanged(VAlignment alignment);
252
void wrapModeChanged();
253
void lineCountChanged();
254
void textFormatChanged(TextFormat textFormat);
255
void readOnlyChanged(bool isReadOnly);
256
void cursorVisibleChanged(bool isCursorVisible);
257
void cursorDelegateChanged();
258
void activeFocusOnPressChanged(bool activeFocusOnPressed);
259
void persistentSelectionChanged(bool isPersistentSelection);
260
void textMarginChanged(qreal textMargin);
261
void selectByMouseChanged(bool selectByMouse);
262
void mouseSelectionModeChanged(SelectionMode mode);
263
void linkActivated(const QString &link);
264
void canPasteChanged();
265
void canUndoChanged();
266
void canRedoChanged();
267
void inputMethodComposingChanged();
268
void effectiveHorizontalAlignmentChanged();
269
void baseUrlChanged();
270
void inputMethodHintsChanged();
275
void select(int start, int end);
277
bool isRightToLeft(int start, int end);
278
#ifndef QT_NO_CLIPBOARD
285
void insert(int position, const QString &text);
286
void remove(int start, int end);
289
void q_textChanged();
290
void updateSelectionMarkers();
291
void moveCursorDelegate();
292
void loadCursorDelegate();
293
void q_canPasteChanged();
294
void updateDocument();
296
void q_updateAlignment();
298
void triggerPreprocess();
301
void updateTotalLines();
304
virtual void geometryChanged(const QRectF &newGeometry,
305
const QRectF &oldGeometry);
307
bool event(QEvent *);
308
void keyPressEvent(QKeyEvent *);
309
void keyReleaseEvent(QKeyEvent *);
310
void focusInEvent(QFocusEvent *event);
313
void mousePressEvent(QMouseEvent *event);
314
void mouseReleaseEvent(QMouseEvent *event);
315
void mouseDoubleClickEvent(QMouseEvent *event);
316
void mouseMoveEvent(QMouseEvent *event);
317
void inputMethodEvent(QInputMethodEvent *e);
318
virtual void itemChange(ItemChange, const ItemChangeData &);
320
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
323
Q_DISABLE_COPY(QQuickTextEdit)
324
Q_DECLARE_PRIVATE(QQuickTextEdit)
329
QML_DECLARE_TYPE(QQuickTextEdit)
333
#endif // QQUICKTEXTEDIT_P_H