summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-19 15:02:56 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-02-19 15:07:45 (GMT)
commitbbdee08472a0763ed9a60ce60f60ddb86bd946df (patch)
tree06591e9faf603682be0181b0e4609242951fe19a /src/gui
parent64158ff163a53ff97d8ae211b0bddaae346f0f7c (diff)
downloadQt-bbdee08472a0763ed9a60ce60f60ddb86bd946df.zip
Qt-bbdee08472a0763ed9a60ce60f60ddb86bd946df.tar.gz
Qt-bbdee08472a0763ed9a60ce60f60ddb86bd946df.tar.bz2
Fix fallback for QStaticText when it's unsupported in paint engine
When the paint engine does not support QStaticText, we fall back to regular drawText() calls. This fallback would previously paint all text to (0, 0). This fixes the qstatictext autotest on Linux. Reviewed-by: Olivier
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qpainter.cpp2
-rw-r--r--src/gui/text/qstatictext.cpp15
-rw-r--r--src/gui/text/qstatictext_p.h2
3 files changed, 11 insertions, 8 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 2cb6915..1b8b718 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5768,7 +5768,7 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
// If we don't have an extended paint engine, or if the painter is projected,
// we go through standard code path
if (d->extended == 0 || !d->state->matrix.isAffine()) {
- staticText_d->paintText(this);
+ staticText_d->paintText(position, this);
return;
}
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 7d4181c..a7138b9 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -530,7 +530,7 @@ namespace {
};
}
-void QStaticTextPrivate::paintText(QPainter *p)
+void QStaticTextPrivate::paintText(const QPointF &pos, QPainter *p)
{
bool preferRichText = textFormat == Qt::RichText
|| (textFormat == Qt::AutoText && Qt::mightBeRichText(text));
@@ -538,13 +538,13 @@ void QStaticTextPrivate::paintText(QPainter *p)
if (!preferRichText) {
if (maximumSize.isValid()) {
QRectF boundingRect;
- p->drawText(QRectF(QPointF(0, 0), maximumSize), Qt::TextWordWrap, text, &boundingRect);
+ p->drawText(QRectF(pos, maximumSize), Qt::TextWordWrap, text, &boundingRect);
actualSize = boundingRect.size();
needsClipRect = boundingRect.width() > maximumSize.width()
|| boundingRect.height() > maximumSize.height();
} else {
- p->drawText(0, 0, text);
+ p->drawText(pos, text);
needsClipRect = false;
QFontMetrics fm(font);
@@ -555,9 +555,12 @@ void QStaticTextPrivate::paintText(QPainter *p)
document.setDefaultFont(font);
document.setHtml(text);
- QRectF rect = maximumSize.isValid() ? QRectF(QPointF(0, 0), maximumSize) : QRectF();
+ QRectF rect = maximumSize.isValid() ? QRectF(pos, maximumSize) : QRectF();
document.adjustSize();
+ p->save();
+ p->translate(pos);
document.drawContents(p, rect);
+ p->restore();
actualSize = document.size();
needsClipRect = maximumSize.isValid()
&& (actualSize.width() > maximumSize.width()
@@ -581,7 +584,7 @@ void QStaticTextPrivate::init()
painter.setFont(font);
painter.setTransform(matrix);
- paintText(&painter);
+ paintText(QPointF(0, 0), &painter);
}
@@ -605,7 +608,7 @@ void QStaticTextPrivate::init()
painter.setFont(font);
painter.setTransform(matrix);
- paintText(&painter);
+ paintText(QPointF(0, 0), &painter);
}
}
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index 89483d8..e758244 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -116,7 +116,7 @@ public:
~QStaticTextPrivate();
void init();
- void paintText(QPainter *p);
+ void paintText(const QPointF &pos, QPainter *p);
QAtomicInt ref; // 4 bytes per text