diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-10-25 21:06:25 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-10-25 21:06:25 (GMT) |
| commit | 0d5336db012f45753abace489f18f0ca299c6961 (patch) | |
| tree | b1bf3280a9046df99226158978502eeb26f5b0a3 /generic/tkEntry.c | |
| parent | e97381a6d921de403516d5b761539a450f4af83c (diff) | |
| parent | 1320b8a2a9c1269a345d44d673a7a35707fbbe9c (diff) | |
| download | tk-core-tip-626.zip tk-core-tip-626.tar.gz tk-core-tip-626.tar.bz2 | |
Merge 9.0core-tip-626
Diffstat (limited to 'generic/tkEntry.c')
| -rw-r--r-- | generic/tkEntry.c | 428 |
1 files changed, 232 insertions, 196 deletions
diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 3271cc5..120a524 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -74,7 +74,7 @@ static const Tk_OptionSpec entryOptSpec[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0}, + DEF_ENTRY_BORDER_WIDTH, offsetof(Entry, borderWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -100,13 +100,13 @@ static const Tk_OptionSpec entryOptSpec[] = { {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, - offsetof(Entry, highlightWidth), 0, 0, 0}, + "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, offsetof(Entry, highlightWidthObj), + TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", - "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE, - offsetof(Entry, insertBorderWidth), 0, + "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, offsetof(Entry, insertBorderWidthObj), + TCL_INDEX_NONE, 0, DEF_ENTRY_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime), @@ -114,16 +114,16 @@ static const Tk_OptionSpec entryOptSpec[] = { {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", - DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0}, + DEF_ENTRY_INSERT_WIDTH, offsetof(Entry, insertWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", - DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), + DEF_ENTRY_INVALIDCMD, offsetof(Entry, invalidCmdObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_SYNONYM, "-invcmd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder", - DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString), + DEF_ENTRY_PLACEHOLDER, offsetof(Entry, placeholderObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground", "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE, @@ -138,35 +138,34 @@ static const Tk_OptionSpec entryOptSpec[] = { DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder), 0, DEF_ENTRY_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", - "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE, - offsetof(Entry, selBorderWidth), - 0, DEF_ENTRY_SELECT_BD_MONO, 0}, + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidthObj), + TCL_INDEX_NONE, 0, DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr), TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0}, {TK_OPTION_STRING, "-show", "show", "Show", - DEF_ENTRY_SHOW, TCL_INDEX_NONE, offsetof(Entry, showChar), + DEF_ENTRY_SHOW, offsetof(Entry, showCharObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state), 0, stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", - DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus), + DEF_ENTRY_TAKE_FOCUS, offsetof(Entry, takeFocusObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", - DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName), + DEF_ENTRY_TEXT_VARIABLE, offsetof(Entry, textVarNameObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate", DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate), 0, validateStrings, 0}, {TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand", - NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0}, + NULL, offsetof(Entry, validateCmdObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_SYNONYM, "-vcmd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0}, {TK_OPTION_INT, "-width", "width", "Width", DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", - DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd), + DEF_ENTRY_SCROLL_COMMAND, offsetof(Entry, scrollCmdObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -200,7 +199,7 @@ static const Tk_OptionSpec sbOptSpec[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0}, + DEF_ENTRY_BORDER_WIDTH, offsetof(Entry, borderWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-buttonbackground", "buttonBackground", "Background", DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(Spinbox, buttonBorder), 0, DEF_BUTTON_BG_MONO, 0}, @@ -212,7 +211,7 @@ static const Tk_OptionSpec sbOptSpec[] = { {TK_OPTION_RELIEF, "-buttonuprelief", "buttonUpRelief", "Relief", DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(Spinbox, buRelief), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", - DEF_SPINBOX_CMD, TCL_INDEX_NONE, offsetof(Spinbox, command), + DEF_SPINBOX_CMD, offsetof(Spinbox, commandObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), @@ -234,7 +233,7 @@ static const Tk_OptionSpec sbOptSpec[] = { {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0}, {TK_OPTION_STRING, "-format", "format", "Format", - DEF_SPINBOX_FORMAT, TCL_INDEX_NONE, offsetof(Spinbox, reqFormat), + DEF_SPINBOX_FORMAT, offsetof(Spinbox, reqFormatObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SPINBOX_FROM, TCL_INDEX_NONE, offsetof(Spinbox, fromValue), 0, 0, 0}, @@ -244,36 +243,35 @@ static const Tk_OptionSpec sbOptSpec[] = { {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, - offsetof(Entry, highlightWidth), 0, 0, 0}, + "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, offsetof(Entry, highlightWidthObj), + TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_DOUBLE, "-increment", "increment", "Increment", DEF_SPINBOX_INCREMENT, TCL_INDEX_NONE, offsetof(Spinbox, increment), 0, 0, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", - "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE, - offsetof(Entry, insertBorderWidth), 0, - DEF_ENTRY_INSERT_BD_MONO, 0}, + "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, offsetof(Entry, insertBorderWidthObj), + TCL_INDEX_NONE, 0, DEF_ENTRY_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime), 0, 0, 0}, {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", - DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0}, + DEF_ENTRY_INSERT_WIDTH, offsetof(Entry, insertWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", - DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), + DEF_ENTRY_INVALIDCMD, offsetof(Entry, invalidCmdObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_SYNONYM, "-invcmd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder", - DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString), + DEF_ENTRY_PLACEHOLDER, offsetof(Entry, placeholderObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground", - "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE, - offsetof(Entry, placeholderColorPtr), 0, 0, 0}, + "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE, + offsetof(Entry, placeholderColorPtr), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground", @@ -290,9 +288,8 @@ static const Tk_OptionSpec sbOptSpec[] = { DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder), 0, DEF_ENTRY_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", - "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE, - offsetof(Entry, selBorderWidth), - 0, DEF_ENTRY_SELECT_BD_MONO, 0}, + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidthObj), + TCL_INDEX_NONE, 0, DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr), TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0}, @@ -300,10 +297,10 @@ static const Tk_OptionSpec sbOptSpec[] = { DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state), 0, stateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", - DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus), + DEF_ENTRY_TAKE_FOCUS, offsetof(Entry, takeFocusObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", - DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName), + DEF_ENTRY_TEXT_VARIABLE, offsetof(Entry, textVarNameObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-to", "to", "To", DEF_SPINBOX_TO, TCL_INDEX_NONE, offsetof(Spinbox, toValue), 0, 0, 0}, @@ -311,9 +308,9 @@ static const Tk_OptionSpec sbOptSpec[] = { DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate), 0, validateStrings, 0}, {TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand", - NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0}, + NULL, offsetof(Entry, validateCmdObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-values", "values", "Values", - DEF_SPINBOX_VALUES, TCL_INDEX_NONE, offsetof(Spinbox, valueStr), + DEF_SPINBOX_VALUES, offsetof(Spinbox, valueObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_SYNONYM, "-vcmd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0}, @@ -322,7 +319,7 @@ static const Tk_OptionSpec sbOptSpec[] = { {TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap", DEF_SPINBOX_WRAP, TCL_INDEX_NONE, offsetof(Spinbox, wrap), 0, 0, 0}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", - DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd), + DEF_ENTRY_SCROLL_COMMAND, offsetof(Entry, scrollCmdObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -698,9 +695,9 @@ EntryWidgetObjCmd( } if ((last >= first) && (entryPtr->state == STATE_NORMAL)) { code = DeleteChars(entryPtr, first, last - first); - if (code != TCL_OK) { - goto error; - } + if (code != TCL_OK) { + goto error; + } } break; } @@ -754,9 +751,9 @@ EntryWidgetObjCmd( } if (entryPtr->state == STATE_NORMAL) { code = InsertChars(entryPtr, index, Tcl_GetString(objv[3])); - if (code != TCL_OK) { - goto error; - } + if (code != TCL_OK) { + goto error; + } } break; } @@ -1048,8 +1045,8 @@ DestroyEntry( */ ckfree((void *)entryPtr->string); - if (entryPtr->textVarName != NULL) { - Tcl_UntraceVar2(entryPtr->interp, entryPtr->textVarName, + if (entryPtr->textVarNameObj != NULL) { + Tcl_UntraceVar2(entryPtr->interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, EntryTextVarProc, entryPtr); entryPtr->flags &= ~ENTRY_VAR_TRACED; @@ -1118,8 +1115,8 @@ ConfigureEntry( Spinbox *sbPtr = (Spinbox *) entryPtr; /* Only used when this widget is of type * TK_SPINBOX */ - char *oldValues = NULL; - char *oldFormat = NULL; + Tcl_Obj *oldValues = NULL; + Tcl_Obj *oldFormat = NULL; int error; int oldExport = 0; int valuesChanged = 0; @@ -1127,14 +1124,16 @@ ConfigureEntry( double oldTo = 0.0; int code; size_t formatSpace = TCL_DOUBLE_SPACE; + int borderWidth, highlightWidth, insertWidth; + int insertBorderWidth, selBorderWidth; /* * Eliminate any existing trace on a variable monitored by the entry. */ - if ((entryPtr->textVarName != NULL) + if ((entryPtr->textVarNameObj != NULL) && (entryPtr->flags & ENTRY_VAR_TRACED)) { - Tcl_UntraceVar2(interp, entryPtr->textVarName, NULL, + Tcl_UntraceVar2(interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, EntryTextVarProc, entryPtr); entryPtr->flags &= ~ENTRY_VAR_TRACED; @@ -1147,8 +1146,8 @@ ConfigureEntry( oldExport = (entryPtr->exportSelection) && (!Tcl_IsSafe(entryPtr->interp)); if (entryPtr->type == TK_SPINBOX) { - oldValues = sbPtr->valueStr; - oldFormat = sbPtr->reqFormat; + oldValues = sbPtr->valueObj; + oldFormat = sbPtr->reqFormatObj; oldFrom = sbPtr->fromValue; oldTo = sbPtr->toValue; } @@ -1190,26 +1189,55 @@ ConfigureEntry( } Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); - if (entryPtr->insertWidth <= 0) { - entryPtr->insertWidth = 2; - } - if (entryPtr->insertBorderWidth > entryPtr->insertWidth/2) { - entryPtr->insertBorderWidth = entryPtr->insertWidth/2; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); + if (borderWidth < 0) { + borderWidth = 0; + Tcl_DecrRefCount(entryPtr->borderWidthObj); + entryPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->borderWidthObj); + } + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->highlightWidthObj, &highlightWidth); + if (highlightWidth < 0) { + highlightWidth = 0; + Tcl_DecrRefCount(entryPtr->highlightWidthObj); + entryPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->highlightWidthObj); + } + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); + if (insertBorderWidth < 0) { + insertBorderWidth = 0; + Tcl_DecrRefCount(entryPtr->insertBorderWidthObj); + entryPtr->insertBorderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->insertBorderWidthObj); + } + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertWidthObj, &insertWidth); + if (insertWidth < 0) { + insertWidth = 0; + Tcl_DecrRefCount(entryPtr->insertWidthObj); + entryPtr->insertWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->insertWidthObj); + } + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->selBorderWidthObj, &selBorderWidth); + if (selBorderWidth < 0) { + selBorderWidth = 0; + Tcl_DecrRefCount(entryPtr->selBorderWidthObj); + entryPtr->selBorderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->selBorderWidthObj); } if (entryPtr->type == TK_SPINBOX) { if (sbPtr->fromValue > sbPtr->toValue) { - /* - * Swap -from and -to values. - */ + /* + * Swap -from and -to values. + */ - double tmpFromTo = sbPtr->fromValue; + double tmpFromTo = sbPtr->fromValue; - sbPtr->fromValue = sbPtr->toValue; - sbPtr->toValue = tmpFromTo; - } + sbPtr->fromValue = sbPtr->toValue; + sbPtr->toValue = tmpFromTo; + } - if (sbPtr->reqFormat && (oldFormat != sbPtr->reqFormat)) { + if (sbPtr->reqFormatObj && (oldFormat != sbPtr->reqFormatObj)) { /* * Make sure that the given format is somewhat correct, and * calculate the minimum space we'll need for the values as @@ -1218,14 +1246,14 @@ ConfigureEntry( int min, max; size_t formatLen; - char fbuf[4], *fmt = sbPtr->reqFormat; + char fbuf[4], *fmt = Tcl_GetString(sbPtr->reqFormatObj); formatLen = strlen(fmt); if ((fmt[0] != '%') || (fmt[formatLen-1] != 'f')) { badFormatOpt: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad spinbox format specifier \"%s\"", - sbPtr->reqFormat)); + Tcl_GetString(sbPtr->reqFormatObj))); Tcl_SetErrorCode(interp, "TK", "SPINBOX", "FORMAT_SANITY", NULL); continue; @@ -1258,16 +1286,16 @@ ConfigureEntry( * See if we have to rearrange our listObj data. */ - if (oldValues != sbPtr->valueStr) { + if (oldValues != sbPtr->valueObj) { if (sbPtr->listObj != NULL) { Tcl_DecrRefCount(sbPtr->listObj); } sbPtr->listObj = NULL; - if (sbPtr->valueStr != NULL) { + if (sbPtr->valueObj != NULL) { Tcl_Obj *newObjPtr; Tcl_Size nelems; - newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, TCL_INDEX_NONE); + newObjPtr = sbPtr->valueObj; if (Tcl_ListObjLength(interp, newObjPtr, &nelems) != TCL_OK) { valuesChanged = -1; @@ -1315,12 +1343,9 @@ ConfigureEntry( */ Tk_SetInternalBorder(entryPtr->tkwin, - entryPtr->borderWidth + entryPtr->highlightWidth); - if (entryPtr->highlightWidth < 0) { - entryPtr->highlightWidth = 0; - } - entryPtr->inset = entryPtr->highlightWidth - + entryPtr->borderWidth + XPAD; + borderWidth + highlightWidth); + entryPtr->inset = highlightWidth + + borderWidth + XPAD; break; } if (!error) { @@ -1332,21 +1357,21 @@ ConfigureEntry( * it doesn't exist, and set the entry's value from the variable's value. */ - if (entryPtr->textVarName != NULL) { + if (entryPtr->textVarNameObj != NULL) { const char *value; - value = Tcl_GetVar2(interp, entryPtr->textVarName, NULL, TCL_GLOBAL_ONLY); + value = Tcl_GetVar2(interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY); if (value == NULL) { - /* - * Since any trace on the textvariable was eliminated above, - * the only possible reason for EntryValueChanged to return - * an error is that the textvariable lives in a namespace - * that does not (yet) exist. Indeed, namespaces are not - * automatically created as needed. Don't trap this error - * here, better do it below when attempting to trace the - * variable. - */ + /* + * Since any trace on the textvariable was eliminated above, + * the only possible reason for EntryValueChanged to return + * an error is that the textvariable lives in a namespace + * that does not (yet) exist. Indeed, namespaces are not + * automatically created as needed. Don't trap this error + * here, better do it below when attempting to trace the + * variable. + */ EntryValueChanged(entryPtr, NULL); } else { @@ -1367,13 +1392,13 @@ ConfigureEntry( Tcl_ListObjIndex(interp, sbPtr->listObj, 0, &objPtr); - /* + /* * No check for error return here as well, because any possible * error will be trapped below when attempting tracing. */ - EntryValueChanged(entryPtr, Tcl_GetString(objPtr)); - } else if ((sbPtr->valueStr == NULL) + EntryValueChanged(entryPtr, Tcl_GetString(objPtr)); + } else if ((sbPtr->valueObj == NULL) && !DOUBLES_EQ(sbPtr->fromValue, sbPtr->toValue) && (!DOUBLES_EQ(sbPtr->fromValue, oldFrom) || !DOUBLES_EQ(sbPtr->toValue, oldTo))) { @@ -1410,15 +1435,15 @@ ConfigureEntry( * the value according to new -from/-to values. */ - if ((entryPtr->textVarName != NULL) + if ((entryPtr->textVarNameObj != NULL) && !(entryPtr->flags & ENTRY_VAR_TRACED)) { - code = Tcl_TraceVar2(interp, entryPtr->textVarName, + code = Tcl_TraceVar2(interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, EntryTextVarProc, entryPtr); - if (code != TCL_OK) { - return TCL_ERROR; - } - entryPtr->flags |= ENTRY_VAR_TRACED; + if (code != TCL_OK) { + return TCL_ERROR; + } + entryPtr->flags |= ENTRY_VAR_TRACED; } EntryWorldChanged(entryPtr); @@ -1524,7 +1549,7 @@ EntryWorldChanged( if (entryPtr->selFgColorPtr != NULL) { gcValues.foreground = entryPtr->selFgColorPtr->pixel; } else { - gcValues.foreground = colorPtr->pixel; + gcValues.foreground = colorPtr->pixel; } gcValues.font = Tk_FontId(entryPtr->tkfont); mask = GCForeground | GCFont; @@ -1625,6 +1650,7 @@ DisplayEntry( Tk_FontMetrics fm; Pixmap pixmap; Tk_3DBorder border; + int borderWidth, selBorderWidth, insertWidth, highlightWidth; entryPtr->flags &= ~REDRAW_PENDING; if ((entryPtr->flags & ENTRY_DELETED) || !Tk_IsMapped(tkwin)) { @@ -1704,6 +1730,7 @@ DisplayEntry( } Tk_Fill3DRectangle(tkwin, pixmap, border, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); + Tk_GetPixelsFromObj(NULL, tkwin, entryPtr->selBorderWidthObj, &selBorderWidth); if (showSelection && (entryPtr->state != STATE_DISABLED) && (entryPtr->selectLast > entryPtr->leftIndex)) { @@ -1714,16 +1741,16 @@ DisplayEntry( &selStartX, NULL, NULL, NULL); selStartX += entryPtr->layoutX; } - if ((selStartX - entryPtr->selBorderWidth) < xBound) { + if ((selStartX - selBorderWidth) < xBound) { Tk_CharBbox(entryPtr->textLayout, entryPtr->selectLast, &selEndX, NULL, NULL, NULL); selEndX += entryPtr->layoutX; Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->selBorder, - selStartX - entryPtr->selBorderWidth, - baseY - fm.ascent - entryPtr->selBorderWidth, - (selEndX - selStartX) + 2*entryPtr->selBorderWidth, - (fm.ascent + fm.descent) + 2*entryPtr->selBorderWidth, - entryPtr->selBorderWidth, + selStartX - selBorderWidth, + baseY - fm.ascent - selBorderWidth, + (selEndX - selStartX) + 2 * selBorderWidth, + (fm.ascent + fm.descent) + 2 * selBorderWidth, + selBorderWidth, #ifndef MAC_OSX_TK TK_RELIEF_RAISED #else @@ -1742,22 +1769,29 @@ DisplayEntry( * hide the cursor. */ + Tk_GetPixelsFromObj(NULL, tkwin, entryPtr->insertWidthObj, &insertWidth); if ((entryPtr->state == STATE_NORMAL) && (entryPtr->flags & GOT_FOCUS)) { Tk_CharBbox(entryPtr->textLayout, entryPtr->insertPos, &cursorX, NULL, NULL, NULL); cursorX += entryPtr->layoutX; - cursorX -= (entryPtr->insertWidth == 1) ? 1 : (entryPtr->insertWidth)/2; + cursorX -= (insertWidth <= 1) ? 1 : (insertWidth)/2; Tk_SetCaretPos(entryPtr->tkwin, cursorX, baseY - fm.ascent, fm.ascent + fm.descent); if ((entryPtr->insertPos >= entryPtr->leftIndex) && cursorX < xBound) { if (entryPtr->flags & CURSOR_ON) { + /* Take minimum of given insertBorderWidth and insertWidth/2 */ + int insertBorderWidth; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); + if (insertBorderWidth > insertWidth/2) { + insertBorderWidth = insertWidth/2; + } Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder, - cursorX, baseY - fm.ascent, entryPtr->insertWidth, - fm.ascent + fm.descent, entryPtr->insertBorderWidth, + cursorX, baseY - fm.ascent, insertWidth, + fm.ascent + fm.descent, insertBorderWidth, TK_RELIEF_RAISED); } else if (entryPtr->insertBorder == entryPtr->selBorder) { Tk_Fill3DRectangle(tkwin, pixmap, border, cursorX, - baseY - fm.ascent, entryPtr->insertWidth, + baseY - fm.ascent, insertWidth, fm.ascent + fm.descent, 0, TK_RELIEF_FLAT); } } @@ -1765,19 +1799,19 @@ DisplayEntry( if ((entryPtr->numChars == 0) && (entryPtr->placeholderChars != 0)) { - /* - * Draw the placeholder text. - */ + /* + * Draw the placeholder text. + */ - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->placeholderGC, + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->placeholderGC, entryPtr->placeholderLayout, entryPtr->placeholderX, entryPtr->layoutY, entryPtr->placeholderLeftIndex, entryPtr->placeholderChars); } else { - if (showSelection && (entryPtr->state != STATE_DISABLED) - && (entryPtr->selTextGC != entryPtr->textGC) - && (entryPtr->selectFirst < entryPtr->selectLast)) { + if (showSelection && (entryPtr->state != STATE_DISABLED) + && (entryPtr->selTextGC != entryPtr->textGC) + && (entryPtr->selectFirst < entryPtr->selectLast)) { /* * Draw the selected and unselected portions separately. @@ -1786,33 +1820,33 @@ DisplayEntry( Tcl_Size selFirst; if (entryPtr->selectFirst < entryPtr->leftIndex) { - selFirst = entryPtr->leftIndex; + selFirst = entryPtr->leftIndex; } else { - selFirst = entryPtr->selectFirst; + selFirst = entryPtr->selectFirst; } if (entryPtr->leftIndex < selFirst) { - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, - entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, - entryPtr->leftIndex, selFirst); + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, selFirst); } Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC, entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, selFirst, entryPtr->selectLast); if (entryPtr->selectLast < entryPtr->numChars) { - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, - entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, - entryPtr->selectLast, entryPtr->numChars); + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->selectLast, entryPtr->numChars); } - } else { + } else { - /* - * Draw the entire visible text - */ + /* + * Draw the entire visible text + */ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, entryPtr->leftIndex, entryPtr->numChars); - } + } } if (entryPtr->type == TK_SPINBOX) { @@ -1909,14 +1943,16 @@ DisplayEntry( * text that extends past the viewable part of the window. */ + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->highlightWidthObj, &highlightWidth); if (!TkpDrawEntryBorderAndFocus(entryPtr, pixmap, (entryPtr->type == TK_SPINBOX))) { - xBound = entryPtr->highlightWidth; + xBound = highlightWidth; if (entryPtr->relief != TK_RELIEF_FLAT) { Tk_Draw3DRectangle(tkwin, pixmap, border, xBound, xBound, Tk_Width(tkwin) - 2 * xBound, Tk_Height(tkwin) - 2 * xBound, - entryPtr->borderWidth, entryPtr->relief); + borderWidth, entryPtr->relief); } if (xBound > 0) { GC fgGC, bgGC; @@ -1986,7 +2022,7 @@ EntryComputeGeometry( * entry, recompute the displayString. */ - if (entryPtr->showChar != NULL) { + if (entryPtr->showCharObj != NULL) { int ch; char buf[6]; int size; @@ -1998,7 +2034,7 @@ EntryComputeGeometry( * resulting string. */ - Tcl_UtfToUniChar(entryPtr->showChar, &ch); + Tcl_UtfToUniChar(Tcl_GetString(entryPtr->showCharObj), &ch); size = Tcl_UniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; @@ -2018,23 +2054,23 @@ EntryComputeGeometry( */ Tk_FreeTextLayout(entryPtr->placeholderLayout); - if (entryPtr->placeholderString) { - entryPtr->placeholderChars = strlen(entryPtr->placeholderString); - entryPtr->placeholderLayout = Tk_ComputeTextLayout(entryPtr->tkfont, - entryPtr->placeholderString, entryPtr->placeholderChars, 0, - entryPtr->justify, TK_IGNORE_NEWLINES, &totalLength, NULL); + if (entryPtr->placeholderObj) { + entryPtr->placeholderChars = strlen(Tcl_GetString(entryPtr->placeholderObj)); + entryPtr->placeholderLayout = Tk_ComputeTextLayout(entryPtr->tkfont, + Tcl_GetString(entryPtr->placeholderObj), entryPtr->placeholderChars, 0, + entryPtr->justify, TK_IGNORE_NEWLINES, &totalLength, NULL); overflow = totalLength - - (Tk_Width(entryPtr->tkwin) - 2*entryPtr->inset - entryPtr->xWidth); + (Tk_Width(entryPtr->tkwin) - 2*entryPtr->inset - entryPtr->xWidth); if (overflow <= 0) { entryPtr->placeholderLeftIndex = 0; if (entryPtr->justify == TK_JUSTIFY_LEFT) { entryPtr->placeholderX = entryPtr->inset; } else if (entryPtr->justify == TK_JUSTIFY_RIGHT) { entryPtr->placeholderX = Tk_Width(entryPtr->tkwin) - entryPtr->inset - - entryPtr->xWidth - totalLength; + - entryPtr->xWidth - totalLength; } else { entryPtr->placeholderX = (Tk_Width(entryPtr->tkwin) - - entryPtr->xWidth - totalLength)/2; + - entryPtr->xWidth - totalLength)/2; } } else { @@ -2055,12 +2091,12 @@ EntryComputeGeometry( Tk_CharBbox(entryPtr->placeholderLayout, entryPtr->placeholderLeftIndex, &rightX, NULL, NULL, NULL); entryPtr->placeholderX = entryPtr->inset -rightX; - } + } } else { - entryPtr->placeholderChars = 0; - entryPtr->placeholderLayout = Tk_ComputeTextLayout(entryPtr->tkfont, - entryPtr->placeholderString, 0, 0, - entryPtr->justify, TK_IGNORE_NEWLINES, NULL, NULL); + entryPtr->placeholderChars = 0; + entryPtr->placeholderLayout = Tk_ComputeTextLayout(entryPtr->tkfont, + (entryPtr->placeholderObj ? Tcl_GetString(entryPtr->placeholderObj) : NULL), 0, 0, + entryPtr->justify, TK_IGNORE_NEWLINES, NULL, NULL); entryPtr->placeholderX = entryPtr->inset; } @@ -2377,10 +2413,10 @@ EntryValueChanged( EntrySetValue(entryPtr, newValue); } - if (entryPtr->textVarName == NULL) { + if (entryPtr->textVarNameObj == NULL) { newValue = NULL; } else { - newValue = Tcl_SetVar2(entryPtr->interp, entryPtr->textVarName, + newValue = Tcl_SetVar2(entryPtr->interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, entryPtr->string, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG); } @@ -2412,8 +2448,8 @@ EntryValueChanged( * Signal this error. */ - if ((entryPtr->textVarName != NULL) && (newValue == NULL)) { - return TCL_ERROR; + if ((entryPtr->textVarNameObj != NULL) && (newValue == NULL)) { + return TCL_ERROR; } return TCL_OK; } @@ -3102,7 +3138,7 @@ EntryUpdateScrollbar( Tcl_Interp *interp; Tcl_DString buf; - if (entryPtr->scrollCmd == NULL) { + if (entryPtr->scrollCmdObj == NULL) { return; } @@ -3112,7 +3148,7 @@ EntryUpdateScrollbar( Tcl_PrintDouble(NULL, first, firstStr); Tcl_PrintDouble(NULL, last, lastStr); Tcl_DStringInit(&buf); - Tcl_DStringAppend(&buf, entryPtr->scrollCmd, TCL_INDEX_NONE); + Tcl_DStringAppend(&buf, Tcl_GetString(entryPtr->scrollCmdObj), TCL_INDEX_NONE); Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE); Tcl_DStringAppend(&buf, firstStr, TCL_INDEX_NONE); Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE); @@ -3261,34 +3297,34 @@ EntryTextVarProc( */ if (flags & TCL_TRACE_UNSETS) { - if (!Tcl_InterpDeleted(interp) && entryPtr->textVarName) { - void *probe = NULL; - - do { - probe = Tcl_VarTraceInfo(interp, - entryPtr->textVarName, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - EntryTextVarProc, probe); - if (probe == entryPtr) { - break; - } - } while (probe); - if (probe) { - /* - * We were able to fetch the unset trace for our - * textVarName, which means it is not unset and not - * the cause of this unset trace. Instead some outdated - * former variable must be, and we should ignore it. - */ - return NULL; - } - Tcl_SetVar2(interp, entryPtr->textVarName, NULL, + if (!Tcl_InterpDeleted(interp) && entryPtr->textVarNameObj) { + void *probe = NULL; + + do { + probe = Tcl_VarTraceInfo(interp, + Tcl_GetString(entryPtr->textVarNameObj), + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + EntryTextVarProc, probe); + if (probe == entryPtr) { + break; + } + } while (probe); + if (probe) { + /* + * We were able to fetch the unset trace for our + * textVarName, which means it is not unset and not + * the cause of this unset trace. Instead some outdated + * former variable must be, and we should ignore it. + */ + return NULL; + } + Tcl_SetVar2(interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, entryPtr->string, TCL_GLOBAL_ONLY); - Tcl_TraceVar2(interp, entryPtr->textVarName, NULL, + Tcl_TraceVar2(interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, EntryTextVarProc, clientData); entryPtr->flags |= ENTRY_VAR_TRACED; - } + } return NULL; } @@ -3298,7 +3334,7 @@ EntryTextVarProc( * value because we changed it because someone typed in the entry). */ - value = Tcl_GetVar2(interp, entryPtr->textVarName, NULL, TCL_GLOBAL_ONLY); + value = Tcl_GetVar2(interp, Tcl_GetString(entryPtr->textVarNameObj), NULL, TCL_GLOBAL_ONLY); if (value == NULL) { value = ""; } @@ -3400,11 +3436,11 @@ EntryValidateChange( char *p; Tcl_DString script; - if (entryPtr->validateCmd == NULL || + if (entryPtr->validateCmdObj == NULL || entryPtr->validate == VALIDATE_NONE) { - if (entryPtr->flags & VALIDATING) { - entryPtr->flags |= VALIDATE_ABORT; - } + if (entryPtr->flags & VALIDATING) { + entryPtr->flags |= VALIDATE_ABORT; + } return (varValidate ? TCL_ERROR : TCL_OK); } @@ -3416,7 +3452,7 @@ EntryValidateChange( if (entryPtr->flags & VALIDATING) { entryPtr->validate = VALIDATE_NONE; - entryPtr->flags |= VALIDATE_ABORT; + entryPtr->flags |= VALIDATE_ABORT; return (varValidate ? TCL_ERROR : TCL_OK); } @@ -3427,7 +3463,7 @@ EntryValidateChange( */ Tcl_DStringInit(&script); - ExpandPercents(entryPtr, entryPtr->validateCmd, + ExpandPercents(entryPtr, (entryPtr->validateCmdObj ? Tcl_GetString(entryPtr->validateCmdObj) : NULL), change, newValue, index, type, &script); Tcl_DStringAppend(&script, "", 1); @@ -3475,11 +3511,11 @@ EntryValidateChange( if (varValidate) { entryPtr->validate = VALIDATE_NONE; - } else if (entryPtr->invalidCmd != NULL) { + } else if (entryPtr->invalidCmdObj != NULL) { int result; Tcl_DStringInit(&script); - ExpandPercents(entryPtr, entryPtr->invalidCmd, + ExpandPercents(entryPtr, Tcl_GetString(entryPtr->invalidCmdObj), change, newValue, index, type, &script); Tcl_DStringAppend(&script, "", 1); p = Tcl_DStringValue(&script); @@ -3932,9 +3968,9 @@ SpinboxWidgetObjCmd( } if ((last >= first) && (entryPtr->state == STATE_NORMAL)) { code = DeleteChars(entryPtr, first, last - first); - if (code != TCL_OK) { - goto error; - } + if (code != TCL_OK) { + goto error; + } } break; } @@ -4007,9 +4043,9 @@ SpinboxWidgetObjCmd( } if (entryPtr->state == STATE_NORMAL) { code = InsertChars(entryPtr, index, Tcl_GetString(objv[3])); - if (code != TCL_OK) { - goto error; - } + if (code != TCL_OK) { + goto error; + } } break; } @@ -4229,9 +4265,9 @@ SpinboxWidgetObjCmd( } if (objc == 3) { code = EntryValueChanged(entryPtr, Tcl_GetString(objv[2])); - if (code != TCL_OK) { - goto error; - } + if (code != TCL_OK) { + goto error; + } } Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, TCL_INDEX_NONE)); break; @@ -4505,12 +4541,12 @@ SpinboxInvoke( } } if (code != TCL_OK) { - return TCL_ERROR; + return TCL_ERROR; } - if (sbPtr->command != NULL) { + if (sbPtr->commandObj != NULL) { Tcl_DStringInit(&script); - ExpandPercents(entryPtr, sbPtr->command, type, "", 0, + ExpandPercents(entryPtr, Tcl_GetString(sbPtr->commandObj), type, "", 0, VALIDATE_BUTTON, &script); Tcl_DStringAppend(&script, "", 1); @@ -4567,8 +4603,8 @@ ComputeFormat( * required for any number in the dial's range. */ - if (sbPtr->reqFormat) { - sbPtr->valueFormat = sbPtr->reqFormat; + if (sbPtr->reqFormatObj) { + sbPtr->valueFormat = Tcl_GetString(sbPtr->reqFormatObj); return TCL_OK; } |
