1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
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.
|
---|
23 | **
|
---|
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.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QDECLARATIVETEXTINPUT_P_H
|
---|
43 | #define QDECLARATIVETEXTINPUT_P_H
|
---|
44 |
|
---|
45 | #include "private/qdeclarativetextinput_p.h"
|
---|
46 |
|
---|
47 | #include "private/qdeclarativepainteditem_p_p.h"
|
---|
48 |
|
---|
49 | #include <qdeclarative.h>
|
---|
50 |
|
---|
51 | #include <QPointer>
|
---|
52 |
|
---|
53 | #include <private/qlinecontrol_p.h>
|
---|
54 |
|
---|
55 | //
|
---|
56 | // W A R N I N G
|
---|
57 | // -------------
|
---|
58 | //
|
---|
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.
|
---|
62 | //
|
---|
63 | // We mean it.
|
---|
64 |
|
---|
65 | #ifndef QT_NO_LINEEDIT
|
---|
66 |
|
---|
67 | QT_BEGIN_NAMESPACE
|
---|
68 |
|
---|
69 | class QDeclarativeTextInputPrivate : public QDeclarativePaintedItemPrivate
|
---|
70 | {
|
---|
71 | Q_DECLARE_PUBLIC(QDeclarativeTextInput)
|
---|
72 | public:
|
---|
73 | QDeclarativeTextInputPrivate() : control(new QLineControl(QString())),
|
---|
74 | color((QRgb)0), style(QDeclarativeText::Normal),
|
---|
75 | styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft),
|
---|
76 | hscroll(0), oldScroll(0), focused(false), focusOnPress(true),
|
---|
77 | showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false),
|
---|
78 | autoScroll(true), selectByMouse(false)
|
---|
79 | {
|
---|
80 | #ifdef Q_OS_SYMBIAN
|
---|
81 | if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
|
---|
82 | showInputPanelOnFocus = false;
|
---|
83 | }
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | }
|
---|
87 |
|
---|
88 | ~QDeclarativeTextInputPrivate()
|
---|
89 | {
|
---|
90 | delete control;
|
---|
91 | }
|
---|
92 |
|
---|
93 | int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const
|
---|
94 | {
|
---|
95 | Q_Q(const QDeclarativeTextInput);
|
---|
96 | QRect cr = q->boundingRect().toRect();
|
---|
97 | x-= cr.x() - hscroll;
|
---|
98 | return control->xToPos(x, betweenOrOn);
|
---|
99 | }
|
---|
100 |
|
---|
101 | void init();
|
---|
102 | void startCreatingCursor();
|
---|
103 | void focusChanged(bool hasFocus);
|
---|
104 | void updateHorizontalScroll();
|
---|
105 | int calculateTextWidth();
|
---|
106 |
|
---|
107 | QLineControl* control;
|
---|
108 |
|
---|
109 | QFont font;
|
---|
110 | QFont sourceFont;
|
---|
111 | QColor color;
|
---|
112 | QColor selectionColor;
|
---|
113 | QColor selectedTextColor;
|
---|
114 | QDeclarativeText::TextStyle style;
|
---|
115 | QColor styleColor;
|
---|
116 | QDeclarativeTextInput::HAlignment hAlign;
|
---|
117 | QPointer<QDeclarativeComponent> cursorComponent;
|
---|
118 | QPointer<QDeclarativeItem> cursorItem;
|
---|
119 |
|
---|
120 | int lastSelectionStart;
|
---|
121 | int lastSelectionEnd;
|
---|
122 | int oldHeight;
|
---|
123 | int oldWidth;
|
---|
124 | bool oldValidity;
|
---|
125 | int hscroll;
|
---|
126 | int oldScroll;
|
---|
127 | bool focused;
|
---|
128 | bool focusOnPress;
|
---|
129 | bool showInputPanelOnFocus;
|
---|
130 | bool clickCausedFocus;
|
---|
131 | bool cursorVisible;
|
---|
132 | bool autoScroll;
|
---|
133 | bool selectByMouse;
|
---|
134 | };
|
---|
135 |
|
---|
136 | QT_END_NAMESPACE
|
---|
137 |
|
---|
138 | #endif // QT_NO_LINEEDIT
|
---|
139 |
|
---|
140 | #endif
|
---|
141 |
|
---|