author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 16 Apr 2010 15:50:13 +0300 | |
changeset 18 | 2f34d5167611 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QPLAINTEXTEDIT_P_H |
|
43 |
#define QPLAINTEXTEDIT_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 "private/qabstractscrollarea_p.h" |
|
57 |
#include "QtGui/qtextdocumentfragment.h" |
|
58 |
#include "QtGui/qscrollbar.h" |
|
59 |
#include "QtGui/qtextcursor.h" |
|
60 |
#include "QtGui/qtextformat.h" |
|
61 |
#include "QtGui/qmenu.h" |
|
62 |
#include "QtGui/qabstracttextdocumentlayout.h" |
|
63 |
#include "QtCore/qbasictimer.h" |
|
64 |
#include "private/qtextcontrol_p.h" |
|
65 |
#include "qplaintextedit.h" |
|
66 |
||
67 |
#ifndef QT_NO_TEXTEDIT |
|
68 |
||
69 |
QT_BEGIN_NAMESPACE |
|
70 |
||
71 |
class QMimeData; |
|
72 |
||
73 |
class QPlainTextEdit; |
|
74 |
class ExtraArea; |
|
75 |
||
76 |
class QPlainTextEditControl : public QTextControl |
|
77 |
{ |
|
78 |
Q_OBJECT |
|
79 |
public: |
|
80 |
QPlainTextEditControl(QPlainTextEdit *parent); |
|
81 |
||
82 |
||
83 |
QMimeData *createMimeDataFromSelection() const; |
|
84 |
bool canInsertFromMimeData(const QMimeData *source) const; |
|
85 |
void insertFromMimeData(const QMimeData *source); |
|
86 |
int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const; |
|
87 |
QRectF blockBoundingRect(const QTextBlock &block) const; |
|
88 |
inline QRectF cursorRect(const QTextCursor &cursor) const { |
|
89 |
QRectF r = QTextControl::cursorRect(cursor); |
|
90 |
r.setLeft(qMax(r.left(), (qreal) 0.)); |
|
91 |
return r; |
|
92 |
} |
|
93 |
inline QRectF cursorRect() { return cursorRect(textCursor()); } |
|
94 |
void ensureCursorVisible() { |
|
95 |
textEdit->ensureCursorVisible(); |
|
96 |
emit microFocusChanged(); |
|
97 |
} |
|
98 |
||
99 |
||
100 |
QPlainTextEdit *textEdit; |
|
101 |
int topBlock; |
|
102 |
QTextBlock firstVisibleBlock() const; |
|
103 |
||
104 |
QVariant loadResource(int type, const QUrl &name) { |
|
105 |
return textEdit->loadResource(type, name); |
|
106 |
} |
|
107 |
||
108 |
}; |
|
109 |
||
110 |
||
111 |
class QPlainTextEditPrivate : public QAbstractScrollAreaPrivate |
|
112 |
{ |
|
113 |
Q_DECLARE_PUBLIC(QPlainTextEdit) |
|
114 |
public: |
|
115 |
QPlainTextEditPrivate(); |
|
116 |
||
117 |
void init(const QString &txt = QString()); |
|
118 |
void _q_repaintContents(const QRectF &contentsRect); |
|
119 |
||
120 |
inline QPoint mapToContents(const QPoint &point) const |
|
121 |
{ return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); } |
|
122 |
||
123 |
void _q_adjustScrollbars(); |
|
124 |
void _q_verticalScrollbarActionTriggered(int action); |
|
125 |
void ensureViewportLayouted(); |
|
126 |
void relayoutDocument(); |
|
127 |
||
128 |
void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode, bool moveCursor = true); |
|
129 |
||
130 |
inline int horizontalOffset() const |
|
131 |
{ return (q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value()); } |
|
132 |
int verticalOffset(int topBlock, int topLine) const; |
|
133 |
int verticalOffset() const; |
|
134 |
||
135 |
inline void sendControlEvent(QEvent *e) |
|
136 |
{ control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); } |
|
137 |
||
138 |
void updateDefaultTextOption(); |
|
139 |
||
140 |
QPlainTextEditControl *control; |
|
141 |
||
142 |
bool tabChangesFocus; |
|
143 |
||
144 |
QBasicTimer autoScrollTimer; |
|
145 |
QPoint autoScrollDragPos; |
|
146 |
||
147 |
QPlainTextEdit::LineWrapMode lineWrap; |
|
148 |
QTextOption::WrapMode wordWrap; |
|
149 |
||
150 |
uint showCursorOnInitialShow : 1; |
|
151 |
uint backgroundVisible : 1; |
|
152 |
uint centerOnScroll : 1; |
|
153 |
uint inDrag : 1; |
|
154 |
uint clickCausedFocus : 1; |
|
155 |
||
156 |
int topLine; |
|
157 |
||
158 |
void setTopLine(int visualTopLine, int dx = 0); |
|
159 |
void setTopBlock(int newTopBlock, int newTopLine, int dx = 0); |
|
160 |
||
161 |
void ensureVisible(int position, bool center, bool forceCenter = false); |
|
162 |
void ensureCursorVisible(bool center = false); |
|
163 |
void updateViewport(); |
|
164 |
||
165 |
QPointer<QPlainTextDocumentLayout> documentLayoutPtr; |
|
166 |
||
167 |
void append(const QString &text, Qt::TextFormat format = Qt::AutoText); |
|
168 |
||
169 |
qreal pageUpDownLastCursorY; |
|
170 |
bool pageUpDownLastCursorYIsValid; |
|
171 |
||
172 |
||
173 |
#ifdef QT_KEYPAD_NAVIGATION |
|
174 |
QBasicTimer deleteAllTimer; |
|
175 |
#endif |
|
176 |
||
177 |
void _q_cursorPositionChanged(); |
|
178 |
void _q_modificationChanged(bool); |
|
179 |
||
180 |
int originalOffsetY; |
|
181 |
}; |
|
182 |
||
183 |
QT_END_NAMESPACE |
|
184 |
||
185 |
#endif // QT_NO_TEXTEDIT |
|
186 |
||
187 |
#endif // QPLAINTEXTEDIT_P_H |