diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-12-21 13:23:21 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2009-12-21 13:28:34 (GMT) |
commit | 22573ddffc28135fba2dbb9eb2d50a76cae0a09c (patch) | |
tree | 0a41bfb51be7b861b5e66a4505730d01bf700a8a /src/gui/painting/qemulationpaintengine.cpp | |
parent | f0c5c37ad8c2497511564d8c52dd53b2503c97c4 (diff) | |
download | Qt-22573ddffc28135fba2dbb9eb2d50a76cae0a09c.zip Qt-22573ddffc28135fba2dbb9eb2d50a76cae0a09c.tar.gz Qt-22573ddffc28135fba2dbb9eb2d50a76cae0a09c.tar.bz2 |
Fixed gradients on text when coordinate mode != logical mode.
Task-number: QTBUG-6395
Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting/qemulationpaintengine.cpp')
-rw-r--r-- | src/gui/painting/qemulationpaintengine.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gui/painting/qemulationpaintengine.cpp b/src/gui/painting/qemulationpaintengine.cpp index 662b163..5bd3c71 100644 --- a/src/gui/painting/qemulationpaintengine.cpp +++ b/src/gui/painting/qemulationpaintengine.cpp @@ -172,6 +172,36 @@ void QEmulationPaintEngine::drawTextItem(const QPointF &p, const QTextItem &text QRectF rect(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); fillBGRect(rect); } + + QPainterState *s = state(); + Qt::BrushStyle style = qbrush_style(s->pen.brush()); + if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) + { + QPen savedPen = s->pen; + QGradient g = *s->pen.brush().gradient(); + + if (g.coordinateMode() > QGradient::LogicalMode) { + QTransform mat = s->pen.brush().transform(); + if (g.coordinateMode() == QGradient::StretchToDeviceMode) { + mat.scale(real_engine->painter()->device()->width(), real_engine->painter()->device()->height()); + } else if (g.coordinateMode() == QGradient::ObjectBoundingMode) { + const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem); + QRectF r(p.x(), p.y() - ti.ascent.toReal(), ti.width.toReal(), (ti.ascent + ti.descent + 1).toReal()); + mat.translate(r.x(), r.y()); + mat.scale(r.width(), r.height()); + } + g.setCoordinateMode(QGradient::LogicalMode); + QBrush brush(g); + brush.setTransform(mat); + s->pen.setBrush(brush); + penChanged(); + real_engine->drawTextItem(p, textItem); + s->pen = savedPen; + penChanged(); + return; + } + } + real_engine->drawTextItem(p, textItem); } |