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 | |
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')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 21 | ||||
-rw-r--r-- | src/gui/text/qstatictext.cpp | 2 |
2 files changed, 22 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(); } /*! diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 5a8fd9b..70e1c47 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -455,6 +455,7 @@ void QStaticTextPrivate::init() DrawTextItemDevice counterDevice; { QPainter painter(&counterDevice); + painter.setFont(font); if (size.isValid()) painter.drawText(QRectF(QPointF(0, 0), size), text); @@ -475,6 +476,7 @@ void QStaticTextPrivate::init() glyphLayoutMemory, logClusterMemory); { QPainter painter(&recorderDevice); + painter.setFont(font); if (size.isValid()) painter.drawText(QRectF(QPointF(0, 0), size), text); |