summaryrefslogtreecommitdiffstats
path: root/src/gui/text
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/text
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/text')
-rw-r--r--src/gui/text/qstatictext.cpp15
-rw-r--r--src/gui/text/qstatictext_p.h2
2 files changed, 10 insertions, 7 deletions
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