~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/widgets/widgets/qtextedit.h

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the QtGui module of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL$
 
9
** Commercial License Usage
 
10
** Licensees holding valid commercial Qt licenses may use this file in
 
11
** accordance with the commercial license agreement provided with the
 
12
** Software or, alternatively, in accordance with the terms contained in
 
13
** a written agreement between you and Digia.  For licensing terms and
 
14
** conditions see http://qt.digia.com/licensing.  For further information
 
15
** use the contact form at http://qt.digia.com/contact-us.
 
16
**
 
17
** GNU Lesser General Public License Usage
 
18
** Alternatively, this file may be used under the terms of the GNU Lesser
 
19
** General Public License version 2.1 as published by the Free Software
 
20
** Foundation and appearing in the file LICENSE.LGPL included in the
 
21
** packaging of this file.  Please review the following information to
 
22
** ensure the GNU Lesser General Public License version 2.1 requirements
 
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
24
**
 
25
** In addition, as a special exception, Digia gives you certain additional
 
26
** rights.  These rights are described in the Digia Qt LGPL Exception
 
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
28
**
 
29
** GNU General Public License Usage
 
30
** Alternatively, this file may be used under the terms of the GNU
 
31
** General Public License version 3.0 as published by the Free Software
 
32
** Foundation and appearing in the file LICENSE.GPL included in the
 
33
** packaging of this file.  Please review the following information to
 
34
** ensure the GNU General Public License version 3.0 requirements will be
 
35
** met: http://www.gnu.org/copyleft/gpl.html.
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#ifndef QTEXTEDIT_H
 
43
#define QTEXTEDIT_H
 
44
 
 
45
#include <QtWidgets/qabstractscrollarea.h>
 
46
#include <QtGui/qtextdocument.h>
 
47
#include <QtGui/qtextoption.h>
 
48
#include <QtGui/qtextcursor.h>
 
49
#include <QtGui/qtextformat.h>
 
50
 
 
51
#ifndef QT_NO_TEXTEDIT
 
52
 
 
53
 
 
54
QT_BEGIN_HEADER
 
55
 
 
56
QT_BEGIN_NAMESPACE
 
57
 
 
58
 
 
59
class QStyleSheet;
 
60
class QTextDocument;
 
61
class QMenu;
 
62
class QTextEditPrivate;
 
63
class QMimeData;
 
64
class QPagedPaintDevice;
 
65
 
 
66
class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
 
