1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #ifndef QQUICKTEXTEDIT_P_P_H
43 #define QQUICKTEXTEDIT_P_P_H
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.
56 #include "qquicktextedit_p.h"
57 #include "qquickimplicitsizeitem_p_p.h"
58 #include "qquicktextcontrol_p.h"
60 #include <QtQml/qqml.h>
64 class QQuickTextDocumentWithImageResources;
65 class QQuickTextControl;
66 class QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate
69 Q_DECLARE_PUBLIC(QQuickTextEdit)
71 typedef QQuickTextEdit Public;
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)
90 static QQuickTextEditPrivate *get(QQuickTextEdit *item) {
91 return static_cast<QQuickTextEditPrivate *>(QObjectPrivate::get(item)); }
95 void updateDefaultTextOption();
96 void relayoutDocument();
97 bool determineHorizontalAlignment();
98 bool setHAlign(QQuickTextEdit::HAlignment, bool forceAlign = false);
100 qreal getImplicitWidth() const;
101 Qt::LayoutDirection textDirection(const QString &text) const;
103 void setNativeCursorEnabled(bool enabled) { control->setCursorWidth(enabled ? 1 : 0); }
106 QColor selectionColor;
107 QColor selectedTextColor;
120 QQmlComponent* cursorComponent;
121 QQuickItem* cursorItem;
122 QQuickTextDocumentWithImageResources *document;
123 QQuickTextControl *control;
125 int lastSelectionStart;
126 int lastSelectionEnd;
131 UpdateOnlyPreprocess,
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;
145 bool documentDirty : 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;
155 bool canPasteValid:1;
156 bool hAlignImplicit:1;
163 #endif // QQUICKTEXTEDIT_P_P_H