summaryrefslogtreecommitdiffstats
path: root/generic/tkCanvPoly.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkCanvPoly.c')
-rw-r--r--generic/tkCanvPoly.c91
1 files changed, 45 insertions, 46 deletions
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index 3b6568e..8e21d4f 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkCanvPoly.c,v 1.6 2000/06/03 08:38:12 hobbs Exp $
+ * RCS: @(#) $Id: tkCanvPoly.c,v 1.7 2001/07/03 06:03:44 hobbs Exp $
*/
#include <stdio.h>
@@ -165,11 +165,11 @@ static Tk_ConfigSpec configSpecs[] = {
static void ComputePolygonBbox _ANSI_ARGS_((Tk_Canvas canvas,
PolygonItem *polyPtr));
static int ConfigurePolygon _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- Tcl_Obj *CONST argv[], int flags));
+ Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tcl_Obj *CONST objv[], int flags));
static int CreatePolygon _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, Tcl_Obj *CONST argv[]));
+ int objc, Tcl_Obj *CONST objv[]));
static void DeletePolygon _ANSI_ARGS_((Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display));
static void DisplayPolygon _ANSI_ARGS_((Tk_Canvas canvas,
@@ -180,7 +180,7 @@ static int GetPolygonIndex _ANSI_ARGS_((Tcl_Interp *interp,
Tcl_Obj *obj, int *indexPtr));
static int PolygonCoords _ANSI_ARGS_((Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- int argc, Tcl_Obj *CONST argv[]));
+ int objc, Tcl_Obj *CONST objv[]));
static void PolygonDeleteCoords _ANSI_ARGS_((Tk_Canvas canvas,
Tk_Item *itemPtr, int first, int last));
static void PolygonInsert _ANSI_ARGS_((Tk_Canvas canvas,
@@ -255,13 +255,13 @@ Tk_ItemType tkPolygonType = {
*/
static int
-CreatePolygon(interp, canvas, itemPtr, argc, argv)
+CreatePolygon(interp, canvas, itemPtr, objc, objv)
Tcl_Interp *interp; /* Interpreter for error reporting. */
Tk_Canvas canvas; /* Canvas to hold new item. */
Tk_Item *itemPtr; /* Record to hold new item; header
* has been initialized by caller. */
- int argc; /* Number of arguments in argv. */
- Tcl_Obj *CONST argv[]; /* Arguments describing polygon. */
+ int objc; /* Number of arguments in objv. */
+ Tcl_Obj *CONST objv[]; /* Arguments describing polygon. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
int i;
@@ -296,18 +296,17 @@ CreatePolygon(interp, canvas, itemPtr, argc, argv)
* start with a digit or a minus sign followed by a digit.
*/
- for (i = 0; i < argc; i++) {
- char *arg = Tcl_GetStringFromObj((Tcl_Obj *) argv[i], NULL);
- if ((arg[0] == '-') && (arg[1] >= 'a')
- && (arg[1] <= 'z')) {
+ for (i = 0; i < objc; i++) {
+ char *arg = Tcl_GetString(objv[i]);
+ if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) {
break;
}
}
- if (i && PolygonCoords(interp, canvas, itemPtr, i, argv) != TCL_OK) {
+ if (i && PolygonCoords(interp, canvas, itemPtr, i, objv) != TCL_OK) {
goto error;
}
- if (ConfigurePolygon(interp, canvas, itemPtr, argc-i, argv+i, 0)
+ if (ConfigurePolygon(interp, canvas, itemPtr, objc-i, objv+i, 0)
== TCL_OK) {
return TCL_OK;
}
@@ -336,20 +335,20 @@ CreatePolygon(interp, canvas, itemPtr, argc, argv)
*/
static int
-PolygonCoords(interp, canvas, itemPtr, argc, argv)
+PolygonCoords(interp, canvas, itemPtr, objc, objv)
Tcl_Interp *interp; /* Used for error reporting. */
Tk_Canvas canvas; /* Canvas containing item. */
Tk_Item *itemPtr; /* Item whose coordinates are to be
* read or modified. */
- int argc; /* Number of coordinates supplied in
- * argv. */
- Tcl_Obj *CONST argv[]; /* Array of coordinates: x1, y1,
+ int objc; /* Number of coordinates supplied in
+ * objv. */
+ Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1,
* x2, y2, ... */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
int i, numPoints;
- if (argc == 0) {
+ if (objc == 0) {
/*
* Print the coords used to create the polygon. If we auto
* closed the polygon then we don't report the last point.
@@ -362,19 +361,19 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv)
Tcl_SetObjResult(interp, obj);
return TCL_OK;
}
- if (argc == 1) {
- if (Tcl_ListObjGetElements(interp, argv[0], &argc,
- (Tcl_Obj ***) &argv) != TCL_OK) {
+ if (objc == 1) {
+ if (Tcl_ListObjGetElements(interp, objv[0], &objc,
+ (Tcl_Obj ***) &objv) != TCL_OK) {
return TCL_ERROR;
}
}
- if (argc & 1) {
+ if (objc & 1) {
Tcl_AppendResult(interp,
"odd number of coordinates specified for polygon",
(char *) NULL);
return TCL_ERROR;
} else {
- numPoints = argc/2;
+ numPoints = objc/2;
if (polyPtr->pointsAllocated <= numPoints) {
if (polyPtr->coordPtr != NULL) {
ckfree((char *) polyPtr->coordPtr);
@@ -386,11 +385,11 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv)
*/
polyPtr->coordPtr = (double *) ckalloc((unsigned)
- (sizeof(double) * (argc+2)));
+ (sizeof(double) * (objc+2)));
polyPtr->pointsAllocated = numPoints+1;
}
- for (i = argc-1; i >= 0; i--) {
- if (Tk_CanvasGetCoordFromObj(interp, canvas, argv[i],
+ for (i = objc-1; i >= 0; i--) {
+ if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[i],
&polyPtr->coordPtr[i]) != TCL_OK) {
return TCL_ERROR;
}
@@ -402,12 +401,12 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv)
* Close the polygon if it isn't already closed.
*/
- if (argc>2 && ((polyPtr->coordPtr[argc-2] != polyPtr->coordPtr[0])
- || (polyPtr->coordPtr[argc-1] != polyPtr->coordPtr[1]))) {
+ if (objc>2 && ((polyPtr->coordPtr[objc-2] != polyPtr->coordPtr[0])
+ || (polyPtr->coordPtr[objc-1] != polyPtr->coordPtr[1]))) {
polyPtr->autoClosed = 1;
polyPtr->numPoints++;
- polyPtr->coordPtr[argc] = polyPtr->coordPtr[0];
- polyPtr->coordPtr[argc+1] = polyPtr->coordPtr[1];
+ polyPtr->coordPtr[objc] = polyPtr->coordPtr[0];
+ polyPtr->coordPtr[objc+1] = polyPtr->coordPtr[1];
}
ComputePolygonBbox(canvas, polyPtr);
}
@@ -434,12 +433,12 @@ PolygonCoords(interp, canvas, itemPtr, argc, argv)
*/
static int
-ConfigurePolygon(interp, canvas, itemPtr, argc, argv, flags)
+ConfigurePolygon(interp, canvas, itemPtr, objc, objv, flags)
Tcl_Interp *interp; /* Interpreter for error reporting. */
Tk_Canvas canvas; /* Canvas containing itemPtr. */
Tk_Item *itemPtr; /* Polygon item to reconfigure. */
- int argc; /* Number of elements in argv. */
- Tcl_Obj *CONST argv[]; /* Arguments describing things to configure. */
+ int objc; /* Number of elements in objv. */
+ Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */
int flags; /* Flags to pass to Tk_ConfigureWidget. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
@@ -452,7 +451,7 @@ ConfigurePolygon(interp, canvas, itemPtr, argc, argv, flags)
Tk_State state;
tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, (char **) argv,
+ if (Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, (char **) objv,
(char *) polyPtr, flags|TK_CONFIG_OBJS) != TCL_OK) {
return TCL_ERROR;
}
@@ -1022,7 +1021,7 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj)
Tcl_Obj *obj; /* New coordinates to be inserted. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- int length, argc, i;
+ int length, objc, i;
Tcl_Obj **objv;
double *new;
Tk_State state = itemPtr->state;
@@ -1031,18 +1030,18 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj)
state = ((TkCanvas *)canvas)->canvas_state;
}
- if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &argc, &objv) != TCL_OK)
- || !argc || argc&1) {
+ if (!obj || (Tcl_ListObjGetElements((Tcl_Interp *) NULL, obj, &objc, &objv) != TCL_OK)
+ || !objc || objc&1) {
return;
}
length = 2*(polyPtr->numPoints - polyPtr->autoClosed);
while(beforeThis>length) beforeThis-=length;
while(beforeThis<0) beforeThis+=length;
- new = (double *) ckalloc((unsigned)(sizeof(double) * (length + 2 + argc)));
+ new = (double *) ckalloc((unsigned)(sizeof(double) * (length + 2 + objc)));
for (i=0; i<beforeThis; i++) {
new[i] = polyPtr->coordPtr[i];
}
- for (i=0; i<argc; i++) {
+ for (i=0; i<objc; i++) {
if (Tcl_GetDoubleFromObj((Tcl_Interp *) NULL,objv[i],
new+(i+beforeThis))!=TCL_OK) {
ckfree((char *) new);
@@ -1051,10 +1050,10 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj)
}
for(i=beforeThis; i<length; i++) {
- new[i+argc] = polyPtr->coordPtr[i];
+ new[i+objc] = polyPtr->coordPtr[i];
}
if(polyPtr->coordPtr) ckfree((char *) polyPtr->coordPtr);
- length+=argc;
+ length+=objc;
polyPtr->coordPtr = new;
polyPtr->numPoints = (length/2) + polyPtr->autoClosed;
@@ -1078,7 +1077,7 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj)
new[length] = new[0];
new[length+1] = new[1];
- if (((length-argc)>3) && (state != TK_STATE_HIDDEN)) {
+ if (((length-objc)>3) && (state != TK_STATE_HIDDEN)) {
/*
* This is some optimizing code that will result that only the part
* of the polygon that changed (and the objects that are overlapping
@@ -1101,11 +1100,11 @@ PolygonInsert(canvas, itemPtr, beforeThis, obj)
itemPtr->x1 = itemPtr->x2 = (int) polyPtr->coordPtr[beforeThis];
itemPtr->y1 = itemPtr->y2 = (int) polyPtr->coordPtr[beforeThis+1];
- beforeThis-=2; argc+=4;
+ beforeThis-=2; objc+=4;
if(polyPtr->smooth) {
- beforeThis-=2; argc+=4;
+ beforeThis-=2; objc+=4;
} /* be carefull; beforeThis could now be negative */
- for(i=beforeThis; i<beforeThis+argc; i+=2) {
+ for(i=beforeThis; i<beforeThis+objc; i+=2) {
j=i;
if(j<0) j+=length;
if(j>=length) j-=length;