| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:FDL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in a
|
|---|
| 14 | ** written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Free Documentation License
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Free
|
|---|
| 18 | ** Documentation License version 1.3 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file included in the packaging of this
|
|---|
| 20 | ** file.
|
|---|
| 21 | **
|
|---|
| 22 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 23 | ** Nokia at [email protected].
|
|---|
| 24 | ** $QT_END_LICENSE$
|
|---|
| 25 | **
|
|---|
| 26 | ****************************************************************************/
|
|---|
| 27 |
|
|---|
| 28 | /*!
|
|---|
| 29 | \page qt4-scribe.html
|
|---|
| 30 | \title The Scribe Classes
|
|---|
| 31 |
|
|---|
| 32 | \contentspage {What's New in Qt 4}{Home}
|
|---|
| 33 | \previouspage The Arthur Paint System
|
|---|
| 34 | \nextpage The Qt 4 Main Window Classes
|
|---|
| 35 |
|
|---|
| 36 | \keyword Scribe
|
|---|
| 37 |
|
|---|
| 38 | Scribe introduces a set of text layout classes to Qt 4. These classes
|
|---|
| 39 | replace the old rich text engine found in Qt 3, and provide new features
|
|---|
| 40 | for processing and laying out both plain and rich text.
|
|---|
| 41 |
|
|---|
| 42 | \tableofcontents
|
|---|
| 43 |
|
|---|
| 44 | For more details about how to use the Scribe classes, see the
|
|---|
| 45 | \l{richtext.html}{Rich Text Processing} document.
|
|---|
| 46 |
|
|---|
| 47 | \section1 Overview of Scribe
|
|---|
| 48 |
|
|---|
| 49 | Support for text rendering and layout in Qt 4 has been redesigned
|
|---|
| 50 | around a system that allows textual content to be represented in a more
|
|---|
| 51 | flexible way than was possible with Qt 3. Qt 4 also provides a more
|
|---|
| 52 | convenient programming interface for editing documents. These
|
|---|
| 53 | improvements are made available through a reimplementation of the
|
|---|
| 54 | existing text rendering engine, and the introduction of several new
|
|---|
| 55 | classes.
|
|---|
| 56 |
|
|---|
| 57 | The following sections provide a brief overview of the main concepts
|
|---|
| 58 | behind Scribe.
|
|---|
| 59 |
|
|---|
| 60 | \section2 The Document Interface
|
|---|
| 61 |
|
|---|
| 62 | Text documents are represented by the QTextDocument class, rather
|
|---|
| 63 | than by QString objects. Each QTextDocument object contains
|
|---|
| 64 | information about the document's internal representation, its
|
|---|
| 65 | structure, and keeps track of modifications to provide undo/redo
|
|---|
| 66 | facilities.
|
|---|
| 67 | This approach allows features such as layout management to be
|
|---|
| 68 | delegated to specialized classes, but also provides a focus for the
|
|---|
| 69 | framework.
|
|---|
| 70 |
|
|---|
| 71 | Documents are either converted from external sources or created from
|
|---|
| 72 | scratch using Qt. The creation process can done by an editor widget,
|
|---|
| 73 | such as QTextEdit, or by explicit calls to the Scribe API.
|
|---|
| 74 |
|
|---|
| 75 | Text documents can be accessed in two complementary ways: as a linear
|
|---|
| 76 | buffer for editors to use, and as an object hierarchy that is useful to
|
|---|
| 77 | layout engines.
|
|---|
| 78 | In the hierarchical document model, objects generally correspond to
|
|---|
| 79 | visual elements such as frames, tables, and lists. At a lower level,
|
|---|
| 80 | these elements describe properties such as the text style and alignment.
|
|---|
| 81 | The linear representation of the document is used for editing and
|
|---|
| 82 | manipulation of the document's contents.
|
|---|
| 83 |
|
|---|
| 84 | \section2 Document Structure
|
|---|
| 85 |
|
|---|
| 86 | Each document contains a root frame into which all other structural
|
|---|
| 87 | elements are placed. This frame contains other structural elements,
|
|---|
| 88 | including tables, text blocks, and other frames; these can be nested to
|
|---|
| 89 | an arbitrary depth.
|
|---|
| 90 |
|
|---|
| 91 | Frames provide logical separation between parts of the document, but
|
|---|
| 92 | also have properties that determine how they will appear when rendered.
|
|---|
| 93 | A table is a specialized type of frame that consists of a number of
|
|---|
| 94 | cells, arranged into rows and columns, each of which can contain
|
|---|
|
|---|