diff options
author | stanton <stanton@noemail.net> | 1999-02-04 20:51:22 (GMT) |
---|---|---|
committer | stanton <stanton@noemail.net> | 1999-02-04 20:51:22 (GMT) |
commit | d2be735a92189a9129d386e4c6de42ee0ac4450a (patch) | |
tree | b53c5a0ea4d7da4d3f9b88a8b2f1212cd4ca3d74 /generic | |
parent | 634d136b76728ec51778d7f9180e7018e63d34d3 (diff) | |
download | tk-d2be735a92189a9129d386e4c6de42ee0ac4450a.zip tk-d2be735a92189a9129d386e4c6de42ee0ac4450a.tar.gz tk-d2be735a92189a9129d386e4c6de42ee0ac4450a.tar.bz2 |
* generic/tkCanvLine.c: Changed to treat zero width lines like
they have width 1 for purposes of selection. [Bug: 925]
FossilOrigin-Name: b2051e226008b17a182a65e68b1d88e447e753aa
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkCanvLine.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 20a9fb6..1c35de5 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvLine.c,v 1.2 1998/09/14 18:23:05 stanton Exp $ + * RCS: @(#) $Id: tkCanvLine.c,v 1.3 1999/02/04 20:51:23 stanton Exp $ */ #include <stdio.h> @@ -814,7 +814,7 @@ LineToPoint(canvas, itemPtr, pointPtr) double *coordPtr, *linePoints; double staticSpace[2*MAX_STATIC_POINTS]; double poly[10]; - double bestDist, dist; + double bestDist, dist, width; int numPoints, count; int changedMiterToBevel; /* Non-zero means that a mitered corner * had to be treated as beveled after all @@ -843,6 +843,11 @@ LineToPoint(canvas, itemPtr, pointPtr) linePoints = linePtr->coordPtr; } + width = (double) linePtr->width; + if (width < 1.0) { + width = 1.0; + } + /* * The overall idea is to iterate through all of the edges of * the line, computing a polygon for each edge and testing the @@ -863,7 +868,7 @@ LineToPoint(canvas, itemPtr, pointPtr) || ((linePtr->joinStyle == JoinRound) && (count != numPoints))) { dist = hypot(coordPtr[0] - pointPtr[0], coordPtr[1] - pointPtr[1]) - - linePtr->width/2.0; + - width/2.0; if (dist <= 0.0) { bestDist = 0.0; goto done; @@ -879,7 +884,7 @@ LineToPoint(canvas, itemPtr, pointPtr) */ if (count == numPoints) { - TkGetButtPoints(coordPtr+2, coordPtr, (double) linePtr->width, + TkGetButtPoints(coordPtr+2, coordPtr, width, linePtr->capStyle == CapProjecting, poly, poly+2); } else if ((linePtr->joinStyle == JoinMiter) && !changedMiterToBevel) { poly[0] = poly[6]; @@ -887,7 +892,7 @@ LineToPoint(canvas, itemPtr, pointPtr) poly[2] = poly[4]; poly[3] = poly[5]; } else { - TkGetButtPoints(coordPtr+2, coordPtr, (double) linePtr->width, 0, + TkGetButtPoints(coordPtr+2, coordPtr, width, 0, poly, poly+2); /* @@ -911,17 +916,17 @@ LineToPoint(canvas, itemPtr, pointPtr) } } if (count == 2) { - TkGetButtPoints(coordPtr, coordPtr+2, (double) linePtr->width, + TkGetButtPoints(coordPtr, coordPtr+2, width, linePtr->capStyle == CapProjecting, poly+4, poly+6); } else if (linePtr->joinStyle == JoinMiter) { if (TkGetMiterPoints(coordPtr, coordPtr+2, coordPtr+4, - (double) linePtr->width, poly+4, poly+6) == 0) { + width, poly+4, poly+6) == 0) { changedMiterToBevel = 1; - TkGetButtPoints(coordPtr, coordPtr+2, (double) linePtr->width, + TkGetButtPoints(coordPtr, coordPtr+2, width, 0, poly+4, poly+6); } } else { - TkGetButtPoints(coordPtr, coordPtr+2, (double) linePtr->width, 0, + TkGetButtPoints(coordPtr, coordPtr+2, width, 0, poly+4, poly+6); } poly[8] = poly[0]; @@ -942,7 +947,7 @@ LineToPoint(canvas, itemPtr, pointPtr) if (linePtr->capStyle == CapRound) { dist = hypot(coordPtr[0] - pointPtr[0], coordPtr[1] - pointPtr[1]) - - linePtr->width/2.0; + - width/2.0; if (dist <= 0.0) { bestDist = 0.0; goto done; @@ -1015,6 +1020,7 @@ LineToArea(canvas, itemPtr, rectPtr) LineItem *linePtr = (LineItem *) itemPtr; double staticSpace[2*MAX_STATIC_POINTS]; double *linePoints; + double width; int numPoints, result; /* @@ -1042,8 +1048,13 @@ LineToArea(canvas, itemPtr, rectPtr) * Check the segments of the line. */ + width = (double) linePtr->width; + if (width < 1.0) { + width = 1.0; + } + result = TkThickPolyLineToArea(linePoints, numPoints, - (double) linePtr->width, linePtr->capStyle, linePtr->joinStyle, + width, linePtr->capStyle, linePtr->joinStyle, rectPtr); if (result == 0) { goto done; |