Qt 4.8
qplaintextedit_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 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 QPLAINTEXTEDIT_P_H
43 #define QPLAINTEXTEDIT_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 "private/qabstractscrollarea_p.h"
57 #include "QtGui/qtextdocumentfragment.h"
58 #include "QtGui/qscrollbar.h"
59 #include "QtGui/qtextcursor.h"
60 #include "QtGui/qtextformat.h"
61 #include "QtGui/qmenu.h"
62 #include "QtGui/qabstracttextdocumentlayout.h"
63 #include "QtCore/qbasictimer.h"
64 #include "private/qtextcontrol_p.h"
65 #include "qplaintextedit.h"
66 
67 #ifndef QT_NO_TEXTEDIT
68 
70 
71 class QMimeData;
72 
73 class QPlainTextEdit;
74 class ExtraArea;
75 
77 {
78  Q_OBJECT
79 public:
81 
82 
84  bool canInsertFromMimeData(const QMimeData *source) const;
85  void insertFromMimeData(const QMimeData *source);
86  int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const;
87  QRectF blockBoundingRect(const QTextBlock &block) const;
88  inline QRectF cursorRect(const QTextCursor &cursor) const {
89  QRectF r = QTextControl::cursorRect(cursor);
90  r.setLeft(qMax(r.left(), (qreal) 0.));
91  return r;
92  }
93  inline QRectF cursorRect() { return cursorRect(textCursor()); }
97  }
98 
99 
101  int topBlock;
103 
105  return textEdit->loadResource(type, name);
106  }
107 
108 };
109 
110 
112 {
114 public:
116 
117  void init(const QString &txt = QString());
118  void _q_repaintContents(const QRectF &contentsRect);
119 
120  inline QPoint mapToContents(const QPoint &point) const
121  { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
122 
123  void _q_adjustScrollbars();
124  void _q_verticalScrollbarActionTriggered(int action);
125  void ensureViewportLayouted();
126  void relayoutDocument();
127 
128  void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode, bool moveCursor = true);
129 
130  inline int horizontalOffset() const
131  { return (q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value()); }
132  qreal verticalOffset(int topBlock, int topLine) const;
133  qreal verticalOffset() const;
134 
135  inline void sendControlEvent(QEvent *e)
136  { control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); }
137 
138  void updateDefaultTextOption();
139 
141 
143 
146 
149 
155 
156  int topLine;
157  qreal topLineFracture; // for non-int sized fonts
158 
159  void setTopLine(int visualTopLine, int dx = 0);
160  void setTopBlock(int newTopBlock, int newTopLine, int dx = 0);
161 
162  void ensureVisible(int position, bool center, bool forceCenter = false);
163  void ensureCursorVisible(bool center = false);
164  void updateViewport();
165 
167 
169 
172 
173 
174 #ifdef QT_KEYPAD_NAVIGATION
175  QBasicTimer deleteAllTimer;
176 #endif
177 
178  void _q_cursorPositionChanged();
179  void _q_modificationChanged(bool);
180 
182 };
183 
185 
186 #endif // QT_NO_TEXTEDIT
187 
188 #endif // QPLAINTEXTEDIT_P_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void ensureCursorVisible()
Ensures that the cursor is visible by scrolling the text edit if necessary.
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670
QPoint mapToContents(const QPoint &point) const
void append(const QString &text)
HitTestAccuracy
Definition: qtextdocument.h:78
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
Definition: qrect.h:525
QPointer< QPlainTextDocumentLayout > documentLayoutPtr
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
WrapMode
This enum describes how text is wrapped in a document.
Definition: qtextoption.h:102
QVariant loadResource(int type, const QUrl &name)
QRectF blockBoundingRect(const QTextBlock &block) const
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
QTextCursor textCursor() const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QPlainTextEdit * textEdit
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
MoveMode
If the anchor() is kept where it is and the position() is moved, the text in between will be selected...
Definition: qtextcursor.h:85
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void insertFromMimeData(const QMimeData *source)
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
static bool init
const char * name
#define emit
Definition: qobjectdefs.h:76
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
unsigned int uint
Definition: qglobal.h:996
void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
The QPlainTextEdit class provides a widget that is used to edit and display plain text...
QPlainTextEditControl(QPlainTextEdit *parent)
QRectF cursorRect(const QTextCursor &cursor) const
QRectF cursorRect() const
The QMimeData class provides a container for data that records information about its MIME type...
Definition: qmimedata.h:57
void sendControlEvent(QEvent *e)
#define Q_OBJECT
Definition: qobjectdefs.h:157
TextFormat
Definition: qnamespace.h:1310
Q_CORE_EXPORT QTextStream & center(QTextStream &s)
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
QTextOption::WrapMode wordWrap
QMimeData * createMimeDataFromSelection() const
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QTextBlock firstVisibleBlock() const
QPlainTextEditControl * control
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
virtual QVariant loadResource(int type, const QUrl &name)
Loads the resource specified by the given type and name.
void microFocusChanged()
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
bool canInsertFromMimeData(const QMimeData *source) const
The QBasicTimer class provides timer events for objects.
Definition: qbasictimer.h:55
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
QPlainTextEdit::LineWrapMode lineWrap
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
int hitTest(const QPointF &point, Qt::HitTestAccuracy=Qt::FuzzyHit) const
#define text
Definition: qobjectdefs.h:80