diff options
Diffstat (limited to 'generic/tkCanvArc.c')
-rw-r--r-- | generic/tkCanvArc.c | 129 |
1 files changed, 59 insertions, 70 deletions
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index ecd57b8..6cbc89b 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -10,7 +10,6 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ -#include <stdio.h> #include "tkInt.h" #include "tkCanvas.h" @@ -79,48 +78,42 @@ typedef struct ArcItem { */ static int StyleParseProc(ClientData clientData, Tcl_Interp *interp, - Tk_Window tkwin, CONST char *value, + Tk_Window tkwin, const char *value, char *widgRec, int offset); -static char * StylePrintProc(ClientData clientData, Tk_Window tkwin, +static const char * StylePrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); -static Tk_CustomOption stateOption = { - (Tk_OptionParseProc *) TkStateParseProc, - TkStatePrintProc, (ClientData) 2 +static const Tk_CustomOption stateOption = { + TkStateParseProc, TkStatePrintProc, INT2PTR(2) }; -static Tk_CustomOption styleOption = { - (Tk_OptionParseProc *) StyleParseProc, - StylePrintProc, (ClientData) NULL +static const Tk_CustomOption styleOption = { + StyleParseProc, StylePrintProc, NULL }; -static Tk_CustomOption tagsOption = { - (Tk_OptionParseProc *) Tk_CanvasTagsParseProc, - Tk_CanvasTagsPrintProc, (ClientData) NULL +static const Tk_CustomOption tagsOption = { + Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL }; -static Tk_CustomOption dashOption = { - (Tk_OptionParseProc *) TkCanvasDashParseProc, - TkCanvasDashPrintProc, (ClientData) NULL +static const Tk_CustomOption dashOption = { + TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL }; -static Tk_CustomOption offsetOption = { - (Tk_OptionParseProc *) TkOffsetParseProc, - TkOffsetPrintProc, (ClientData) (TK_OFFSET_RELATIVE) +static const Tk_CustomOption offsetOption = { + TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE) }; -static Tk_CustomOption pixelOption = { - (Tk_OptionParseProc *) TkPixelParseProc, - TkPixelPrintProc, (ClientData) NULL +static const Tk_CustomOption pixelOption = { + TkPixelParseProc, TkPixelPrintProc, NULL }; -static Tk_ConfigSpec configSpecs[] = { +static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_CUSTOM, "-activedash", NULL, NULL, NULL, Tk_Offset(ArcItem, outline.activeDash), TK_CONFIG_NULL_OK, &dashOption}, {TK_CONFIG_COLOR, "-activefill", NULL, NULL, - NULL, Tk_Offset(ArcItem, activeFillColor), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_COLOR, "-activeoutline", NULL, NULL, - NULL, Tk_Offset(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(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, Tk_Offset(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_BITMAP, "-activestipple", NULL, NULL, - NULL, Tk_Offset(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL, "0.0", Tk_Offset(ArcItem, outline.activeWidth), TK_CONFIG_DONT_SET_DEFAULT, &pixelOption}, @@ -128,41 +121,41 @@ static Tk_ConfigSpec configSpecs[] = { NULL, Tk_Offset(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}, + "0", Tk_Offset(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL}, {TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL, NULL, Tk_Offset(ArcItem, outline.disabledDash), TK_CONFIG_NULL_OK, &dashOption}, {TK_CONFIG_COLOR, "-disabledfill", NULL, NULL, - NULL, Tk_Offset(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL, - NULL, Tk_Offset(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(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, Tk_Offset(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL, - NULL, Tk_Offset(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL, "0.0", Tk_Offset(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}, + "90", Tk_Offset(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL}, {TK_CONFIG_COLOR, "-fill", NULL, NULL, - NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-offset", NULL, NULL, "0,0", Tk_Offset(ArcItem, tsoffset), TK_CONFIG_DONT_SET_DEFAULT, &offsetOption}, {TK_CONFIG_COLOR, "-outline", NULL, NULL, - "black", Tk_Offset(ArcItem, outline.color), TK_CONFIG_NULL_OK}, + "black", Tk_Offset(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL, "0,0", Tk_Offset(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, Tk_Offset(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_DOUBLE, "-start", NULL, NULL, - "0", Tk_Offset(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT}, + "0", Tk_Offset(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}, {TK_CONFIG_BITMAP, "-stipple", NULL, NULL, - NULL, Tk_Offset(ArcItem, fillStipple), TK_CONFIG_NULL_OK}, + NULL, Tk_Offset(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-style", NULL, NULL, NULL, Tk_Offset(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT, &styleOption}, @@ -171,7 +164,7 @@ static Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_CUSTOM, "-width", NULL, NULL, "1.0", Tk_Offset(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT, &pixelOption}, - {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} + {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; /* @@ -181,17 +174,17 @@ static 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, - Tcl_Obj *CONST objv[], int flags); + Tcl_Obj *const objv[], int flags); static int CreateArc(Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, - int objc, Tcl_Obj *CONST objv[]); + int 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, int objc, Tcl_Obj *const objv[]); static int ArcToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); static double ArcToPoint(Tk_Canvas canvas, @@ -239,11 +232,8 @@ Tk_ItemType tkArcType = { NULL, /* insertProc */ NULL, /* dTextProc */ NULL, /* nextPtr */ + NULL, 0, NULL, NULL }; - -#ifndef PI -#define PI 3.14159265358979323846 -#endif /* *-------------------------------------------------------------- @@ -271,13 +261,13 @@ CreateArc( 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 arc. */ + Tcl_Obj *const objv[]) /* Arguments describing arc. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; int i; if (objc == 0) { - Tcl_Panic("canvas did not pass any coords\n"); + Tcl_Panic("canvas did not pass any coords"); } /* @@ -307,7 +297,7 @@ CreateArc( */ for (i = 1; i < objc; i++) { - char *arg = Tcl_GetString(objv[i]); + const char *arg = Tcl_GetString(objv[i]); if ((arg[0] == '-') && (arg[1] >= 'a') && (arg[1] <= 'z')) { break; @@ -349,7 +339,7 @@ ArcCoords( 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, ... */ + Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */ { ArcItem *arcPtr = (ArcItem *) itemPtr; @@ -424,7 +414,7 @@ ConfigureArc( Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Arc item to reconfigure. */ int objc, /* Number of elements in objv. */ - Tcl_Obj *CONST objv[], /* Arguments describing things to configure. */ + Tcl_Obj *const objv[], /* Arguments describing things to configure. */ int flags) /* Flags to pass to Tk_ConfigureWidget. */ { ArcItem *arcPtr = (ArcItem *) itemPtr; @@ -440,7 +430,7 @@ ConfigureArc( tkwin = Tk_CanvasTkwin(canvas); if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc, - (CONST char **) objv, (char *) arcPtr, flags|TK_CONFIG_OBJS)) { + (const char **) objv, (char *) arcPtr, flags|TK_CONFIG_OBJS)) { return TCL_ERROR; } @@ -501,7 +491,7 @@ ConfigureArc( arcPtr->outline.gc = newGC; if(state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } if (state==TK_STATE_HIDDEN) { ComputeArcBbox(canvas, arcPtr); @@ -510,7 +500,7 @@ ConfigureArc( color = arcPtr->fillColor; stipple = arcPtr->fillStipple; - if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { + if (Canvas(canvas)->currentItemPtr == itemPtr) { if (arcPtr->activeFillColor!=NULL) { color = arcPtr->activeFillColor; } @@ -598,7 +588,7 @@ DeleteArc( Tk_DeleteOutline(display, &(arcPtr->outline)); if (arcPtr->numOutlinePoints != 0) { - ckfree((char *) arcPtr->outlinePtr); + ckfree(arcPtr->outlinePtr); } if (arcPtr->fillColor != NULL) { Tk_FreeColor(arcPtr->fillColor); @@ -651,7 +641,7 @@ ComputeArcBbox( Tk_State state = arcPtr->header.state; if (state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } width = arcPtr->outline.width; @@ -662,7 +652,7 @@ ComputeArcBbox( arcPtr->header.x1 = arcPtr->header.x2 = arcPtr->header.y1 = arcPtr->header.y2 = -1; return; - } else if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *) arcPtr) { + } else if (Canvas(canvas)->currentItemPtr == (Tk_Item *) arcPtr) { if (arcPtr->outline.activeWidth>width) { width = arcPtr->outline.activeWidth; } @@ -794,7 +784,7 @@ DisplayArc( Pixmap stipple; if (state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } lineWidth = arcPtr->outline.width; if (lineWidth < 1.0) { @@ -802,7 +792,7 @@ DisplayArc( } dashnumber = arcPtr->outline.dash.number; stipple = arcPtr->fillStipple; - if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { + if (Canvas(canvas)->currentItemPtr == itemPtr) { if (arcPtr->outline.activeWidth>lineWidth) { lineWidth = arcPtr->outline.activeWidth; } @@ -970,11 +960,11 @@ ArcToPoint( Tk_State state = itemPtr->state; if (state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } width = (double) arcPtr->outline.width; - if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { + if (Canvas(canvas)->currentItemPtr == itemPtr) { if (arcPtr->outline.activeWidth>width) { width = (double) arcPtr->outline.activeWidth; } @@ -1146,10 +1136,10 @@ ArcToArea( Tk_State state = itemPtr->state; if(state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } width = (double) arcPtr->outline.width; - if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { + if (Canvas(canvas)->currentItemPtr == itemPtr) { if (arcPtr->outline.activeWidth>width) { width = (double) arcPtr->outline.activeWidth; } @@ -1461,14 +1451,13 @@ ComputeArcOutline( */ if (arcPtr->numOutlinePoints == 0) { - arcPtr->outlinePtr = (double *) ckalloc((unsigned) - (26 * sizeof(double))); + arcPtr->outlinePtr = ckalloc(26 * sizeof(double)); arcPtr->numOutlinePoints = 22; } outlinePtr = arcPtr->outlinePtr; if (state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } /* @@ -1526,7 +1515,7 @@ ComputeArcOutline( */ width = arcPtr->outline.width; - if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *) arcPtr) { + if (Canvas(canvas)->currentItemPtr == (Tk_Item *) arcPtr) { if (arcPtr->outline.activeWidth>arcPtr->outline.width) { width = arcPtr->outline.activeWidth; } @@ -1852,13 +1841,13 @@ ArcToPostscript( } if (state == TK_STATE_NULL) { - state = ((TkCanvas *)canvas)->canvas_state; + state = Canvas(canvas)->canvas_state; } color = arcPtr->outline.color; stipple = arcPtr->outline.stipple; fillColor = arcPtr->fillColor; fillStipple = arcPtr->fillStipple; - if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { + if (Canvas(canvas)->currentItemPtr == itemPtr) { if (arcPtr->outline.activeColor!=NULL) { color = arcPtr->outline.activeColor; } @@ -2002,7 +1991,7 @@ StyleParseProc( ClientData clientData, /* some flags.*/ Tcl_Interp *interp, /* Used for reporting errors. */ Tk_Window tkwin, /* Window containing canvas widget. */ - CONST char *value, /* Value of option. */ + const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ int offset) /* Offset into item. */ { @@ -2059,7 +2048,7 @@ StyleParseProc( *-------------------------------------------------------------- */ -static char * +static const char * StylePrintProc( ClientData clientData, /* Ignored. */ Tk_Window tkwin, /* Ignored. */ |