diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2011-01-28 11:58:10 +1000 |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2011-01-28 14:12:00 +1000 |
commit | 7c1ab9b6a8e1b3d64c08a4f5067448884b068945 (patch) | |
tree | 2b3d3f787f42e2558e8f26475c2114e6d4b28704 /src/gui/text/qtextdocumentlayout.cpp | |
parent | 64c0ee4e5f1f05105ab6168ebb4cb188e8fd838f (diff) | |
download | qt4-tools-7c1ab9b6a8e1b3d64c08a4f5067448884b068945.tar.gz |
Add support for line spacing in Text element.
This change adds the lineHeight and lineHeightMode properties.
Task-number: QTBUG-14296
Reviewed-by: Martin Jones
Diffstat (limited to 'src/gui/text/qtextdocumentlayout.cpp')
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index d721c91d90..c1c3768585 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -513,6 +513,9 @@ public: qreal scaleToDevice(qreal value) const; QFixed scaleToDevice(QFixed value) const; + + qreal lineH; + QTextDocumentLayout::LineHeightMode lineHeightMode; }; QTextDocumentLayoutPrivate::QTextDocumentLayoutPrivate() @@ -520,7 +523,9 @@ QTextDocumentLayoutPrivate::QTextDocumentLayoutPrivate() cursorWidth(1), currentLazyLayoutPosition(-1), lazyLayoutStepSize(1000), - lastPageCount(-1) + lastPageCount(-1), + lineH(1), + lineHeightMode(QTextDocumentLayout::MultiplyHeight) { showLayoutProgress = true; insideDocumentChange = false; @@ -2639,7 +2644,8 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi } - QFixed lineHeight = QFixed::fromReal(line.height()); + QFixed lineHeight = (lineHeightMode == QTextDocumentLayout::PixelHeight) ? QFixed::fromReal(lineH) : QFixed::fromReal(line.height() * lineH); + if (layoutStruct->pageHeight > 0 && layoutStruct->absoluteY() + lineHeight > layoutStruct->pageBottom) { layoutStruct->newPage(); @@ -2714,6 +2720,13 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi } } +void QTextDocumentLayout::setLineHeight(qreal lineH, QTextDocumentLayout::LineHeightMode mode = QTextDocumentLayout::MultiplyHeight) +{ + Q_D(QTextDocumentLayout); + d->lineH = lineH; + d->lineHeightMode = mode; +} + void QTextDocumentLayoutPrivate::floatMargins(const QFixed &y, const QTextLayoutStruct *layoutStruct, QFixed *left, QFixed *right) const { |