1 // Commit: 27e4302b7f45f22180693d26747f419177c81e27
2 /****************************************************************************
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
41 ****************************************************************************/
43 #ifndef QSGTEXTINPUT_P_P_H
44 #define QSGTEXTINPUT_P_P_H
46 #include "qsgtextinput_p.h"
47 #include "qsgtext_p.h"
48 #include "qsgimplicitsizeitem_p_p.h"
50 #include <private/qlinecontrol_p.h>
52 #include <QtDeclarative/qdeclarative.h>
53 #include <QtCore/qpointer.h>
60 // This file is not part of the Qt API. It exists purely as an
61 // implementation detail. This header file may change from version to
62 // version without notice, or even be removed.
68 class Q_AUTOTEST_EXPORT QSGTextInputPrivate : public QSGImplicitSizePaintedItemPrivate
70 Q_DECLARE_PUBLIC(QSGTextInput)
72 QSGTextInputPrivate() : control(new QLineControl(QString())),
73 color((QRgb)0), style(QSGText::Normal),
74 styleColor((QRgb)0), hAlign(QSGTextInput::AlignLeft),
75 mouseSelectionMode(QSGTextInput::SelectCharacters),
76 hscroll(0), oldScroll(0), oldValidity(false), focused(false), focusOnPress(true),
77 showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false),
78 autoScroll(true), selectByMouse(false), canPaste(false), hAlignImplicit(true)
81 if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
82 showInputPanelOnFocus = false;
88 ~QSGTextInputPrivate()
93 int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const
95 Q_Q(const QSGTextInput);
96 QRect cr = q->boundingRect().toRect();
98 return control->xToPos(x, betweenOrOn);
102 void startCreatingCursor();
103 void updateHorizontalScroll();
104 bool determineHorizontalAlignment();
105 bool setHAlign(QSGTextInput::HAlignment, bool forceAlign = false);
107 int calculateTextWidth();
108 bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
110 QLineControl* control;
115 QColor selectionColor;
116 QColor selectedTextColor;
117 QSGText::TextStyle style;
119 QSGTextInput::HAlignment hAlign;
120 QSGTextInput::SelectionMode mouseSelectionMode;
121 QPointer<QDeclarativeComponent> cursorComponent;
122 QPointer<QSGItem> cursorItem;
125 int lastSelectionStart;
126 int lastSelectionEnd;
135 bool showInputPanelOnFocus:1;
136 bool clickCausedFocus:1;
137 bool cursorVisible:1;
139 bool selectByMouse:1;
141 bool hAlignImplicit:1;
143 static inline QSGTextInputPrivate *get(QSGTextInput *t) {
150 #endif // QSGTEXTINPUT_P_P_H