Export QTextImageHandler and add accessor for image
[profile/ivi/qtbase.git] / src / gui / text / qtextcontrol_p_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
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 ** 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 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/qtextcursor.h"
58 #include "QtGui/qtextformat.h"
59 #include "QtGui/qabstracttextdocumentlayout.h"
60 #include "QtCore/qbasictimer.h"
61 #include "QtCore/qpointer.h"
62 #include "private/qobject_p.h"
63
64 QT_BEGIN_NAMESPACE
65
66 class QMimeData;
67 class QAbstractScrollArea;
68 class QInputContext;
69
70 class QTextControlPrivate : public QObjectPrivate
71 {
72     Q_DECLARE_PUBLIC(QTextControl)
73 public:
74     QTextControlPrivate();
75
76     bool cursorMoveKeyEvent(QKeyEvent *e);
77
78     void updateCurrentCharFormat();
79
80     void indent();
81     void outdent();
82
83     void gotoNextTableCell();
84     void gotoPreviousTableCell();
85
86     void createAutoBulletList();
87
88     void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
89               QTextDocument *document = 0);
90     void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
91                     QTextDocument *document = 0);
92     void startDrag();
93
94     void paste(const QMimeData *source);
95
96     void setCursorPosition(const QPointF &pos);
97     void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
98
99     void repaintCursor();
100     inline void repaintSelection()
101     { repaintOldAndNewSelection(QTextCursor()); }
102     void repaintOldAndNewSelection(const QTextCursor &oldSelection);
103
104     void selectionChanged(bool forceEmitSelectionChanged = false);
105
106     void _q_updateCurrentCharFormatAndSelection();
107
108 #ifndef QT_NO_CLIPBOARD
109     void setClipboardSelection();
110 #endif
111
112     void _q_emitCursorPosChanged(const QTextCursor &someCursor);
113
114     void setBlinkingCursorEnabled(bool enable);
115
116     void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
117     void extendBlockwiseSelection(int suggestedNewPosition);
118
119     void _q_deleteSelected();
120
121     void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
122
123     QRectF cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const;
124     QRectF rectForPosition(int position) const;
125     QRectF selectionRect(const QTextCursor &cursor) const;
126     inline QRectF selectionRect() const
127     { return selectionRect(this->cursor); }
128
129     QString anchorForCursor(const QTextCursor &anchor) const;
130
131     void keyPressEvent(QKeyEvent *e);
132     void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
133                          Qt::KeyboardModifiers modifiers,
134                          Qt::MouseButtons buttons,
135                          const QPoint &globalPos);
136     void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
137                         Qt::KeyboardModifiers modifiers,
138                         Qt::MouseButtons buttons,
139                         const QPoint &globalPos);
140     void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
141                            Qt::KeyboardModifiers modifiers,
142                            Qt::MouseButtons buttons,
143                            const QPoint &globalPos);
144     void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
145                                Qt::KeyboardModifiers modifiers,
146                                Qt::MouseButtons buttons,
147                                const QPoint &globalPos);
148     bool sendMouseEventToInputContext(QEvent *e,  QEvent::Type eventType, Qt::MouseButton button,
149                                       const QPointF &pos,
150                                       Qt::KeyboardModifiers modifiers,
151                                       Qt::MouseButtons buttons,
152                                       const QPoint &globalPos);
153     void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
154     void focusEvent(QFocusEvent *e);
155 #ifdef QT_KEYPAD_NAVIGATION
156     void editFocusEvent(QEvent *e);
157 #endif
158     bool dragEnterEvent(QEvent *e, const QMimeData *mimeData);
159     void dragLeaveEvent();
160     bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos);
161     bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source);
162
163     void inputMethodEvent(QInputMethodEvent *);
164
165     void activateLinkUnderCursor(QString href = QString());
166
167     void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
168
169     QInputContext *inputContext();
170
171     QTextDocument *doc;
172     bool cursorOn;
173     QTextCursor cursor;
174     bool cursorIsFocusIndicator;
175     QTextCharFormat lastCharFormat;
176
177     QTextCursor dndFeedbackCursor;
178
179     Qt::TextInteractionFlags interactionFlags;
180
181     QBasicTimer cursorBlinkTimer;
182     QBasicTimer trippleClickTimer;
183     QPointF trippleClickPoint;
184
185     bool dragEnabled;
186
187     bool mousePressed;
188
189     bool mightStartDrag;
190     QPoint dragStartPos;
191     QPointer<QObject> contextObject;
192
193     bool lastSelectionState;
194
195     bool ignoreAutomaticScrollbarAdjustement;
196
197     QTextCursor selectedWordOnDoubleClick;
198     QTextCursor selectedBlockOnTrippleClick;
199
200     bool overwriteMode;
201     bool acceptRichText;
202
203     int preeditCursor;
204     bool hideCursor; // used to hide the cursor in the preedit area
205
206     QVector<QAbstractTextDocumentLayout::Selection> extraSelections;
207
208     QPalette palette;
209     bool hasFocus;
210 #ifdef QT_KEYPAD_NAVIGATION
211     bool hasEditFocus;
212 #endif
213     bool isEnabled;
214
215     QString highlightedAnchor; // Anchor below cursor
216     QString anchorOnMousePress;
217     bool hadSelectionOnMousePress;
218
219     bool ignoreUnusedNavigationEvents;
220     bool openExternalLinks;
221
222     bool wordSelectionEnabled;
223
224     QString linkToCopy;
225     void _q_copyLink();
226     void _q_updateBlock(const QTextBlock &);
227     void _q_documentLayoutChanged();
228 };
229
230 QT_END_NAMESPACE
231
232 #endif // QTextControl_P_H