From f7476c80f61de0e7a0a1454d80e7d6808cb89593 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 19 Aug 2009 15:26:55 +0200 Subject: 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. --- src/gui/painting/qpainter.cpp | 19 +++++++++---------- 1 file 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; iitemCount; ++i) { QStaticTextItem *item = staticText_d->items + i; - d->extended->drawStaticTextItem(translatedPosition, item); + d->extended->drawStaticTextItem(transformedPosition, item); } if (restoreWhenFinished) -- cgit v0.12