1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVETEXTINPUT_P_H
43 #define QDECLARATIVETEXTINPUT_P_H
45 #include "private/qdeclarativetextinput_p.h"
47 #include "private/qdeclarativeimplicitsizeitem_p_p.h"
49 #include <qdeclarative.h>
53 #include <private/qlinecontrol_p.h>
59 // This file is not part of the Qt API. It exists purely as an
60 // implementation detail. This header file may change from version to
61 // version without notice, or even be removed.
65 #ifndef QT_NO_LINEEDIT
69 class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplicitSizePaintedItemPrivate
71 Q_DECLARE_PUBLIC(QDeclarativeTextInput)
73 QDeclarativeTextInputPrivate() : control(new QLineControl(QString())),
74 color((QRgb)0), style(QDeclarativeText::Normal),
75 styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
76 mouseSelectionMode(QDeclarativeTextInput::SelectCharacters), inputMethodHints(Qt::ImhNone),
77 hscroll(0), oldScroll(0), oldValidity(false), focused(false), focusOnPress(true),
78 showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false),
79 autoScroll(true), selectByMouse(false), canPaste(false), hAlignImplicit(true),
83 if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
84 showInputPanelOnFocus = false;
90 ~QDeclarativeTextInputPrivate()
95 int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const
97 Q_Q(const QDeclarativeTextInput);
98 QRect cr = q->boundingRect().toRect();
100 return control->xToPos(x, betweenOrOn);
104 void startCreatingCursor();
105 void focusChanged(bool hasFocus);
106 void updateHorizontalScroll();
107 bool determineHorizontalAlignment();
108 bool setHAlign(QDeclarativeTextInput::HAlignment, bool forceAlign = false);
110 int calculateTextWidth();
111 bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
112 void updateInputMethodHints();
114 QLineControl* control;
119 QColor selectionColor;
120 QColor selectedTextColor;
121 QDeclarativeText::TextStyle style;
123 QDeclarativeTextInput::HAlignment hAlign;
124 QDeclarativeTextInput::SelectionMode mouseSelectionMode;
125 Qt::InputMethodHints inputMethodHints;
126 QPointer<QDeclarativeComponent> cursorComponent;
127 QPointer<QDeclarativeItem> cursorItem;
130 int lastSelectionStart;
131 int lastSelectionEnd;
139 bool showInputPanelOnFocus:1;
140 bool clickCausedFocus:1;
141 bool cursorVisible:1;
143 bool selectByMouse:1;
145 bool hAlignImplicit:1;
146 bool selectPressed:1;
148 static inline QDeclarativeTextInputPrivate *get(QDeclarativeTextInput *t) {
155 #endif // QT_NO_LINEEDIT