summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-08-24 19:30:57 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-08-24 19:30:57 (GMT)
commit0ef3c9007ffca1184323614b7b4bf7d6f8565dbb (patch)
tree8be30083ab09e97dbc195a74248bd8c33e583018
parent822405119df96bb41e97177fec589eed3e476385 (diff)
parentdff4ae6a604838f20e92f3c15f476ea05bd38fec (diff)
downloadtk-0ef3c9007ffca1184323614b7b4bf7d6f8565dbb.zip
tk-0ef3c9007ffca1184323614b7b4bf7d6f8565dbb.tar.gz
tk-0ef3c9007ffca1184323614b7b4bf7d6f8565dbb.tar.bz2
polygon and closed polylines in canvas don't fully honor -joinstyle on Windows and OS X
-rw-r--r--macosx/tkMacOSXDraw.c10
-rw-r--r--win/tkWinDraw.c52
2 files changed, 59 insertions, 3 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 5ca8bfe..d1e67dc 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -858,6 +858,16 @@ XDrawLines(
CGContextAddLineToPoint(dc.context, prevx, prevy);
}
}
+ /*
+ * In the case of closed polylines, the first and last points
+ * are the same. We want miter or bevel join be rendered also
+ * at this point, this needs telling CoreGraphics that the
+ * path is closed.
+ */
+ if ((points[0].x == points[npoints-1].x) &&
+ (points[0].y == points[npoints-1].y)) {
+ CGContextClosePath(dc.context);
+ }
CGContextStrokePath(dc.context);
}
TkMacOSXRestoreDrawingContext(&dc);
diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c
index 1d17cc6..e13a5e5 100644
--- a/win/tkWinDraw.c
+++ b/win/tkWinDraw.c
@@ -741,6 +741,52 @@ XFillRectangles(
/*
*----------------------------------------------------------------------
*
+ * MakeAndStrokePath --
+ *
+ * This function draws a shape using a list of points, a stipple pattern,
+ * and the specified drawing function. It does it through creation of a
+ * so-called 'path' (see GDI documentation on MSDN).
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+MakeAndStrokePath(
+ HDC dc,
+ POINT *winPoints,
+ int npoints,
+ WinDrawFunc func) /* Name of the Windows GDI drawing function:
+ this is either Polyline or Polygon. */
+{
+ BeginPath(dc);
+ func(dc, winPoints, npoints);
+ /*
+ * In the case of closed polylines, the first and last points
+ * are the same. We want miter or bevel join be rendered also
+ * at this point, this needs telling the Windows GDI that the
+ * path is closed.
+ */
+ if (func == Polyline) {
+ if ((winPoints[0].x == winPoints[npoints-1].x) &&
+ (winPoints[0].y == winPoints[npoints-1].y)) {
+ CloseFigure(dc);
+ }
+ EndPath(dc);
+ StrokePath(dc);
+ } else {
+ EndPath(dc);
+ StrokeAndFillPath(dc);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* RenderObject --
*
* This function draws a shape using a list of points, a stipple pattern,
@@ -833,7 +879,7 @@ RenderObject(
SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE
: WINDING);
oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground));
- func(dcMem, winPoints, npoints);
+ MakeAndStrokePath(dcMem, winPoints, npoints, func);
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG);
/*
@@ -845,7 +891,7 @@ RenderObject(
if (gc->fill_style == FillOpaqueStippled) {
DeleteObject(SelectObject(dcMem,
CreateSolidBrush(gc->background)));
- func(dcMem, winPoints, npoints);
+ MakeAndStrokePath(dcMem, winPoints, npoints, func);
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0,
COPYBG);
}
@@ -861,7 +907,7 @@ RenderObject(
SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE
: WINDING);
- func(dc, winPoints, npoints);
+ MakeAndStrokePath(dc, winPoints, npoints, func);
SelectObject(dc, oldPen);
}
DeleteObject(SelectObject(dc, oldBrush));