Qt 4.8
qtextdocumentlayout_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 QTEXTDOCUMENTLAYOUT_P_H
43 #define QTEXTDOCUMENTLAYOUT_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/qabstracttextdocumentlayout.h"
57 #include "QtGui/qtextoption.h"
58 #include "QtGui/qtextobject.h"
59 
61 
62 class QTextListFormat;
63 
65 
67 {
69  Q_OBJECT
73 public:
74  explicit QTextDocumentLayout(QTextDocument *doc);
75 
76  // from the abstract layout
77  void draw(QPainter *painter, const PaintContext &context);
78  int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
79 
80  int pageCount() const;
81  QSizeF documentSize() const;
82 
83  void setCursorWidth(int width);
84  int cursorWidth() const;
85 
86  // internal, to support the ugly FixedColumnWidth wordwrap mode in QTextEdit
87  void setFixedColumnWidth(int width);
88 
89  // internal for QTextEdit's NoWrap mode
90  void setViewport(const QRectF &viewport);
91 
92  virtual QRectF frameBoundingRect(QTextFrame *frame) const;
93  virtual QRectF blockBoundingRect(const QTextBlock &block) const;
94 
95  // ####
96  int layoutStatus() const;
97  int dynamicPageCount() const;
98  QSizeF dynamicDocumentSize() const;
99  void ensureLayouted(qreal);
100 
101  qreal idealWidth() const;
102 
103  bool contentHasAlignment() const;
104 
105 protected:
106  void documentChanged(int from, int oldLength, int length);
107  void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format);
108  void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format);
109  void drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item,
110  int posInDocument, const QTextFormat &format);
111  virtual void timerEvent(QTimerEvent *e);
112 private:
113  QRectF doLayout(int from, int oldLength, int length);
114  void layoutFinished();
115 };
116 
118 
119 #endif // QTEXTDOCUMENTLAYOUT_P_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double qreal
Definition: qglobal.h:1193
The QTextListFormat class provides formatting information for lists in a QTextDocument.
Definition: qtextformat.h:642
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QTextFrame class represents a frame in a QTextDocument.
Definition: qtextobject.h:122
virtual void resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format)
Sets the size of the inline object item corresponding to the text format.
virtual void drawInlineObject(QPainter *painter, const QRectF &rect, QTextInlineObject object, int posInDocument, const QTextFormat &format)
This function is called to draw the inline object, object, with the given painter within the rectangl...
HitTestAccuracy
Definition: qtextdocument.h:78
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
virtual void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Definition: qobject.cpp:1294
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual int pageCount() const =0
Returns the number of pages contained in the layout.
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
virtual QSizeF documentSize() const =0
Returns the total size of the document's layout.
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
virtual QRectF frameBoundingRect(QTextFrame *frame) const =0
Returns the bounding rectangle of frame.
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual QRectF blockBoundingRect(const QTextBlock &block) const =0
Returns the bounding rectangle of block.
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
The QTextInlineObject class represents an inline object in a QTextLayout.
Definition: qtextlayout.h:69
The QAbstractTextDocumentLayout::PaintContext class is a convenience class defining the parameters us...
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
virtual void positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format)
Lays out the inline object item using the given text format.
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const =0
Returns the cursor postion for the given point with the specified accuracy.
virtual void documentChanged(int from, int charsRemoved, int charsAdded)=0
This function is called whenever the contents of the document change.
virtual void draw(QPainter *painter, const PaintContext &context)=0
Draws the layout with the given painter using the given context.
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for ...