1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QPLAINTEXTEDIT_H
|
---|
43 | #define QPLAINTEXTEDIT_H
|
---|
44 |
|
---|
45 | #include <QtGui/qtextedit.h>
|
---|
46 |
|
---|
47 | #include <QtGui/qabstractscrollarea.h>
|
---|
48 | #include <QtGui/qtextdocument.h>
|
---|
49 | #include <QtGui/qtextoption.h>
|
---|
50 | #include <QtGui/qtextcursor.h>
|
---|
51 | #include <QtGui/qtextformat.h>
|
---|
52 | #include <QtGui/qabstracttextdocumentlayout.h>
|
---|
53 |
|
---|
54 | #ifndef QT_NO_TEXTEDIT
|
---|
55 |
|
---|
56 | QT_BEGIN_HEADER
|
---|
57 |
|
---|
58 | QT_BEGIN_NAMESPACE
|
---|
59 |
|
---|
60 | QT_MODULE(Gui)
|
---|
61 |
|
---|
62 | class QStyleSheet;
|
---|
63 | class QTextDocument;
|
---|
64 | class QMenu;
|
---|
65 | class QPlainTextEditPrivate;
|
---|
66 | class QMimeData;
|
---|
67 |
|
---|
68 |
|
---|
69 | class Q_GUI_EXPORT QPlainTextEdit : public QAbstractScrollArea
|
---|
70 | {
|
---|
71 | Q_OBJECT
|
---|
72 | Q_DECLARE_PRIVATE(QPlainTextEdit)
|
---|
73 | Q_ENUMS(LineWrapMode)
|
---|
74 | Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
|
---|
75 | Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
|
---|
76 | Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
|
---|
77 | Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
|
---|
78 | QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
|
---|
79 | Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
|
---|
80 | Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText NOTIFY textChanged USER true)
|
---|
81 | Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
|
---|
82 | Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
|
---|
83 | Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
|
---|
84 | Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
|
---|
85 | Q_PROPERTY(int blockCount READ blockCount)
|
---|
86 | Q_PROPERTY(int maximumBlockCount READ maximumBlockCount WRITE setMaximumBlockCount)
|
---|
87 | Q_PROPERTY(bool backgroundVisible READ backgroundVisible WRITE setBackgroundVisible)
|
---|
88 | Q_PROPERTY(bool centerOnScroll READ centerOnScroll WRITE setCenterOnScroll)
|
---|
89 | public:
|
---|
90 | enum LineWrapMode {
|
---|
91 | NoWrap,
|
---|
92 | WidgetWidth
|
---|
93 | };
|
---|
94 |
|
---|
95 | explicit QPlainTextEdit(QWidget *parent = 0);
|
---|
96 | explicit QPlainTextEdit(const QString &text, QWidget *parent = 0);
|
---|
97 | virtual ~QPlainTextEdit();
|
---|
98 |
|
---|
99 | void setDocument(QTextDocument *document);
|
---|
100 | QTextDocument *document() const;
|
---|
101 |
|
---|
102 | void setTextCursor(const QTextCursor &cursor);
|
---|
103 | QTextCursor textCursor() const;
|
---|
104 |
|
---|
105 | bool isReadOnly() const;
|
---|
106 | void setReadOnly(bool ro);
|
---|
107 |
|
---|
108 | void setTextInteractionFlags(Qt::TextInteractionFlags flags);
|
---|
109 | Qt::TextInteractionFlags textInteractionFlags() const;
|
---|
110 |
|
---|
111 | void mergeCurrentCharFormat(const QTextCharFormat &modifier);
|
---|
112 | void setCurrentCharFormat(const QTextCharFormat &format);
|
---|
113 | QTextCharFormat currentCharFormat() const;
|
---|
114 |
|
---|
115 | bool tabChangesFocus() const;
|
---|
116 | void setTabChangesFocus(bool b);
|
---|
117 |
|
---|
118 | inline void setDocumentTitle(const QString &title)
|
---|
119 | { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
|
---|
120 | inline QString documentTitle() const
|
---|
121 | { return document()->metaInformation(QTextDocument::DocumentTitle); }
|
---|
122 |
|
---|
123 | inline bool isUndoRedoEnabled() const
|
---|
124 | { return document()->isUndoRedoEnabled(); }
|
---|
125 | inline void setUndoRedoEnabled(bool enable)
|
---|
126 | { document()->setUndoRedoEnabled(enable); }
|
---|
127 |
|
---|
128 | inline void setMaximumBlockCount(int maximum)
|
---|
129 | { document()->setMaximumBlockCount(maximum); }
|
---|
130 | inline int maximumBlockCount() const
|
---|
131 | { return document()->maximumBlockCount(); }
|
---|
|
---|