1 // Commit: 27e4302b7f45f22180693d26747f419177c81e27
2 /****************************************************************************
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
41 ****************************************************************************/
43 #ifndef QQUICKTEXTEDIT_P_H
44 #define QQUICKTEXTEDIT_P_H
46 #include "qquickimplicitsizeitem_p.h"
48 #include <QtGui/qtextoption.h>
54 class QQuickTextEditPrivate;
55 class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
62 Q_ENUMS(SelectionMode)
64 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
65 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
66 Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
67 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
68 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
69 Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
70 Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
71 Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
72 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
73 Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged)
74 Q_PROPERTY(int length READ length NOTIFY textChanged)
75 Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
76 Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
77 Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
78 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
79 Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
80 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
81 Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
82 Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
83 Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
84 Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
85 Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
86 Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
87 Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
88 Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
89 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
90 Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
91 Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
92 Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
93 Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
94 Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
95 Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
96 Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
99 QQuickTextEdit(QQuickItem *parent=0);
102 AlignLeft = Qt::AlignLeft,
103 AlignRight = Qt::AlignRight,
104 AlignHCenter = Qt::AlignHCenter,
105 AlignJustify = Qt::AlignJustify
109 AlignTop = Qt::AlignTop,
110 AlignBottom = Qt::AlignBottom,
111 AlignVCenter = Qt::AlignVCenter
115 PlainText = Qt::PlainText,
116 RichText = Qt::RichText,
117 AutoText = Qt::AutoText
120 enum WrapMode { NoWrap = QTextOption::NoWrap,
121 WordWrap = QTextOption::WordWrap,
122 WrapAnywhere = QTextOption::WrapAnywhere,
123 WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
124 Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
132 Q_INVOKABLE void openSoftwareInputPanel();
133 Q_INVOKABLE void closeSoftwareInputPanel();
135 QString text() const;
136 void setText(const QString &);
138 TextFormat textFormat() const;
139 void setTextFormat(TextFormat format);
142 void setFont(const QFont &font);
144 QColor color() const;
145 void setColor(const QColor &c);
147 QColor selectionColor() const;
148 void setSelectionColor(const QColor &c);
150 QColor selectedTextColor() const;
151 void setSelectedTextColor(const QColor &c);
153 HAlignment hAlign() const;
154 void setHAlign(HAlignment align);
156 HAlignment effectiveHAlign() const;
158 VAlignment vAlign() const;
159 void setVAlign(VAlignment align);
161 WrapMode wrapMode() const;
162 void setWrapMode(WrapMode w);
164 int lineCount() const;
168 bool isCursorVisible() const;
169 void setCursorVisible(bool on);
171 int cursorPosition() const;
172 void setCursorPosition(int pos);
174 QDeclarativeComponent* cursorDelegate() const;
175 void setCursorDelegate(QDeclarativeComponent*);
177 int selectionStart() const;
178 int selectionEnd() const;
180 QString selectedText() const;
182 bool focusOnPress() const;
183 void setFocusOnPress(bool on);
185 bool persistentSelection() const;
186 void setPersistentSelection(bool on);
188 qreal textMargin() const;
189 void setTextMargin(qreal margin);
191 bool selectByMouse() const;
192 void setSelectByMouse(bool);
194 SelectionMode mouseSelectionMode() const;
195 void setMouseSelectionMode(SelectionMode mode);
197 bool canPaste() const;
199 bool canUndo() const;
200 bool canRedo() const;
202 virtual void componentComplete();
205 void setReadOnly(bool);
206 bool isReadOnly() const;
208 void setTextInteractionFlags(Qt::TextInteractionFlags flags);
209 Qt::TextInteractionFlags textInteractionFlags() const;
211 QRect cursorRectangle() const;
213 QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
215 qreal paintedWidth() const;
216 qreal paintedHeight() const;
218 QUrl baseUrl() const;
219 void setBaseUrl(const QUrl &url);
222 Q_INVOKABLE QRectF positionToRectangle(int) const;
223 Q_INVOKABLE int positionAt(int x, int y) const;
224 Q_INVOKABLE void moveCursorSelection(int pos);
225 Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
227 QRectF boundingRect() const;
229 bool isInputMethodComposing() const;
231 Q_INVOKABLE QString getText(int start, int end) const;
232 Q_INVOKABLE QString getFormattedText(int start, int end) const;
236 void paintedSizeChanged();
237 void cursorPositionChanged();
238 void cursorRectangleChanged();
239 void selectionStartChanged();
240 void selectionEndChanged();
241 void selectionChanged();
242 void colorChanged(const QColor &color);
243 void selectionColorChanged(const QColor &color);
244 void selectedTextColorChanged(const QColor &color);
245 void fontChanged(const QFont &font);
246 void horizontalAlignmentChanged(HAlignment alignment);
247 void verticalAlignmentChanged(VAlignment alignment);
248 void wrapModeChanged();
249 void lineCountChanged();
250 void textFormatChanged(TextFormat textFormat);
251 void readOnlyChanged(bool isReadOnly);
252 void cursorVisibleChanged(bool isCursorVisible);
253 void cursorDelegateChanged();
254 void activeFocusOnPressChanged(bool activeFocusOnPressed);
255 void persistentSelectionChanged(bool isPersistentSelection);
256 void textMarginChanged(qreal textMargin);
257 void selectByMouseChanged(bool selectByMouse);
258 void mouseSelectionModeChanged(SelectionMode mode);
259 void linkActivated(const QString &link);
260 void canPasteChanged();
261 void canUndoChanged();
262 void canRedoChanged();
263 void inputMethodComposingChanged();
264 void effectiveHorizontalAlignmentChanged();
265 void baseUrlChanged();
270 void select(int start, int end);
272 bool isRightToLeft(int start, int end);
273 #ifndef QT_NO_CLIPBOARD
280 void insert(int position, const QString &text);
281 void remove(int start, int end);
284 void q_textChanged();
285 void updateSelectionMarkers();
286 void moveCursorDelegate();
287 void loadCursorDelegate();
288 void q_canPasteChanged();
289 void updateDocument();
291 void q_updateAlignment();
293 void triggerPreprocess();
296 void updateTotalLines();
297 void updateImageCache(const QRectF &rect = QRectF());
300 virtual void geometryChanged(const QRectF &newGeometry,
301 const QRectF &oldGeometry);
303 bool event(QEvent *);
304 void keyPressEvent(QKeyEvent *);
305 void keyReleaseEvent(QKeyEvent *);
306 void focusInEvent(QFocusEvent *event);
309 void mousePressEvent(QMouseEvent *event);
310 void mouseReleaseEvent(QMouseEvent *event);
311 void mouseDoubleClickEvent(QMouseEvent *event);
312 void mouseMoveEvent(QMouseEvent *event);
313 void inputMethodEvent(QInputMethodEvent *e);
314 virtual void itemChange(ItemChange, const ItemChangeData &);
316 QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
319 Q_DISABLE_COPY(QQuickTextEdit)
320 Q_DECLARE_PRIVATE(QQuickTextEdit)
325 QML_DECLARE_TYPE(QQuickTextEdit)
329 #endif // QQUICKTEXTEDIT_P_H