1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.gui.abstracttextdocumentlayout;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.namespace;
19 import qt.core.object;
20 import qt.core.point;
21 import qt.core.rect;
22 import qt.core.size;
23 import qt.core.string;
24 import qt.core.vector;
25 import qt.gui.paintdevice;
26 import qt.gui.painter;
27 import qt.gui.palette;
28 import qt.gui.textcursor;
29 import qt.gui.textdocument;
30 import qt.gui.textformat;
31 import qt.gui.textlayout;
32 import qt.gui.textobject;
33 import qt.helpers;
34 
35 extern(C++, class) struct QAbstractTextDocumentLayoutPrivate;
36 /+ class QTextBlock;
37 class QTextObjectInterface;
38 class QTextFrame; +/
39 
40 abstract class /+ Q_GUI_EXPORT +/ QAbstractTextDocumentLayout : QObject
41 {
42     mixin(Q_OBJECT);
43     /+ Q_DECLARE_PRIVATE(QAbstractTextDocumentLayout) +/
44 
45 public:
46     /+ explicit +/this(QTextDocument doc);
47     ~this();
48 
49     struct Selection
50     {
51         QTextCursor cursor;
52         QTextCharFormat format;
53     }
54 
55     struct PaintContext
56     {
57         @disable this(this);
58         int cursorPosition = -1;
59         QPalette palette;
60         QRectF clip;
61         QVector!(Selection) selections;
62     }
63 
64     /+ virtual +/ abstract void draw(QPainter* painter, ref const(PaintContext) context);
65     /+ virtual +/ abstract int hitTest(ref const(QPointF) point, /+ Qt:: +/qt.core.namespace.HitTestAccuracy accuracy) const;
66 
67     final QString anchorAt(ref const(QPointF) pos) const;
68     final QString imageAt(ref const(QPointF) pos) const;
69     final QTextFormat formatAt(ref const(QPointF) pos) const;
70 //    final QTextBlock blockWithMarkerAt(ref const(QPointF) pos) const;
71 
72     /+ virtual +/ abstract int pageCount() const;
73     /+ virtual +/ abstract QSizeF documentSize() const;
74 
75     /+ virtual +/ abstract QRectF frameBoundingRect(QTextFrame frame) const;
76     /+ virtual +/ abstract QRectF blockBoundingRect(ref const(QTextBlock) block) const;
77 
78     final void setPaintDevice(QPaintDevice device);
79     final QPaintDevice paintDevice() const;
80 
81     final QTextDocument document() const;
82 
83     final void registerHandler(int objectType, QObject component);
84     final void unregisterHandler(int objectType, QObject component = null);
85     final QTextObjectInterface handlerForObject(int objectType) const;
86 
87 /+ Q_SIGNALS +/public:
88     @QSignal final void update(ref const(QRectF)  /+ = QRectF(0., 0., 1000000000., 1000000000.) +/);
89     @QSignal final void updateBlock(ref const(QTextBlock) block);
90     @QSignal final void documentSizeChanged(ref const(QSizeF) newSize);
91     @QSignal final void pageCountChanged(int newPages);
92 
93 protected:
94     this(ref QAbstractTextDocumentLayoutPrivate , QTextDocument );
95 
96     /+ virtual +/ abstract void documentChanged(int from, int charsRemoved, int charsAdded);
97 
98     /+ virtual +/ void resizeInlineObject(QTextInlineObject item, int posInDocument, ref const(QTextFormat) format);
99     /+ virtual +/ void positionInlineObject(QTextInlineObject item, int posInDocument, ref const(QTextFormat) format);
100     /+ virtual +/ void drawInlineObject(QPainter* painter, ref const(QRectF) rect, QTextInlineObject object, int posInDocument, ref const(QTextFormat) format);
101 
102     final int formatIndex(int pos);
103     final QTextCharFormat format(int pos);
104 
105 private:
106     /+ friend class QWidgetTextControl; +/
107     /+ friend class QTextDocument; +/
108     /+ friend class QTextDocumentPrivate; +/
109     /+ friend class QTextEngine; +/
110     /+ friend class QTextLayout; +/
111     /+ friend class QTextLine; +/
112     /+ Q_PRIVATE_SLOT(d_func(), void _q_handlerDestroyed(QObject *obj))
113     Q_PRIVATE_SLOT(d_func(), int _q_dynamicPageCountSlot())
114     Q_PRIVATE_SLOT(d_func(), QSizeF _q_dynamicDocumentSizeSlot()) +/
115 }
116 /+ Q_DECLARE_TYPEINFO(QAbstractTextDocumentLayout::Selection,    Q_RELOCATABLE_TYPE);
117 Q_DECLARE_TYPEINFO(QAbstractTextDocumentLayout::PaintContext, Q_RELOCATABLE_TYPE); +/
118 
119 class /+ Q_GUI_EXPORT +/ QTextObjectInterface
120 {
121 public:
122     /+ virtual +/~this();
123     /+ virtual +/ abstract QSizeF intrinsicSize(QTextDocument doc, int posInDocument, ref const(QTextFormat) format);
124     /+ virtual +/ abstract void drawObject(QPainter* painter, ref const(QRectF) rect, QTextDocument doc, int posInDocument, ref const(QTextFormat) format);
125 }
126 
127 /+ #ifndef Q_CLANG_QDOC
128 Q_DECLARE_INTERFACE(QTextObjectInterface, "org.qt-project.Qt.QTextObjectInterface")
129 #endif +/
130