diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-18 14:26:19 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-01-18 14:26:19 (GMT) |
commit | 0b830897c6256b26289c912e28257d040e9c1b4c (patch) | |
tree | 909768c49098b9b129e92d585da70a4cee05c321 /src/gui/painting/qpaintbuffer.cpp | |
parent | c2337d7f1d3b4239c21809d664cc60009d08449c (diff) | |
download | Qt-0b830897c6256b26289c912e28257d040e9c1b4c.zip Qt-0b830897c6256b26289c912e28257d040e9c1b4c.tar.gz Qt-0b830897c6256b26289c912e28257d040e9c1b4c.tar.bz2 |
Implement QPaintBufferEngine::drawStaticTextItem()
Make QPaintEngineEx::drawStaticTextItem() pure virtual to make sure
it's implemented in all engines, and implement the paint buffer version
to make gui compile.
Diffstat (limited to 'src/gui/painting/qpaintbuffer.cpp')
-rw-r--r-- | src/gui/painting/qpaintbuffer.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 2344c04..e0067b0 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -45,6 +45,7 @@ #include <private/qfontengine_p.h> #include <private/qemulationpaintengine_p.h> #include <private/qimage_p.h> +#include <private/qstatictext_p.h> #include <QDebug> @@ -960,6 +961,30 @@ void QPaintBufferEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con buffer->updateBoundingRect(r); } +void QPaintBufferEngine::drawStaticTextItem(QStaticTextItem *staticTextItem) +{ + QString text = QString(staticTextItem->chars, staticTextItem->numChars); + + QFontDef fontDef = staticTextItem->fontEngine->fontDef; + QFont font(fontDef.family, fontDef.pointSize, fontDef.weight, fontDef.style == QFont::StyleItalic); + + QTransform xform; + for (int i=buffer->commands.size()-1; i>=0; --i) { + const QPaintBufferCommand &cmd = buffer->commands.at(i); + if (cmd.id == QPaintBufferPrivate::Cmd_SetTransform) { + xform = qVariantValue<QTransform>(buffer->variants.at(cmd.offset)); + break; + } + } + + QStaticText staticText(text); + staticText.prepare(xform, font); + + QVariantList variants; + variants << QVariant(font) << QVariant::fromValue(staticText); + buffer->addCommand(QPaintBufferPrivate::Cmd_DrawStaticText, QVariant(variants)); +} + void QPaintBufferEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) { #ifdef QPAINTBUFFER_DEBUG_DRAW @@ -1425,6 +1450,18 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) #endif painter->setClipRegion(region, Qt::ClipOperation(cmd.extra)); break; } + + case QPaintBufferPrivate::Cmd_DrawStaticText: { + + QVariantList variants(d->variants.at(cmd.offset).value<QVariantList>()); + + QFont font(variants.at(0).value<QFont>()); + QStaticText text(variants.at(0).value<QStaticText>()); + + painter->setFont(font); + painter->drawStaticText(QPointF(0, 0), text); + + break; } case QPaintBufferPrivate::Cmd_DrawText: { QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); |