Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtGui/qtextobject.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QTEXTOBJECT_H
0005 #define QTEXTOBJECT_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtCore/qobject.h>
0009 #include <QtGui/qtextformat.h>
0010 #include <QtGui/qtextlayout.h>
0011 #include <QtGui/qglyphrun.h>
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 
0016 class QTextObjectPrivate;
0017 class QTextDocument;
0018 class QTextDocumentPrivate;
0019 class QTextCursor;
0020 class QTextBlock;
0021 class QTextFragment;
0022 class QTextList;
0023 
0024 class Q_GUI_EXPORT QTextObject : public QObject
0025 {
0026     Q_OBJECT
0027 
0028 protected:
0029     explicit QTextObject(QTextDocument *doc);
0030     ~QTextObject();
0031 
0032     void setFormat(const QTextFormat &format);
0033 
0034 public:
0035     QTextFormat format() const;
0036     int formatIndex() const;
0037 
0038     QTextDocument *document() const;
0039 
0040     int objectIndex() const;
0041 
0042 protected:
0043     QTextObject(QTextObjectPrivate &p, QTextDocument *doc);
0044 
0045 private:
0046     Q_DECLARE_PRIVATE(QTextObject)
0047     Q_DISABLE_COPY(QTextObject)
0048     friend class QTextDocumentPrivate;
0049 };
0050 
0051 class QTextBlockGroupPrivate;
0052 class Q_GUI_EXPORT QTextBlockGroup : public QTextObject
0053 {
0054     Q_OBJECT
0055 
0056 protected:
0057     explicit QTextBlockGroup(QTextDocument *doc);
0058     ~QTextBlockGroup();
0059 
0060     virtual void blockInserted(const QTextBlock &block);
0061     virtual void blockRemoved(const QTextBlock &block);
0062     virtual void blockFormatChanged(const QTextBlock &block);
0063 
0064     QList<QTextBlock> blockList() const;
0065 
0066 protected:
0067     QTextBlockGroup(QTextBlockGroupPrivate &p, QTextDocument *doc);
0068 private:
0069     Q_DECLARE_PRIVATE(QTextBlockGroup)
0070     Q_DISABLE_COPY(QTextBlockGroup)
0071     friend class QTextDocumentPrivate;
0072 };
0073 
0074 class Q_GUI_EXPORT QTextFrameLayoutData {
0075 public:
0076     virtual ~QTextFrameLayoutData();
0077 };
0078 
0079 class QTextFramePrivate;
0080 class Q_GUI_EXPORT QTextFrame : public QTextObject
0081 {
0082     Q_OBJECT
0083 
0084 public:
0085     explicit QTextFrame(QTextDocument *doc);
0086     ~QTextFrame();
0087 
0088     inline void setFrameFormat(const QTextFrameFormat &format);
0089     QTextFrameFormat frameFormat() const { return QTextObject::format().toFrameFormat(); }
0090 
0091     QTextCursor firstCursorPosition() const;
0092     QTextCursor lastCursorPosition() const;
0093     int firstPosition() const;
0094     int lastPosition() const;
0095 
0096     QTextFrameLayoutData *layoutData() const;
0097     void setLayoutData(QTextFrameLayoutData *data);
0098 
0099     QList<QTextFrame *> childFrames() const;
0100     QTextFrame *parentFrame() const;
0101 
0102     class iterator {
0103         QTextFrame *f = nullptr;
0104         int b = 0;
0105         int e = 0;
0106         QTextFrame *cf = nullptr;
0107         int cb = 0;
0108 
0109         friend class QTextFrame;
0110         friend class QTextTableCell;
0111         friend class QTextDocumentLayoutPrivate;
0112         inline iterator(QTextFrame *frame, int block, int begin, int end)
0113             : f(frame), b(begin), e(end), cb(block)
0114         {}
0115     public:
0116         constexpr iterator() noexcept = default;
0117         QTextFrame *parentFrame() const { return f; }
0118 
0119         QTextFrame *currentFrame() const { return cf; }
0120         Q_GUI_EXPORT QTextBlock currentBlock() const;
0121 
0122         bool atEnd() const { return !cf && cb == e; }
0123 
0124         inline bool operator==(const iterator &o) const { return f == o.f && cf == o.cf && cb == o.cb; }
0125         inline bool operator!=(const iterator &o) const { return f != o.f || cf != o.cf || cb != o.cb; }
0126         Q_GUI_EXPORT iterator &operator++();
0127         inline iterator operator++(int) { iterator tmp = *this; operator++(); return tmp; }
0128         Q_GUI_EXPORT iterator &operator--();
0129         inline iterator operator--(int) { iterator tmp = *this; operator--(); return tmp; }
0130     };
0131 
0132     friend class iterator;
0133     // more Qt
0134     typedef iterator Iterator;
0135 
0136     iterator begin() const;
0137     iterator end() const;
0138 
0139 protected:
0140     QTextFrame(QTextFramePrivate &p, QTextDocument *doc);
0141 private:
0142     friend class QTextDocumentPrivate;
0143     Q_DECLARE_PRIVATE(QTextFrame)
0144     Q_DISABLE_COPY(QTextFrame)
0145 };
0146 Q_DECLARE_TYPEINFO(QTextFrame::iterator, Q_RELOCATABLE_TYPE);
0147 
0148 inline void QTextFrame::setFrameFormat(const QTextFrameFormat &aformat)
0149 { QTextObject::setFormat(aformat); }
0150 
0151 class Q_GUI_EXPORT QTextBlockUserData {
0152 public:
0153     virtual ~QTextBlockUserData();
0154 };
0155 
0156 class Q_GUI_EXPORT QTextBlock
0157 {
0158     friend class QSyntaxHighlighter;
0159 public:
0160     inline QTextBlock(QTextDocumentPrivate *priv, int b) : p(priv), n(b) {}
0161     inline QTextBlock() : p(nullptr), n(0) {}
0162     inline QTextBlock(const QTextBlock &o) : p(o.p), n(o.n) {}
0163     inline QTextBlock &operator=(const QTextBlock &o) { p = o.p; n = o.n; return *this; }
0164 
0165     bool isValid() const;
0166 
0167     inline bool operator==(const QTextBlock &o) const { return p == o.p && n == o.n; }
0168     inline bool operator!=(const QTextBlock &o) const { return p != o.p || n != o.n; }
0169     inline bool operator<(const QTextBlock &o) const { return position() < o.position(); }
0170 
0171     int position() const;
0172     int length() const;
0173     bool contains(int position) const;
0174 
0175     QTextLayout *layout() const;
0176     void clearLayout();
0177     QTextBlockFormat blockFormat() const;
0178     int blockFormatIndex() const;
0179     QTextCharFormat charFormat() const;
0180     int charFormatIndex() const;
0181 
0182     Qt::LayoutDirection textDirection() const;
0183 
0184     QString text() const;
0185 
0186     QList<QTextLayout::FormatRange> textFormats() const;
0187 
0188     const QTextDocument *document() const;
0189 
0190     QTextList *textList() const;
0191 
0192     QTextBlockUserData *userData() const;
0193     void setUserData(QTextBlockUserData *data);
0194 
0195     int userState() const;
0196     void setUserState(int state);
0197 
0198     int revision() const;
0199     void setRevision(int rev);
0200 
0201     bool isVisible() const;
0202     void setVisible(bool visible);
0203 
0204     int blockNumber() const;
0205     int firstLineNumber() const;
0206 
0207     void setLineCount(int count);
0208     int lineCount() const;
0209 
0210     class iterator {
0211         const QTextDocumentPrivate *p = nullptr;
0212         int b = 0;
0213         int e = 0;
0214         int n = 0;
0215         friend class QTextBlock;
0216         iterator(const QTextDocumentPrivate *priv, int begin, int end, int f)
0217             : p(priv), b(begin), e(end), n(f) {}
0218     public:
0219         constexpr iterator() = default;
0220 
0221         Q_GUI_EXPORT QTextFragment fragment() const;
0222 
0223         bool atEnd() const { return n == e; }
0224 
0225         inline bool operator==(const iterator &o) const { return p == o.p && n == o.n; }
0226         inline bool operator!=(const iterator &o) const { return p != o.p || n != o.n; }
0227         Q_GUI_EXPORT iterator &operator++();
0228         inline iterator operator++(int) { iterator tmp = *this; operator++(); return tmp; }
0229         Q_GUI_EXPORT iterator &operator--();
0230         inline iterator operator--(int) { iterator tmp = *this; operator--(); return tmp; }
0231     };
0232 
0233     // more Qt
0234     typedef iterator Iterator;
0235 
0236     iterator begin() const;
0237     iterator end() const;
0238 
0239     QTextBlock next() const;
0240     QTextBlock previous() const;
0241 
0242     inline int fragmentIndex() const { return n; }
0243 
0244 private:
0245     QTextDocumentPrivate *p;
0246     int n;
0247     friend class QTextDocumentPrivate;
0248     friend class QTextLayout;
0249 };
0250 
0251 Q_DECLARE_TYPEINFO(QTextBlock, Q_RELOCATABLE_TYPE);
0252 Q_DECLARE_TYPEINFO(QTextBlock::iterator, Q_RELOCATABLE_TYPE);
0253 
0254 
0255 class Q_GUI_EXPORT QTextFragment
0256 {
0257 public:
0258     inline QTextFragment(const QTextDocumentPrivate *priv, int f, int fe) : p(priv), n(f), ne(fe) {}
0259     inline QTextFragment() : p(nullptr), n(0), ne(0) {}
0260     inline QTextFragment(const QTextFragment &o) : p(o.p), n(o.n), ne(o.ne) {}
0261     inline QTextFragment &operator=(const QTextFragment &o) { p = o.p; n = o.n; ne = o.ne; return *this; }
0262 
0263     inline bool isValid() const { return p && n; }
0264 
0265     inline bool operator==(const QTextFragment &o) const { return p == o.p && n == o.n; }
0266     inline bool operator!=(const QTextFragment &o) const { return p != o.p || n != o.n; }
0267     inline bool operator<(const QTextFragment &o) const { return position() < o.position(); }
0268 
0269     int position() const;
0270     int length() const;
0271     bool contains(int position) const;
0272 
0273     QTextCharFormat charFormat() const;
0274     int charFormatIndex() const;
0275     QString text() const;
0276 
0277 #if !defined(QT_NO_RAWFONT)
0278     QList<QGlyphRun> glyphRuns(int from = -1, int length = -1) const;
0279 #endif
0280 
0281 private:
0282     const QTextDocumentPrivate *p;
0283     int n;
0284     int ne;
0285 };
0286 
0287 Q_DECLARE_TYPEINFO(QTextFragment, Q_RELOCATABLE_TYPE);
0288 
0289 QT_END_NAMESPACE
0290 
0291 #endif // QTEXTOBJECT_H