From 2df18ac4dd17f8630f1ea0f6dc2415aca53d931a Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Fri, 26 Jun 2009 11:03:45 +0200 Subject: Fixed cap and join styles when printing to native Windows printers. Line and polygon strokes did not respect the join/cap styles set on a painter. Task-number: 256914 Reviewed-by: Samuel --- src/gui/painting/qprintengine_win.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index 179927f..77b82f8 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -862,7 +862,25 @@ void QWin32PrintEnginePrivate::fillPath_dev(const QPainterPath &path, const QCol void QWin32PrintEnginePrivate::strokePath_dev(const QPainterPath &path, const QColor &color, qreal penWidth) { composeGdiPath(path); - HPEN pen = CreatePen(PS_SOLID, qRound(penWidth), RGB(color.red(), color.green(), color.blue())); + LOGBRUSH brush; + brush.lbStyle = BS_SOLID; + brush.lbColor = RGB(color.red(), color.green(), color.blue()); + DWORD capStyle = PS_ENDCAP_SQUARE; + DWORD joinStyle = PS_JOIN_BEVEL; + if (pen.capStyle() == Qt::FlatCap) + capStyle = PS_ENDCAP_FLAT; + else if (pen.capStyle() == Qt::RoundCap) + capStyle = PS_ENDCAP_ROUND; + + if (pen.joinStyle() == Qt::MiterJoin) + joinStyle = PS_JOIN_MITER; + else if (pen.joinStyle() == Qt::RoundJoin) + joinStyle = PS_JOIN_ROUND; + + HPEN pen = ExtCreatePen(((penWidth == 0) ? PS_COSMETIC : PS_GEOMETRIC) + | PS_SOLID | capStyle | joinStyle, + penWidth, &brush, 0, 0); + HGDIOBJ old_pen = SelectObject(hdc, pen); StrokePath(hdc); DeleteObject(SelectObject(hdc, old_pen)); -- cgit v0.12