1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QTEXTCONTROL_P_P_H
|
---|
43 | #define QTEXTCONTROL_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 "QtGui/qtextdocumentfragment.h"
|
---|
57 | #include "QtGui/qscrollbar.h"
|
---|
58 | #include "QtGui/qtextcursor.h"
|
---|
59 | #include "QtGui/qtextformat.h"
|
---|
60 | #include "QtGui/qmenu.h"
|
---|
61 | #include "QtGui/qabstracttextdocumentlayout.h"
|
---|
62 | #include "QtCore/qbasictimer.h"
|
---|
63 | #include "QtCore/qpointer.h"
|
---|
64 | #include "private/qobject_p.h"
|
---|
65 |
|
---|
66 | QT_BEGIN_NAMESPACE
|
---|
67 |
|
---|
68 | class QMimeData;
|
---|
69 | class QAbstractScrollArea;
|
---|
70 | class QInputContext;
|
---|
71 |
|
---|
72 | class QTextControlPrivate : public QObjectPrivate
|
---|
73 | {
|
---|
74 | Q_DECLARE_PUBLIC(QTextControl)
|
---|
75 | public:
|
---|
76 | QTextControlPrivate();
|
---|
77 |
|
---|
78 | bool cursorMoveKeyEvent(QKeyEvent *e);
|
---|
79 |
|
---|
80 | void updateCurrentCharFormat();
|
---|
81 |
|
---|
82 | void indent();
|
---|
83 | void outdent();
|
---|
84 |
|
---|
85 | void gotoNextTableCell();
|
---|
86 | void gotoPreviousTableCell();
|
---|
87 |
|
---|
88 | void createAutoBulletList();
|
---|
89 |
|
---|
90 | void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
|
---|
91 | QTextDocument *document = 0);
|
---|
92 | void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
|
---|
93 | QTextDocument *document = 0);
|
---|
94 | void startDrag();
|
---|
95 |
|
---|
96 | void paste(const QMimeData *source);
|
---|
97 |
|
---|
98 | void setCursorPosition(const QPointF &pos);
|
---|
99 | void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
|
---|
100 |
|
---|
101 | void repaintCursor();
|
---|
102 | inline void repaintSelection()
|
---|
103 | { repaintOldAndNewSelection(QTextCursor()); }
|
---|
104 | void repaintOldAndNewSelection(const QTextCursor &oldSelection);
|
---|
105 |
|
---|
106 | void selectionChanged(bool forceEmitSelectionChanged = false);
|
---|
107 |
|
---|
108 | void _q_updateCurrentCharFormatAndSelection();
|
---|
109 |
|
---|
110 | #ifndef QT_NO_CLIPBOARD
|
---|
111 | void setClipboardSelection();
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | void _q_emitCursorPosChanged(const QTextCursor &someCursor);
|
---|
115 |
|
---|
116 | void setBlinkingCursorEnabled(bool enable);
|
---|
117 |
|
---|
118 | void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
|
---|
119 | void extendBlockwiseSelection(int suggestedNewPosition);
|
---|
120 |
|
---|
121 | void _q_deleteSelected();
|
---|
122 |
|
---|
123 | void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
|
---|
124 |
|
---|
125 | QRectF cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const;
|
---|
126 | QRectF rectForPosition(int position) const;
|
---|
127 | QRectF selectionRect(const QTextCursor &cursor) const;
|
---|
128 | inline QRectF selectionRect() const
|
---|
129 | { return selectionRect(this->cursor); }
|
---|
130 |
|
---|
131 | QString anchorForCursor(const QTextCursor &anchor) const;
|
---|
132 |
|
---|
133 | void keyPressEvent(QKeyEvent *e);
|
---|
134 | void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
|
---|
135 | Qt::KeyboardModifiers modifiers,
|
---|
136 | Qt::MouseButtons buttons,
|
---|
137 | const QPoint &globalPos);
|
---|
138 | void mouseMoveEvent(Qt::MouseButtons buttons, const QPointF &pos);
|
---|
139 | void mouseReleaseEvent(Qt::MouseButton button, const QPointF &pos);
|
---|
140 | void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos);
|
---|
141 | void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
|
---|
142 | void focusEvent(QFocusEvent *e);
|
---|
143 | #ifdef QT_KEYPAD_NAVIGATION
|
---|
144 | void editFocusEvent(QEvent *e);
|
---|
145 | #endif
|
---|
146 | bool dragEnterEvent(QEvent *e, const QMimeData *mimeData);
|
---|
147 | void dragLeaveEvent();
|
---|
148 | bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos);
|
---|
149 | bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source);
|
---|
150 |
|
---|
151 | void inputMethodEvent(QInputMethodEvent *);
|
---|
152 |
|
---|
153 | void activateLinkUnderCursor(QString href = QString());
|
---|
154 |
|
---|
155 | #ifndef QT_NO_TOOLTIP
|
---|
156 | void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget);
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
|
---|
160 |
|
---|
161 | QInputContext *inputContext();
|
---|
162 |
|
---|
163 | QTextDocument *doc;
|
---|
164 | bool cursorOn;
|
---|
165 | QTextCursor cursor;
|
---|
166 | bool cursorIsFocusIndicator;
|
---|
167 | QTextCharFormat lastCharFormat;
|
---|
168 |
|
---|
169 | QTextCursor dndFeedbackCursor;
|
---|
170 |
|
---|
171 | Qt::TextInteractionFlags interactionFlags;
|
---|
172 |
|
---|
173 | QBasicTimer cursorBlinkTimer;
|
---|
174 | QBasicTimer trippleClickTimer;
|
---|
175 | QPointF trippleClickPoint;
|
---|
176 |
|
---|
177 | bool mousePressed;
|
---|
178 |
|
---|
179 | bool mightStartDrag;
|
---|
180 | QPoint dragStartPos;
|
---|
181 | QPointer<QWidget> contextWidget;
|
---|
182 |
|
---|
183 | bool lastSelectionState;
|
---|
184 |
|
---|
185 | bool ignoreAutomaticScrollbarAdjustement;
|
---|
186 |
|
---|
187 | QTextCursor selectedWordOnDoubleClick;
|
---|
188 | QTextCursor selectedBlockOnTrippleClick;
|
---|
189 |
|
---|
190 | bool overwriteMode;
|
---|
191 | bool acceptRichText;
|
---|
192 |
|
---|
193 | int preeditCursor;
|
---|
194 | bool hideCursor; // used to hide the cursor in the preedit area
|
---|
195 |
|
---|
196 | QVector<QAbstractTextDocumentLayout::Selection> extraSelections;
|
---|
197 |
|
---|
198 | QPalette palette;
|
---|
199 | bool hasFocus;
|
---|
200 | #ifdef QT_KEYPAD_NAVIGATION
|
---|
201 | bool hasEditFocus;
|
---|
202 | #endif
|
---|
203 | bool isEnabled;
|
---|
204 |
|
---|
205 | QString highlightedAnchor; // Anchor below cursor
|
---|
206 | QString anchorOnMousePress;
|
---|
207 | bool hadSelectionOnMousePress;
|
---|
208 |
|
---|
209 | bool ignoreUnusedNavigationEvents;
|
---|
210 | bool openExternalLinks;
|
---|
211 |
|
---|
212 | QString linkToCopy;
|
---|
213 | void _q_copyLink();
|
---|
214 | void _q_updateBlock(const QTextBlock &);
|
---|
215 | void _q_documentLayoutChanged();
|
---|
216 | };
|
---|
217 |
|
---|
218 | QT_END_NAMESPACE
|
---|
219 |
|
---|
220 | #endif // QTEXTCONTROL_P_H
|
---|