diff options
author | Eskil Abrahamsen Blomfeldt <eblomfel@trolltech.com> | 2009-08-07 11:15:50 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-14 12:49:30 (GMT) |
commit | 4417f485dbaac79412d43ec403e56e7e2067e5ac (patch) | |
tree | 6bb9c818cd225f3aae5d7fb6e368aacb519d2016 /src/gui/painting | |
parent | c07a9073eaba1b065edb4148c03e0995df618545 (diff) | |
download | Qt-4417f485dbaac79412d43ec403e56e7e2067e5ac.zip Qt-4417f485dbaac79412d43ec403e56e7e2067e5ac.tar.gz Qt-4417f485dbaac79412d43ec403e56e7e2067e5ac.tar.bz2 |
Respect font settings of QStaticText and clip to maximum size
drawText() that renders into a QRect will clip the text (unless
otherwise set by the text flags passed to the function.) In
drawStaticText() we should do the same for identical behavior. We also
need to respect the font set on the QStaticText object.
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 1057893..83f66e2 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5728,11 +5728,30 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static if (!d->engine || staticText.isEmpty() || pen().style() == Qt::NoPen) return; - const QStaticTextPrivate *staticText_d = QStaticTextPrivate::get(&staticText); + const QStaticTextPrivate *staticText_d = QStaticTextPrivate::get(&staticText); + bool restoreWhenFinished = false; + + if (staticText_d->size.isValid()) { + setClipRect(QRectF(position, staticText_d->size)); + + save(); + restoreWhenFinished = true; + } + + if (font() != staticText_d->font) { + setFont(staticText_d->font); + + save(); + restoreWhenFinished = true; + } + for (int i=0; i<staticText_d->itemCount; ++i) { const QTextItemInt &gf = staticText_d->items[i]; d->engine->drawTextItem(staticText_d->itemPositions[i] + position, gf); } + + if (restoreWhenFinished) + restore(); } /*! |