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>
(cherry picked from commit ee9455ed2a83084692d969c398ecb91bcd4fc33a)
This commit is contained in:
Dmitry Zelenkovsky 2011-04-28 11:49:13 +02:00 committed by Eskil Abrahamsen Blomfeldt
parent 774527dd1e
commit f26c4ba80d
2 changed files with 13 additions and 3 deletions

View File

@ -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);
}

View File

@ -378,7 +378,8 @@ public:
AlignSubScript,
AlignMiddle,
AlignTop,
AlignBottom
AlignBottom,
AlignBaseline
};
enum UnderlineStyle { // keep in sync with Qt::PenStyle!
NoUnderline,