c02e34c166abf0bc245d12133af56bbb4b631a71
[profile/ivi/qtdeclarative.git] / src / quick / items / qquicktextedit_p_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQUICKTEXTEDIT_P_P_H
43 #define QQUICKTEXTEDIT_P_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include "qquicktextedit_p.h"
57 #include "qquickimplicitsizeitem_p_p.h"
58 #include "qquicktextcontrol_p.h"
59
60 #include <QtQml/qqml.h>
61
62 QT_BEGIN_NAMESPACE
63 class QTextLayout;
64 class QQuickTextDocumentWithImageResources;
65 class QQuickTextControl;
66 class QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
67 {
68 public:
69     Q_DECLARE_PUBLIC(QQuickTextEdit)
70
71     typedef QQuickTextEdit Public;
72
73     QQuickTextEditPrivate()
74         : color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
75         , textMargin(0.0), xoff(0), yoff(0), font(sourceFont), cursorComponent(0), cursorItem(0), document(0), control(0)
76         , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
77         , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
78         , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
79         , renderType(QQuickTextEdit::QtRendering)
80         , contentDirection(Qt::LayoutDirectionAuto)
81         , mouseSelectionMode(QQuickTextEdit::SelectCharacters), inputMethodHints(Qt::ImhNone)
82         , updateType(UpdatePaintNode)
83         , documentDirty(true), dirty(false), richText(false), cursorVisible(false), cursorPending(false)
84         , focusOnPress(true), persistentSelection(false), requireImplicitWidth(false)
85         , selectByMouse(false), canPaste(false), canPasteValid(false), hAlignImplicit(true)
86         , textCached(true), inLayout(false)
87     {
88     }
89
90     static QQuickTextEditPrivate *get(QQuickTextEdit *item) {
91         return static_cast<QQuickTextEditPrivate *>(QObjectPrivate::get(item)); }
92
93     void init();
94
95     void updateDefaultTextOption();
96     void relayoutDocument();
97     bool determineHorizontalAlignment();
98     bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false);
99     void mirrorChange();
100     qreal getImplicitWidth() const;
101     Qt::LayoutDirection textDirection(const QString &text) const;
102
103     void setNativeCursorEnabled(bool enabled) { control->setCursorWidth(enabled ? 1 : 0); }
104
105     QColor color;
106     QColor selectionColor;
107     QColor selectedTextColor;
108
109     QSizeF contentSize;
110
111     qreal textMargin;
112     qreal xoff;
113     qreal yoff;
114
115     QString text;
116     QUrl baseUrl;
117     QFont sourceFont;
118     QFont font;
119
120     QQmlComponent* cursorComponent;
121     QQuickItem* cursorItem;
122     QQuickTextDocumentWithImageResources *document;
123     QQuickTextControl *control;
124
125     int lastSelectionStart;
126     int lastSelectionEnd;
127     int lineCount;
128
129     enum UpdateType {
130         UpdateNone,
131         UpdateOnlyPreprocess,
132         UpdatePaintNode
133     };
134
135     QQuickTextEdit::HAlignment hAlign;
136     QQuickTextEdit::VAlignment vAlign;
137     QQuickTextEdit::TextFormat format;
138     QQuickTextEdit::WrapMode wrapMode;
139     QQuickTextEdit::RenderType renderType;
140     Qt::LayoutDirection contentDirection;
141     QQuickTextEdit::SelectionMode mouseSelectionMode;
142     Qt::InputMethodHints inputMethodHints;
143     UpdateType updateType;
144
145     bool documentDirty : 1;
146     bool dirty : 1;
147     bool richText : 1;
148     bool cursorVisible : 1;
149     bool cursorPending : 1;
150     bool focusOnPress : 1;
151     bool persistentSelection : 1;
152     bool requireImplicitWidth:1;
153     bool selectByMouse:1;
154     bool canPaste:1;
155     bool canPasteValid:1;
156     bool hAlignImplicit:1;
157     bool textCached:1;
158     bool inLayout:1;
159 };
160
161 QT_END_NAMESPACE
162
163 #endif // QQUICKTEXTEDIT_P_P_H