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 ** 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.
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 <QtDeclarative/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 QDeclarative1TextInputPrivate : public QDeclarative1ImplicitSizePaintedItemPrivate
71 Q_DECLARE_PUBLIC(QDeclarative1TextInput)
73 QDeclarative1TextInputPrivate() : control(new QLineControl),
74 color((QRgb)0), style(QDeclarative1Text::Normal),
75 styleColor((QRgb)0), hAlign(QDeclarative1TextInput::AlignLeft),
76 mouseSelectionMode(QDeclarative1TextInput::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;
89 ~QDeclarative1TextInputPrivate()
93 int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const
95 Q_Q(const QDeclarative1TextInput);
96 QRect cr = q->boundingRect().toRect();
98 return control->xToPos(x, betweenOrOn);
102 void startCreatingCursor();
103 void focusChanged(bool hasFocus);
104 void updateHorizontalScroll();
105 bool determineHorizontalAlignment();
106 bool setHAlign(QDeclarative1TextInput::HAlignment, bool forceAlign = false);
108 int calculateTextWidth();
109 bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
110 void updateInputMethodHints();
112 QLineControl* control;
117 QColor selectionColor;
118 QColor selectedTextColor;
119 QDeclarative1Text::TextStyle style;
121 QDeclarative1TextInput::HAlignment hAlign;
122 QDeclarative1TextInput::SelectionMode mouseSelectionMode;
123 Qt::InputMethodHints inputMethodHints;
124 QPointer<QDeclarativeComponent> cursorComponent;
125 QPointer<QDeclarativeItem> cursorItem;
128 int lastSelectionStart;
129 int lastSelectionEnd;
137 bool showInputPanelOnFocus:1;
138 bool clickCausedFocus:1;
139 bool cursorVisible:1;
141 bool selectByMouse:1;
143 bool hAlignImplicit:1;
144 bool selectPressed:1;
146 static inline QDeclarative1TextInputPrivate *get(QDeclarative1TextInput *t) {
153 #endif // QT_NO_LINEEDIT