diff options
Diffstat (limited to 'generic/tkRectOval.c')
-rw-r--r-- | generic/tkRectOval.c | 808 |
1 files changed, 405 insertions, 403 deletions
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index b7ab331..c9cd7cb 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -1,20 +1,17 @@ -/* +/* * tkRectOval.c -- * - * This file implements rectangle and oval items for canvas - * widgets. + * This file implements rectangle and oval items for canvas widgets. * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 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. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include <stdio.h> -#include "tk.h" #include "tkInt.h" -#include "tkPort.h" #include "tkCanvas.h" /* @@ -23,18 +20,22 @@ typedef struct RectOvalItem { Tk_Item header; /* Generic stuff that's the same for all - * types. MUST BE FIRST IN STRUCTURE. */ + * types. MUST BE FIRST IN STRUCTURE. */ Tk_Outline outline; /* Outline structure */ double bbox[4]; /* Coordinates of bounding box for rectangle - * or oval (x1, y1, x2, y2). Item includes - * x1 and x2 but not y1 and y2. */ + * or oval (x1, y1, x2, y2). Item includes x1 + * and x2 but not y1 and y2. */ Tk_TSOffset tsoffset; XColor *fillColor; /* Color for filling rectangle/oval. */ - XColor *activeFillColor; /* Color for filling rectangle/oval if state is active. */ - XColor *disabledFillColor; /* Color for filling rectangle/oval if state is disabled. */ + XColor *activeFillColor; /* Color for filling rectangle/oval if state + * is active. */ + XColor *disabledFillColor; /* Color for filling rectangle/oval if state + * is disabled. */ Pixmap fillStipple; /* Stipple bitmap for filling item. */ - Pixmap activeFillStipple; /* Stipple bitmap for filling item if state is active. */ - Pixmap disabledFillStipple; /* Stipple bitmap for filling item if state is disabled. */ + Pixmap activeFillStipple; /* Stipple bitmap for filling item if state is + * active. */ + Pixmap disabledFillStipple; /* Stipple bitmap for filling item if state is + * disabled. */ GC fillGC; /* Graphics context for filling item. */ } RectOvalItem; @@ -64,160 +65,150 @@ static Tk_CustomOption pixelOption = { }; static Tk_ConfigSpec configSpecs[] = { - {TK_CONFIG_CUSTOM, "-activedash", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.activeDash), + {TK_CONFIG_CUSTOM, "-activedash", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.activeDash), TK_CONFIG_NULL_OK, &dashOption}, - {TK_CONFIG_COLOR, "-activefill", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, activeFillColor), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_COLOR, "-activeoutline", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.activeColor), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_BITMAP, "-activeoutlinestipple", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.activeStipple), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_BITMAP, "-activestipple", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, activeFillStipple), + {TK_CONFIG_COLOR, "-activefill", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, activeFillColor), TK_CONFIG_NULL_OK}, + {TK_CONFIG_COLOR, "-activeoutline", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.activeColor), TK_CONFIG_NULL_OK}, + {TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.activeStipple), TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-activewidth", (char *) NULL, (char *) NULL, + {TK_CONFIG_BITMAP, "-activestipple", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, activeFillStipple), TK_CONFIG_NULL_OK}, + {TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL, "0.0", Tk_Offset(RectOvalItem, outline.activeWidth), TK_CONFIG_DONT_SET_DEFAULT, &pixelOption}, - {TK_CONFIG_CUSTOM, "-dash", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.dash), + {TK_CONFIG_CUSTOM, "-dash", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.dash), TK_CONFIG_NULL_OK, &dashOption}, - {TK_CONFIG_PIXELS, "-dashoffset", (char *) NULL, (char *) NULL, + {TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL, "0", Tk_Offset(RectOvalItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT}, - {TK_CONFIG_CUSTOM, "-disableddash", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.disabledDash), + {TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.disabledDash), TK_CONFIG_NULL_OK, &dashOption}, - {TK_CONFIG_COLOR, "-disabledfill", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, disabledFillColor), + {TK_CONFIG_COLOR, "-disabledfill", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, disabledFillColor), TK_CONFIG_NULL_OK}, + {TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.disabledColor), TK_CONFIG_NULL_OK}, - {TK_CONFIG_COLOR, "-disabledoutline", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.disabledColor), + {TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.disabledStipple), TK_CONFIG_NULL_OK}, - {TK_CONFIG_BITMAP, "-disabledoutlinestipple", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.disabledStipple), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_BITMAP, "-disabledstipple", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, disabledFillStipple), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_PIXELS, "-disabledwidth", (char *) NULL, (char *) NULL, + {TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, disabledFillStipple), TK_CONFIG_NULL_OK}, + {TK_CONFIG_PIXELS, "-disabledwidth", NULL, NULL, "0.0", Tk_Offset(RectOvalItem, outline.disabledWidth), TK_CONFIG_DONT_SET_DEFAULT, &pixelOption}, - {TK_CONFIG_COLOR, "-fill", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, fillColor), TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-offset", (char *) NULL, (char *) NULL, + {TK_CONFIG_COLOR, "-fill", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, fillColor), TK_CONFIG_NULL_OK}, + {TK_CONFIG_CUSTOM, "-offset", NULL, NULL, "0,0", Tk_Offset(RectOvalItem, tsoffset), TK_CONFIG_DONT_SET_DEFAULT, &offsetOption}, - {TK_CONFIG_COLOR, "-outline", (char *) NULL, (char *) NULL, + {TK_CONFIG_COLOR, "-outline", NULL, NULL, "black", Tk_Offset(RectOvalItem, outline.color), TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-outlineoffset", (char *) NULL, (char *) NULL, + {TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL, "0,0", Tk_Offset(RectOvalItem, outline.tsoffset), TK_CONFIG_DONT_SET_DEFAULT, &offsetOption}, - {TK_CONFIG_BITMAP, "-outlinestipple", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, outline.stipple), - TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-state", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(Tk_Item, state),TK_CONFIG_NULL_OK, - &stateOption}, - {TK_CONFIG_BITMAP, "-stipple", (char *) NULL, (char *) NULL, - (char *) NULL, Tk_Offset(RectOvalItem, fillStipple), TK_CONFIG_NULL_OK}, - {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL, - (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption}, - {TK_CONFIG_CUSTOM, "-width", (char *) NULL, (char *) NULL, + {TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, outline.stipple), TK_CONFIG_NULL_OK}, + {TK_CONFIG_CUSTOM, "-state", NULL, NULL, + NULL, Tk_Offset(Tk_Item, state),TK_CONFIG_NULL_OK, &stateOption}, + {TK_CONFIG_BITMAP, "-stipple", NULL, NULL, + NULL, Tk_Offset(RectOvalItem, fillStipple),TK_CONFIG_NULL_OK}, + {TK_CONFIG_CUSTOM, "-tags", NULL, NULL, + NULL, 0, TK_CONFIG_NULL_OK, &tagsOption}, + {TK_CONFIG_CUSTOM, "-width", NULL, NULL, "1.0", Tk_Offset(RectOvalItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT, &pixelOption}, - {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL, - (char *) NULL, 0, 0} + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} }; /* - * Prototypes for procedures defined in this file: + * Prototypes for functions defined in this file: */ -static void ComputeRectOvalBbox _ANSI_ARGS_((Tk_Canvas canvas, - RectOvalItem *rectOvalPtr)); -static int ConfigureRectOval _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int objc, - Tcl_Obj *CONST objv[], int flags)); -static int CreateRectOval _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, struct Tk_Item *itemPtr, - int objc, Tcl_Obj *CONST objv[])); -static void DeleteRectOval _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, Display *display)); -static void DisplayRectOval _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, Display *display, Drawable dst, - int x, int y, int width, int height)); -static int OvalToArea _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, double *areaPtr)); -static double OvalToPoint _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, double *pointPtr)); -static int RectOvalCoords _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int objc, - Tcl_Obj *CONST objv[])); -static int RectOvalToPostscript _ANSI_ARGS_((Tcl_Interp *interp, - Tk_Canvas canvas, Tk_Item *itemPtr, int prepass)); -static int RectToArea _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, double *areaPtr)); -static double RectToPoint _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, double *pointPtr)); -static void ScaleRectOval _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, double originX, double originY, - double scaleX, double scaleY)); -static void TranslateRectOval _ANSI_ARGS_((Tk_Canvas canvas, - Tk_Item *itemPtr, double deltaX, double deltaY)); +static void ComputeRectOvalBbox(Tk_Canvas canvas, + RectOvalItem *rectOvalPtr); +static int ConfigureRectOval(Tcl_Interp *interp, Tk_Canvas canvas, + Tk_Item *itemPtr, int objc, Tcl_Obj *CONST objv[], + int flags); +static int CreateRectOval(Tcl_Interp *interp, Tk_Canvas canvas, + Tk_Item *itemPtr, int objc, Tcl_Obj *CONST objv[]); +static void DeleteRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, + Display *display); +static void DisplayRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, + Display *display, Drawable dst, int x, int y, + int width, int height); +static int OvalToArea(Tk_Canvas canvas, Tk_Item *itemPtr, + double *areaPtr); +static double OvalToPoint(Tk_Canvas canvas, Tk_Item *itemPtr, + double *pointPtr); +static int RectOvalCoords(Tcl_Interp *interp, Tk_Canvas canvas, + Tk_Item *itemPtr, int objc, Tcl_Obj *CONST objv[]); +static int RectOvalToPostscript(Tcl_Interp *interp, + Tk_Canvas canvas, Tk_Item *itemPtr, int prepass); +static int RectToArea(Tk_Canvas canvas, Tk_Item *itemPtr, + double *areaPtr); +static double RectToPoint(Tk_Canvas canvas, Tk_Item *itemPtr, + double *pointPtr); +static void ScaleRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, + double originX, double originY, + double scaleX, double scaleY); +static void TranslateRectOval(Tk_Canvas canvas, Tk_Item *itemPtr, + double deltaX, double deltaY); /* - * The structures below defines the rectangle and oval item types - * by means of procedures that can be invoked by generic item code. + * The structures below defines the rectangle and oval item types by means of + * functions that can be invoked by generic item code. */ Tk_ItemType tkRectangleType = { - "rectangle", /* name */ - sizeof(RectOvalItem), /* itemSize */ - CreateRectOval, /* createProc */ - configSpecs, /* configSpecs */ - ConfigureRectOval, /* configureProc */ - RectOvalCoords, /* coordProc */ - DeleteRectOval, /* deleteProc */ - DisplayRectOval, /* displayProc */ - TK_CONFIG_OBJS, /* flags */ - RectToPoint, /* pointProc */ - RectToArea, /* areaProc */ - RectOvalToPostscript, /* postscriptProc */ - ScaleRectOval, /* scaleProc */ - TranslateRectOval, /* translateProc */ - (Tk_ItemIndexProc *) NULL, /* indexProc */ - (Tk_ItemCursorProc *) NULL, /* icursorProc */ - (Tk_ItemSelectionProc *) NULL, /* selectionProc */ - (Tk_ItemInsertProc *) NULL, /* insertProc */ - (Tk_ItemDCharsProc *) NULL, /* dTextProc */ - (Tk_ItemType *) NULL, /* nextPtr */ + "rectangle", /* name */ + sizeof(RectOvalItem), /* itemSize */ + CreateRectOval, /* createProc */ + configSpecs, /* configSpecs */ + ConfigureRectOval, /* configureProc */ + RectOvalCoords, /* coordProc */ + DeleteRectOval, /* deleteProc */ + DisplayRectOval, /* displayProc */ + TK_CONFIG_OBJS, /* flags */ + RectToPoint, /* pointProc */ + RectToArea, /* areaProc */ + RectOvalToPostscript, /* postscriptProc */ + ScaleRectOval, /* scaleProc */ + TranslateRectOval, /* translateProc */ + NULL, /* indexProc */ + NULL, /* icursorProc */ + NULL, /* selectionProc */ + NULL, /* insertProc */ + NULL, /* dTextProc */ + NULL, /* nextPtr */ }; Tk_ItemType tkOvalType = { - "oval", /* name */ - sizeof(RectOvalItem), /* itemSize */ - CreateRectOval, /* createProc */ - configSpecs, /* configSpecs */ - ConfigureRectOval, /* configureProc */ - RectOvalCoords, /* coordProc */ - DeleteRectOval, /* deleteProc */ - DisplayRectOval, /* displayProc */ - TK_CONFIG_OBJS, /* flags */ - OvalToPoint, /* pointProc */ - OvalToArea, /* areaProc */ - RectOvalToPostscript, /* postscriptProc */ - ScaleRectOval, /* scaleProc */ - TranslateRectOval, /* translateProc */ - (Tk_ItemIndexProc *) NULL, /* indexProc */ - (Tk_ItemCursorProc *) NULL, /* cursorProc */ - (Tk_ItemSelectionProc *) NULL, /* selectionProc */ - (Tk_ItemInsertProc *) NULL, /* insertProc */ - (Tk_ItemDCharsProc *) NULL, /* dTextProc */ - (Tk_ItemType *) NULL, /* nextPtr */ + "oval", /* name */ + sizeof(RectOvalItem), /* itemSize */ + CreateRectOval, /* createProc */ + configSpecs, /* configSpecs */ + ConfigureRectOval, /* configureProc */ + RectOvalCoords, /* coordProc */ + DeleteRectOval, /* deleteProc */ + DisplayRectOval, /* displayProc */ + TK_CONFIG_OBJS, /* flags */ + OvalToPoint, /* pointProc */ + OvalToArea, /* areaProc */ + RectOvalToPostscript, /* postscriptProc */ + ScaleRectOval, /* scaleProc */ + TranslateRectOval, /* translateProc */ + NULL, /* indexProc */ + NULL, /* cursorProc */ + NULL, /* selectionProc */ + NULL, /* insertProc */ + NULL, /* dTextProc */ + NULL, /* nextPtr */ }; /* @@ -225,14 +216,14 @@ Tk_ItemType tkOvalType = { * * CreateRectOval -- * - * This procedure is invoked to create a new rectangle - * or oval item in a canvas. + * This function is invoked to create a new rectangle or oval item in a + * canvas. * * Results: - * A standard Tcl return value. If an error occurred in - * creating the item, then an error message is left in - * the interp's result; in this case itemPtr is left uninitialized, - * so it can be safely freed by the caller. + * A standard Tcl return value. If an error occurred in creating the + * item, then an error message is left in the interp's result; in this + * case itemPtr is left uninitialized, so it can be safely freed by the + * caller. * * Side effects: * A new rectangle or oval item is created. @@ -241,24 +232,24 @@ Tk_ItemType tkOvalType = { */ static int -CreateRectOval(interp, canvas, itemPtr, objc, objv) - Tcl_Interp *interp; /* 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 objc; /* Number of arguments in objv. */ - Tcl_Obj *CONST objv[]; /* Arguments describing rectangle. */ +CreateRectOval( + Tcl_Interp *interp, /* 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 objc, /* Number of arguments in objv. */ + Tcl_Obj *CONST objv[]) /* Arguments describing rectangle. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; int i; if (objc == 0) { - panic("canvas did not pass any coords\n"); + Tcl_Panic("canvas did not pass any coords\n"); } /* - * Carry out initialization that is needed in order to clean - * up after errors during the the remainder of this procedure. + * Carry out initialization that is needed in order to clean up after + * errors during the the remainder of this function. */ Tk_CreateOutline(&(rectOvalPtr->outline)); @@ -279,6 +270,7 @@ CreateRectOval(interp, canvas, itemPtr, objc, objv) for (i = 1; i < objc; i++) { char *arg = Tcl_GetString(objv[i]); + if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { break; } @@ -291,7 +283,7 @@ CreateRectOval(interp, canvas, itemPtr, objc, objv) return TCL_OK; } - error: + error: DeleteRectOval(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas))); return TCL_ERROR; } @@ -301,9 +293,9 @@ CreateRectOval(interp, canvas, itemPtr, objc, objv) * * RectOvalCoords -- * - * This procedure is invoked to process the "coords" widget - * command on rectangles and ovals. See the user documentation - * for details on what it does. + * This function is invoked to process the "coords" widget command on + * rectangles and ovals. See the user documentation for details on what + * it does. * * Results: * Returns TCL_OK or TCL_ERROR, and sets the interp's result. @@ -315,60 +307,73 @@ CreateRectOval(interp, canvas, itemPtr, objc, objv) */ static int -RectOvalCoords(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 objc; /* Number of coordinates supplied in - * objv. */ - Tcl_Obj *CONST objv[]; /* Array of coordinates: x1, y1, - * x2, y2, ... */ +RectOvalCoords( + 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 objc, /* Number of coordinates supplied in objv. */ + Tcl_Obj *CONST objv[]) /* Array of coordinates: x1,y1,x2,y2,... */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; + /* + * If no coordinates, return the current coordinates (i.e. bounding box). + */ + if (objc == 0) { Tcl_Obj *obj = Tcl_NewObj(); - Tcl_Obj *subobj = Tcl_NewDoubleObj(rectOvalPtr->bbox[0]); - Tcl_ListObjAppendElement(interp, obj, subobj); - subobj = Tcl_NewDoubleObj(rectOvalPtr->bbox[1]); - Tcl_ListObjAppendElement(interp, obj, subobj); - subobj = Tcl_NewDoubleObj(rectOvalPtr->bbox[2]); - Tcl_ListObjAppendElement(interp, obj, subobj); - subobj = Tcl_NewDoubleObj(rectOvalPtr->bbox[3]); - Tcl_ListObjAppendElement(interp, obj, subobj); + + Tcl_ListObjAppendElement(NULL, obj, + Tcl_NewDoubleObj(rectOvalPtr->bbox[0])); + Tcl_ListObjAppendElement(NULL, obj, + Tcl_NewDoubleObj(rectOvalPtr->bbox[1])); + Tcl_ListObjAppendElement(NULL, obj, + Tcl_NewDoubleObj(rectOvalPtr->bbox[2])); + Tcl_ListObjAppendElement(NULL, obj, + Tcl_NewDoubleObj(rectOvalPtr->bbox[3])); Tcl_SetObjResult(interp, obj); - } else if ((objc == 1)||(objc == 4)) { - if (objc==1) { - if (Tcl_ListObjGetElements(interp, objv[0], &objc, - (Tcl_Obj ***) &objv) != TCL_OK) { - return TCL_ERROR; - } else if (objc != 4) { - char buf[64 + TCL_INTEGER_SPACE]; + return TCL_OK; + } - sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", objc); - Tcl_SetResult(interp, buf, TCL_VOLATILE); - return TCL_ERROR; - } - } - if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], - &rectOvalPtr->bbox[0]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], - &rectOvalPtr->bbox[1]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[2], - &rectOvalPtr->bbox[2]) != TCL_OK) - || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], - &rectOvalPtr->bbox[3]) != TCL_OK)) { + /* + * If one "coordinate", treat as list of coordinates. + */ + + if (objc == 1) { + if (Tcl_ListObjGetElements(interp, objv[0], &objc, + (Tcl_Obj ***) &objv) != TCL_OK) { return TCL_ERROR; } - ComputeRectOvalBbox(canvas, rectOvalPtr); - } else { + } + + /* + * Better have four coordinates now. Spit out an error message otherwise. + */ + + if (objc != 4) { char buf[64 + TCL_INTEGER_SPACE]; - + sprintf(buf, "wrong # coordinates: expected 0 or 4, got %d", objc); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_ERROR; } + + /* + * Parse the coordinates and update our bounding box. + */ + + if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], + &rectOvalPtr->bbox[0]) != TCL_OK) + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], + &rectOvalPtr->bbox[1]) != TCL_OK) + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[2], + &rectOvalPtr->bbox[2]) != TCL_OK) + || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], + &rectOvalPtr->bbox[3]) != TCL_OK)) { + return TCL_ERROR; + } + ComputeRectOvalBbox(canvas, rectOvalPtr); return TCL_OK; } @@ -377,29 +382,28 @@ RectOvalCoords(interp, canvas, itemPtr, objc, objv) * * ConfigureRectOval -- * - * This procedure is invoked to configure various aspects - * of a rectangle or oval item, such as its border and - * background colors. + * This function is invoked to configure various aspects of a rectangle + * or oval item, such as its border and background colors. * * Results: - * A standard Tcl result code. If an error occurs, then - * an error message is left in the interp's result. + * A standard Tcl result code. If an error occurs, then an error message + * is left in the interp's result. * * Side effects: - * Configuration information, such as colors and stipple - * patterns, may be set for itemPtr. + * Configuration information, such as colors and stipple patterns, may be + * set for itemPtr. * *-------------------------------------------------------------- */ static int -ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) - Tcl_Interp *interp; /* Used for error reporting. */ - Tk_Canvas canvas; /* Canvas containing itemPtr. */ - Tk_Item *itemPtr; /* Rectangle item to reconfigure. */ - int objc; /* Number of elements in objv. */ - Tcl_Obj *CONST objv[]; /* Arguments describing things to configure. */ - int flags; /* Flags to pass to Tk_ConfigureWidget. */ +ConfigureRectOval( + Tcl_Interp *interp, /* Used for error reporting. */ + Tk_Canvas canvas, /* Canvas containing itemPtr. */ + Tk_Item *itemPtr, /* Rectangle item to reconfigure. */ + int objc, /* Number of elements in objv. */ + Tcl_Obj *CONST objv[], /* Arguments describing things to configure. */ + int flags) /* Flags to pass to Tk_ConfigureWidget. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; XGCValues gcValues; @@ -414,14 +418,14 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) tkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, - (CONST char **) objv, (char *) rectOvalPtr, flags|TK_CONFIG_OBJS)) { + (CONST char **)objv, (char *) rectOvalPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } state = itemPtr->state; /* - * A few of the options require additional processing, such as - * graphics contexts. + * A few of the options require additional processing, such as graphics + * contexts. */ if (rectOvalPtr->outline.activeWidth > rectOvalPtr->outline.width || @@ -440,27 +444,28 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) if (flags & TK_OFFSET_LEFT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[0] + 0.5); } else if (flags & TK_OFFSET_CENTER) { - tsoffset->xoffset = (int) ((rectOvalPtr->bbox[0]+rectOvalPtr->bbox[2]+1)/2); + tsoffset->xoffset = (int) + ((rectOvalPtr->bbox[0]+rectOvalPtr->bbox[2]+1)/2); } else if (flags & TK_OFFSET_RIGHT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[2] + 0.5); } if (flags & TK_OFFSET_TOP) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[1] + 0.5); } else if (flags & TK_OFFSET_MIDDLE) { - tsoffset->yoffset = (int) ((rectOvalPtr->bbox[1]+rectOvalPtr->bbox[3]+1)/2); + tsoffset->yoffset = (int) + ((rectOvalPtr->bbox[1]+rectOvalPtr->bbox[3]+1)/2); } else if (flags & TK_OFFSET_BOTTOM) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[2] + 0.5); } /* - * Configure the outline graphics context. If mask is non-zero, - * the gc has changed and must be reallocated, provided that the - * new settings specify a valid outline (non-zero width and non-NULL - * color) + * Configure the outline graphics context. If mask is non-zero, the gc has + * changed and must be reallocated, provided that the new settings specify + * a valid outline (non-zero width and non-NULL color) */ mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, - &(rectOvalPtr->outline)); + &(rectOvalPtr->outline)); if (mask && \ rectOvalPtr->outline.width != 0 && \ rectOvalPtr->outline.color != NULL) { @@ -475,10 +480,10 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) } rectOvalPtr->outline.gc = newGC; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } - if (state==TK_STATE_HIDDEN) { + if (state == TK_STATE_HIDDEN) { ComputeRectOvalBbox(canvas, rectOvalPtr); return TCL_OK; } @@ -492,7 +497,7 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) if (rectOvalPtr->activeFillStipple!=None) { stipple = rectOvalPtr->activeFillStipple; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (rectOvalPtr->disabledFillColor!=NULL) { color = rectOvalPtr->disabledFillColor; } @@ -533,14 +538,16 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) if (flags & TK_OFFSET_LEFT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[0] + 0.5); } else if (flags & TK_OFFSET_CENTER) { - tsoffset->xoffset = (int) ((rectOvalPtr->bbox[0]+rectOvalPtr->bbox[2]+1)/2); + tsoffset->xoffset = (int) + ((rectOvalPtr->bbox[0]+rectOvalPtr->bbox[2]+1)/2); } else if (flags & TK_OFFSET_RIGHT) { tsoffset->xoffset = (int) (rectOvalPtr->bbox[2] + 0.5); } if (flags & TK_OFFSET_TOP) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[1] + 0.5); } else if (flags & TK_OFFSET_MIDDLE) { - tsoffset->yoffset = (int) ((rectOvalPtr->bbox[1]+rectOvalPtr->bbox[3]+1)/2); + tsoffset->yoffset = (int) + ((rectOvalPtr->bbox[1]+rectOvalPtr->bbox[3]+1)/2); } else if (flags & TK_OFFSET_BOTTOM) { tsoffset->yoffset = (int) (rectOvalPtr->bbox[3] + 0.5); } @@ -555,8 +562,8 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) * * DeleteRectOval -- * - * This procedure is called to clean up the data structure - * associated with a rectangle or oval item. + * This function is called to clean up the data structure associated with + * a rectangle or oval item. * * Results: * None. @@ -568,11 +575,10 @@ ConfigureRectOval(interp, canvas, itemPtr, objc, objv, flags) */ static void -DeleteRectOval(canvas, itemPtr, display) - Tk_Canvas canvas; /* Info about overall widget. */ - Tk_Item *itemPtr; /* Item that is being deleted. */ - Display *display; /* Display containing window for - * canvas. */ +DeleteRectOval( + Tk_Canvas canvas, /* Info about overall widget. */ + Tk_Item *itemPtr, /* Item that is being deleted. */ + Display *display) /* Display containing window for canvas. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; @@ -605,37 +611,34 @@ DeleteRectOval(canvas, itemPtr, display) * * ComputeRectOvalBbox -- * - * This procedure is invoked to compute the bounding box of - * all the pixels that may be drawn as part of a rectangle - * or oval. + * This function is invoked to compute the bounding box of all the pixels + * that may be drawn as part of a rectangle or oval. * * Results: * None. * * Side effects: - * The fields x1, y1, x2, and y2 are updated in the header - * for itemPtr. + * The fields x1, y1, x2, and y2 are updated in the header for itemPtr. * *-------------------------------------------------------------- */ /* ARGSUSED */ static void -ComputeRectOvalBbox(canvas, rectOvalPtr) - Tk_Canvas canvas; /* Canvas that contains item. */ - RectOvalItem *rectOvalPtr; /* Item whose bbox is to be - * recomputed. */ +ComputeRectOvalBbox( + Tk_Canvas canvas, /* Canvas that contains item. */ + RectOvalItem *rectOvalPtr) /* Item whose bbox is to be recomputed. */ { int bloat, tmp; double dtmp, width; Tk_State state = rectOvalPtr->header.state; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } width = rectOvalPtr->outline.width; - if (state==TK_STATE_HIDDEN) { + if (state == TK_STATE_HIDDEN) { rectOvalPtr->header.x1 = rectOvalPtr->header.y1 = rectOvalPtr->header.x2 = rectOvalPtr->header.y2 = -1; return; @@ -644,7 +647,7 @@ ComputeRectOvalBbox(canvas, rectOvalPtr) if (rectOvalPtr->outline.activeWidth>width) { width = rectOvalPtr->outline.activeWidth; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (rectOvalPtr->outline.disabledWidth>0) { width = rectOvalPtr->outline.disabledWidth; } @@ -655,24 +658,25 @@ ComputeRectOvalBbox(canvas, rectOvalPtr) */ if (rectOvalPtr->bbox[1] > rectOvalPtr->bbox[3]) { - double tmp; - tmp = rectOvalPtr->bbox[3]; + double tmpY = rectOvalPtr->bbox[3]; + rectOvalPtr->bbox[3] = rectOvalPtr->bbox[1]; - rectOvalPtr->bbox[1] = tmp; + rectOvalPtr->bbox[1] = tmpY; } if (rectOvalPtr->bbox[0] > rectOvalPtr->bbox[2]) { - double tmp; - tmp = rectOvalPtr->bbox[2]; + double tmpX = rectOvalPtr->bbox[2]; + rectOvalPtr->bbox[2] = rectOvalPtr->bbox[0]; - rectOvalPtr->bbox[0] = tmp; + rectOvalPtr->bbox[0] = tmpX; } if (rectOvalPtr->outline.gc == None) { /* - * The Win32 switch was added for 8.3 to solve a problem - * with ovals leaving traces on bottom and right of 1 pixel. - * This may not be the correct place to solve it, but it works. + * The Win32 switch was added for 8.3 to solve a problem with ovals + * leaving traces on bottom and right of 1 pixel. This may not be the + * correct place to solve it, but it works. */ + #ifdef __WIN32__ bloat = 1; #else @@ -680,9 +684,12 @@ ComputeRectOvalBbox(canvas, rectOvalPtr) #endif } else { #ifdef MAC_OSX_TK - /* Mac OS X CoreGraphics needs correct rounding here - * otherwise it will draw outside the bounding box. - * Probably correct on other platforms as well? */ + /* + * Mac OS X CoreGraphics needs correct rounding here otherwise it will + * draw outside the bounding box. Probably correct on other platforms + * as well? + */ + bloat = (int) (width+1.5)/2; #else bloat = (int) (width+1)/2; @@ -690,9 +697,9 @@ ComputeRectOvalBbox(canvas, rectOvalPtr) } /* - * Special note: the rectangle is always drawn at least 1x1 in - * size, so round up the upper coordinates to be at least 1 unit - * greater than the lower ones. + * Special note: the rectangle is always drawn at least 1x1 in size, so + * round up the upper coordinates to be at least 1 unit greater than the + * lower ones. */ tmp = (int) ((rectOvalPtr->bbox[0] >= 0) ? rectOvalPtr->bbox[0] + .5 @@ -720,28 +727,28 @@ ComputeRectOvalBbox(canvas, rectOvalPtr) * * DisplayRectOval -- * - * This procedure is invoked to draw a rectangle or oval - * item in a given drawable. + * This function is invoked to draw a rectangle or oval item in a given + * drawable. * * Results: * None. * * Side effects: - * ItemPtr is drawn in drawable using the transformation - * information in canvas. + * ItemPtr is drawn in drawable using the transformation information in + * canvas. * *-------------------------------------------------------------- */ static void -DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) - Tk_Canvas canvas; /* Canvas that contains item. */ - Tk_Item *itemPtr; /* Item to be displayed. */ - Display *display; /* Display on which to draw item. */ - Drawable drawable; /* Pixmap or window in which to draw - * item. */ - int x, y, width, height; /* Describes region of canvas that - * must be redisplayed (not used). */ +DisplayRectOval( + Tk_Canvas canvas, /* Canvas that contains item. */ + Tk_Item *itemPtr, /* Item to be displayed. */ + Display *display, /* Display on which to draw item. */ + Drawable drawable, /* Pixmap or window in which to draw item. */ + int x, int y, int width, int height) + /* Describes region of canvas that must be + * redisplayed (not used). */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; short x1, y1, x2, y2; @@ -749,9 +756,9 @@ DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) Tk_State state = itemPtr->state; /* - * Compute the screen coordinates of the bounding box for the item. - * Make sure that the bbox is at least one pixel large, since some - * X servers will die if it isn't. + * Compute the screen coordinates of the bounding box for the item. Make + * sure that the bbox is at least one pixel large, since some X servers + * will die if it isn't. */ Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[0], rectOvalPtr->bbox[1], @@ -766,22 +773,21 @@ DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) } /* - * Display filled part first (if wanted), then outline. If we're - * stippling, then modify the stipple offset in the GC. Be sure to - * reset the offset when done, since the GC is supposed to be - * read-only. + * Display filled part first (if wanted), then outline. If we're + * stippling, then modify the stipple offset in the GC. Be sure to reset + * the offset when done, since the GC is supposed to be read-only. */ - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } fillStipple = rectOvalPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)rectOvalPtr) { - if (rectOvalPtr->activeFillStipple!=None) { + if (rectOvalPtr->activeFillStipple != None) { fillStipple = rectOvalPtr->activeFillStipple; } - } else if (state==TK_STATE_DISABLED) { - if (rectOvalPtr->disabledFillStipple!=None) { + } else if (state == TK_STATE_DISABLED) { + if (rectOvalPtr->disabledFillStipple != None) { fillStipple = rectOvalPtr->disabledFillStipple; } } @@ -789,10 +795,12 @@ DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) if (rectOvalPtr->fillGC != None) { if (fillStipple != None) { Tk_TSOffset *tsoffset; - int w=0; int h=0; + int w = 0, h = 0; + tsoffset = &rectOvalPtr->tsoffset; if (tsoffset) { int flags = tsoffset->flags; + if (flags & (TK_OFFSET_CENTER|TK_OFFSET_MIDDLE)) { Tk_SizeOfBitmap(display, fillStipple, &w, &h); if (flags & TK_OFFSET_CENTER) { @@ -827,6 +835,7 @@ DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) XSetTSOrigin(display, rectOvalPtr->fillGC, 0, 0); } } + if (rectOvalPtr->outline.gc != None) { Tk_ChangeOutlineGC(canvas, itemPtr, &(rectOvalPtr->outline)); if (rectOvalPtr->header.typePtr == &tkRectangleType) { @@ -845,17 +854,16 @@ DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) * * RectToPoint -- * - * Computes the distance from a given point to a given - * rectangle, in canvas units. + * Computes the distance from a given point to a given rectangle, in + * canvas units. * * Results: - * The return value is 0 if the point whose x and y coordinates - * are coordPtr[0] and coordPtr[1] is inside the rectangle. If the - * point isn't inside the rectangle then the return value is the - * distance from the point to the rectangle. If itemPtr is filled, - * then anywhere in the interior is considered "inside"; if - * itemPtr isn't filled, then "inside" means only the area - * occupied by the outline. + * The return value is 0 if the point whose x and y coordinates are + * coordPtr[0] and coordPtr[1] is inside the rectangle. If the point + * isn't inside the rectangle then the return value is the distance from + * the point to the rectangle. If itemPtr is filled, then anywhere in the + * interior is considered "inside"; if itemPtr isn't filled, then + * "inside" means only the area occupied by the outline. * * Side effects: * None. @@ -865,17 +873,17 @@ DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height) /* ARGSUSED */ static double -RectToPoint(canvas, itemPtr, pointPtr) - Tk_Canvas canvas; /* Canvas containing item. */ - Tk_Item *itemPtr; /* Item to check against point. */ - double *pointPtr; /* Pointer to x and y coordinates. */ +RectToPoint( + Tk_Canvas canvas, /* Canvas containing item. */ + Tk_Item *itemPtr, /* Item to check against point. */ + double *pointPtr) /* Pointer to x and y coordinates. */ { RectOvalItem *rectPtr = (RectOvalItem *) itemPtr; double xDiff, yDiff, x1, y1, x2, y2, inc, tmp; double width; Tk_State state = itemPtr->state; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } @@ -884,15 +892,15 @@ RectToPoint(canvas, itemPtr, pointPtr) if (rectPtr->outline.activeWidth>width) { width = rectPtr->outline.activeWidth; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (rectPtr->outline.disabledWidth>0) { width = rectPtr->outline.disabledWidth; } } /* - * Generate a new larger rectangle that includes the border - * width, if there is one. + * Generate a new larger rectangle that includes the border width, if + * there is one. */ x1 = rectPtr->bbox[0]; @@ -908,14 +916,13 @@ RectToPoint(canvas, itemPtr, pointPtr) } /* - * If the point is inside the rectangle, handle specially: - * distance is 0 if rectangle is filled, otherwise compute - * distance to nearest edge of rectangle and subtract width - * of edge. + * If the point is inside the rectangle, handle specially: distance is 0 + * if rectangle is filled, otherwise compute distance to nearest edge of + * rectangle and subtract width of edge. */ if ((pointPtr[0] >= x1) && (pointPtr[0] < x2) - && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) { + && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) { if ((rectPtr->fillGC != None) || (rectPtr->outline.gc == None)) { return 0.0; } @@ -967,17 +974,16 @@ RectToPoint(canvas, itemPtr, pointPtr) * * OvalToPoint -- * - * Computes the distance from a given point to a given - * oval, in canvas units. + * Computes the distance from a given point to a given oval, in canvas + * units. * * Results: - * The return value is 0 if the point whose x and y coordinates - * are coordPtr[0] and coordPtr[1] is inside the oval. If the - * point isn't inside the oval then the return value is the - * distance from the point to the oval. If itemPtr is filled, - * then anywhere in the interior is considered "inside"; if - * itemPtr isn't filled, then "inside" means only the area - * occupied by the outline. + * The return value is 0 if the point whose x and y coordinates are + * coordPtr[0] and coordPtr[1] is inside the oval. If the point isn't + * inside the oval then the return value is the distance from the point + * to the oval. If itemPtr is filled, then anywhere in the interior is + * considered "inside"; if itemPtr isn't filled, then "inside" means only + * the area occupied by the outline. * * Side effects: * None. @@ -987,17 +993,17 @@ RectToPoint(canvas, itemPtr, pointPtr) /* ARGSUSED */ static double -OvalToPoint(canvas, itemPtr, pointPtr) - Tk_Canvas canvas; /* Canvas containing item. */ - Tk_Item *itemPtr; /* Item to check against point. */ - double *pointPtr; /* Pointer to x and y coordinates. */ +OvalToPoint( + Tk_Canvas canvas, /* Canvas containing item. */ + Tk_Item *itemPtr, /* Item to check against point. */ + double *pointPtr) /* Pointer to x and y coordinates. */ { RectOvalItem *ovalPtr = (RectOvalItem *) itemPtr; double width; int filled; Tk_State state = itemPtr->state; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } @@ -1006,7 +1012,7 @@ OvalToPoint(canvas, itemPtr, pointPtr) if (ovalPtr->outline.activeWidth>width) { width = (double) ovalPtr->outline.activeWidth; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (ovalPtr->outline.disabledWidth>0) { width = (double) ovalPtr->outline.disabledWidth; } @@ -1026,14 +1032,13 @@ OvalToPoint(canvas, itemPtr, pointPtr) * * RectToArea -- * - * This procedure is called to determine whether an item - * lies entirely inside, entirely outside, or overlapping - * a given rectangle. + * This function is called to determine whether an item lies entirely + * inside, entirely outside, or overlapping a given rectangle. * * Results: - * -1 is returned if the item is entirely outside the area - * given by rectPtr, 0 if it overlaps, and 1 if it is entirely - * inside the given area. + * -1 is returned if the item is entirely outside the area given by + * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given + * area. * * Side effects: * None. @@ -1043,19 +1048,18 @@ OvalToPoint(canvas, itemPtr, pointPtr) /* ARGSUSED */ static int -RectToArea(canvas, itemPtr, areaPtr) - Tk_Canvas canvas; /* Canvas containing item. */ - Tk_Item *itemPtr; /* Item to check against rectangle. */ - double *areaPtr; /* Pointer to array of four coordinates - * (x1, y1, x2, y2) describing rectangular - * area. */ +RectToArea( + Tk_Canvas canvas, /* Canvas containing item. */ + Tk_Item *itemPtr, /* Item to check against rectangle. */ + double *areaPtr) /* Pointer to array of four coordinates (x1, + * y1, x2, y2) describing rectangular area. */ { RectOvalItem *rectPtr = (RectOvalItem *) itemPtr; double halfWidth; double width; Tk_State state = itemPtr->state; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } @@ -1064,7 +1068,7 @@ RectToArea(canvas, itemPtr, areaPtr) if (rectPtr->outline.activeWidth>width) { width = rectPtr->outline.activeWidth; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (rectPtr->outline.disabledWidth>0) { width = rectPtr->outline.disabledWidth; } @@ -1102,14 +1106,13 @@ RectToArea(canvas, itemPtr, areaPtr) * * OvalToArea -- * - * This procedure is called to determine whether an item - * lies entirely inside, entirely outside, or overlapping - * a given rectangular area. + * This function is called to determine whether an item lies entirely + * inside, entirely outside, or overlapping a given rectangular area. * * Results: - * -1 is returned if the item is entirely outside the area - * given by rectPtr, 0 if it overlaps, and 1 if it is entirely - * inside the given area. + * -1 is returned if the item is entirely outside the area given by + * rectPtr, 0 if it overlaps, and 1 if it is entirely inside the given + * area. * * Side effects: * None. @@ -1119,12 +1122,11 @@ RectToArea(canvas, itemPtr, areaPtr) /* ARGSUSED */ static int -OvalToArea(canvas, itemPtr, areaPtr) - Tk_Canvas canvas; /* Canvas containing item. */ - Tk_Item *itemPtr; /* Item to check against oval. */ - double *areaPtr; /* Pointer to array of four coordinates - * (x1, y1, x2, y2) describing rectangular - * area. */ +OvalToArea( + Tk_Canvas canvas, /* Canvas containing item. */ + Tk_Item *itemPtr, /* Item to check against oval. */ + double *areaPtr) /* Pointer to array of four coordinates (x1, + * y1, x2, y2) describing rectangular area. */ { RectOvalItem *ovalPtr = (RectOvalItem *) itemPtr; double oval[4], halfWidth; @@ -1132,7 +1134,7 @@ OvalToArea(canvas, itemPtr, areaPtr) double width; Tk_State state = itemPtr->state; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } @@ -1141,7 +1143,7 @@ OvalToArea(canvas, itemPtr, areaPtr) if (ovalPtr->outline.activeWidth>width) { width = ovalPtr->outline.activeWidth; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (ovalPtr->outline.disabledWidth>0) { width = ovalPtr->outline.disabledWidth; } @@ -1163,10 +1165,10 @@ OvalToArea(canvas, itemPtr, areaPtr) result = TkOvalToArea(oval, areaPtr); /* - * If the rectangle appears to overlap the oval and the oval - * isn't filled, do one more check to see if perhaps all four - * of the rectangle's corners are totally inside the oval's - * unfilled center, in which case we should return "outside". + * If the rectangle appears to overlap the oval and the oval isn't filled, + * do one more check to see if perhaps all four of the rectangle's corners + * are totally inside the oval's unfilled center, in which case we should + * return "outside". */ if ((result == 0) && (ovalPtr->outline.gc != None) @@ -1201,16 +1203,14 @@ OvalToArea(canvas, itemPtr, areaPtr) * * ScaleRectOval -- * - * This procedure is invoked to rescale a rectangle or oval - * item. + * This function is invoked to rescale a rectangle or oval item. * * Results: * None. * * Side effects: - * The rectangle or oval referred to by itemPtr is rescaled - * so that the following transformation is applied to all - * point coordinates: + * The rectangle or oval referred to by itemPtr is rescaled so that the + * following transformation is applied to all point coordinates: * x' = originX + scaleX*(x-originX) * y' = originY + scaleY*(y-originY) * @@ -1218,12 +1218,13 @@ OvalToArea(canvas, itemPtr, areaPtr) */ static void -ScaleRectOval(canvas, itemPtr, originX, originY, scaleX, scaleY) - Tk_Canvas canvas; /* Canvas containing rectangle. */ - Tk_Item *itemPtr; /* Rectangle to be scaled. */ - double originX, originY; /* Origin about which to scale rect. */ - double scaleX; /* Amount to scale in X direction. */ - double scaleY; /* Amount to scale in Y direction. */ +ScaleRectOval( + Tk_Canvas canvas, /* Canvas containing rectangle. */ + Tk_Item *itemPtr, /* Rectangle to be scaled. */ + double originX, double originY, + /* Origin about which to scale rect. */ + double scaleX, /* Amount to scale in X direction. */ + double scaleY) /* Amount to scale in Y direction. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; @@ -1239,26 +1240,25 @@ ScaleRectOval(canvas, itemPtr, originX, originY, scaleX, scaleY) * * TranslateRectOval -- * - * This procedure is called to move a rectangle or oval by a - * given amount. + * This function is called to move a rectangle or oval by a given amount. * * Results: * None. * * Side effects: - * The position of the rectangle or oval is offset by - * (xDelta, yDelta), and the bounding box is updated in the - * generic part of the item structure. + * The position of the rectangle or oval is offset by (xDelta, yDelta), + * and the bounding box is updated in the generic part of the item + * structure. * *-------------------------------------------------------------- */ static void -TranslateRectOval(canvas, itemPtr, deltaX, deltaY) - Tk_Canvas canvas; /* Canvas containing item. */ - Tk_Item *itemPtr; /* Item that is being moved. */ - double deltaX, deltaY; /* Amount by which item is to be - * moved. */ +TranslateRectOval( + Tk_Canvas canvas, /* Canvas containing item. */ + Tk_Item *itemPtr, /* Item that is being moved. */ + double deltaX, double deltaY) + /* Amount by which item is to be moved. */ { RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; @@ -1274,15 +1274,14 @@ TranslateRectOval(canvas, itemPtr, deltaX, deltaY) * * RectOvalToPostscript -- * - * This procedure is called to generate Postscript for - * rectangle and oval items. + * This function is called to generate Postscript for rectangle and oval + * items. * * Results: - * The return value is a standard Tcl result. If an error - * occurs in generating Postscript then an error message is - * left in the interp's result, replacing whatever used to be there. - * If no error occurs, then Postscript for the rectangle is - * appended to the result. + * The return value is a standard Tcl result. If an error occurs in + * generating Postscript then an error message is left in the interp's + * result, replacing whatever used to be there. If no error occurs, then + * Postscript for the rectangle is appended to the result. * * Side effects: * None. @@ -1291,14 +1290,13 @@ TranslateRectOval(canvas, itemPtr, deltaX, deltaY) */ static int -RectOvalToPostscript(interp, canvas, itemPtr, prepass) - Tcl_Interp *interp; /* Interpreter for error reporting. */ - Tk_Canvas canvas; /* Information about overall canvas. */ - Tk_Item *itemPtr; /* Item for which Postscript is - * wanted. */ - int prepass; /* 1 means this is a prepass to - * collect font information; 0 means - * final Postscript is being created. */ +RectOvalToPostscript( + Tcl_Interp *interp, /* Interpreter for error reporting. */ + Tk_Canvas canvas, /* Information about overall canvas. */ + Tk_Item *itemPtr, /* Item for which Postscript is wanted. */ + int prepass) /* 1 means this is a prepass to collect font + * information; 0 means final Postscript is + * being created. */ { char pathCmd[500]; RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; @@ -1312,12 +1310,10 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) y2 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[3]); /* - * Generate a string that creates a path for the rectangle or oval. - * This is the only part of the procedure's code that is type- - * specific. + * Generate a string that creates a path for the rectangle or oval. This + * is the only part of the function's code that is type-specific. */ - if (rectOvalPtr->header.typePtr == &tkRectangleType) { sprintf(pathCmd, "%.15g %.15g moveto %.15g 0 rlineto 0 %.15g rlineto %.15g 0 rlineto closepath\n", rectOvalPtr->bbox[0], y1, @@ -1329,7 +1325,7 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) (rectOvalPtr->bbox[2] - rectOvalPtr->bbox[0])/2, (y1 - y2)/2); } - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } color = rectOvalPtr->outline.color; @@ -1345,7 +1341,7 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) if (rectOvalPtr->activeFillStipple!=None) { fillStipple = rectOvalPtr->activeFillStipple; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (rectOvalPtr->outline.disabledColor!=NULL) { color = rectOvalPtr->outline.disabledColor; } @@ -1362,22 +1358,20 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) */ if (fillColor != NULL) { - Tcl_AppendResult(interp, pathCmd, (char *) NULL); - if (Tk_CanvasPsColor(interp, canvas, fillColor) - != TCL_OK) { + Tcl_AppendResult(interp, pathCmd, NULL); + if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } if (fillStipple != None) { - Tcl_AppendResult(interp, "clip ", (char *) NULL); - if (Tk_CanvasPsStipple(interp, canvas, fillStipple) - != TCL_OK) { + Tcl_AppendResult(interp, "clip ", NULL); + if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; } if (color != NULL) { - Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL); + Tcl_AppendResult(interp, "grestore gsave\n", NULL); } } else { - Tcl_AppendResult(interp, "fill\n", (char *) NULL); + Tcl_AppendResult(interp, "fill\n", NULL); } } @@ -1387,7 +1381,7 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) if (color != NULL) { Tcl_AppendResult(interp, pathCmd, "0 setlinejoin 2 setlinecap\n", - (char *) NULL); + NULL); if (Tk_CanvasPsOutline(canvas, itemPtr, &(rectOvalPtr->outline))!= TCL_OK) { return TCL_ERROR; @@ -1395,3 +1389,11 @@ RectOvalToPostscript(interp, canvas, itemPtr, prepass) } return TCL_OK; } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ |