summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Zelenkovsky <Dmitry.Zelenkovskiy@nokia.com>2011-04-28 09:49:13 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-04-28 09:49:13 (GMT)
commitee9455ed2a83084692d969c398ecb91bcd4fc33a (patch)
treee5f5ffdef2bbd0e68b26a4f0e64977e29b5da537 /src
parentf0faf4011e1128ab5e58ce3912d379481f8320cb (diff)
downloadQt-ee9455ed2a83084692d969c398ecb91bcd4fc33a.zip
Qt-ee9455ed2a83084692d969c398ecb91bcd4fc33a.tar.gz
Qt-ee9455ed2a83084692d969c398ecb91bcd4fc33a.tar.bz2
Support more items for QTextCharFormat::VerticalAlignment enum for custom text objects.
* QTextCharFormat::AlignNormal - support text format descent, place text object bottom on (baseline - descent). * QTextCharFormat::AlignBottom - place text object bottom on baseline. * QTextCharFormat::AlignTop - Still not supported. * Any other vertical alignment is mapped QTextCharFormat::AlignBottom. Add new enum AlignBaseline for custom inline objects to take into account font baseline. Merge-request: 2578 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp13
-rw-r--r--src/gui/text/qtextformat.h3
2 files changed, 13 insertions, 3 deletions
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index ce157be..130f012 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -2996,10 +2996,19 @@ void QTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDo
QSizeF inlineSize = (pos == QTextFrameFormat::InFlow ? intrinsic : QSizeF(0, 0));
item.setWidth(inlineSize.width());
- if (f.verticalAlignment() == QTextCharFormat::AlignMiddle) {
+
+ QFontMetrics m(f.font());
+ switch (f.verticalAlignment())
+ {
+ case QTextCharFormat::AlignMiddle:
item.setDescent(inlineSize.height() / 2);
item.setAscent(inlineSize.height() / 2 - 1);
- } else {
+ break;
+ case QTextCharFormat::AlignBaseline:
+ item.setDescent(m.descent());
+ item.setAscent(inlineSize.height() - m.descent() - 1);
+ break;
+ default:
item.setDescent(0);
item.setAscent(inlineSize.height() - 1);
}
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index ff28eaa..4f4752a 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -378,7 +378,8 @@ public:
AlignSubScript,
AlignMiddle,
AlignTop,
- AlignBottom
+ AlignBottom,
+ AlignBaseline
};
enum UnderlineStyle { // keep in sync with Qt::PenStyle!
NoUnderline,