summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-08-19 13:26:55 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-01-14 12:56:25 (GMT)
commitf7476c80f61de0e7a0a1454d80e7d6808cb89593 (patch)
tree0dd7bcc9fb9e652ea279929efdb1220059ce0d2b /src/gui/painting/qpainter.cpp
parent6ebcad8e355a3d076cf76a3d670c1abbf5e9b1c7 (diff)
downloadQt-f7476c80f61de0e7a0a1454d80e7d6808cb89593.zip
Qt-f7476c80f61de0e7a0a1454d80e7d6808cb89593.tar.gz
Qt-f7476c80f61de0e7a0a1454d80e7d6808cb89593.tar.bz2
Apply painter matrix to position in QPainter::drawStaticText()
We need to transform the position of the text in accordance with the painter's matrix. Also, use state->matrix directly instead of calling a function to get it.
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 4eace16..9ad19f0 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -5745,18 +5745,17 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
// Don't recalculate entire layout because of translation, rather add the dx and dy
// into the position to move each text item the correct distance.
- QPointF translatedPosition = position;
- QTransform matrix = d->state->transform();
- if (matrix.isTranslating()) {
- translatedPosition.rx() += matrix.dx();
- translatedPosition.ry() += matrix.dy();
- translate(-matrix.dx(), -matrix.dy());
- }
+ QPointF transformedPosition = position * d->state->matrix;
+ QTransform matrix = d->state->matrix;
+
+ // Already added in transformedPosition
+ if (d->state->matrix.isTranslating())
+ translate(-d->state->matrix.dx(), -d->state->matrix.dy());
// If the transform is not identical to the text transform,
// we have to relayout the text (for other transformations than plain translation)
- if (staticText_d->matrix != d->state->transform()) {
- staticText_d->matrix = d->state->transform();
+ if (staticText_d->matrix != d->state->matrix) {
+ staticText_d->matrix = d->state->matrix;
staticText_d->init();
}
@@ -5779,7 +5778,7 @@ void QPainter::drawStaticText(const QPointF &position, const QStaticText &static
for (int i=0; i<staticText_d->itemCount; ++i) {
QStaticTextItem *item = staticText_d->items + i;
- d->extended->drawStaticTextItem(translatedPosition, item);
+ d->extended->drawStaticTextItem(transformedPosition, item);
}
if (restoreWhenFinished)