diff options
Diffstat (limited to 'unix/tkUnixCursor.c')
-rw-r--r-- | unix/tkUnixCursor.c | 82 |
1 files changed, 49 insertions, 33 deletions
diff --git a/unix/tkUnixCursor.c b/unix/tkUnixCursor.c index bbf5206..5266bde 100644 --- a/unix/tkUnixCursor.c +++ b/unix/tkUnixCursor.c @@ -182,7 +182,7 @@ static const struct TkCursorName { static Cursor CreateCursorFromTableOrFile(Tcl_Interp *interp, Tk_Window tkwin, int argc, const char **argv, const struct TkCursorName *tkCursorPtr); - + /* *---------------------------------------------------------------------- * @@ -275,8 +275,9 @@ TkGetCursorByName( bg.red = bg.green = bg.blue = 65535; } else { if (TkParseColor(display, Tk_Colormap(tkwin), argv[1], &fg) == 0) { - Tcl_AppendResult(interp, "invalid color name \"", argv[1], - "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid color name \"%s\"", argv[1])); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } if (argc == 2) { @@ -284,8 +285,9 @@ TkGetCursorByName( maskIndex = namePtr->shape; } else if (TkParseColor(display, Tk_Colormap(tkwin), argv[2], &bg) == 0) { - Tcl_AppendResult(interp, "invalid color name \"", argv[2], - "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid color name \"%s\"", argv[2])); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } } @@ -293,7 +295,9 @@ TkGetCursorByName( if (dispPtr->cursorFont == None) { dispPtr->cursorFont = XLoadFont(display, CURSORFONT); if (dispPtr->cursorFont == None) { - Tcl_SetResult(interp, "couldn't load cursor font", TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "couldn't load cursor font", -1)); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "FONT", NULL); goto cleanup; } } @@ -306,8 +310,10 @@ TkGetCursorByName( */ if (!inTkTable && Tcl_IsSafe(interp)) { - Tcl_AppendResult(interp, "can't get cursor from a file in", - " a safe interpreter", NULL); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "can't get cursor from a file in a safe interpreter", + -1)); + Tcl_SetErrorCode(interp, "TK", "SAFE", "CURSOR_FILE", NULL); cursorPtr = NULL; goto cleanup; } @@ -347,10 +353,11 @@ TkGetCursorByName( if (argv) { ckfree(argv); } - Tcl_AppendResult(interp, "bad cursor spec \"", string, "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad cursor spec \"%s\"", string)); + Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL); return NULL; } - + /* *---------------------------------------------------------------------- * @@ -419,8 +426,9 @@ CreateCursorFromTableOrFile( data = TkGetBitmapData(NULL, tkCursorPtr->data, NULL, &width, &height, &xHot, &yHot); if (data == NULL) { - Tcl_AppendResult(interp, "error reading bitmap data for \"", - argv[0], "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "error reading bitmap data for \"%s\"", argv[0])); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAP_DATA", NULL); goto cleanup; } @@ -430,20 +438,22 @@ CreateCursorFromTableOrFile( if (TkReadBitmapFile(display, drawable, &argv[0][1], (unsigned *) &width, (unsigned *) &height, &source, &xHot, &yHot) != BitmapSuccess) { - Tcl_AppendResult(interp, "cleanup reading bitmap file \"", - &argv[0][1], "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "cleanup reading bitmap file \"%s\"", &argv[0][1])); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAP_FILE", NULL); goto cleanup; } } if ((xHot < 0) || (yHot < 0) || (xHot >= width) || (yHot >= height)) { if (inTkTable) { - Tcl_AppendResult(interp, "bad hot spot in bitmap data for \"", - argv[0], "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "bad hot spot in bitmap data for \"%s\"", argv[0])); } else { - Tcl_AppendResult(interp, "bad hot spot in bitmap file \"", - &argv[0][1], "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "bad hot spot in bitmap file \"%s\"", &argv[0][1])); } + Tcl_SetErrorCode(interp, "TK", "CURSOR", "HOTSPOT", NULL); goto cleanup; } @@ -457,8 +467,9 @@ CreateCursorFromTableOrFile( } else if (argc == 2) { fgColor = argv[1]; if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) { - Tcl_AppendResult(interp, "invalid color name \"", - fgColor, "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid color name \"%s\"", fgColor)); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } if (inTkTable) { @@ -476,13 +487,15 @@ CreateCursorFromTableOrFile( bgColor = argv[3]; } if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) { - Tcl_AppendResult(interp, "invalid color name \"", - fgColor, "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid color name \"%s\"", fgColor)); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } if (TkParseColor(display, Tk_Colormap(tkwin), bgColor, &bg) == 0) { - Tcl_AppendResult(interp, "invalid color name \"", - bgColor, "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "invalid color name \"%s\"", bgColor)); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "COLOR", NULL); goto cleanup; } } @@ -511,8 +524,9 @@ CreateCursorFromTableOrFile( data = TkGetBitmapData(NULL, tkCursorPtr->mask, NULL, &maskWidth, &maskHeight, &dummy1, &dummy2); if (data == NULL) { - Tcl_AppendResult(interp, "error reading bitmap mask data for \"", - argv[0], "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "error reading bitmap mask data for \"%s\"", argv[0])); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASK_DATA", NULL); goto cleanup; } @@ -524,15 +538,17 @@ CreateCursorFromTableOrFile( if (TkReadBitmapFile(display, drawable, argv[1], (unsigned int *) &maskWidth, (unsigned int *) &maskHeight, &mask, &dummy1, &dummy2) != BitmapSuccess) { - Tcl_AppendResult(interp, "cleanup reading bitmap file \"", - argv[1], "\"", NULL); + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "cleanup reading bitmap file \"%s\"", argv[1])); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASK_FILE", NULL); goto cleanup; } } if ((maskWidth != width) || (maskHeight != height)) { - Tcl_SetResult(interp, "source and mask bitmaps have different sizes", - TCL_STATIC); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "source and mask bitmaps have different sizes", -1)); + Tcl_SetErrorCode(interp, "TK", "CURSOR", "SIZE_MATCH", NULL); goto cleanup; } @@ -548,7 +564,7 @@ CreateCursorFromTableOrFile( } return cursor; } - + /* *---------------------------------------------------------------------- * @@ -598,7 +614,7 @@ TkCreateCursorFromData( } return (TkCursor *) cursorPtr; } - + /* *---------------------------------------------------------------------- * @@ -625,7 +641,7 @@ TkpFreeCursor( XFreeCursor(unixCursorPtr->display, (Cursor) unixCursorPtr->info.cursor); Tk_FreeXId(unixCursorPtr->display, (XID) unixCursorPtr->info.cursor); } - + /* * Local Variables: * mode: c |