67
{
 
68
    Q_OBJECT
 
69
    Q_DECLARE_PRIVATE(QTextEdit)
 
70
    Q_FLAGS(AutoFormatting)
 
71
    Q_ENUMS(LineWrapMode)
 
72
    Q_PROPERTY(AutoFormatting autoFormatting READ autoFormatting WRITE setAutoFormatting)
 
73
    Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
 
74
    Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
 
75
    Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
 
76
    Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
 
77
    QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
 
78
    Q_PROPERTY(int lineWrapColumnOrWidth READ lineWrapColumnOrWidth WRITE setLineWrapColumnOrWidth)
 
79
    Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
 
80
#ifndef QT_NO_TEXTHTMLPARSER
 
81
    Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
 
82
#endif
 
83
    Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
 
84
    Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
 
85
    Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
 
86
    Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
 
87
    Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
 
88
    Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
 
89
    Q_PROPERTY(QTextDocument *document READ document WRITE setDocument)
 
90
public:
 
91
    enum LineWrapMode {
 
92
        NoWrap,
 
93
        WidgetWidth,
 
94
        FixedPixelWidth,
 
95
        FixedColumnWidth
 
96
    };
 
97
 
 
98
    enum AutoFormattingFlag {
 
99
        AutoNone = 0,
 
100
        AutoBulletList = 0x00000001,
 
101
        AutoAll = 0xffffffff
 
102
    };
 
103
 
 
104
    Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
 
105
 
 
106
    explicit QTextEdit(QWidget *parent = 0);
 
107
    explicit QTextEdit(const QString &text, QWidget *parent = 0);
 
108
    virtual ~QTextEdit();
 
109
 
 
110
    void setDocument(QTextDocument *document);
 
111
    QTextDocument *document() const;
 
112
 
 
113
    void setTextCursor(const QTextCursor &cursor);
 
114
    QTextCursor textCursor() const;
 
115
 
 
116
    bool isReadOnly() const;
 
117
    void setReadOnly(bool ro);
 
118
 
 
119
    void setTextInteractionFlags(Qt::TextInteractionFlags flags);
 
120
    Qt::TextInteractionFlags textInteractionFlags() const;
 
121
 
 
122
    qreal fontPointSize() const;
 
123
    QString fontFamily() const;
 
124
    int fontWeight() const;
 
125
    bool fontUnderline() const;
 
126
    bool fontItalic() const;
 
127
    QColor textColor() const;
 
128
    QColor textBackgroundColor() const;
 
129
    QFont currentFont() const;
 
130
    Qt::Alignment alignment() const;
 
131
 
 
132
    void mergeCurrentCharFormat(const QTextCharFormat &modifier);
 
133
 
 
134
    void setCurrentCharFormat(const QTextCharFormat &format);
 
135
    QTextCharFormat currentCharFormat() const;
 
136
 
 
137
    AutoFormatting autoFormatting() const;
 
138
    void setAutoFormatting(AutoFormatting features);
 
139
 
 
140
    bool tabChangesFocus() const;
 
141
    void setTabChangesFocus(bool b);
 
142
 
 
143
    inline void setDocumentTitle(const QString &title)
 
144
    { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
 
145
    inline QString documentTitle() const
 
146
    { return document()->metaInformation(QTextDocument::DocumentTitle); }
 
147
 
 
148
    inline bool isUndoRedoEnabled() const
 
149
    { return document()->isUndoRedoEnabled(); }
 
150
    inline void setUndoRedoEnabled(bool enable)
 
151
    { document()->setUndoRedoEnabled(enable); }
 
152
 
 
153
    LineWrapMode lineWrapMode() const;
 
154
    void setLineWrapMode(LineWrapMode mode);
 
155
 
 
156
    int lineWrapColumnOrWidth() const;
 
157
    void setLineWrapColumnOrWidth(int w);
 
158
 
 
159
    QTextOption::WrapMode wordWrapMode() const;
 
160
    void setWordWrapMode(QTextOption::WrapMode policy);
 
161
 
 
162
    bool find(const QString &exp, QTextDocument::FindFlags options = 0);
 
163
 
 
164
    QString toPlainText() const;
 
165
#ifndef QT_NO_TEXTHTMLPARSER
 
166
    QString toHtml() const;
 
167
#endif
 
168
 
 
169
    void ensureCursorVisible();
 
170
 
 
171
    Q_INVOKABLE virtual QVariant loadResource(int type, const QUrl &name);
 
172
#ifndef QT_NO_CONTEXTMENU
 
173
    QMenu *createStandardContextMenu();
 
174
    QMenu *createStandardContextMenu(const QPoint &position);
 
175
#endif
 
176
 
 
177
    QTextCursor cursorForPosition(const QPoint &pos) const;
 
178
    QRect cursorRect(const QTextCursor &cursor) const;
 
179
    QRect cursorRect() const;
 
180
 
 
181
    QString anchorAt(const QPoint& pos) const;
 
182
 
 
183
    bool overwriteMode() const;
 
184
    void setOverwriteMode(bool overwrite);
 
185
 
 
186
    int tabStopWidth() const;
 
187
    void setTabStopWidth(int width);
 
188
 
 
189
    int cursorWidth() const;
 
190
    void setCursorWidth(int width);
 
191
 
 
192
    bool acceptRichText() const;
 
193
    void setAcceptRichText(bool accept);
 
194
 
 
195
    struct ExtraSelection
 
196
    {
 
197
        QTextCursor cursor;
 
198
        QTextCharFormat format;
 
199
    };
 
200
    void setExtraSelections(const QList<ExtraSelection> &selections);
 
201
    QList<ExtraSelection> extraSelections() const;
 
202
 
 
203
    void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
 
204
 
 
205
    bool canPaste() const;
 
206
 
 
207
    void print(QPagedPaintDevice *printer) const;
 
208
 
 
209
    QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
 
210
 
 
211
public Q_SLOTS:
 
212
    void setFontPointSize(qreal s);
 
213
    void setFontFamily(const QString &fontFamily);
 
214
    void setFontWeight(int w);
 
215
    void setFontUnderline(bool b);
 
216
    void setFontItalic(bool b);
 
217
    void setTextColor(const QColor &c);
 
218
    void setTextBackgroundColor(const QColor &c);
 
219
    void setCurrentFont(const QFont &f);
 
220
    void setAlignment(Qt::Alignment a);
 
221
 
 
222
    void setPlainText(const QString &text);
 
223
#ifndef QT_NO_TEXTHTMLPARSER
 
224
    void setHtml(const QString &text);
 
225
#endif
 
226
    void setText(const QString &text);
 
227
 
 
228
#ifndef QT_NO_CLIPBOARD
 
229
    void cut();
 
230
    void copy();
 
231
    void paste();
 
232
#endif
 
233
 
 
234
    void undo();
 
235
    void redo();
 
236
 
 
237
    void clear();
 
238
    void selectAll();
 
239
 
 
240
    void insertPlainText(const QString &text);
 
241
#ifndef QT_NO_TEXTHTMLPARSER
 
242
    void insertHtml(const QString &text);
 
243
#endif // QT_NO_TEXTHTMLPARSER
 
244
 
 
245
    void append(const QString &text);
 
246
 
 
247
    void scrollToAnchor(const QString &name);
 
248
 
 
249
    void zoomIn(int range = 1);
 
250
    void zoomOut(int range = 1);
 
251
 
 
252
Q_SIGNALS:
 
253
    void textChanged();
 
254
    void undoAvailable(bool b);
 
255
    void redoAvailable(bool b);
 
256
    void currentCharFormatChanged(const QTextCharFormat &format);
 
257
    void copyAvailable(bool b);
 
258
    void selectionChanged();
 
259
    void cursorPositionChanged();
 
260
 
 
261
protected:
 
262
    virtual bool event(QEvent *e);
 
263
    virtual void timerEvent(QTimerEvent *e);
 
264
    virtual void keyPressEvent(QKeyEvent *e);
 
265
    virtual void keyReleaseEvent(QKeyEvent *e);
 
266
    virtual void resizeEvent(QResizeEvent *e);
 
267
    virtual void paintEvent(QPaintEvent *e);
 
268
    virtual void mousePressEvent(QMouseEvent *e);
 
269
    virtual void mouseMoveEvent(QMouseEvent *e);
 
270
    virtual void mouseReleaseEvent(QMouseEvent *e);
 
271
    virtual void mouseDoubleClickEvent(QMouseEvent *e);
 
272
    virtual bool focusNextPrevChild(bool next);
 
273
#ifndef QT_NO_CONTEXTMENU
 
274
    virtual void contextMenuEvent(QContextMenuEvent *e);
 
275
#endif
 
276
#ifndef QT_NO_DRAGANDDROP
 
277
    virtual void dragEnterEvent(QDragEnterEvent *e);
 
278
    virtual void dragLeaveEvent(QDragLeaveEvent *e);
 
279
    virtual void dragMoveEvent(QDragMoveEvent *e);
 
280
    virtual void dropEvent(QDropEvent *e);
 
281
#endif
 
282
    virtual void focusInEvent(QFocusEvent *e);
 
283
    virtual void focusOutEvent(QFocusEvent *e);
 
284
    virtual void showEvent(QShowEvent *);
 
285
    virtual void changeEvent(QEvent *e);
 
286
#ifndef QT_NO_WHEELEVENT
 
287
    virtual void wheelEvent(QWheelEvent *e);
 
288
#endif
 
289
 
 
290
    virtual QMimeData *createMimeDataFromSelection() const;
 
291
    virtual bool canInsertFromMimeData(const QMimeData *source) const;
 
292
    virtual void insertFromMimeData(const QMimeData *source);
 
293
 
 
294
    virtual void inputMethodEvent(QInputMethodEvent *);
 
295
 
 
296
    QTextEdit(QTextEditPrivate &dd, QWidget *parent);
 
297
 
 
298
    virtual void scrollContentsBy(int dx, int dy);
 
299
    virtual void doSetTextCursor(const QTextCursor &cursor);
 
300
 
 
301
private:
 
302
    Q_DISABLE_COPY(QTextEdit)
 
303
    Q_PRIVATE_SLOT(d_func(), void _q_repaintContents(const QRectF &r))
 
304
    Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
 
305
    Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
 
306
    Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
 
307
    Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged())
 
308
    friend class QTextEditControl;
 
309
    friend class QTextDocument;
 
310
    friend class QWidgetTextControl;
 
311
};
 
312
 
 
313
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEdit::AutoFormatting)
 
314
 
 
315
QT_END_NAMESPACE
 
316
 
 
317
QT_END_HEADER
 
318
 
 
319
#endif // QT_NO_TEXTEDIT
 
320
 
 
321
#endif // QTEXTEDIT_H