05c99fe994b545cf70a53a75c87fba0b8d832787
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativetextinput_p_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
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/qwidgetlinecontrol_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 QWidgetLineControl),
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     }
83
84     ~QDeclarative1TextInputPrivate()
85     {
86     }
87
88     int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const
89     {
90         Q_Q(const QDeclarative1TextInput);
91         QRect cr = q->boundingRect().toRect();
92         x-= cr.x() - hscroll;
93         return control->xToPos(x, betweenOrOn);
94     }
95
96     void init();
97     void startCreatingCursor();
98     void focusChanged(bool hasFocus);
99     void updateHorizontalScroll();
100     bool determineHorizontalAlignment();
101     bool setHAlign(QDeclarative1TextInput::HAlignment, bool forceAlign = false);
102     void mirrorChange();
103     int calculateTextWidth();
104     bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType);
105     void updateInputMethodHints();
106
107     QWidgetLineControl* control;
108
109     QFont font;
110     QFont sourceFont;
111     QColor  color;
112     QColor  selectionColor;
113     QColor  selectedTextColor;
114     QDeclarative1Text::TextStyle style;
115     QColor  styleColor;
116     QDeclarative1TextInput::HAlignment hAlign;
117     QDeclarative1TextInput::SelectionMode mouseSelectionMode;
118     Qt::InputMethodHints inputMethodHints;
119     QPointer<QDeclarativeComponent> cursorComponent;
120     QPointer<QDeclarativeItem> cursorItem;
121     QPointF pressPos;
122
123     int lastSelectionStart;
124     int lastSelectionEnd;
125     int oldHeight;
126     int oldWidth;
127     int hscroll;
128     int oldScroll;
129     bool oldValidity:1;
130     bool focused:1;
131     bool focusOnPress:1;
132     bool showInputPanelOnFocus:1;
133     bool clickCausedFocus:1;
134     bool cursorVisible:1;
135     bool autoScroll:1;
136     bool selectByMouse:1;
137     bool canPaste:1;
138     bool hAlignImplicit:1;
139     bool selectPressed:1;
140
141     static inline QDeclarative1TextInputPrivate *get(QDeclarative1TextInput *t) {
142         return t->d_func();
143     }
144 };
145
146 QT_END_NAMESPACE
147
148 #endif // QT_NO_LINEEDIT
149
150 #endif
151