summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextobject.h
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit38be0d13830efd2d98281c645c3a60afe05ffece (patch)
tree6ea73f3ec77f7d153333779883e8120f82820abe /src/gui/text/qtextobject.h
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to 'src/gui/text/qtextobject.h')
-rw-r--r--src/gui/text/qtextobject.h335
1 files changed, 335 insertions, 0 deletions
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
new file mode 100644
index 0000000000..ad8e6579dc
--- /dev/null
+++ b/src/gui/text/qtextobject.h
@@ -0,0 +1,335 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTOBJECT_H
+#define QTEXTOBJECT_H
+
+#include <QtCore/qobject.h>
+#include <QtGui/qtextformat.h>
+#include <QtGui/qglyphs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QTextObjectPrivate;
+class QTextDocument;
+class QTextDocumentPrivate;
+class QTextCursor;
+class QTextBlock;
+class QTextFragment;
+class QTextLayout;
+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();
+ iterator(const iterator &o);
+ iterator &operator=(const iterator &o);
+
+ 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(0), 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;
+
+ 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(0), b(0), e(0), n(0) {}
+ iterator(const iterator &o) : p(o.p), b(o.b), e(o.e), n(o.n) {}
+
+ 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(0), 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<QGlyphs> glyphs() const;
+#endif
+
+private:
+ const QTextDocumentPrivate *p;
+ int n;
+ int ne;
+};
+
+Q_DECLARE_TYPEINFO(QTextFragment, Q_MOVABLE_TYPE);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTEXTOBJECT_H