summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-18 14:26:19 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-18 14:26:19 (GMT)
commit0b830897c6256b26289c912e28257d040e9c1b4c (patch)
tree909768c49098b9b129e92d585da70a4cee05c321 /src
parentc2337d7f1d3b4239c21809d664cc60009d08449c (diff)
downloadQt-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')
-rw-r--r--src/gui/painting/qpaintbuffer.cpp37
-rw-r--r--src/gui/painting/qpaintbuffer_p.h2
-rw-r--r--src/gui/painting/qpaintengineex_p.h2
-rw-r--r--src/gui/text/qstatictext.h2
4 files changed, 42 insertions, 1 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));
diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h
index 79d7b35..41a26c5 100644
--- a/src/gui/painting/qpaintbuffer_p.h
+++ b/src/gui/painting/qpaintbuffer_p.h
@@ -175,6 +175,7 @@ public:
Cmd_DrawText,
Cmd_DrawTextItem,
+ Cmd_DrawStaticText,
Cmd_DrawImagePos,
Cmd_DrawImageRect,
@@ -394,6 +395,7 @@ public:
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
virtual void drawTextItem(const QPointF &pos, const QTextItem &ti);
+ virtual void drawStaticTextItem(QStaticTextItem *staticTextItem);
virtual void setState(QPainterState *s);
virtual uint flags() const {return QPaintEngineEx::DoNotEmulate;}
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 1370e82..90c4f9f 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -201,7 +201,7 @@ public:
virtual void updateState(const QPaintEngineState &state);
- virtual void drawStaticTextItem(QStaticTextItem *) { /* ### should be pure virtual ### */ };
+ virtual void drawStaticTextItem(QStaticTextItem *) = 0;
virtual void setState(QPainterState *s);
inline QPainterState *state() { return static_cast<QPainterState *>(QPaintEngine::state); }
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index e507d82..6c70816 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -85,6 +85,8 @@ private:
friend class QStaticTextPrivate;
};
+Q_DECLARE_METATYPE(QStaticText)
+
QT_END_NAMESPACE
QT_END_HEADER