summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvLine.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkCanvLine.c')
-rw-r--r--generic/tkCanvLine.c70
1 files changed, 30 insertions, 40 deletions
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index 1c35de5..131b73d 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -4,12 +4,13 @@
* This file implements line items for canvas widgets.
*
* Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 1998-1999 by Scriptics Corporation.
*
* 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.3 1999/02/04 20:51:23 stanton Exp $
+ * RCS: @(#) $Id: tkCanvLine.c,v 1.4 1999/04/16 01:51:11 stanton Exp $
*/
#include <stdio.h>
@@ -180,15 +181,6 @@ Tk_ItemType tkLineType = {
};
/*
- * The Tk_Uid's below refer to uids for the various arrow types:
- */
-
-static Tk_Uid noneUid = NULL;
-static Tk_Uid firstUid = NULL;
-static Tk_Uid lastUid = NULL;
-static Tk_Uid bothUid = NULL;
-
-/*
* The definition below determines how large are static arrays
* used to hold spline points (splines larger than this have to
* have their arrays malloc-ed).
@@ -207,7 +199,7 @@ static Tk_Uid bothUid = NULL;
* Results:
* A standard Tcl return value. If an error occurred in
* creating the item, then an error message is left in
- * interp->result; in this case itemPtr is left uninitialized,
+ * the interp's result; in this case itemPtr is left uninitialized,
* so it can be safely freed by the caller.
*
* Side effects:
@@ -252,13 +244,7 @@ CreateLine(interp, canvas, itemPtr, argc, argv)
linePtr->joinStyle = JoinRound;
linePtr->gc = None;
linePtr->arrowGC = None;
- if (noneUid == NULL) {
- noneUid = Tk_GetUid("none");
- firstUid = Tk_GetUid("first");
- lastUid = Tk_GetUid("last");
- bothUid = Tk_GetUid("both");
- }
- linePtr->arrow = noneUid;
+ linePtr->arrow = Tk_GetUid("none");
linePtr->arrowShapeA = (float)8.0;
linePtr->arrowShapeB = (float)10.0;
linePtr->arrowShapeC = (float)3.0;
@@ -302,7 +288,7 @@ CreateLine(interp, canvas, itemPtr, argc, argv)
* on what it does.
*
* Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
+ * Returns TCL_OK or TCL_ERROR, and sets the interp's result.
*
* Side effects:
* The coordinates for the given item may be changed.
@@ -385,7 +371,7 @@ LineCoords(interp, canvas, itemPtr, argc, argv)
ckfree((char *) linePtr->lastArrowPtr);
linePtr->lastArrowPtr = NULL;
}
- if (linePtr->arrow != noneUid) {
+ if (linePtr->arrow != Tk_GetUid("none")) {
ConfigureArrows(canvas, linePtr);
}
ComputeLineBbox(canvas, linePtr);
@@ -403,7 +389,7 @@ LineCoords(interp, canvas, itemPtr, argc, argv)
*
* Results:
* A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
+ * an error message is left in the interp's result.
*
* Side effects:
* Configuration information, such as colors and stipple
@@ -426,6 +412,10 @@ ConfigureLine(interp, canvas, itemPtr, argc, argv, flags)
GC newGC, arrowGC;
unsigned long mask;
Tk_Window tkwin;
+ Tk_Uid noneUid = Tk_GetUid("none");
+ Tk_Uid bothUid = Tk_GetUid("both");
+ Tk_Uid firstUid = Tk_GetUid("first");
+ Tk_Uid lastUid = Tk_GetUid("last");
tkwin = Tk_CanvasTkwin(canvas);
if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
@@ -493,8 +483,8 @@ ConfigureLine(interp, canvas, itemPtr, argc, argv, flags)
ckfree((char *) linePtr->firstArrowPtr);
linePtr->firstArrowPtr = NULL;
}
- if ((linePtr->lastArrowPtr != NULL) && (linePtr->arrow != lastUid)
- && (linePtr->arrow != bothUid)) {
+ if ((linePtr->lastArrowPtr != NULL) && (linePtr->arrow != lastUid)
+ && (linePtr->arrow != bothUid)) {
int i;
i = 2*(linePtr->numPoints-1);
@@ -505,7 +495,7 @@ ConfigureLine(interp, canvas, itemPtr, argc, argv, flags)
}
if (linePtr->arrow != noneUid) {
if ((linePtr->arrow != firstUid) && (linePtr->arrow != lastUid)
- && (linePtr->arrow != bothUid)) {
+ && (linePtr->arrow != bothUid)) {
Tcl_AppendResult(interp, "bad arrow spec \"",
linePtr->arrow, "\": must be none, first, last, or both",
(char *) NULL);
@@ -652,14 +642,14 @@ ComputeLineBbox(canvas, linePtr)
* Add in the sizes of arrowheads, if any.
*/
- if (linePtr->arrow != noneUid) {
- if (linePtr->arrow != lastUid) {
+ if (linePtr->arrow != Tk_GetUid("none")) {
+ if (linePtr->arrow != Tk_GetUid("last")) {
for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
i++, coordPtr += 2) {
TkIncludePoint((Tk_Item *) linePtr, coordPtr);
}
}
- if (linePtr->arrow != firstUid) {
+ if (linePtr->arrow != Tk_GetUid("first")) {
for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
i++, coordPtr += 2) {
TkIncludePoint((Tk_Item *) linePtr, coordPtr);
@@ -960,8 +950,8 @@ LineToPoint(canvas, itemPtr, pointPtr)
* If there are arrowheads, check the distance to the arrowheads.
*/
- if (linePtr->arrow != noneUid) {
- if (linePtr->arrow != lastUid) {
+ if (linePtr->arrow != Tk_GetUid("none")) {
+ if (linePtr->arrow != Tk_GetUid("last")) {
dist = TkPolygonToPoint(linePtr->firstArrowPtr, PTS_IN_ARROW,
pointPtr);
if (dist <= 0.0) {
@@ -971,7 +961,7 @@ LineToPoint(canvas, itemPtr, pointPtr)
bestDist = dist;
}
}
- if (linePtr->arrow != firstUid) {
+ if (linePtr->arrow != Tk_GetUid("first")) {
dist = TkPolygonToPoint(linePtr->lastArrowPtr, PTS_IN_ARROW,
pointPtr);
if (dist <= 0.0) {
@@ -1064,15 +1054,15 @@ LineToArea(canvas, itemPtr, rectPtr)
* Check arrowheads, if any.
*/
- if (linePtr->arrow != noneUid) {
- if (linePtr->arrow != lastUid) {
+ if (linePtr->arrow != Tk_GetUid("none")) {
+ if (linePtr->arrow != Tk_GetUid("last")) {
if (TkPolygonToArea(linePtr->firstArrowPtr, PTS_IN_ARROW,
rectPtr) != result) {
result = 0;
goto done;
}
}
- if (linePtr->arrow != firstUid) {
+ if (linePtr->arrow != Tk_GetUid("first")) {
if (TkPolygonToArea(linePtr->lastArrowPtr, PTS_IN_ARROW,
rectPtr) != result) {
result = 0;
@@ -1145,7 +1135,7 @@ ScaleLine(canvas, itemPtr, originX, originY, scaleX, scaleY)
coordPtr[0] = originX + scaleX*(*coordPtr - originX);
coordPtr[1] = originY + scaleY*(coordPtr[1] - originY);
}
- if (linePtr->arrow != noneUid) {
+ if (linePtr->arrow != Tk_GetUid("none")) {
ConfigureArrows(canvas, linePtr);
}
ComputeLineBbox(canvas, linePtr);
@@ -1366,7 +1356,7 @@ ConfigureArrows(canvas, linePtr)
fracHeight = (linePtr->width/2.0)/shapeC;
backup = fracHeight*shapeB + shapeA*(1.0 - fracHeight)/2.0;
- if (linePtr->arrow != lastUid) {
+ if (linePtr->arrow != Tk_GetUid("last")) {
poly = linePtr->firstArrowPtr;
if (poly == NULL) {
poly = (double *) ckalloc((unsigned)
@@ -1411,7 +1401,7 @@ ConfigureArrows(canvas, linePtr)
* Similar arrowhead calculation for the last point of the line.
*/
- if (linePtr->arrow != firstUid) {
+ if (linePtr->arrow != Tk_GetUid("first")) {
coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2);
poly = linePtr->lastArrowPtr;
if (poly == NULL) {
@@ -1460,7 +1450,7 @@ ConfigureArrows(canvas, linePtr)
* Results:
* The return value is a standard Tcl result. If an error
* occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
+ * left in the interp's result, replacing whatever used
* to be there. If no error occurs, then Postscript for the
* item is appended to the result.
*
@@ -1482,7 +1472,7 @@ LineToPostscript(interp, canvas, itemPtr, prepass)
* final Postscript is being created. */
{
LineItem *linePtr = (LineItem *) itemPtr;
- char buffer[200];
+ char buffer[64 + TCL_INTEGER_SPACE];
char *style;
if (linePtr->fg == NULL) {
@@ -1600,7 +1590,7 @@ LineToPostscript(interp, canvas, itemPtr, prepass)
* Results:
* The return value is a standard Tcl result. If an error
* occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
+ * left in the interp's result, replacing whatever used
* to be there. If no error occurs, then Postscript for the
* arrowhead is appended to the result.
*