Extract all QtQuick 1 elements into a separate library/plugin.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativetextinput_p_p.h
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 ** 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.
17 **
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.
21 **
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.
29 **
30 ** Other Usage
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.
33 **
34 **
35 **
36 **
37 **
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/qdeclarativeimplicitsizeitem_p_p.h"
48
49 #include <QtDeclarative/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 Q_AUTOTEST_EXPORT QDeclarative1TextInputPrivate : public QDeclarative1ImplicitSizePaintedItemPrivate
70 {
71     Q_DECLARE_PUBLIC(QDeclarative1TextInput)
72 public:
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),
80                  selectPressed(false)
81     {
82 #ifdef Q_OS_SYMBIAN
83         if (QSysInfo::symbianVersion() == QSysInfo::SV_SF_1 || QSysInfo::symbianVersion() == QSysInfo::SV_SF_3) {
84             showInputPanelOnFocus = false;
85         }
86 #endif
87     }
88
89     ~QDeclarative1TextInputPrivate()
90     {
91     }
92
93     int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const
94     {
95         Q_Q(const QDeclarative1TextInput);
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     bool determineHorizontalAlignment();
106     bool setHAlign(QDeclarative1TextInput::HAlignment, bool forceAlign = false);
107     void mirrorChange();
108     int calculateTextWidth();
109     bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
110     void updateInputMethodHints();
111
112     QLineControl* control;
113
114     QFont font;
115     QFont sourceFont;
116     QColor  color;
117     QColor  selectionColor;
118     QColor  selectedTextColor;
119     QDeclarative1Text::TextStyle style;
120     QColor  styleColor;
121     QDeclarative1TextInput::HAlignment hAlign;
122     QDeclarative1TextInput::SelectionMode mouseSelectionMode;
123     Qt::InputMethodHints inputMethodHints;
124     QPointer<QDeclarativeComponent> cursorComponent;
125     QPointer<QDeclarativeItem> cursorItem;
126     QPointF pressPos;
127
128     int lastSelectionStart;
129     int lastSelectionEnd;
130     int oldHeight;
131     int oldWidth;
132     int hscroll;
133     int oldScroll;
134     bool oldValidity:1;
135     bool focused:1;
136     bool focusOnPress:1;
137     bool showInputPanelOnFocus:1;
138     bool clickCausedFocus:1;
139     bool cursorVisible:1;
140     bool autoScroll:1;
141     bool selectByMouse:1;
142     bool canPaste:1;
143     bool hAlignImplicit:1;
144     bool selectPressed:1;
145
146     static inline QDeclarative1TextInputPrivate *get(QDeclarative1TextInput *t) {
147         return t->d_func();
148     }
149 };
150
151 QT_END_NAMESPACE
152
153 #endif // QT_NO_LINEEDIT
154
155 #endif
156