summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvArc.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkCanvArc.c')
-rw-r--r--generic/tkCanvArc.c348
1 files changed, 257 insertions, 91 deletions
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index ccfe116..da40b99 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -3,8 +3,8 @@
*
* This file implements arc items for canvas widgets.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -14,6 +14,8 @@
#include "tkCanvas.h"
#include "default.h"
+#include "float.h"
+
/*
* The structure below defines the record for each arc item.
*/
@@ -63,6 +65,12 @@ typedef struct ArcItem {
* start (see ComputeArcOutline). */
double center2[2]; /* Coordinates of center of arc outline at
* start+extent (see ComputeArcOutline). */
+ double height; /* Distance from the arc's chord to its
+ * mid-point. */
+ double startPoint[2]; /* Start point of arc used when specifying
+ * height. */
+ double endPoint[2]; /* End point of arc used when specifying
+ * height. */
} ArcItem;
/*
@@ -78,11 +86,11 @@ typedef struct ArcItem {
* Information used for parsing configuration specs:
*/
-static int StyleParseProc(ClientData clientData, Tcl_Interp *interp,
+static int StyleParseProc(void *clientData, Tcl_Interp *interp,
Tk_Window tkwin, const char *value,
- char *widgRec, int offset);
-static const char * StylePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+ char *widgRec, Tcl_Size offset);
+static const char * StylePrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr);
static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
@@ -105,65 +113,67 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeDash),
+ NULL, offsetof(ArcItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(ArcItem, outline.activeWidth),
+ "0.0", offsetof(ArcItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.dash),
+ NULL, offsetof(ArcItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledDash),
+ NULL, offsetof(ArcItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(ArcItem, outline.disabledWidth),
+ "0.0", offsetof(ArcItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_DOUBLE, "-extent", NULL, NULL,
- "90", Tk_Offset(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "90", offsetof(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ {TK_CONFIG_DOUBLE, "-height", NULL, NULL,
+ 0, offsetof(ArcItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(ArcItem, tsoffset),
+ "0,0", offsetof(ArcItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- DEF_CANVITEM_OUTLINE, Tk_Offset(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(ArcItem, outline.tsoffset),
+ "0,0", offsetof(ArcItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-start", NULL, NULL,
- "0", Tk_Offset(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-style", NULL, NULL,
- NULL, Tk_Offset(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT,
+ NULL, offsetof(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT,
&styleOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT,
+ "1.0", offsetof(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT,
&pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -174,18 +184,19 @@ static const Tk_ConfigSpec configSpecs[] = {
static void ComputeArcBbox(Tk_Canvas canvas, ArcItem *arcPtr);
static int ConfigureArc(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
+static void ComputeArcParametersFromHeight(ArcItem *arcPtr);
static int CreateArc(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteArc(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayArc(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
static int ArcCoords(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static int ArcToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
static double ArcToPoint(Tk_Canvas canvas,
@@ -206,6 +217,8 @@ static int HorizLineToArc(double x1, double x2,
static int VertLineToArc(double x, double y1,
double y2, double rx, double ry,
double start, double extent);
+static void RotateArc(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
/*
* The structures below defines the arc item types by means of functions that
@@ -233,7 +246,8 @@ Tk_ItemType tkArcType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateArc, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -261,11 +275,11 @@ CreateArc(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing arc. */
{
ArcItem *arcPtr = (ArcItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -292,6 +306,7 @@ CreateArc(
arcPtr->disabledFillStipple = None;
arcPtr->style = PIESLICE_STYLE;
arcPtr->fillGC = NULL;
+ arcPtr->height = 0;
/*
* Process the arguments to fill in the item record.
@@ -339,7 +354,7 @@ ArcCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
ArcItem *arcPtr = (ArcItem *) itemPtr;
@@ -359,9 +374,9 @@ ArcCoords(
return TCL_ERROR;
} else if (objc != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 4, got %d", objc));
+ "wrong # coordinates: expected 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -375,11 +390,22 @@ ArcCoords(
&arcPtr->bbox[3]) != TCL_OK)) {
return TCL_ERROR;
}
+
+ /*
+ * Store bbox as start and end points so they can be used if either
+ * radius or height is specified.
+ */
+
+ arcPtr->startPoint[0] = arcPtr->bbox[0];
+ arcPtr->startPoint[1] = arcPtr->bbox[1];
+ arcPtr->endPoint[0] = arcPtr->bbox[2];
+ arcPtr->endPoint[1] = arcPtr->bbox[3];
+
ComputeArcBbox(canvas, arcPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 4, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", NULL);
+ "wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -409,7 +435,7 @@ ConfigureArc(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Arc item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -448,6 +474,22 @@ ConfigureArc(
itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT;
}
+ /*
+ * Override the start and extent if the height is given.
+ */
+
+ ComputeArcParametersFromHeight(arcPtr);
+
+ ComputeArcBbox(canvas, arcPtr);
+
+ i = (int) (arcPtr->start/360.0);
+ arcPtr->start -= i*360.0;
+ if (arcPtr->start < 0) {
+ arcPtr->start += 360.0;
+ }
+ i = (int) (arcPtr->extent/360.0);
+ arcPtr->extent -= i*360.0;
+
tsoffset = &arcPtr->outline.tsoffset;
flags = tsoffset->flags;
if (flags & TK_OFFSET_LEFT) {
@@ -465,15 +507,7 @@ ConfigureArc(
tsoffset->yoffset = (int) (arcPtr->bbox[2] + 0.5);
}
- i = (int) (arcPtr->start/360.0);
- arcPtr->start -= i*360.0;
- if (arcPtr->start < 0) {
- arcPtr->start += 360.0;
- }
- i = (int) (arcPtr->extent/360.0);
- arcPtr->extent -= i*360.0;
-
- mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(arcPtr->outline));
+ mask = (unsigned long)Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(arcPtr->outline));
if (mask) {
gcValues.cap_style = CapButt;
mask |= GCCapStyle;
@@ -560,6 +594,103 @@ ConfigureArc(
/*
*--------------------------------------------------------------
*
+ * ComputeArcParametersFromHeight --
+ *
+ * This function calculates the arc parameters given start-point,
+ * end-point and height (!= 0).
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The height parameter is set to 0 on exit.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+ComputeArcParametersFromHeight(
+ ArcItem* arcPtr)
+{
+ double chordLen, chordDir[2], chordCen[2], arcCen[2], d, radToDeg, radius;
+
+ /*
+ * Do nothing if no height has been specified.
+ */
+
+ if (arcPtr->height == 0)
+ return;
+
+ /*
+ * Calculate the chord length, return early if it is too small.
+ */
+
+ chordLen = hypot(arcPtr->endPoint[1] - arcPtr->startPoint[1],
+ arcPtr->startPoint[0] - arcPtr->endPoint[0]);
+
+ if (chordLen < DBL_EPSILON) {
+ arcPtr->start = arcPtr->extent = arcPtr->height = 0;
+ return;
+ }
+
+ chordDir[0] = (arcPtr->endPoint[0] - arcPtr->startPoint[0]) / chordLen;
+ chordDir[1] = (arcPtr->endPoint[1] - arcPtr->startPoint[1]) / chordLen;
+ chordCen[0] = (arcPtr->startPoint[0] + arcPtr->endPoint[0]) / 2;
+ chordCen[1] = (arcPtr->startPoint[1] + arcPtr->endPoint[1]) / 2;
+
+ /*
+ * Calculate the radius (assumes height != 0).
+ */
+
+ radius = (4*pow(arcPtr->height, 2) + pow(chordLen, 2))
+ / (8 * arcPtr->height);
+
+ /*
+ * The arc centre.
+ */
+
+ d = radius - arcPtr->height;
+ arcCen[0] = chordCen[0] - d * chordDir[1];
+ arcCen[1] = chordCen[1] + d * chordDir[0];
+
+ /*
+ * The arc start and span. Angles are negated because the coordinate
+ * system is left-handed.
+ */
+
+ radToDeg = 45 / atan(1);
+ arcPtr->start = atan2(arcCen[1] - arcPtr->startPoint[1],
+ arcPtr->startPoint[0] - arcCen[0]) * radToDeg;
+ arcPtr->extent = -2 * asin(chordLen / (2 * radius)) * radToDeg;
+
+ /*
+ * Handle spans > 180.
+ */
+
+ if (fabs(2 * arcPtr->height) > chordLen) {
+ arcPtr->extent = arcPtr->extent > 0 ? (360 - arcPtr->extent)
+ : -(360 + arcPtr->extent);
+ }
+
+ /*
+ * Create the bounding box.
+ */
+
+ arcPtr->bbox[0] = arcCen[0] - radius;
+ arcPtr->bbox[1] = arcCen[1] - radius;
+ arcPtr->bbox[2] = arcCen[0] + radius;
+ arcPtr->bbox[3] = arcCen[1] + radius;
+
+ /*
+ * Set the height to 0 so that itemcget -height returns 0.
+ */
+
+ arcPtr->height = 0;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* DeleteArc --
*
* This function is called to clean up the data structure associated with
@@ -1379,6 +1510,60 @@ ScaleArc(
/*
*--------------------------------------------------------------
*
+ * RotateArc --
+ *
+ * This function is called to rotate an arc by a given amount.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the arc is rotated by angleRad radians about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateArc(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ ArcItem *arcPtr = (ArcItem *) itemPtr;
+ double newX, newY, oldX, oldY;
+
+ /*
+ * Compute the centre of the box, then rotate that about the origin.
+ */
+
+ newX = oldX = (arcPtr->bbox[0] + arcPtr->bbox[2]) / 2.0;
+ newY = oldY = (arcPtr->bbox[1] + arcPtr->bbox[3]) / 2.0;
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &newX, &newY);
+
+ /*
+ * Apply the translation to the box.
+ */
+
+ arcPtr->bbox[0] += newX - oldX;
+ arcPtr->bbox[1] += newY - oldY;
+ arcPtr->bbox[2] += newX - oldX;
+ arcPtr->bbox[3] += newY - oldY;
+
+ /*
+ * TODO: update the arc endpoints?
+ */
+
+ ComputeArcBbox(canvas, arcPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslateArc --
*
* This function is called to move an arc by a given amount.
@@ -1891,32 +2076,28 @@ ArcToPostscript(
(arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2);
if (arcPtr->style != CHORD_STYLE) {
- Tcl_AppendToObj(psObj, "0 0 moveto ", -1);
+ Tcl_AppendToObj(psObj, "0 0 moveto ", TCL_INDEX_NONE);
}
Tcl_AppendPrintfToObj(psObj,
"0 0 1 %.15g %.15g arc closepath\nsetmatrix\n",
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->outline.gc != NULL) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
}
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
}
@@ -1935,13 +2116,11 @@ ArcToPostscript(
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->style != ARC_STYLE) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
if (arcPtr->style == CHORD_STYLE) {
@@ -1950,44 +2129,36 @@ ArcToPostscript(
} else {
Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
PIE_OUTLINE1_PTS);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) !=TCL_OK){
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
Tk_CanvasPsPath(interp, canvas,
arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
PIE_OUTLINE2_PTS);
}
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
}
}
@@ -2000,11 +2171,6 @@ ArcToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
@@ -2032,7 +2198,7 @@ StyleParseProc(
TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
int c;
size_t length;
@@ -2062,7 +2228,7 @@ StyleParseProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad -style option \"%s\": must be arc, chord, or pieslice",
value));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARC_STYLE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARC_STYLE", (char *)NULL);
*stylePtr = PIESLICE_STYLE;
return TCL_ERROR;
}
@@ -2093,7 +2259,7 @@ StylePrintProc(
TCL_UNUSED(void *), /* Ignored. */
TCL_UNUSED(Tk_Window), /* Ignored. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
+ Tcl_Size offset, /* Offset into item. */
TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */