diff options
author | Ian Roxborough <irox@redhat.com> | 2001-09-10 00:22:29 +0000 |
---|---|---|
committer | Ian Roxborough <irox@redhat.com> | 2001-09-10 00:22:29 +0000 |
commit | ee7709783c85577eba6af30cd711e17e403befed (patch) | |
tree | 74233a880ee1f7e13c7ded61d093318e8c6e7d5c /tk/generic/tkScrollbar.c | |
parent | a850c17c374d03259483e799b09326d255e17487 (diff) | |
download | gdb-ee7709783c85577eba6af30cd711e17e403befed.tar.gz |
Tk 8.3 upgradeTK_8_3
Diffstat (limited to 'tk/generic/tkScrollbar.c')
-rw-r--r-- | tk/generic/tkScrollbar.c | 83 |
1 files changed, 52 insertions, 31 deletions
diff --git a/tk/generic/tkScrollbar.c b/tk/generic/tkScrollbar.c index b49069a0a8a..d0f07c59000 100644 --- a/tk/generic/tkScrollbar.c +++ b/tk/generic/tkScrollbar.c @@ -20,6 +20,16 @@ #include "default.h" /* + * Custom option for handling "-orient" + */ + +static Tk_CustomOption orientOption = { + (Tk_OptionParseProc *) TkOrientParseProc, + TkOrientPrintProc, + (ClientData) NULL +}; + +/* * Information used for argv parsing. */ @@ -63,8 +73,9 @@ Tk_ConfigSpec tkpScrollbarConfigSpecs[] = { DEF_SCROLLBAR_HIGHLIGHT_WIDTH, Tk_Offset(TkScrollbar, highlightWidth), 0}, {TK_CONFIG_BOOLEAN, "-jump", "jump", "Jump", DEF_SCROLLBAR_JUMP, Tk_Offset(TkScrollbar, jump), 0}, - {TK_CONFIG_UID, "-orient", "orient", "Orient", - DEF_SCROLLBAR_ORIENT, Tk_Offset(TkScrollbar, orientUid), 0}, + {TK_CONFIG_CUSTOM, "-orient", "orient", "Orient", + DEF_SCROLLBAR_ORIENT, Tk_Offset(TkScrollbar, vertical), 0, + &orientOption}, {TK_CONFIG_RELIEF, "-relief", "relief", "Relief", DEF_SCROLLBAR_RELIEF, Tk_Offset(TkScrollbar, relief), 0}, {TK_CONFIG_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", @@ -156,7 +167,6 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) scrollPtr->widgetCmd = Tcl_CreateCommand(interp, Tk_PathName(scrollPtr->tkwin), ScrollbarWidgetCmd, (ClientData) scrollPtr, ScrollbarCmdDeletedProc); - scrollPtr->orientUid = NULL; scrollPtr->vertical = 0; scrollPtr->width = 0; scrollPtr->command = NULL; @@ -193,7 +203,7 @@ Tk_ScrollbarCmd(clientData, interp, argc, argv) return TCL_ERROR; } - interp->result = Tk_PathName(scrollPtr->tkwin); + Tcl_SetResult(interp, Tk_PathName(scrollPtr->tkwin), TCL_STATIC); return TCL_OK; } @@ -240,9 +250,15 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) int oldActiveField; if (argc == 2) { switch (scrollPtr->activeField) { - case TOP_ARROW: interp->result = "arrow1"; break; - case SLIDER: interp->result = "slider"; break; - case BOTTOM_ARROW: interp->result = "arrow2"; break; + case TOP_ARROW: + Tcl_SetResult(interp, "arrow1", TCL_STATIC); + break; + case SLIDER: + Tcl_SetResult(interp, "slider", TCL_STATIC); + break; + case BOTTOM_ARROW: + Tcl_SetResult(interp, "arrow2", TCL_STATIC); + break; } goto done; } @@ -292,6 +308,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } else if ((c == 'd') && (strncmp(argv[1], "delta", length) == 0)) { int xDelta, yDelta, pixels, length; double fraction; + char buf[TCL_DOUBLE_SPACE]; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -316,10 +333,12 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } else { fraction = ((double) pixels / (double) length); } - sprintf(interp->result, "%g", fraction); + sprintf(buf, "%g", fraction); + Tcl_SetResult(interp, buf, TCL_VOLATILE); } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) { int x, y, pos, length; double fraction; + char buf[TCL_DOUBLE_SPACE]; if (argc != 4) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -349,7 +368,8 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } else if (fraction > 1.0) { fraction = 1.0; } - sprintf(interp->result, "%g", fraction); + sprintf(buf, "%g", fraction); + Tcl_SetResult(interp, buf, TCL_VOLATILE); } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) { if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", @@ -363,9 +383,12 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) Tcl_PrintDouble(interp, scrollPtr->lastFraction, last); Tcl_AppendResult(interp, first, " ", last, (char *) NULL); } else { - sprintf(interp->result, "%d %d %d %d", scrollPtr->totalUnits, + char buf[TCL_INTEGER_SPACE * 4]; + + sprintf(buf, "%d %d %d %d", scrollPtr->totalUnits, scrollPtr->windowUnits, scrollPtr->firstUnit, scrollPtr->lastUnit); + Tcl_SetResult(interp, buf, TCL_VOLATILE); } } else if ((c == 'i') && (strncmp(argv[1], "identify", length) == 0)) { int x, y, thing; @@ -381,11 +404,21 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) } thing = TkpScrollbarPosition(scrollPtr, x,y); switch (thing) { - case TOP_ARROW: interp->result = "arrow1"; break; - case TOP_GAP: interp->result = "trough1"; break; - case SLIDER: interp->result = "slider"; break; - case BOTTOM_GAP: interp->result = "trough2"; break; - case BOTTOM_ARROW: interp->result = "arrow2"; break; + case TOP_ARROW: + Tcl_SetResult(interp, "arrow1", TCL_STATIC); + break; + case TOP_GAP: + Tcl_SetResult(interp, "trough1", TCL_STATIC); + break; + case SLIDER: + Tcl_SetResult(interp, "slider", TCL_STATIC); + break; + case BOTTOM_GAP: + Tcl_SetResult(interp, "trough2", TCL_STATIC); + break; + case BOTTOM_ARROW: + Tcl_SetResult(interp, "arrow2", TCL_STATIC); + break; } } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) { int totalUnits, windowUnits, firstUnit, lastUnit; @@ -488,7 +521,7 @@ ScrollbarWidgetCmd(clientData, interp, argc, argv) * * Results: * The return value is a standard Tcl result. If TCL_ERROR is - * returned, then interp->result contains an error message. + * returned, then the interp's result contains an error message. * * Side effects: * Configuration information, such as colors, border width, @@ -509,29 +542,16 @@ ConfigureScrollbar(interp, scrollPtr, argc, argv, flags) int flags; /* Flags to pass to * Tk_ConfigureWidget. */ { - size_t length; - if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, tkpScrollbarConfigSpecs, argc, argv, (char *) scrollPtr, flags) != TCL_OK) { return TCL_ERROR; } /* - * A few options need special processing, such as parsing the - * orientation or setting the background from a 3-D border. + * A few options need special processing, such as setting the + * background from a 3-D border. */ - length = strlen(scrollPtr->orientUid); - if (strncmp(scrollPtr->orientUid, "vertical", length) == 0) { - scrollPtr->vertical = 1; - } else if (strncmp(scrollPtr->orientUid, "horizontal", length) == 0) { - scrollPtr->vertical = 0; - } else { - Tcl_AppendResult(interp, "bad orientation \"", scrollPtr->orientUid, - "\": must be vertical or horizontal", (char *) NULL); - return TCL_ERROR; - } - if (scrollPtr->command != NULL) { scrollPtr->commandSize = strlen(scrollPtr->command); } else { @@ -689,3 +709,4 @@ TkScrollbarEventuallyRedraw(scrollPtr) scrollPtr->flags |= REDRAW_PENDING; } } + |