1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTEXTOBJECT_H
#define QTEXTOBJECT_H
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
#include <QtGui/qtextlayout.h>
#include <QtGui/qglyphrun.h>
QT_BEGIN_NAMESPACE
class QTextObjectPrivate;
class QTextDocument;
class QTextDocumentPrivate;
class QTextCursor;
class QTextBlock;
class QTextFragment;
class QTextList;
class Q_GUI_EXPORT QTextObject : public QObject
{
Q_OBJECT
protected:
explicit QTextObject(QTextDocument *doc);
~QTextObject();
void setFormat(const QTextFormat &format);
public:
QTextFormat format() const;
int formatIndex() const;
QTextDocument *document() const;
int objectIndex() const;
QTextDocumentPrivate *docHandle() const;
protected:
QTextObject(QTextObjectPrivate &p, QTextDocument *doc);
private:
Q_DECLARE_PRIVATE(QTextObject)
Q_DISABLE_COPY(QTextObject)
friend class QTextDocumentPrivate;
};
class QTextBlockGroupPrivate;
class Q_GUI_EXPORT QTextBlockGroup : public QTextObject
{
Q_OBJECT
protected:
explicit QTextBlockGroup(QTextDocument *doc);
~QTextBlockGroup();
virtual void blockInserted(const QTextBlock &block);
virtual void blockRemoved(const QTextBlock &block);
virtual void blockFormatChanged(const QTextBlock &block);
QList<QTextBlock> blockList() const;
protected:
QTextBlockGroup(QTextBlockGroupPrivate &p, QTextDocument *doc);
private:
Q_DECLARE_PRIVATE(QTextBlockGroup)
Q_DISABLE_COPY(QTextBlockGroup)
friend class QTextDocumentPrivate;
};
class Q_GUI_EXPORT QTextFrameLayoutData {
public:
virtual ~QTextFrameLayoutData();
};
class QTextFramePrivate;
class Q_GUI_EXPORT QTextFrame : public QTextObject
{
Q_OBJECT
public:
explicit QTextFrame(QTextDocument *doc);
~QTextFrame();
inline void setFrameFormat(const QTextFrameFormat &format);
QTextFrameFormat frameFormat() const { return QTextObject::format().toFrameFormat(); }
QTextCursor firstCursorPosition() const;
QTextCursor lastCursorPosition() const;
int firstPosition() const;
int lastPosition() const;
QTextFrameLayoutData *layoutData() const;
void setLayoutData(QTextFrameLayoutData *data);
QList<QTextFrame *> childFrames() const;
QTextFrame *parentFrame() const;
class Q_GUI_EXPORT iterator {
QTextFrame *f;
int b;
int e;
QTextFrame *cf;
int cb;
friend class QTextFrame;
friend class QTextTableCell;
friend class QTextDocumentLayoutPrivate;
iterator(QTextFrame *frame, int block, int begin, int end);
public:
iterator();
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
iterator(const iterator &o);
iterator &operator=(const iterator &o);
#endif
QTextFrame *parentFrame() const { return f; }
QTextFrame *currentFrame() const;
QTextBlock currentBlock() const;
bool atEnd() const { return !cf && cb == e; }
inline bool operator==(const iterator &o) const { return f == o.f && cf == o.cf && cb == o.cb; }
inline bool operator!=(const iterator &o) const { return f != o.f || cf != o.cf || cb != o.cb; }
iterator &operator++();
inline iterator operator++(int) { iterator tmp = *this; operator++(); return tmp; }
iterator &operator--();
inline iterator operator--(int) { iterator tmp = *this; operator--(); return tmp; }
};
friend class iterator;
// more Qt
typedef iterator Iterator;
iterator begin() const;
iterator end() const;
protected:
QTextFrame(QTextFramePrivate &p, QTextDocument *doc);
private:
friend class QTextDocumentPrivate;
Q_DECLARE_PRIVATE(QTextFrame)
Q_DISABLE_COPY(QTextFrame)
};
Q_DECLARE_TYPEINFO(QTextFrame::iterator, Q_MOVABLE_TYPE);
inline void QTextFrame::setFrameFormat(const QTextFrameFormat &aformat)
{ QTextObject::setFormat(aformat); }
class Q_GUI_EXPORT QTextBlockUserData {
public:
virtual ~QTextBlockUserData();
};
class Q_GUI_EXPORT QTextBlock
{
friend class QSyntaxHighlighter;
public:
inline QTextBlock(QTextDocumentPrivate *priv, int b) : p(priv), n(b) {}
inline QTextBlock() : p(Q_NULLPTR), n(0) {}
inline QTextBlock(const QTextBlock &o) : p(o.p), n(o.n) {}
inline QTextBlock &operator=(const QTextBlock &o) { p = o.p; n = o.n; return *this; }
bool isValid() const;
inline bool operator==(const QTextBlock &o) const { return p == o.p && n == o.n; }
inline bool operator!=(const QTextBlock &o) const { return p != o.p || n != o.n; }
inline bool operator<(const QTextBlock &o) const { return position() < o.position(); }
int position() const;
int length() const;
bool contains(int position) const;
QTextLayout *layout() const;
void clearLayout();
QTextBlockFormat blockFormat() const;
int blockFormatIndex() const;
QTextCharFormat charFormat() const;
int charFormatIndex() const;
Qt::LayoutDirection textDirection() const;
QString text() const;
QVector<QTextLayout::FormatRange> textFormats() const;
const QTextDocument *document() const;
QTextList *textList() const;
QTextBlockUserData *userData() const;
void setUserData(QTextBlockUserData *data);
int userState() const;
void setUserState(int state);
int revision() const;
void setRevision(int rev);
bool isVisible() const;
void setVisible(bool visible);
int blockNumber() const;
int firstLineNumber() const;
void setLineCount(int count);
int lineCount() const;
class Q_GUI_EXPORT iterator {
const QTextDocumentPrivate *p;
int b;
int e;
int n;
friend class QTextBlock;
iterator(const QTextDocumentPrivate *priv, int begin, int end, int f) : p(priv), b(begin), e(end), n(f) {}
public:
iterator() : p(Q_NULLPTR), b(0), e(0), n(0) {}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
iterator(const iterator &o) : p(o.p), b(o.b), e(o.e), n(o.n) {}
#endif
QTextFragment fragment() const;
bool atEnd() const { return n == e; }
inline bool operator==(const iterator &o) const { return p == o.p && n == o.n; }
inline bool operator!=(const iterator &o) const { return p != o.p || n != o.n; }
iterator &operator++();
inline iterator operator++(int) { iterator tmp = *this; operator++(); return tmp; }
iterator &operator--();
inline iterator operator--(int) { iterator tmp = *this; operator--(); return tmp; }
};
// more Qt
typedef iterator Iterator;
iterator begin() const;
iterator end() const;
QTextBlock next() const;
QTextBlock previous() const;
inline QTextDocumentPrivate *docHandle() const { return p; }
inline int fragmentIndex() const { return n; }
private:
QTextDocumentPrivate *p;
int n;
friend class QTextDocumentPrivate;
friend class QTextLayout;
};
Q_DECLARE_TYPEINFO(QTextBlock, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QTextBlock::iterator, Q_MOVABLE_TYPE);
class Q_GUI_EXPORT QTextFragment
{
public:
inline QTextFragment(const QTextDocumentPrivate *priv, int f, int fe) : p(priv), n(f), ne(fe) {}
inline QTextFragment() : p(Q_NULLPTR), n(0), ne(0) {}
inline QTextFragment(const QTextFragment &o) : p(o.p), n(o.n), ne(o.ne) {}
inline QTextFragment &operator=(const QTextFragment &o) { p = o.p; n = o.n; ne = o.ne; return *this; }
inline bool isValid() const { return p && n; }
inline bool operator==(const QTextFragment &o) const { return p == o.p && n == o.n; }
inline bool operator!=(const QTextFragment &o) const { return p != o.p || n != o.n; }
inline bool operator<(const QTextFragment &o) const { return position() < o.position(); }
int position() const;
int length() const;
bool contains(int position) const;
QTextCharFormat charFormat() const;
int charFormatIndex() const;
QString text() const;
#if !defined(QT_NO_RAWFONT)
QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
#endif
private:
const QTextDocumentPrivate *p;
int n;
int ne;
};
Q_DECLARE_TYPEINFO(QTextFragment, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
#endif // QTEXTOBJECT_H
|