2011-05-04 07:53:51 +00:00
|
|
|
// Commit: 2f173e4945dd8414636c1061acfaf9c2d8b718d8
|
2011-04-27 12:13:26 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2012-01-05 04:29:18 +00:00
|
|
|
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-04-27 12:13:26 +00:00
|
|
|
** All rights reserved.
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
**
|
|
|
|
** This file is part of the QtDeclarative module of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
** GNU Lesser General Public License Usage
|
2011-07-07 12:52:03 +00:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this
|
|
|
|
** file. Please review the following information to ensure the GNU Lesser
|
|
|
|
** General Public License version 2.1 requirements will be met:
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2011-04-27 12:13:26 +00:00
|
|
|
**
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-07-07 12:52:03 +00:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2011-04-27 12:13:26 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
2011-07-07 12:52:03 +00:00
|
|
|
** GNU General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU General
|
|
|
|
** Public License version 3.0 as published by the Free Software Foundation
|
|
|
|
** and appearing in the file LICENSE.GPL included in the packaging of this
|
|
|
|
** file. Please review the following information to ensure the GNU General
|
|
|
|
** Public License version 3.0 requirements will be met:
|
|
|
|
** http://www.gnu.org/copyleft/gpl.html.
|
2011-04-27 12:13:26 +00:00
|
|
|
**
|
2011-07-07 12:52:03 +00:00
|
|
|
** Other Usage
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
2011-04-27 12:13:26 +00:00
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
#ifndef QQUICKTEXTINPUT_P_H
|
|
|
|
#define QQUICKTEXTINPUT_P_H
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
#include "qquickimplicitsizeitem_p.h"
|
2011-12-15 01:36:54 +00:00
|
|
|
#include <QtGui/qtextoption.h>
|
2011-04-27 12:13:26 +00:00
|
|
|
#include <QtGui/qvalidator.h>
|
|
|
|
|
|
|
|
QT_BEGIN_HEADER
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
class QQuickTextInputPrivate;
|
2011-04-27 12:13:26 +00:00
|
|
|
class QValidator;
|
2011-10-14 08:51:42 +00:00
|
|
|
class Q_AUTOTEST_EXPORT QQuickTextInput : public QQuickImplicitSizeItem
|
2011-04-27 12:13:26 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_ENUMS(HAlignment)
|
2011-12-15 01:36:54 +00:00
|
|
|
Q_ENUMS(VAlignment)
|
|
|
|
Q_ENUMS(WrapMode)
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_ENUMS(EchoMode)
|
|
|
|
Q_ENUMS(SelectionMode)
|
2011-12-15 01:36:54 +00:00
|
|
|
Q_ENUMS(CursorPosition)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
2012-01-04 00:53:26 +00:00
|
|
|
Q_PROPERTY(int length READ length NOTIFY textChanged)
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
|
|
|
Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
|
|
|
|
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
|
|
|
|
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
|
|
|
|
Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
|
|
|
|
Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
|
2011-12-15 01:36:54 +00:00
|
|
|
Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
|
|
|
|
Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
|
|
|
|
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
|
|
|
|
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
|
2011-07-25 02:55:57 +00:00
|
|
|
Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
|
|
|
|
Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
|
|
|
|
Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
|
|
|
|
Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged)
|
|
|
|
#ifndef QT_NO_VALIDATOR
|
|
|
|
Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged)
|
|
|
|
#endif
|
|
|
|
Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged)
|
2011-05-04 07:53:51 +00:00
|
|
|
Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ imHints WRITE setIMHints)
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged)
|
|
|
|
Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged)
|
|
|
|
Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
|
|
|
|
Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged)
|
|
|
|
Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged)
|
|
|
|
Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged)
|
|
|
|
Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
|
|
|
|
Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
|
|
|
|
Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
|
|
|
|
Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
|
|
|
|
|
|
|
|
public:
|
2011-10-14 08:51:42 +00:00
|
|
|
QQuickTextInput(QQuickItem * parent=0);
|
|
|
|
~QQuickTextInput();
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2011-12-15 01:36:54 +00:00
|
|
|
void componentComplete();
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
enum EchoMode {//To match QLineEdit::EchoMode
|
|
|
|
Normal,
|
|
|
|
NoEcho,
|
|
|
|
Password,
|
|
|
|
PasswordEchoOnEdit
|
|
|
|
};
|
|
|
|
|
|
|
|
enum HAlignment {
|
|
|
|
AlignLeft = Qt::AlignLeft,
|
|
|
|
AlignRight = Qt::AlignRight,
|
|
|
|
AlignHCenter = Qt::AlignHCenter
|
|
|
|
};
|
|
|
|
|
2011-12-15 01:36:54 +00:00
|
|
|
enum VAlignment {
|
|
|
|
AlignTop = Qt::AlignTop,
|
|
|
|
AlignBottom = Qt::AlignBottom,
|
|
|
|
AlignVCenter = Qt::AlignVCenter
|
|
|
|
};
|
|
|
|
|
|
|
|
enum WrapMode {
|
|
|
|
NoWrap = QTextOption::NoWrap,
|
|
|
|
WordWrap = QTextOption::WordWrap,
|
|
|
|
WrapAnywhere = QTextOption::WrapAnywhere,
|
|
|
|
WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
|
|
|
|
Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
|
|
|
|
};
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
enum SelectionMode {
|
|
|
|
SelectCharacters,
|
|
|
|
SelectWords
|
|
|
|
};
|
|
|
|
|
|
|
|
enum CursorPosition {
|
|
|
|
CursorBetweenCharacters,
|
|
|
|
CursorOnCharacter
|
|
|
|
};
|
|
|
|
|
2011-12-15 01:36:54 +00:00
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
//Auxilliary functions needed to control the TextInput from QML
|
2011-12-15 01:36:54 +00:00
|
|
|
Q_INVOKABLE void positionAt(QDeclarativeV8Function *args) const;
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_INVOKABLE QRectF positionToRectangle(int pos) const;
|
|
|
|
Q_INVOKABLE void moveCursorSelection(int pos);
|
|
|
|
Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
|
|
|
|
|
|
|
|
Q_INVOKABLE void openSoftwareInputPanel();
|
|
|
|
Q_INVOKABLE void closeSoftwareInputPanel();
|
|
|
|
|
|
|
|
QString text() const;
|
|
|
|
void setText(const QString &);
|
|
|
|
|
2012-01-04 00:53:26 +00:00
|
|
|
int length() const;
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
QFont font() const;
|
|
|
|
void setFont(const QFont &font);
|
|
|
|
|
|
|
|
QColor color() const;
|
|
|
|
void setColor(const QColor &c);
|
|
|
|
|
|
|
|
QColor selectionColor() const;
|
|
|
|
void setSelectionColor(const QColor &c);
|
|
|
|
|
|
|
|
QColor selectedTextColor() const;
|
|
|
|
void setSelectedTextColor(const QColor &c);
|
|
|
|
|
|
|
|
HAlignment hAlign() const;
|
|
|
|
void setHAlign(HAlignment align);
|
|
|
|
void resetHAlign();
|
|
|
|
HAlignment effectiveHAlign() const;
|
|
|
|
|
2011-12-15 01:36:54 +00:00
|
|
|
VAlignment vAlign() const;
|
|
|
|
void setVAlign(VAlignment align);
|
|
|
|
|
|
|
|
WrapMode wrapMode() const;
|
|
|
|
void setWrapMode(WrapMode w);
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
bool isReadOnly() const;
|
|
|
|
void setReadOnly(bool);
|
|
|
|
|
|
|
|
bool isCursorVisible() const;
|
|
|
|
void setCursorVisible(bool on);
|
|
|
|
|
|
|
|
int cursorPosition() const;
|
|
|
|
void setCursorPosition(int cp);
|
|
|
|
|
|
|
|
QRect cursorRectangle() const;
|
|
|
|
|
|
|
|
int selectionStart() const;
|
|
|
|
int selectionEnd() const;
|
|
|
|
|
|
|
|
QString selectedText() const;
|
|
|
|
|
|
|
|
int maxLength() const;
|
|
|
|
void setMaxLength(int ml);
|
|
|
|
|
|
|
|
#ifndef QT_NO_VALIDATOR
|
|
|
|
QValidator * validator() const;
|
|
|
|
void setValidator(QValidator* v);
|
|
|
|
#endif
|
|
|
|
QString inputMask() const;
|
|
|
|
void setInputMask(const QString &im);
|
|
|
|
|
|
|
|
EchoMode echoMode() const;
|
|
|
|
void setEchoMode(EchoMode echo);
|
|
|
|
|
|
|
|
QString passwordCharacter() const;
|
|
|
|
void setPasswordCharacter(const QString &str);
|
|
|
|
|
|
|
|
QString displayText() const;
|
|
|
|
|
|
|
|
QDeclarativeComponent* cursorDelegate() const;
|
|
|
|
void setCursorDelegate(QDeclarativeComponent*);
|
|
|
|
|
|
|
|
bool focusOnPress() const;
|
|
|
|
void setFocusOnPress(bool);
|
|
|
|
|
|
|
|
bool autoScroll() const;
|
|
|
|
void setAutoScroll(bool);
|
|
|
|
|
|
|
|
bool selectByMouse() const;
|
|
|
|
void setSelectByMouse(bool);
|
|
|
|
|
|
|
|
SelectionMode mouseSelectionMode() const;
|
|
|
|
void setMouseSelectionMode(SelectionMode mode);
|
|
|
|
|
|
|
|
bool hasAcceptableInput() const;
|
|
|
|
|
|
|
|
QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
|
|
|
|
|
|
|
|
QRectF boundingRect() const;
|
|
|
|
bool canPaste() const;
|
|
|
|
|
|
|
|
bool isInputMethodComposing() const;
|
|
|
|
|
2011-05-04 07:53:51 +00:00
|
|
|
Qt::InputMethodHints imHints() const;
|
|
|
|
void setIMHints(Qt::InputMethodHints hints);
|
|
|
|
|
2012-01-04 00:53:26 +00:00
|
|
|
Q_INVOKABLE QString getText(int start, int end) const;
|
|
|
|
|
2011-04-27 12:13:26 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void textChanged();
|
|
|
|
void cursorPositionChanged();
|
2011-07-25 02:55:57 +00:00
|
|
|
void cursorRectangleChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void selectionStartChanged();
|
|
|
|
void selectionEndChanged();
|
|
|
|
void selectedTextChanged();
|
|
|
|
void accepted();
|
|
|
|
void acceptableInputChanged();
|
|
|
|
void colorChanged(const QColor &color);
|
|
|
|
void selectionColorChanged(const QColor &color);
|
|
|
|
void selectedTextColorChanged(const QColor &color);
|
|
|
|
void fontChanged(const QFont &font);
|
|
|
|
void horizontalAlignmentChanged(HAlignment alignment);
|
2011-12-15 01:36:54 +00:00
|
|
|
void verticalAlignmentChanged(VAlignment alignment);
|
|
|
|
void wrapModeChanged();
|
2011-04-27 12:13:26 +00:00
|
|
|
void readOnlyChanged(bool isReadOnly);
|
|
|
|
void cursorVisibleChanged(bool isCursorVisible);
|
|
|
|
void cursorDelegateChanged();
|
|
|
|
void maximumLengthChanged(int maximumLength);
|
|
|
|
void validatorChanged();
|
|
|
|
void inputMaskChanged(const QString &inputMask);
|
|
|
|
void echoModeChanged(EchoMode echoMode);
|
|
|
|
void passwordCharacterChanged();
|
|
|
|
void displayTextChanged();
|
|
|
|
void activeFocusOnPressChanged(bool activeFocusOnPress);
|
|
|
|
void autoScrollChanged(bool autoScroll);
|
|
|
|
void selectByMouseChanged(bool selectByMouse);
|
|
|
|
void mouseSelectionModeChanged(SelectionMode mode);
|
|
|
|
void canPasteChanged();
|
|
|
|
void inputMethodComposingChanged();
|
|
|
|
void effectiveHorizontalAlignmentChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void geometryChanged(const QRectF &newGeometry,
|
|
|
|
const QRectF &oldGeometry);
|
|
|
|
|
2011-08-30 14:48:57 +00:00
|
|
|
void mousePressEvent(QMouseEvent *event);
|
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event);
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
2011-04-27 12:13:26 +00:00
|
|
|
void keyPressEvent(QKeyEvent* ev);
|
|
|
|
void inputMethodEvent(QInputMethodEvent *);
|
|
|
|
void mouseUngrabEvent();
|
|
|
|
bool event(QEvent *e);
|
|
|
|
void focusInEvent(QFocusEvent *event);
|
2011-11-11 03:47:59 +00:00
|
|
|
void timerEvent(QTimerEvent *event);
|
2011-04-27 12:13:26 +00:00
|
|
|
virtual void itemChange(ItemChange, const ItemChangeData &);
|
2011-06-01 07:45:55 +00:00
|
|
|
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data);
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void selectAll();
|
|
|
|
void selectWord();
|
|
|
|
void select(int start, int end);
|
|
|
|
void deselect();
|
|
|
|
bool isRightToLeft(int start, int end);
|
|
|
|
#ifndef QT_NO_CLIPBOARD
|
|
|
|
void cut();
|
|
|
|
void copy();
|
|
|
|
void paste();
|
|
|
|
#endif
|
2012-01-04 00:53:26 +00:00
|
|
|
void insert(int position, const QString &text);
|
|
|
|
void remove(int start, int end);
|
2011-04-27 12:13:26 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void selectionChanged();
|
|
|
|
void createCursor();
|
2011-07-25 02:55:57 +00:00
|
|
|
void updateCursorRectangle();
|
2011-04-27 12:13:26 +00:00
|
|
|
void q_canPasteChanged();
|
|
|
|
|
|
|
|
private:
|
2011-10-14 08:51:42 +00:00
|
|
|
Q_DECLARE_PRIVATE(QQuickTextInput)
|
2011-04-27 12:13:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
QML_DECLARE_TYPE(QQuickTextInput)
|
2011-04-27 12:13:26 +00:00
|
|
|
#ifndef QT_NO_VALIDATOR
|
|
|
|
QML_DECLARE_TYPE(QValidator)
|
|
|
|
QML_DECLARE_TYPE(QIntValidator)
|
|
|
|
QML_DECLARE_TYPE(QDoubleValidator)
|
|
|
|
QML_DECLARE_TYPE(QRegExpValidator)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QT_END_HEADER
|
|
|
|
|
2011-10-14 08:51:42 +00:00
|
|
|
#endif // QQUICKTEXTINPUT_P_H
|