diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-08-29 08:21:18 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-08-29 08:21:18 (GMT) |
commit | fc24ab8dc13b3cef3287047da608c1c06d711e41 (patch) | |
tree | 0af39b2401fb15c7ad4cbe3674f3c2a2e8c5862e | |
parent | 609726a57ddf5af1752ba35a5c90945591e162dd (diff) | |
parent | 737f6447422a84d722dfa1b05bd62522064a0884 (diff) | |
download | tk-fc24ab8dc13b3cef3287047da608c1c06d711e41.zip tk-fc24ab8dc13b3cef3287047da608c1c06d711e41.tar.gz tk-fc24ab8dc13b3cef3287047da608c1c06d711e41.tar.bz2 |
Performance improvement in tkOldConfig.c. See [610a73a179]. Backport some formatting from 9.0
-rw-r--r-- | generic/tk3d.c | 5 | ||||
-rw-r--r-- | generic/tkCanvArc.c | 2 | ||||
-rw-r--r-- | generic/tkCanvImg.c | 2 | ||||
-rw-r--r-- | generic/tkCanvPoly.c | 4 | ||||
-rw-r--r-- | generic/tkCanvas.c | 474 | ||||
-rw-r--r-- | generic/tkCanvas.h | 4 | ||||
-rw-r--r-- | generic/tkGet.c | 2 | ||||
-rw-r--r-- | generic/tkGrab.c | 20 | ||||
-rw-r--r-- | generic/tkGrid.c | 10 | ||||
-rw-r--r-- | generic/tkOldConfig.c | 87 | ||||
-rw-r--r-- | generic/tkRectOval.c | 184 | ||||
-rw-r--r-- | generic/tkScrollbar.h | 2 | ||||
-rw-r--r-- | generic/ttk/ttkTreeview.c | 18 | ||||
-rw-r--r-- | tests/canvImg.test | 2 | ||||
-rw-r--r-- | tests/canvText.test | 2 | ||||
-rw-r--r-- | tests/canvas.test | 2 |
16 files changed, 412 insertions, 408 deletions
diff --git a/generic/tk3d.c b/generic/tk3d.c index be7ba9b..8082f0c 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -677,9 +677,10 @@ Tk_GetRelief( relief = TK_RELIEF_SUNKEN; } else { if (interp) { + int ambigeous = (c == 'r' || c == 's') && (name[1] == '\0'); Tcl_SetObjResult(interp, - Tcl_ObjPrintf("bad relief \"%.50s\": must be %s", - name, "flat, groove, raised, ridge, solid, or sunken")); + Tcl_ObjPrintf("%s relief \"%.50s\": must be %s", + ambigeous ? "ambigeous" : "bad", name, "flat, groove, raised, ridge, solid, or sunken")); Tcl_SetErrorCode(interp, "TK", "VALUE", "RELIEF", (char *)NULL); } return TCL_ERROR; diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index da40b99..a96f86e 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -381,7 +381,7 @@ ArcCoords( } } if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], - &arcPtr->bbox[0]) != TCL_OK) + &arcPtr->bbox[0]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], &arcPtr->bbox[1]) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[2], diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c index 5f67ec6..08526d5 100644 --- a/generic/tkCanvImg.c +++ b/generic/tkCanvImg.c @@ -256,7 +256,7 @@ ImageCoords( if ((Tk_CanvasGetCoordFromObj(interp, canvas, objv[0], &imgPtr->x) != TCL_OK) || (Tk_CanvasGetCoordFromObj(interp, canvas, objv[1], - &imgPtr->y) != TCL_OK)) { + &imgPtr->y) != TCL_OK)) { return TCL_ERROR; } ComputeImageBbox(canvas, imgPtr); diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 400e4c5..569060e 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -680,7 +680,7 @@ ComputePolygonBbox( if (index < 0) { index += (polyPtr->numPoints - polyPtr->autoClosed) * 2; } - tsoffset->xoffset = (int) (polyPtr->coordPtr[index] + 0.5); + tsoffset->xoffset = (int) (polyPtr->coordPtr[index] + 0.5); tsoffset->yoffset = (int) (polyPtr->coordPtr[index+1] + 0.5); } else { if (tsoffset->flags & TK_OFFSET_LEFT) { @@ -1100,7 +1100,7 @@ PolygonInsert( * [5fb8145997]. */ - double width; + double width; int j; itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW; diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 38a297d..e539f99 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -269,7 +269,7 @@ static Tcl_Obj * ScrollFractions(int screen1, int screen2, int object1, int object2); static int RelinkItems(TkCanvas *canvasPtr, Tcl_Obj *tag, Tk_Item *prevPtr, TagSearch **searchPtrPtr); -static void TagSearchExprInit(TagSearchExpr **exprPtrPtr); +static void TagSearchExprInit(TagSearchExpr **exprPtrPtr); static void TagSearchExprDestroy(TagSearchExpr *expr); static void TagSearchDestroy(TagSearch *searchPtr); static int TagSearchScan(TkCanvas *canvasPtr, @@ -751,8 +751,8 @@ Tk_CanvasObjCmd( canvasPtr->highlightColorPtr = NULL; canvasPtr->inset = 0; canvasPtr->pixmapGC = NULL; - canvasPtr->width = None; - canvasPtr->height = None; + canvasPtr->width = 0; + canvasPtr->height = 0; canvasPtr->confine = 0; canvasPtr->textInfo.selBorder = NULL; canvasPtr->textInfo.selBorderWidth = 0; @@ -871,7 +871,7 @@ CanvasWidgetCmd( "canvasy", "cget", "configure", "coords", "create", "dchars", "delete", "dtag", "find", "focus", "gettags", "icursor", - "image", "imove", "index", "insert", + "image", "imove", "index", "insert", "itemcget", "itemconfigure", "lower", "move", "moveto", "postscript", "raise", "rchars", "rotate", "scale", @@ -883,7 +883,7 @@ CanvasWidgetCmd( CANV_CANVASY, CANV_CGET, CANV_CONFIGURE, CANV_COORDS, CANV_CREATE, CANV_DCHARS, CANV_DELETE, CANV_DTAG, CANV_FIND, CANV_FOCUS, CANV_GETTAGS, CANV_ICURSOR, - CANV_IMAGE, CANV_IMOVE, CANV_INDEX, CANV_INSERT, + CANV_IMAGE, CANV_IMOVE, CANV_INDEX, CANV_INSERT, CANV_ITEMCGET, CANV_ITEMCONFIGURE, CANV_LOWER, CANV_MOVE, CANV_MOVETO, CANV_POSTSCRIPT, CANV_RAISE, CANV_RCHARS, CANV_ROTATE, CANV_SCALE, @@ -1028,7 +1028,7 @@ CanvasWidgetCmd( * If new tag expression, then insert in linked list. */ - TagSearchExpr *expr, **lastPtr; + TagSearchExpr *expr, **lastPtr; lastPtr = &(canvasPtr->bindTagExprs); while ((expr = *lastPtr) != NULL) { @@ -1485,21 +1485,21 @@ CanvasWidgetCmd( for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) { if (itemPtr->tagPtr[i] == tag) { - /* - * Don't shuffle the tags sequence: memmove the tags. - */ + /* + * Don't shuffle the tags sequence: memmove the tags. + */ - memmove((void *)(itemPtr->tagPtr + i), - itemPtr->tagPtr + i + 1, - (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid)); + memmove((void *)(itemPtr->tagPtr + i), + itemPtr->tagPtr + i + 1, + (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid)); itemPtr->numTags--; - /* - * There must be no break here: all tags with the same name must - * be deleted. - */ + /* + * There must be no break here: all tags with the same name must + * be deleted. + */ - } + } } } break; @@ -1863,15 +1863,15 @@ CanvasWidgetCmd( x1 = itemPtr->x1; y1 = itemPtr->y1; x2 = itemPtr->x2; y2 = itemPtr->y2; - itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; + itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; ItemDelChars(canvasPtr, itemPtr, first, last); dontRedraw1 = itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW; - itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; + itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; ItemInsert(canvasPtr, itemPtr, first, objv[5]); dontRedraw2 = itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW; - if (!(dontRedraw1 && dontRedraw2)) { + if (!(dontRedraw1 && dontRedraw2)) { Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr, x1, y1, x2, y2); EventuallyRedrawItem(canvasPtr, itemPtr); @@ -2177,44 +2177,44 @@ CanvasWidgetCmd( break; } case CANV_IMAGE: { - Tk_PhotoHandle photohandle; - int subsample = 1, zoom = 1; + Tk_PhotoHandle photohandle; + int subsample = 1, zoom = 1; - if (objc < 3 || objc > 5) { - Tcl_WrongNumArgs(interp, 2, objv, "imagename ?subsample? ?zoom?"); - result = TCL_ERROR; - goto done; - } + if (objc < 3 || objc > 5) { + Tcl_WrongNumArgs(interp, 2, objv, "imagename ?subsample? ?zoom?"); + result = TCL_ERROR; + goto done; + } - if ((photohandle = Tk_FindPhoto(interp, Tcl_GetString(objv[2]) )) == 0) { - result = TCL_ERROR; - goto done; - } + if ((photohandle = Tk_FindPhoto(interp, Tcl_GetString(objv[2]) )) == 0) { + result = TCL_ERROR; + goto done; + } - /* - * If we are given a subsample or a zoom then grab them. - */ + /* + * If we are given a subsample or a zoom then grab them. + */ - if (objc >= 4 && Tcl_GetIntFromObj(interp, objv[3], &subsample) != TCL_OK) { - result = TCL_ERROR; - goto done; - } - if (objc >= 5 && Tcl_GetIntFromObj(interp, objv[4], &zoom) != TCL_OK) { - result = TCL_ERROR; - goto done; - } + if (objc >= 4 && Tcl_GetIntFromObj(interp, objv[3], &subsample) != TCL_OK) { + result = TCL_ERROR; + goto done; + } + if (objc >= 5 && Tcl_GetIntFromObj(interp, objv[4], &zoom) != TCL_OK) { + result = TCL_ERROR; + goto done; + } - /* - * Set the image size to zero, which allows the DrawCanvas() function - * to expand the image automatically when it copies the pixmap into it. - */ + /* + * Set the image size to zero, which allows the DrawCanvas() function + * to expand the image automatically when it copies the pixmap into it. + */ - if (Tk_PhotoSetSize(interp, photohandle, 0, 0) != TCL_OK) { - result = TCL_ERROR; - goto done; - } + if (Tk_PhotoSetSize(interp, photohandle, 0, 0) != TCL_OK) { + result = TCL_ERROR; + goto done; + } - result = DrawCanvas(interp, clientData, photohandle, subsample, zoom); + result = DrawCanvas(interp, clientData, photohandle, subsample, zoom); } } @@ -2362,7 +2362,7 @@ ConfigureCanvas( int result; for ( itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL; - itemPtr = itemPtr->nextPtr) { + itemPtr = itemPtr->nextPtr) { if ( itemPtr->state == TK_STATE_NULL ) { result = (*itemPtr->typePtr->configProc)(canvasPtr->interp, (Tk_Canvas) canvasPtr, itemPtr, 0, NULL, @@ -2531,31 +2531,31 @@ DecomposeMaskToShiftAndBits( */ for (i = 0; i < 32; ++i) { - if (mask & 1 << i) - break; + if (mask & 1 << i) + break; } if (i < 32) { - *shift = i; + *shift = i; - /* - * Now find the next '0' bit and the width of the mask. - */ + /* + * Now find the next '0' bit and the width of the mask. + */ - for ( ; i < 32; ++i) { - if ((mask & 1 << i) == 0) - break; - else - ++*bits; - } + for ( ; i < 32; ++i) { + if ((mask & 1 << i) == 0) + break; + else + ++*bits; + } - /* - * Limit to the top 8 bits if the mask was wider than 8. - */ + /* + * Limit to the top 8 bits if the mask was wider than 8. + */ - if (*bits > 8) { - *shift += *bits - 8; - *bits = 8; - } + if (*bits > 8) { + *shift += *bits - 8; + *bits = 8; + } } } @@ -2580,7 +2580,7 @@ DecomposeMaskToShiftAndBits( */ #define OVERDRAW_PIXELS 32 /* How much larger we make the pixmap - * that the canvas objects are drawn into */ + * that the canvas objects are drawn into */ #ifdef WORDS_BIGENDIAN #define IS_BIG_ENDIAN 1 @@ -2611,18 +2611,18 @@ DrawCanvas( GC xgc = 0; XGCValues xgcValues; int canvasX1, canvasY1, canvasX2, canvasY2, cWidth, cHeight, - pixmapX1, pixmapY1, pixmapX2, pixmapY2, pmWidth, pmHeight, - bitsPerPixel, bytesPerPixel, x, y, result = TCL_OK, - rshift, gshift, bshift, rbits, gbits, bbits; + pixmapX1, pixmapY1, pixmapX2, pixmapY2, pmWidth, pmHeight, + bitsPerPixel, bytesPerPixel, x, y, result = TCL_OK, + rshift, gshift, bshift, rbits, gbits, bbits; #ifdef DEBUG_DRAWCANVAS char buffer[128]; #endif if ((tkwin = canvasPtr->tkwin) == NULL) { - Tcl_AppendResult(interp, "canvas tkwin is NULL!", (char *)NULL); - result = TCL_ERROR; - goto done; + Tcl_AppendResult(interp, "canvas tkwin is NULL!", (char *)NULL); + result = TCL_ERROR; + goto done; } /* @@ -2633,21 +2633,21 @@ DrawCanvas( do { - if ((displayPtr = Tk_Display(tkwin)) == NULL) { - Tcl_AppendResult(interp, "canvas (or parent) display is NULL!", (char *)NULL); - result = TCL_ERROR; - goto done; - } + if ((displayPtr = Tk_Display(tkwin)) == NULL) { + Tcl_AppendResult(interp, "canvas (or parent) display is NULL!", (char *)NULL); + result = TCL_ERROR; + goto done; + } - if ((wid = Tk_WindowId(tkwin)) != 0) { - continue; - } + if ((wid = Tk_WindowId(tkwin)) != 0) { + continue; + } - if ((tkwin = Tk_Parent(tkwin)) == NULL) { - Tcl_AppendResult(interp, "canvas has no parent with a valid window id! Is the toplevel window mapped?", (char *)NULL); - result = TCL_ERROR; - goto done; - } + if ((tkwin = Tk_Parent(tkwin)) == NULL) { + Tcl_AppendResult(interp, "canvas has no parent with a valid window id! Is the toplevel window mapped?", (char *)NULL); + result = TCL_ERROR; + goto done; + } } while (wid == 0); @@ -2655,9 +2655,9 @@ DrawCanvas( visualPtr = Tk_Visual(tkwin); if (subsample == 0) { - Tcl_AppendResult(interp, "subsample cannot be zero", (char *)NULL); - result = TCL_ERROR; - goto done; + Tcl_AppendResult(interp, "subsample cannot be zero", (char *)NULL); + result = TCL_ERROR; + goto done; } /* @@ -2667,12 +2667,12 @@ DrawCanvas( */ for (itemPtr = canvasPtr -> firstItemPtr; itemPtr != NULL; - itemPtr = itemPtr -> nextPtr) { - if (itemPtr -> redraw_flags & FORCE_REDRAW) { - itemPtr -> redraw_flags &= ~FORCE_REDRAW; - EventuallyRedrawItem(canvasPtr, itemPtr); - itemPtr -> redraw_flags &= ~FORCE_REDRAW; - } + itemPtr = itemPtr -> nextPtr) { + if (itemPtr -> redraw_flags & FORCE_REDRAW) { + itemPtr -> redraw_flags &= ~FORCE_REDRAW; + EventuallyRedrawItem(canvasPtr, itemPtr); + itemPtr -> redraw_flags &= ~FORCE_REDRAW; + } } /* @@ -2683,23 +2683,23 @@ DrawCanvas( * of 0,0. */ if (canvasPtr->scrollX1 != 0 || canvasPtr->scrollY1 != 0 || - canvasPtr->scrollX2 != 0 || canvasPtr->scrollY2 != 0) { + canvasPtr->scrollX2 != 0 || canvasPtr->scrollY2 != 0) { - canvasX1 = canvasPtr->scrollX1; - canvasY1 = canvasPtr->scrollY1; - canvasX2 = canvasPtr->scrollX2; - canvasY2 = canvasPtr->scrollY2; - cWidth = canvasX2 - canvasX1 + 1; - cHeight = canvasY2 - canvasY1 + 1; + canvasX1 = canvasPtr->scrollX1; + canvasY1 = canvasPtr->scrollY1; + canvasX2 = canvasPtr->scrollX2; + canvasY2 = canvasPtr->scrollY2; + cWidth = canvasX2 - canvasX1 + 1; + cHeight = canvasY2 - canvasY1 + 1; } else { - cWidth = Tk_Width(tkwin); - cHeight = Tk_Height(tkwin); - canvasX1 = 0; - canvasY1 = 0; - canvasX2 = canvasX1 + cWidth - 1; - canvasY2 = canvasY1 + cHeight - 1; + cWidth = Tk_Width(tkwin); + cHeight = Tk_Height(tkwin); + canvasX1 = 0; + canvasY1 = 0; + canvasX2 = canvasX1 + cWidth - 1; + canvasY2 = canvasY1 + cHeight - 1; } /* @@ -2715,10 +2715,10 @@ DrawCanvas( pmWidth = pixmapX2 - pixmapX1 + 1; pmHeight = pixmapY2 - pixmapY1 + 1; if ((pixmap = Tk_GetPixmap(displayPtr, Tk_WindowId(tkwin), pmWidth, pmHeight, - bitsPerPixel)) == 0) { - Tcl_AppendResult(interp, "failed to create drawing Pixmap", (char *)NULL); - result = TCL_ERROR; - goto done; + bitsPerPixel)) == 0) { + Tcl_AppendResult(interp, "failed to create drawing Pixmap", (char *)NULL); + result = TCL_ERROR; + goto done; } /* @@ -2738,20 +2738,20 @@ DrawCanvas( canvasPtr->drawableXOrigin = pixmapX1; canvasPtr->drawableYOrigin = pixmapY1; for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL; - itemPtr = itemPtr->nextPtr) { - if ((itemPtr->x1 >= pixmapX2) || (itemPtr->y1 >= pixmapY2) || - (itemPtr->x2 < pixmapX1) || (itemPtr->y2 < pixmapY1)) { - if (!AlwaysRedraw(itemPtr)) { - continue; - } - } - if (itemPtr->state == TK_STATE_HIDDEN || - (itemPtr->state == TK_STATE_NULL && canvasPtr->canvas_state - == TK_STATE_HIDDEN)) { - continue; - } - ItemDisplay(canvasPtr, itemPtr, pixmap, pixmapX1, pixmapY1, pmWidth, - pmHeight); + itemPtr = itemPtr->nextPtr) { + if ((itemPtr->x1 >= pixmapX2) || (itemPtr->y1 >= pixmapY2) || + (itemPtr->x2 < pixmapX1) || (itemPtr->y2 < pixmapY1)) { + if (!AlwaysRedraw(itemPtr)) { + continue; + } + } + if (itemPtr->state == TK_STATE_HIDDEN || + (itemPtr->state == TK_STATE_NULL && canvasPtr->canvas_state + == TK_STATE_HIDDEN)) { + continue; + } + ItemDisplay(canvasPtr, itemPtr, pixmap, pixmapX1, pixmapY1, pmWidth, + pmHeight); } /* @@ -2762,10 +2762,10 @@ DrawCanvas( */ if ((ximagePtr = XGetImage(displayPtr, pixmap, -pixmapX1, -pixmapY1, cWidth, - cHeight, AllPlanes, ZPixmap)) == NULL) { - Tcl_AppendResult(interp, "failed to copy Pixmap to XImage", (char *)NULL); - result = TCL_ERROR; - goto done; + cHeight, AllPlanes, ZPixmap)) == NULL) { + Tcl_AppendResult(interp, "failed to copy Pixmap to XImage", (char *)NULL); + result = TCL_ERROR; + goto done; } #ifdef DEBUG_DRAWCANVAS @@ -2778,18 +2778,18 @@ DrawCanvas( if (ximagePtr->data != NULL) { int ix, iy; - Tcl_AppendResult(interp, " {", (char *)NULL); + Tcl_AppendResult(interp, " {", (char *)NULL); for (iy = 0; iy < ximagePtr->height; ++ iy) { Tcl_AppendResult(interp, " {", (char *)NULL); for (ix = 0; ix < ximagePtr->bytes_per_line; ++ ix) { - if (ix > 0) { - if (ix % 4 == 0) - Tcl_AppendResult(interp, "-", (char *)NULL); - else - Tcl_AppendResult(interp, " ", (char *)NULL); - } - snprintf(buffer,sizeof(buffer),"%2.2x",ximagePtr->data[ximagePtr->bytes_per_line * iy + ix]&0xFF); - Tcl_AppendResult(interp, buffer, (char *)NULL); + if (ix > 0) { + if (ix % 4 == 0) + Tcl_AppendResult(interp, "-", (char *)NULL); + else + Tcl_AppendResult(interp, " ", (char *)NULL); + } + snprintf(buffer,sizeof(buffer),"%2.2x",ximagePtr->data[ximagePtr->bytes_per_line * iy + ix]&0xFF); + Tcl_AppendResult(interp, buffer, (char *)NULL); } Tcl_AppendResult(interp, " }", (char *)NULL); } @@ -2871,62 +2871,62 @@ DrawCanvas( for (y = 0; y < blockPtr.height; ++y) { #ifdef DEBUG_DRAWCANVAS - Tcl_AppendResult(interp, " {", (char *)NULL); + Tcl_AppendResult(interp, " {", (char *)NULL); #endif - for(x = 0; x < blockPtr.width; ++x) { - unsigned int pixel = 0; + for(x = 0; x < blockPtr.width; ++x) { + unsigned int pixel = 0; int pixel_offset = blockPtr.pitch * y + blockPtr.pixelSize * x; - switch (ximagePtr->bits_per_pixel) { - - /* - * Get an 8 bit pixel from the XImage. - */ - - case 8 : - pixel = *((unsigned char *)(ximagePtr->data + bytesPerPixel * x - + ximagePtr->bytes_per_line * y)); - break; - - /* - * Get a 16 bit pixel from the XImage, and correct the - * byte order as necessary. - */ - - case 16 : - pixel = *((unsigned short *)(ximagePtr->data + bytesPerPixel * x - + ximagePtr->bytes_per_line * y)); - if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst) - || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst)) - pixel = BYTE_SWAP16(pixel); - break; - - /* - * Grab a 32 bit pixel from the XImage, and correct the - * byte order as necessary. - */ - - case 32 : - pixel = *((unsigned int *)(ximagePtr->data + bytesPerPixel * x - + ximagePtr->bytes_per_line * y)); - if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst) - || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst)) - pixel = BYTE_SWAP32(pixel); - break; - } - - /* - * We have a pixel with the correct byte order, so pull out the - * colours and place them in the photo block. Perhaps we could - * just not bother with the alpha byte because we are using - * TK_PHOTO_COMPOSITE_SET later? - * ***Windows: We have to swap the red and blue values. The - * XImage storage is B - G - R - A which becomes a 32bit ARGB - * quad. However the visual mask is a 32bit ABGR quad. And - * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad. - * If the visual mask was correct there would be no need to - * swap anything here. - */ + switch (ximagePtr->bits_per_pixel) { + + /* + * Get an 8 bit pixel from the XImage. + */ + + case 8 : + pixel = *((unsigned char *)(ximagePtr->data + bytesPerPixel * x + + ximagePtr->bytes_per_line * y)); + break; + + /* + * Get a 16 bit pixel from the XImage, and correct the + * byte order as necessary. + */ + + case 16 : + pixel = *((unsigned short *)(ximagePtr->data + bytesPerPixel * x + + ximagePtr->bytes_per_line * y)); + if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst) + || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst)) + pixel = BYTE_SWAP16(pixel); + break; + + /* + * Grab a 32 bit pixel from the XImage, and correct the + * byte order as necessary. + */ + + case 32 : + pixel = *((unsigned int *)(ximagePtr->data + bytesPerPixel * x + + ximagePtr->bytes_per_line * y)); + if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst) + || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst)) + pixel = BYTE_SWAP32(pixel); + break; + } + + /* + * We have a pixel with the correct byte order, so pull out the + * colours and place them in the photo block. Perhaps we could + * just not bother with the alpha byte because we are using + * TK_PHOTO_COMPOSITE_SET later? + * ***Windows: We have to swap the red and blue values. The + * XImage storage is B - G - R - A which becomes a 32bit ARGB + * quad. However the visual mask is a 32bit ABGR quad. And + * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad. + * If the visual mask was correct there would be no need to + * swap anything here. + */ #ifdef _WIN32 #define R_OFFSET blockPtr.offset[2] @@ -2953,11 +2953,11 @@ DrawCanvas( *((unsigned int *) (blockPtr.pixelPtr + pixel_offset)) = pixel; } else { blockPtr.pixelPtr[pixel_offset + R_OFFSET] = - (unsigned char)((pixel & visualPtr->red_mask) >> rshift); + (unsigned char)((pixel & visualPtr->red_mask) >> rshift); blockPtr.pixelPtr[pixel_offset + G_OFFSET] = - (unsigned char)((pixel & visualPtr->green_mask) >> gshift); + (unsigned char)((pixel & visualPtr->green_mask) >> gshift); blockPtr.pixelPtr[pixel_offset + B_OFFSET] = - (unsigned char)((pixel & visualPtr->blue_mask) >> bshift); + (unsigned char)((pixel & visualPtr->blue_mask) >> bshift); blockPtr.pixelPtr[pixel_offset + A_OFFSET] = 0xFF; } @@ -2968,25 +2968,25 @@ DrawCanvas( blockPtr.pixelPtr[pixel_offset + 1], blockPtr.pixelPtr[pixel_offset + 2], blockPtr.pixelPtr[pixel_offset + 3]); - { + { int ix; - if (x > 0) - Tcl_AppendResult(interp, "-", (char *)NULL); - for (ix = 0; ix < 4; ++ix) { - if (ix > 0) - Tcl_AppendResult(interp, " ", (char *)NULL); + if (x > 0) + Tcl_AppendResult(interp, "-", (char *)NULL); + for (ix = 0; ix < 4; ++ix) { + if (ix > 0) + Tcl_AppendResult(interp, " ", (char *)NULL); snprintf(buffer,sizeof(buffer),"%2.2x", - blockPtr.pixelPtr[blockPtr.pitch * y - + blockPtr.pixelSize * x + ix]&0xFF); - Tcl_AppendResult(interp, buffer, (char *)NULL); - } - } + blockPtr.pixelPtr[blockPtr.pitch * y + + blockPtr.pixelSize * x + ix]&0xFF); + Tcl_AppendResult(interp, buffer, (char *)NULL); + } + } #endif - } + } #ifdef DEBUG_DRAWCANVAS - Tcl_AppendResult(interp, " }", (char *)NULL); + Tcl_AppendResult(interp, " }", (char *)NULL); #endif } @@ -3001,17 +3001,17 @@ DrawCanvas( */ if (subsample != 1 || zoom != 1) { - if ((result = Tk_PhotoPutZoomedBlock(interp, photohandle, &blockPtr, - 0, 0, cWidth * zoom / subsample, cHeight * zoom / subsample, - zoom, zoom, subsample, subsample, TK_PHOTO_COMPOSITE_SET)) - != TCL_OK) { - goto done; - } + if ((result = Tk_PhotoPutZoomedBlock(interp, photohandle, &blockPtr, + 0, 0, cWidth * zoom / subsample, cHeight * zoom / subsample, + zoom, zoom, subsample, subsample, TK_PHOTO_COMPOSITE_SET)) + != TCL_OK) { + goto done; + } } else { - if ((result = Tk_PhotoPutBlock(interp, photohandle, &blockPtr, 0, 0, - cWidth, cHeight, TK_PHOTO_COMPOSITE_SET)) != TCL_OK) { - goto done; - } + if ((result = Tk_PhotoPutBlock(interp, photohandle, &blockPtr, 0, 0, + cWidth, cHeight, TK_PHOTO_COMPOSITE_SET)) != TCL_OK) { + goto done; + } } /* @@ -3020,13 +3020,13 @@ DrawCanvas( done: if (blockPtr.pixelPtr) - ckfree(blockPtr.pixelPtr); + ckfree(blockPtr.pixelPtr); if (pixmap) - Tk_FreePixmap(Tk_Display(tkwin), pixmap); + Tk_FreePixmap(Tk_Display(tkwin), pixmap); if (ximagePtr) - XDestroyImage(ximagePtr); + XDestroyImage(ximagePtr); if (xgc) - XFreeGC(displayPtr,xgc); + XFreeGC(displayPtr,xgc); return result; } @@ -3269,10 +3269,10 @@ DisplayCanvas( if (canvasPtr->textInfo.gotFocus) { fgGC = Tk_GCForColor(canvasPtr->highlightColorPtr, Tk_WindowId(tkwin)); - Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, + Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, canvasPtr->highlightWidth, Tk_WindowId(tkwin)); } else { - Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, + Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, canvasPtr->highlightWidth, Tk_WindowId(tkwin)); } } @@ -3453,7 +3453,7 @@ Tk_CanvasEventuallyRedraw( } if ((x1 >= x2) || (y1 >= y2) || - (x2 < canvasPtr->xOrigin) || (y2 < canvasPtr->yOrigin) || + (x2 < canvasPtr->xOrigin) || (y2 < canvasPtr->yOrigin) || (x1 >= canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin)) || (y1 >= canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin))) { return; @@ -3511,7 +3511,7 @@ EventuallyRedrawItem( return; } if ((itemPtr->x1 >= itemPtr->x2) || (itemPtr->y1 >= itemPtr->y2) || - (itemPtr->x2 < canvasPtr->xOrigin) || + (itemPtr->x2 < canvasPtr->xOrigin) || (itemPtr->y2 < canvasPtr->yOrigin) || (itemPtr->x1 >= canvasPtr->xOrigin+Tk_Width(canvasPtr->tkwin)) || (itemPtr->y1 >= canvasPtr->yOrigin+Tk_Height(canvasPtr->tkwin))) { @@ -3759,7 +3759,7 @@ TagSearchExprDestroy( TagSearchExpr *expr) { if (expr != NULL) { - if (expr->uids) { + if (expr->uids) { ckfree(expr->uids); } ckfree(expr); @@ -5367,9 +5367,9 @@ PickCurrentItem( for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) { if (itemPtr->tagPtr[i] == searchUids->currentUid) /* then */ { - memmove((void *)(itemPtr->tagPtr + i), - itemPtr->tagPtr + i + 1, - (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid)); + memmove((void *)(itemPtr->tagPtr + i), + itemPtr->tagPtr + i + 1, + (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid)); itemPtr->numTags--; break; } @@ -5538,7 +5538,7 @@ CanvasDoEvent( expr = canvasPtr->bindTagExprs; while (expr) { expr->index = 0; - expr->match = TagSearchEvalExpr(expr, itemPtr); + expr->match = TagSearchEvalExpr(expr, itemPtr); if (expr->match) { numExprs++; } @@ -5564,7 +5564,7 @@ CanvasDoEvent( i = itemPtr->numTags+2; expr = canvasPtr->bindTagExprs; while (expr) { - if (expr->match) { + if (expr->match) { objectPtr[i++] = (int *) expr->uid; } expr = expr->next; diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index 4adde33..9e5b52b 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -241,7 +241,7 @@ typedef struct TkCanvas { * * REDRAW_PENDING - 1 means a DoWhenIdle handler has already been * created to redraw some or all of the canvas. - * REDRAW_BORDERS - 1 means that the borders need to be redrawn + * REDRAW_BORDERS - 1 means that the borders need to be redrawn * during the next redisplay operation. * REPICK_NEEDED - 1 means DisplayCanvas should pick a new * current item before redrawing the canvas. @@ -292,7 +292,7 @@ typedef struct TkCanvas { MODULE_SCOPE int TkCanvPostscriptObjCmd(TkCanvas *canvasPtr, Tcl_Interp *interp, Tcl_Size argc, Tcl_Obj *const objv[]); -MODULE_SCOPE int TkCanvTranslatePath(TkCanvas *canvPtr, +MODULE_SCOPE int TkCanvTranslatePath(TkCanvas *canvPtr, int numVertex, double *coordPtr, int closed, XPoint *outPtr); /* diff --git a/generic/tkGet.c b/generic/tkGet.c index f109582..1994697 100644 --- a/generic/tkGet.c +++ b/generic/tkGet.c @@ -153,7 +153,7 @@ Tk_GetAnchor( error: Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad anchor position \"%s\": must be" + "bad anchor \"%s\": must be" " n, ne, e, se, s, sw, w, nw, or center", string)); Tcl_SetErrorCode(interp, "TK", "VALUE", "ANCHOR", (char *)NULL); return TCL_ERROR; diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 5a25dea..5b7cbde 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -781,12 +781,12 @@ TkPointerEvent( if ((eventPtr->type == MotionNotify) && !appGrabbed) { - /* - * Warp the mouse pointer with respect to window dispPtr->warpWindow - * if such a window was set in HandleEventGenerate. - */ + /* + * Warp the mouse pointer with respect to window dispPtr->warpWindow + * if such a window was set in HandleEventGenerate. + */ - TkDoWarpWrtWin(dispPtr); + TkDoWarpWrtWin(dispPtr); } if (!appGrabbed) { @@ -820,12 +820,12 @@ TkPointerEvent( return 0; } - /* - * Warp the mouse pointer with respect to window dispPtr->warpWindow - * if such a window was set in HandleEventGenerate. - */ + /* + * Warp the mouse pointer with respect to window dispPtr->warpWindow + * if such a window was set in HandleEventGenerate. + */ - TkDoWarpWrtWin(dispPtr); + TkDoWarpWrtWin(dispPtr); return 1; } diff --git a/generic/tkGrid.c b/generic/tkGrid.c index 50068b5..078ae9e 100644 --- a/generic/tkGrid.c +++ b/generic/tkGrid.c @@ -3338,12 +3338,12 @@ ConfigureContent( if (containerPtr == NULL) { containerPtr = GetGrid(parent); InitContainerData(containerPtr); - } + } if (contentPtr->containerPtr != NULL && contentPtr->containerPtr != containerPtr) { - if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { - Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); - } + if (contentPtr->containerPtr->tkwin != Tk_Parent(contentPtr->tkwin)) { + Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin); + } Unlink(contentPtr); contentPtr->containerPtr = NULL; } @@ -3385,7 +3385,7 @@ ConfigureContent( if (container == (TkWindow *)content) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't put \"%s\" inside \"%s\": would cause management loop", - Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); + Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin))); Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL); Unlink(contentPtr); return TCL_ERROR; diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 23259ec..dab66b4 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -33,8 +33,8 @@ */ static int DoConfig(Tcl_Interp *interp, Tk_Window tkwin, - Tk_ConfigSpec *specPtr, Tk_Uid value, - int valueIsUid, void *widgRec); + Tk_ConfigSpec *specPtr, Tcl_Obj *value, + void *widgRec); static Tk_ConfigSpec * FindConfigSpec(Tcl_Interp *interp, Tk_ConfigSpec *specs, const char *argvName, int needFlags, int hateFlags); @@ -91,6 +91,7 @@ Tk_ConfigureWidget( * else they are not considered. */ int hateFlags; /* If a spec contains any bits here, it's not * considered. */ + Tcl_Obj *obj; if (tkwin == NULL) { /* @@ -129,12 +130,11 @@ Tk_ConfigureWidget( const char *arg; if (flags & TK_CONFIG_OBJS) { - arg = Tcl_GetString((Tcl_Obj *) *argv); + arg = Tcl_GetString((Tcl_Obj *)*argv); } else { + arg = *argv; #if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8) Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory"); -#else - arg = *argv; #endif } specPtr = FindConfigSpec(interp, staticSpecs, arg, needFlags, hateFlags); @@ -153,19 +153,27 @@ Tk_ConfigureWidget( return TCL_ERROR; } if (flags & TK_CONFIG_OBJS) { - arg = Tcl_GetString((Tcl_Obj *) argv[1]); + obj = (Tcl_Obj *)argv[1]; + arg = Tcl_GetString(obj); } else { + arg = argv[1]; + obj = Tcl_NewStringObj(arg, TCL_INDEX_NONE); + Tcl_IncrRefCount(obj); #if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8) Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory"); -#else - arg = argv[1]; #endif } - if (DoConfig(interp, tkwin, specPtr, arg, 0, widgRec) != TCL_OK) { + if (DoConfig(interp, tkwin, specPtr, obj, widgRec) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( - "\n (processing \"%.40s\" option)",specPtr->argvName)); + "\n (processing \"%.40s\" option)", specPtr->argvName)); + if (!(flags & TK_CONFIG_OBJS)) { + Tcl_DecrRefCount(obj); + } return TCL_ERROR; } + if (!(flags & TK_CONFIG_OBJS)) { + Tcl_DecrRefCount(obj); + } if (!(flags & TK_CONFIG_ARGV_ONLY)) { specPtr->specFlags |= TK_CONFIG_OPTION_SPECIFIED; } @@ -193,14 +201,18 @@ Tk_ConfigureWidget( value = Tk_GetOption(tkwin, specPtr->dbName, specPtr->dbClass); } if (value != NULL) { - if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != + Tcl_Obj *arg = Tcl_NewStringObj(value, TCL_INDEX_NONE); + Tcl_IncrRefCount(arg); + if (DoConfig(interp, tkwin, specPtr, arg, widgRec) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (%s \"%.50s\" in widget \"%.50s\")", "database entry for", specPtr->dbName, Tk_PathName(tkwin))); + Tcl_DecrRefCount(arg); return TCL_ERROR; } + Tcl_DecrRefCount(arg); } else { if (specPtr->defValue != NULL) { value = Tk_GetUid(specPtr->defValue); @@ -209,14 +221,18 @@ Tk_ConfigureWidget( } if ((value != NULL) && !(specPtr->specFlags & TK_CONFIG_DONT_SET_DEFAULT)) { - if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) != + Tcl_Obj *arg = Tcl_NewStringObj(value, TCL_INDEX_NONE); + Tcl_IncrRefCount(arg); + if (DoConfig(interp, tkwin, specPtr, arg, widgRec) != TCL_OK) { Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf( "\n (%s \"%.50s\" in widget \"%.50s\")", "default value for", specPtr->dbName, Tk_PathName(tkwin))); + Tcl_DecrRefCount(arg); return TCL_ERROR; } + Tcl_DecrRefCount(arg); } } } @@ -348,17 +364,14 @@ DoConfig( Tk_Window tkwin, /* Window containing widget (needed to set up * X resources). */ Tk_ConfigSpec *specPtr, /* Specifier to apply. */ - Tk_Uid value, /* Value to use to fill in widgRec. */ - int valueIsUid, /* Non-zero means value is a Tk_Uid; zero - * means it's an ordinary string. */ + Tcl_Obj *arg, /* Value to use to fill in widgRec. */ void *widgRec) /* Record whose fields are to be modified. * Values must be properly initialized. */ { void *ptr; - Tk_Uid uid; - int nullValue; + int nullValue = 0; + const char *value = Tcl_GetString(arg); - nullValue = 0; if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1))) { nullValue = 1; } @@ -370,17 +383,17 @@ DoConfig( ptr = (char *)widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_BOOLEAN: - if (Tcl_GetBoolean(interp, value, (int *)ptr) != TCL_OK) { + if (Tcl_GetBooleanFromObj(interp, arg, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_INT: - if (Tcl_GetInt(interp, value, (int *)ptr) != TCL_OK) { + if (Tcl_GetIntFromObj(interp, arg, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_DOUBLE: - if (Tcl_GetDouble(interp, value, (double *)ptr) != TCL_OK) { + if (Tcl_GetDoubleFromObj(interp, arg, (double *)ptr) != TCL_OK) { return TCL_ERROR; } break; @@ -404,8 +417,7 @@ DoConfig( if (nullValue) { *((Tk_Uid *) ptr) = NULL; } else { - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - *((Tk_Uid *) ptr) = uid; + *((Tk_Uid *) ptr) = Tk_GetUid(value); } break; case TK_CONFIG_COLOR: { @@ -414,8 +426,7 @@ DoConfig( if (nullValue) { newPtr = NULL; } else { - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - newPtr = Tk_GetColor(interp, tkwin, uid); + newPtr = Tk_GetColor(interp, tkwin, value); if (newPtr == NULL) { return TCL_ERROR; } @@ -448,8 +459,7 @@ DoConfig( if (nullValue) { newBmp = None; } else { - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - newBmp = Tk_GetBitmap(interp, tkwin, uid); + newBmp = Tk_GetBitmap(interp, tkwin, value); if (newBmp == None) { return TCL_ERROR; } @@ -467,8 +477,7 @@ DoConfig( if (nullValue) { newBorder = NULL; } else { - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - newBorder = Tk_Get3DBorder(interp, tkwin, uid); + newBorder = Tk_Get3DBorder(interp, tkwin, value); if (newBorder == NULL) { return TCL_ERROR; } @@ -481,8 +490,7 @@ DoConfig( break; } case TK_CONFIG_RELIEF: - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetRelief(interp, uid, (int *)ptr) != TCL_OK) { + if (Tk_GetReliefFromObj(interp, arg, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; @@ -493,8 +501,7 @@ DoConfig( if (nullValue) { newCursor = NULL; } else { - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - newCursor = Tk_GetCursor(interp, tkwin, uid); + newCursor = Tk_GetCursor(interp, tkwin, value); if (newCursor == NULL) { return TCL_ERROR; } @@ -510,33 +517,29 @@ DoConfig( break; } case TK_CONFIG_JUSTIFY: - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetJustify(interp, uid, (Tk_Justify *) ptr) != TCL_OK) { + if (Tk_GetJustify(interp, value, (Tk_Justify *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_ANCHOR: - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetAnchor(interp, uid, (Tk_Anchor *) ptr) != TCL_OK) { + if (Tk_GetAnchorFromObj(interp, arg, (Tk_Anchor *) ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_CAP_STYLE: - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetCapStyle(interp, uid, (int *)ptr) != TCL_OK) { + if (Tk_GetCapStyle(interp, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_JOIN_STYLE: - uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - if (Tk_GetJoinStyle(interp, uid, (int *)ptr) != TCL_OK) { + if (Tk_GetJoinStyle(interp, value, (int *)ptr) != TCL_OK) { return TCL_ERROR; } break; case TK_CONFIG_PIXELS: if (nullValue) { *(int *)ptr = INT_MIN; - } else if (Tk_GetPixels(interp, tkwin, value, (int *)ptr) + } else if (Tk_GetPixelsFromObj(interp, tkwin, arg, (int *)ptr) != TCL_OK) { return TCL_ERROR; } diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index 2162591..72bb711 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -765,101 +765,101 @@ DisplayRectOval( &x2, &y2); if (x2 == x1) { - /* - * The width of the bounding box corresponds to less than one pixel - * on screen. Adjustment is needed to avoid drawing attempts with zero - * width items (which would draw nothing). The bounding box spans - * either 1 or 2 pixels. Select which pixel will be drawn. - */ - - short ix1 = (short) (rectOvalPtr->bbox[0]); - short ix2 = (short) (rectOvalPtr->bbox[2]); - - if (ix1 == ix2) { - - /* - * x1 and x2 are "within the same pixel". Use this pixel. - * Note: the degenerated case (bbox[0]==bbox[2]) of a completely - * flat box results in arbitrary selection of the pixel at the - * right (with positive coordinate) or left (with negative - * coordinate) of the box. There is no "best choice" here. - */ - - if (ix1 > 0) { - x2 += 1; - } else { - x1 -= 1; - } - } else { - - /* - * (x1,x2) span two pixels. Select the one with the larger - * covered "area". - */ - - if (ix1 > 0) { - if ((rectOvalPtr->bbox[2] - ix2) > (ix2 - rectOvalPtr->bbox[0])) { - x2 += 1; - } else { - x1 -= 1; - } - } else { - if ((rectOvalPtr->bbox[2] - ix1) > (ix1 - rectOvalPtr->bbox[0])) { - x2 += 1; - } else { - x1 -= 1; - } - } - } + /* + * The width of the bounding box corresponds to less than one pixel + * on screen. Adjustment is needed to avoid drawing attempts with zero + * width items (which would draw nothing). The bounding box spans + * either 1 or 2 pixels. Select which pixel will be drawn. + */ + + short ix1 = (short) (rectOvalPtr->bbox[0]); + short ix2 = (short) (rectOvalPtr->bbox[2]); + + if (ix1 == ix2) { + + /* + * x1 and x2 are "within the same pixel". Use this pixel. + * Note: the degenerated case (bbox[0]==bbox[2]) of a completely + * flat box results in arbitrary selection of the pixel at the + * right (with positive coordinate) or left (with negative + * coordinate) of the box. There is no "best choice" here. + */ + + if (ix1 > 0) { + x2 += 1; + } else { + x1 -= 1; + } + } else { + + /* + * (x1,x2) span two pixels. Select the one with the larger + * covered "area". + */ + + if (ix1 > 0) { + if ((rectOvalPtr->bbox[2] - ix2) > (ix2 - rectOvalPtr->bbox[0])) { + x2 += 1; + } else { + x1 -= 1; + } + } else { + if ((rectOvalPtr->bbox[2] - ix1) > (ix1 - rectOvalPtr->bbox[0])) { + x2 += 1; + } else { + x1 -= 1; + } + } + } } if (y2 == y1) { - /* - * The height of the bounding box corresponds to less than one pixel - * on screen. Adjustment is needed to avoid drawing attempts with zero - * height items (which would draw nothing). The bounding box spans - * either 1 or 2 pixels. Select which pixel will be drawn. - */ - - short iy1 = (short) (rectOvalPtr->bbox[1]); - short iy2 = (short) (rectOvalPtr->bbox[3]); - - if (iy1 == iy2) { - - /* - * y1 and y2 are "within the same pixel". Use this pixel. - * Note: the degenerated case (bbox[1]==bbox[3]) of a completely - * flat box results in arbitrary selection of the pixel below - * (with positive coordinate) or above (with negative coordinate) - * the box. There is no "best choice" here. - */ - - if (iy1 > 0) { - y2 += 1; - } else { - y1 -= 1; - } - } else { - - /* - * (y1,y2) span two pixels. Select the one with the larger - * covered "area". - */ - - if (iy1 > 0) { - if ((rectOvalPtr->bbox[3] - iy2) > (iy2 - rectOvalPtr->bbox[1])) { - y2 += 1; - } else { - y1 -= 1; - } - } else { - if ((rectOvalPtr->bbox[3] - iy1) > (iy1 - rectOvalPtr->bbox[1])) { - y2 += 1; - } else { - y1 -= 1; - } - } - } + /* + * The height of the bounding box corresponds to less than one pixel + * on screen. Adjustment is needed to avoid drawing attempts with zero + * height items (which would draw nothing). The bounding box spans + * either 1 or 2 pixels. Select which pixel will be drawn. + */ + + short iy1 = (short) (rectOvalPtr->bbox[1]); + short iy2 = (short) (rectOvalPtr->bbox[3]); + + if (iy1 == iy2) { + + /* + * y1 and y2 are "within the same pixel". Use this pixel. + * Note: the degenerated case (bbox[1]==bbox[3]) of a completely + * flat box results in arbitrary selection of the pixel below + * (with positive coordinate) or above (with negative coordinate) + * the box. There is no "best choice" here. + */ + + if (iy1 > 0) { + y2 += 1; + } else { + y1 -= 1; + } + } else { + + /* + * (y1,y2) span two pixels. Select the one with the larger + * covered "area". + */ + + if (iy1 > 0) { + if ((rectOvalPtr->bbox[3] - iy2) > (iy2 - rectOvalPtr->bbox[1])) { + y2 += 1; + } else { + y1 -= 1; + } + } else { + if ((rectOvalPtr->bbox[3] - iy1) > (iy1 - rectOvalPtr->bbox[1])) { + y2 += 1; + } else { + y1 -= 1; + } + } + } } /* diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index 6912e71..b5a7439 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -180,7 +180,7 @@ MODULE_SCOPE void TkScrollbarEventProc(void *clientData, MODULE_SCOPE void TkScrollbarEventuallyRedraw(TkScrollbar *scrollPtr); MODULE_SCOPE void TkpComputeScrollbarGeometry(TkScrollbar *scrollPtr); MODULE_SCOPE TkScrollbar *TkpCreateScrollbar(Tk_Window tkwin); -MODULE_SCOPE void TkpDestroyScrollbar(TkScrollbar *scrollPtr); +MODULE_SCOPE void TkpDestroyScrollbar(TkScrollbar *scrollPtr); MODULE_SCOPE void TkpDisplayScrollbar(void *clientData); MODULE_SCOPE void TkpConfigureScrollbar(TkScrollbar *scrollPtr); MODULE_SCOPE int TkpScrollbarPosition(TkScrollbar *scrollPtr, diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 4cef94b..fab1018 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -2270,8 +2270,8 @@ static void DrawItem( dispRow = DisplayRow(item->rowPos, tv); h = tv->tree.rowHeight * dispRow; if (h >= tv->tree.treeArea.height) { - /* The item is outside the visible area */ - return; + /* The item is outside the visible area */ + return; } rowHeight = tv->tree.rowHeight * item->height; @@ -2409,7 +2409,7 @@ static void DrawForest( */ static void DrawTreeArea(Treeview *tv, Drawable d) { if (tv->tree.showFlags & SHOW_HEADINGS) { - DrawHeadings(tv, d); + DrawHeadings(tv, d); } DrawForest(tv, tv->tree.root->children, d, 0); DrawSeparators(tv, d); @@ -2430,12 +2430,12 @@ static void TreeviewDisplay(void *clientData, Drawable d) /* When the tree area does not fit in the available space, there is a * risk that it will be drawn over other areas of the layout. */ - - winWidth = Tk_Width(tkwin); + + winWidth = Tk_Width(tkwin); winHeight = Tk_Height(tkwin); width = tv->tree.treeArea.width; height = tv->tree.headingArea.height + tv->tree.treeArea.height; - + if ((width == winWidth && height == winHeight) || (tv->tree.treeArea.height % tv->tree.rowHeight == 0 && TreeWidth(tv) <= width)) { @@ -2446,9 +2446,9 @@ static void TreeviewDisplay(void *clientData, Drawable d) } else { /* The tree area needs to be clipped */ - + int x, y; - + x = tv->tree.treeArea.x; if (tv->tree.showFlags & SHOW_HEADINGS) { y = tv->tree.headingArea.y; @@ -4265,7 +4265,7 @@ static void AllocCellTagSets(Treeview *tv, TreeItem *item, Tcl_Size columnNumber { Tcl_Size i, newSize = columnNumber + 1; if (newSize < tv->tree.nColumns + 1) { - newSize = tv->tree.nColumns + 1; + newSize = tv->tree.nColumns + 1; } if (item->nTagSets < newSize) { if (item->cellTagSets == NULL) { diff --git a/tests/canvImg.test b/tests/canvImg.test index 36c5b4b..9426d56 100644 --- a/tests/canvImg.test +++ b/tests/canvImg.test @@ -29,7 +29,7 @@ test canvImg-1.2 {options for image items} -body { .c create image 50 50 -anchor gorp -tags i1 } -cleanup { .c delete all -} -returnCodes error -result {bad anchor position "gorp": must be n, ne, e, se, s, sw, w, nw, or center} +} -returnCodes error -result {bad anchor "gorp": must be n, ne, e, se, s, sw, w, nw, or center} test canvImg-1.3 {options for image items} -constraints testImageType -setup { image create test foo .c delete all diff --git a/tests/canvText.test b/tests/canvText.test index 6c14430..da41395 100644 --- a/tests/canvText.test +++ b/tests/canvText.test @@ -26,7 +26,7 @@ test canvText-1.1 {configuration options: good value for "anchor"} -body { } -result {nw nw} test canvasText-1.2 {configuration options: bad value for "anchor"} -body { .c itemconfigure test -anchor xyz -} -returnCodes error -result {bad anchor position "xyz": must be n, ne, e, se, s, sw, w, nw, or center} +} -returnCodes error -result {bad anchor "xyz": must be n, ne, e, se, s, sw, w, nw, or center} test canvText-1.3 {configuration options: good value for "fill"} -body { .c itemconfigure test -fill #ff0000 list [lindex [.c itemconfigure test -fill] 4] [.c itemcget test -fill] diff --git a/tests/canvas.test b/tests/canvas.test index e75ab36..7b1e883 100644 --- a/tests/canvas.test +++ b/tests/canvas.test @@ -138,7 +138,7 @@ test canvas-1.33 {configuration options: good value for "relief"} -body { } -result {groove} test canvas-1.34 {configuration options: bad value for "relief"} -body { .c configure -relief r -} -returnCodes error -result {bad relief "r": must be flat, groove, raised, ridge, solid, or sunken} +} -returnCodes error -result {ambiguous relief "r": must be flat, groove, raised, ridge, solid, or sunken} test canvas-1.35 {configuration options: good value for "selectbackground"} -body { .c configure -selectbackground #110022 .c cget -selectbackground |