diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index da25b3737..15218c049 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -101,7 +101,7 @@ static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL}, {TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL}, {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_CANVAS_BORDER_WIDTH, offsetof(TkCanvas, borderWidth), 0, NULL}, + DEF_CANVAS_BORDER_WIDTH, offsetof(TkCanvas, borderWidthObj), TK_CONFIG_OBJS, NULL}, {TK_CONFIG_DOUBLE, "-closeenough", "closeEnough", "CloseEnough", DEF_CANVAS_CLOSE_ENOUGH, offsetof(TkCanvas, closeEnough), 0, NULL}, {TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine", @@ -117,7 +117,7 @@ static const Tk_ConfigSpec configSpecs[] = { DEF_CANVAS_HIGHLIGHT, offsetof(TkCanvas, highlightColorPtr), 0, NULL}, {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", - DEF_CANVAS_HIGHLIGHT_WIDTH, offsetof(TkCanvas, highlightWidth), 0, NULL}, + DEF_CANVAS_HIGHLIGHT_WIDTH, offsetof(TkCanvas, highlightWidthObj), TK_CONFIG_OBJS, NULL}, {TK_CONFIG_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_CANVAS_INSERT_BG, offsetof(TkCanvas, textInfo.insertBorder), 0, NULL}, {TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", @@ -138,8 +138,8 @@ static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_RELIEF, "-relief", "relief", "Relief", DEF_CANVAS_RELIEF, offsetof(TkCanvas, relief), 0, NULL}, {TK_CONFIG_STRING, "-scrollregion", "scrollRegion", "ScrollRegion", - DEF_CANVAS_SCROLL_REGION, offsetof(TkCanvas, regionString), - TK_CONFIG_NULL_OK, NULL}, + DEF_CANVAS_SCROLL_REGION, offsetof(TkCanvas, regionObj), + TK_CONFIG_OBJS|TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground", DEF_CANVAS_SELECT_COLOR, offsetof(TkCanvas, textInfo.selBorder), TK_CONFIG_COLOR_ONLY, NULL}, @@ -162,24 +162,24 @@ static const Tk_ConfigSpec configSpecs[] = { "normal", offsetof(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT, &stateOption}, {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus", - DEF_CANVAS_TAKE_FOCUS, offsetof(TkCanvas, takeFocus), - TK_CONFIG_NULL_OK, NULL}, + DEF_CANVAS_TAKE_FOCUS, offsetof(TkCanvas, takeFocusObj), + TK_CONFIG_OBJS|TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_PIXELS, "-width", "width", "Width", DEF_CANVAS_WIDTH, offsetof(TkCanvas, widthObj), TK_CONFIG_OBJS, NULL}, {TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", - DEF_CANVAS_X_SCROLL_CMD, offsetof(TkCanvas, xScrollCmd), - TK_CONFIG_NULL_OK, NULL}, + DEF_CANVAS_X_SCROLL_CMD, offsetof(TkCanvas, xScrollCmdObj), + TK_CONFIG_OBJS|TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_PIXELS, "-xscrollincrement", "xScrollIncrement", "ScrollIncrement", - DEF_CANVAS_X_SCROLL_INCREMENT, offsetof(TkCanvas, xScrollIncrement), - 0, NULL}, + DEF_CANVAS_X_SCROLL_INCREMENT, offsetof(TkCanvas, xScrollIncrementObj), + TK_CONFIG_OBJS, NULL}, {TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand", - DEF_CANVAS_Y_SCROLL_CMD, offsetof(TkCanvas, yScrollCmd), - TK_CONFIG_NULL_OK, NULL}, + DEF_CANVAS_Y_SCROLL_CMD, offsetof(TkCanvas, yScrollCmdObj), + TK_CONFIG_OBJS|TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_PIXELS, "-yscrollincrement", "yScrollIncrement", "ScrollIncrement", - DEF_CANVAS_Y_SCROLL_INCREMENT, offsetof(TkCanvas, yScrollIncrement), - 0, NULL}, + DEF_CANVAS_Y_SCROLL_INCREMENT, offsetof(TkCanvas, yScrollIncrementObj), + TK_CONFIG_OBJS, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; @@ -678,10 +678,10 @@ Tk_CanvasObjCmd( CanvasCmdDeletedProc); canvasPtr->firstItemPtr = NULL; canvasPtr->lastItemPtr = NULL; - canvasPtr->borderWidth = 0; + canvasPtr->borderWidthObj = NULL; canvasPtr->bgBorder = NULL; canvasPtr->relief = TK_RELIEF_FLAT; - canvasPtr->highlightWidth = 0; + canvasPtr->highlightWidthObj = NULL; canvasPtr->highlightBgColorPtr = NULL; canvasPtr->highlightColorPtr = NULL; canvasPtr->inset = 0; @@ -716,15 +716,15 @@ Tk_CanvasObjCmd( canvasPtr->pickEvent.xcrossing.x = 0; canvasPtr->pickEvent.xcrossing.y = 0; canvasPtr->state = 0; - canvasPtr->xScrollCmd = NULL; - canvasPtr->yScrollCmd = NULL; + canvasPtr->xScrollCmdObj = NULL; + canvasPtr->yScrollCmdObj = NULL; canvasPtr->scrollX1 = 0; canvasPtr->scrollY1 = 0; canvasPtr->scrollX2 = 0; canvasPtr->scrollY2 = 0; - canvasPtr->regionString = NULL; - canvasPtr->xScrollIncrement = 0; - canvasPtr->yScrollIncrement = 0; + canvasPtr->regionObj = NULL; + canvasPtr->xScrollIncrementObj = NULL; + canvasPtr->yScrollIncrementObj = NULL; canvasPtr->scanX = 0; canvasPtr->scanXOrigin = 0; canvasPtr->scanY = 0; @@ -732,7 +732,7 @@ Tk_CanvasObjCmd( canvasPtr->hotPtr = NULL; canvasPtr->hotPrevPtr = NULL; canvasPtr->cursor = NULL; - canvasPtr->takeFocus = NULL; + canvasPtr->takeFocusObj = NULL; canvasPtr->pixelsPerMM = WidthOfScreen(Tk_Screen(newWin)); canvasPtr->pixelsPerMM /= WidthMMOfScreen(Tk_Screen(newWin)); canvasPtr->flags = 0; @@ -2054,16 +2054,19 @@ CanvasWidgetCmd( break; case TK_SCROLL_PAGES: newX = (int) (canvasPtr->xOrigin + count * .9 - * (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset)); + * (Tk_Width(canvasPtr->tkwin) - 2 * canvasPtr->inset)); break; - case TK_SCROLL_UNITS: - if (canvasPtr->xScrollIncrement > 0) { - newX = canvasPtr->xOrigin + count*canvasPtr->xScrollIncrement; + case TK_SCROLL_UNITS: { + int xScrollIncrement; + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->xScrollIncrementObj, &xScrollIncrement); + if (xScrollIncrement > 0) { + newX = canvasPtr->xOrigin + count * xScrollIncrement; } else { newX = (int) (canvasPtr->xOrigin + count * .1 - * (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset)); + * (Tk_Width(canvasPtr->tkwin) - 2 * canvasPtr->inset)); } break; + } default: result = TCL_ERROR; goto done; @@ -2094,16 +2097,19 @@ CanvasWidgetCmd( break; case TK_SCROLL_PAGES: newY = (int) (canvasPtr->yOrigin + count * .9 - * (Tk_Height(canvasPtr->tkwin) - 2*canvasPtr->inset)); + * (Tk_Height(canvasPtr->tkwin) - 2 * canvasPtr->inset)); break; - case TK_SCROLL_UNITS: - if (canvasPtr->yScrollIncrement > 0) { - newY = canvasPtr->yOrigin + count*canvasPtr->yScrollIncrement; + case TK_SCROLL_UNITS: { + int yScrollIncrement; + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->yScrollIncrementObj, &yScrollIncrement); + if (yScrollIncrement > 0) { + newY = canvasPtr->yOrigin + count * yScrollIncrement; } else { newY = (int) (canvasPtr->yOrigin + count * .1 - * (Tk_Height(canvasPtr->tkwin) - 2*canvasPtr->inset)); + * (Tk_Height(canvasPtr->tkwin) - 2 * canvasPtr->inset)); } break; + } default: result = TCL_ERROR; goto done; @@ -2259,7 +2265,8 @@ ConfigureCanvas( XGCValues gcValues; GC newGC; Tk_State old_canvas_state=canvasPtr->canvas_state; - int width, height; + int width, height, borderWidth, highlightWidth; + int xScrollIncrement, yScrollIncrement; if (Tk_ConfigureWidget(interp, canvasPtr->tkwin, configSpecs, objc, objv, canvasPtr, @@ -2274,24 +2281,49 @@ ConfigureCanvas( Tk_SetBackgroundFromBorder(canvasPtr->tkwin, canvasPtr->bgBorder); - if (canvasPtr->highlightWidth < 0) { - canvasPtr->highlightWidth = 0; - } - canvasPtr->inset = canvasPtr->borderWidth + canvasPtr->highlightWidth; + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->heightObj, &height); + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->highlightWidthObj, &highlightWidth); Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->widthObj, &width); + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->xScrollIncrementObj, &xScrollIncrement); + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->yScrollIncrementObj, &yScrollIncrement); + if (borderWidth < 0) { + borderWidth = 0; + Tcl_DecrRefCount(canvasPtr->borderWidthObj); + canvasPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(canvasPtr->borderWidthObj); + } if (height < 0) { height = 0; Tcl_DecrRefCount(canvasPtr->heightObj); canvasPtr->heightObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(canvasPtr->heightObj); } + if (highlightWidth < 0) { + highlightWidth = 0; + Tcl_DecrRefCount(canvasPtr->highlightWidthObj); + canvasPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(canvasPtr->highlightWidthObj); + } if (width < 0) { width = 0; Tcl_DecrRefCount(canvasPtr->widthObj); canvasPtr->widthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(canvasPtr->widthObj); } + if (xScrollIncrement < 0) { + xScrollIncrement = 0; + Tcl_DecrRefCount(canvasPtr->xScrollIncrementObj); + canvasPtr->xScrollIncrementObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(canvasPtr->xScrollIncrementObj); + } + if (yScrollIncrement < 0) { + yScrollIncrement = 0; + Tcl_DecrRefCount(canvasPtr->yScrollIncrementObj); + canvasPtr->yScrollIncrementObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(canvasPtr->yScrollIncrementObj); + } + canvasPtr->inset = borderWidth + highlightWidth; gcValues.function = GXcopy; gcValues.graphics_exposures = False; @@ -2328,8 +2360,8 @@ ConfigureCanvas( * Reset the desired dimensions for the window. */ - Tk_GeometryRequest(canvasPtr->tkwin, width + 2*canvasPtr->inset, - height + 2*canvasPtr->inset); + Tk_GeometryRequest(canvasPtr->tkwin, width + 2 * canvasPtr->inset, + height + 2 * canvasPtr->inset); /* * Restart the cursor timing sequence in case the on-time or off-time just @@ -2348,22 +2380,22 @@ ConfigureCanvas( canvasPtr->scrollY1 = 0; canvasPtr->scrollX2 = 0; canvasPtr->scrollY2 = 0; - if (canvasPtr->regionString != NULL) { + if (canvasPtr->regionObj != NULL) { Tcl_Size argc2; const char **argv2; - if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString, + if (Tcl_SplitList(canvasPtr->interp, Tcl_GetString(canvasPtr->regionObj), &argc2, &argv2) != TCL_OK) { return TCL_ERROR; } if (argc2 != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad scrollRegion \"%s\"", canvasPtr->regionString)); + "bad scrollRegion \"%s\"", Tcl_GetString(canvasPtr->regionObj))); Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLL_REGION", (char *)NULL); badRegion: - ckfree(canvasPtr->regionString); + Tcl_DecrRefCount(canvasPtr->regionObj); ckfree(argv2); - canvasPtr->regionString = NULL; + canvasPtr->regionObj = NULL; return TCL_ERROR; } if ((Tk_GetPixels(canvasPtr->interp, canvasPtr->tkwin, @@ -3007,6 +3039,7 @@ DisplayCanvas( Tk_Item *itemPtr; Pixmap pixmap; int screenX1, screenX2, screenY1, screenY2, width, height; + int borderWidth, highlightWidth; if (canvasPtr->tkwin == NULL) { return; @@ -3184,17 +3217,18 @@ DisplayCanvas( */ borders: + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->highlightWidthObj, &highlightWidth); if (canvasPtr->flags & REDRAW_BORDERS) { canvasPtr->flags &= ~REDRAW_BORDERS; - if (canvasPtr->borderWidth > 0) { + if (borderWidth > 0) { Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), - canvasPtr->bgBorder, canvasPtr->highlightWidth, - canvasPtr->highlightWidth, - Tk_Width(tkwin) - 2*canvasPtr->highlightWidth, - Tk_Height(tkwin) - 2*canvasPtr->highlightWidth, - canvasPtr->borderWidth, canvasPtr->relief); + canvasPtr->bgBorder, highlightWidth, highlightWidth, + Tk_Width(tkwin) - 2 * highlightWidth, + Tk_Height(tkwin) - 2 * highlightWidth, + borderWidth, canvasPtr->relief); } - if (canvasPtr->highlightWidth > 0) { + if (highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(canvasPtr->highlightBgColorPtr, @@ -3203,10 +3237,10 @@ DisplayCanvas( fgGC = Tk_GCForColor(canvasPtr->highlightColorPtr, Tk_WindowId(tkwin)); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, - canvasPtr->highlightWidth, Tk_WindowId(tkwin)); + highlightWidth, Tk_WindowId(tkwin)); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, - canvasPtr->highlightWidth, Tk_WindowId(tkwin)); + highlightWidth, Tk_WindowId(tkwin)); } } } @@ -5580,6 +5614,8 @@ CanvasFocusProc( int gotFocus) /* 1 means window is getting focus, 0 means * it's losing it. */ { + int highlightWidth; + Tcl_DeleteTimerHandler(canvasPtr->insertBlinkHandler); if (gotFocus) { canvasPtr->textInfo.gotFocus = 1; @@ -5594,7 +5630,8 @@ CanvasFocusProc( canvasPtr->insertBlinkHandler = NULL; } EventuallyRedrawItem(canvasPtr, canvasPtr->textInfo.focusItemPtr); - if (canvasPtr->highlightWidth > 0) { + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->highlightWidthObj, &highlightWidth); + if (highlightWidth > 0) { canvasPtr->flags |= REDRAW_BORDERS; if (!(canvasPtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(DisplayCanvas, canvasPtr); @@ -5841,7 +5878,7 @@ CanvasUpdateScrollbars( Tcl_Interp *interp; int xOrigin, yOrigin, inset, width, height; int scrollX1, scrollX2, scrollY1, scrollY2; - char *xScrollCmd, *yScrollCmd; + Tcl_Obj *xScrollCmdObj, *yScrollCmdObj; Tcl_DString buf; /* @@ -5851,13 +5888,13 @@ CanvasUpdateScrollbars( interp = canvasPtr->interp; Tcl_Preserve(interp); - xScrollCmd = canvasPtr->xScrollCmd; - if (xScrollCmd != NULL) { - Tcl_Preserve(xScrollCmd); + xScrollCmdObj = canvasPtr->xScrollCmdObj; + if (xScrollCmdObj != NULL) { + Tcl_IncrRefCount(xScrollCmdObj); } - yScrollCmd = canvasPtr->yScrollCmd; - if (yScrollCmd != NULL) { - Tcl_Preserve(yScrollCmd); + yScrollCmdObj = canvasPtr->yScrollCmdObj; + if (yScrollCmdObj != NULL) { + Tcl_IncrRefCount(yScrollCmdObj); } xOrigin = canvasPtr->xOrigin; yOrigin = canvasPtr->yOrigin; @@ -5869,12 +5906,12 @@ CanvasUpdateScrollbars( scrollY1 = canvasPtr->scrollY1; scrollY2 = canvasPtr->scrollY2; canvasPtr->flags &= ~UPDATE_SCROLLBARS; - if (canvasPtr->xScrollCmd != NULL) { + if (canvasPtr->xScrollCmdObj != NULL) { Tcl_Obj *fractions = ScrollFractions(xOrigin + inset, xOrigin + width - inset, scrollX1, scrollX2); Tcl_DStringInit(&buf); - Tcl_DStringAppend(&buf, xScrollCmd, TCL_INDEX_NONE); + Tcl_DStringAppend(&buf, Tcl_GetString(xScrollCmdObj), TCL_INDEX_NONE); Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE); Tcl_DStringAppend(&buf, Tcl_GetString(fractions), TCL_INDEX_NONE); result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL); @@ -5884,15 +5921,15 @@ CanvasUpdateScrollbars( Tcl_BackgroundException(interp, result); } Tcl_ResetResult(interp); - Tcl_Release(xScrollCmd); + Tcl_DecrRefCount(xScrollCmdObj); } - if (yScrollCmd != NULL) { + if (yScrollCmdObj != NULL) { Tcl_Obj *fractions = ScrollFractions(yOrigin + inset, yOrigin + height - inset, scrollY1, scrollY2); Tcl_DStringInit(&buf); - Tcl_DStringAppend(&buf, yScrollCmd, TCL_INDEX_NONE); + Tcl_DStringAppend(&buf, Tcl_GetString(yScrollCmdObj), TCL_INDEX_NONE); Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE); Tcl_DStringAppend(&buf, Tcl_GetString(fractions), TCL_INDEX_NONE); result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL); @@ -5902,7 +5939,7 @@ CanvasUpdateScrollbars( Tcl_BackgroundException(interp, result); } Tcl_ResetResult(interp); - Tcl_Release(yScrollCmd); + Tcl_DecrRefCount(yScrollCmdObj); } Tcl_Release(interp); } @@ -5936,6 +5973,7 @@ CanvasSetOrigin( * window). */ { int left, right, top, bottom, delta; + int xScrollIncrement, yScrollIncrement; /* * If scroll increments have been set, round the window origin to the @@ -5943,26 +5981,28 @@ CanvasSetOrigin( * just inside the borders, not the upper left corner. */ - if (canvasPtr->xScrollIncrement > 0) { + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->xScrollIncrementObj, &xScrollIncrement); + Tk_GetPixelsFromObj(NULL, canvasPtr->tkwin, canvasPtr->yScrollIncrementObj, &yScrollIncrement); + if (xScrollIncrement > 0) { if (xOrigin >= 0) { - xOrigin += canvasPtr->xScrollIncrement/2; + xOrigin += xScrollIncrement/2; xOrigin -= (xOrigin + canvasPtr->inset) - % canvasPtr->xScrollIncrement; + % xScrollIncrement; } else { - xOrigin = (-xOrigin) + canvasPtr->xScrollIncrement/2; + xOrigin = (-xOrigin) + xScrollIncrement/2; xOrigin = -(xOrigin - (xOrigin - canvasPtr->inset) - % canvasPtr->xScrollIncrement); + % xScrollIncrement); } } - if (canvasPtr->yScrollIncrement > 0) { + if (yScrollIncrement > 0) { if (yOrigin >= 0) { - yOrigin += canvasPtr->yScrollIncrement/2; + yOrigin += yScrollIncrement/2; yOrigin -= (yOrigin + canvasPtr->inset) - % canvasPtr->yScrollIncrement; + % yScrollIncrement; } else { - yOrigin = (-yOrigin) + canvasPtr->yScrollIncrement/2; + yOrigin = (-yOrigin) + yScrollIncrement/2; yOrigin = -(yOrigin - (yOrigin - canvasPtr->inset) - % canvasPtr->yScrollIncrement); + % yScrollIncrement); } } @@ -5977,7 +6017,7 @@ CanvasSetOrigin( * full increments. */ - if ((canvasPtr->confine) && (canvasPtr->regionString != NULL)) { + if ((canvasPtr->confine) && (canvasPtr->regionObj != NULL)) { left = xOrigin + canvasPtr->inset - canvasPtr->scrollX1; right = canvasPtr->scrollX2 - (xOrigin + Tk_Width(canvasPtr->tkwin) - canvasPtr->inset); @@ -5986,27 +6026,27 @@ CanvasSetOrigin( - (yOrigin + Tk_Height(canvasPtr->tkwin) - canvasPtr->inset); if ((left < 0) && (right > 0)) { delta = (right > -left) ? -left : right; - if (canvasPtr->xScrollIncrement > 0) { - delta -= delta % canvasPtr->xScrollIncrement; + if (xScrollIncrement > 0) { + delta -= delta % xScrollIncrement; } xOrigin += delta; } else if ((right < 0) && (left > 0)) { delta = (left > -right) ? -right : left; - if (canvasPtr->xScrollIncrement > 0) { - delta -= delta % canvasPtr->xScrollIncrement; + if (xScrollIncrement > 0) { + delta -= delta % xScrollIncrement; } xOrigin -= delta; } if ((top < 0) && (bottom > 0)) { delta = (bottom > -top) ? -top : bottom; - if (canvasPtr->yScrollIncrement > 0) { - delta -= delta % canvasPtr->yScrollIncrement; + if (yScrollIncrement > 0) { + delta -= delta % yScrollIncrement; } yOrigin += delta; } else if ((bottom < 0) && (top > 0)) { delta = (top > -bottom) ? -bottom : top; - if (canvasPtr->yScrollIncrement > 0) { - delta -= delta % canvasPtr->yScrollIncrement; + if (yScrollIncrement > 0) { + delta -= delta % yScrollIncrement; } yOrigin -= delta; } diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index 249b0bbcf..4542ec14b 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -60,11 +60,11 @@ typedef struct TkCanvas { * Information used when displaying widget: */ - int borderWidth; /* Width of 3-D border around window. */ + Tcl_Obj *borderWidthObj; /* Width of 3-D border around window. */ Tk_3DBorder bgBorder; /* Used for canvas background. */ int relief; /* Indicates whether window as a whole is * raised, sunken, or flat. */ - int highlightWidth; /* Width in pixels of highlight to draw around + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ XColor *highlightBgColorPtr; @@ -155,25 +155,25 @@ typedef struct TkCanvas { * Information used for managing scrollbars: */ - char *xScrollCmd; /* Command prefix for communicating with + Tcl_Obj *xScrollCmdObj; /* Command prefix for communicating with * horizontal scrollbar. NULL means no - * horizontal scrollbar. Malloc'ed. */ - char *yScrollCmd; /* Command prefix for communicating with + * horizontal scrollbar. */ + Tcl_Obj *yScrollCmdObj; /* Command prefix for communicating with * vertical scrollbar. NULL means no vertical - * scrollbar. Malloc'ed. */ + * scrollbar. */ int scrollX1, scrollY1, scrollX2, scrollY2; /* These four coordinates define the region * that is the 100% area for scrolling (i.e. * these numbers determine the size and * location of the sliders on scrollbars). * Units are pixels in canvas coords. */ - char *regionString; /* The option string from which scrollX1 etc. - * are derived. Malloc'ed. */ - int xScrollIncrement; /* If >0, defines a grid for horizontal + Tcl_Obj *regionObj; /* The option string from which scrollX1 etc. + * are derived. */ + Tcl_Obj *xScrollIncrementObj; /* If >0, defines a grid for horizontal * scrolling. This is the size of the "unit", * and the left edge of the screen will always * lie on an even unit boundary. */ - int yScrollIncrement; /* If >0, defines a grid for horizontal + Tcl_Obj *yScrollIncrementObj; /* If >0, defines a grid for horizontal * scrolling. This is the size of the "unit", * and the left edge of the screen will always * lie on an even unit boundary. */ @@ -207,9 +207,9 @@ typedef struct TkCanvas { */ Tk_Cursor cursor; /* Current cursor for window, or NULL. */ - char *takeFocus; /* Value of -takefocus option; not used in the + Tcl_Obj *takeFocusObj; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal - * scripts. Malloc'ed, but may be NULL. */ + * scripts. May be NULL. */ double pixelsPerMM; /* Scale factor between MM and pixels; used * when converting coordinates. */ int flags; /* Various flags; see below for