source: trunk/src/gui/widgets/qtextedit.h@ 324

Last change on this file since 324 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 13.8 KB
Line 
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 QTEXTEDIT_H
43#define QTEXTEDIT_H
44
45#include <QtGui/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#ifdef QT3_SUPPORT
54#include <QtGui/qtextobject.h>
55#include <QtGui/qtextlayout.h>
56#endif
57
58QT_BEGIN_HEADER
59
60QT_BEGIN_NAMESPACE
61
62QT_MODULE(Gui)
63
64class QStyleSheet;
65class QTextDocument;
66class QMenu;
67class QTextEditPrivate;
68class QMimeData;
69
70class Q_GUI_EXPORT QTextEdit : public QAbstractScrollArea
71{
72 Q_OBJECT
73 Q_DECLARE_PRIVATE(QTextEdit)
74 Q_FLAGS(AutoFormatting)
75 Q_ENUMS(LineWrapMode)
76 Q_PROPERTY(AutoFormatting autoFormatting READ autoFormatting WRITE setAutoFormatting)
77 Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
78 Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
79 Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
80 Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
81 QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
82 Q_PROPERTY(int lineWrapColumnOrWidth READ lineWrapColumnOrWidth WRITE setLineWrapColumnOrWidth)
83 Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
84#ifndef QT_NO_TEXTHTMLPARSER
85 Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
86#endif
87 Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
88 Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
89 Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
90 Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
91 Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
92 Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
93public:
94 enum LineWrapMode {
95 NoWrap,
96 WidgetWidth,
97 FixedPixelWidth,
98 FixedColumnWidth
99 };
100
101 enum AutoFormattingFlag {
102 AutoNone = 0,
103 AutoBulletList = 0x00000001,
104 AutoAll = 0xffffffff
105 };
106
107 Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
108
109#if defined(QT3_SUPPORT)
110 enum CursorAction {
111 MoveBackward,
112 MoveForward,
113 MoveWordBackward,
114 MoveWordForward,
115 MoveUp,
116 MoveDown,
117 MoveLineStart,
118 MoveLineEnd,
119 MoveHome,
120 MoveEnd,
121 MovePageUp,
122 MovePageDown
123#if !defined(Q_MOC_RUN)
124 ,
125 MovePgUp = MovePageUp,
126 MovePgDown = MovePageDown
127#endif
128 };
129#endif
130
131 explicit QTextEdit(QWidget *parent = 0);
132 explicit QTextEdit(const QString &text, QWidget *parent = 0);
133 virtual ~QTextEdit();
134
135 void setDocument(QTextDocument *document);
136 QTextDocument *document() const;
137
138 void setTextCursor(const QTextCursor &cursor);
139 QTextCursor textCursor() const;
140
141 bool isReadOnly() const;
142 void setReadOnly(bool ro);
143
144 void setTextInteractionFlags(Qt::TextInteractionFlags flags);
145 Qt::TextInteractionFlags textInteractionFlags() const;
146
147 qreal fontPointSize() const;
148 QString fontFamily() const;
149 int fontWeight() const;
150 bool fontUnderline() const;
151 bool fontItalic() const;
152 QColor textColor() const;
153 QColor textBackgroundColor() const;
154 QFont currentFont() const;
155 Qt::Alignment alignment() const;
156
157 void mergeCurrentCharFormat(const QTextCharFormat &modifier);
158
159 void setCurrentCharFormat(const QTextCharFormat &format);
160 QTextCharFormat currentCharFormat() const;
161
162 AutoFormatting autoFormatting() const;
163 void setAutoFormatting(AutoFormatting features);
164
165 bool tabChangesFocus() const;
166 void setTabChangesFocus(bool b);
167
168 inline void setDocumentTitle(const QString &title)
169 { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }