Skip to content

Commit

Permalink
Fix [f91aa24bbe] for allmost all remaining widgets. Canvtext is the o…
Browse files Browse the repository at this point in the history
…nly one which is not complete yet.
  • Loading branch information
jan.nijtmans committed Oct 23, 2024
2 parents b64e7fb + 93452ca commit 9b2eac7
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 133 deletions.
27 changes: 12 additions & 15 deletions generic/tkEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ static const Tk_OptionSpec entryOptSpec[] = {
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},
offsetof(Entry, selBorderWidth), 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},
Expand Down Expand Up @@ -252,8 +251,7 @@ static const Tk_OptionSpec sbOptSpec[] = {
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},
offsetof(Entry, insertBorderWidth), 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},
Expand Down Expand Up @@ -291,8 +289,7 @@ static const Tk_OptionSpec sbOptSpec[] = {
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},
offsetof(Entry, selBorderWidth), 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},
Expand All @@ -313,7 +310,7 @@ static const Tk_OptionSpec sbOptSpec[] = {
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
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},
Expand Down Expand Up @@ -1118,7 +1115,7 @@ ConfigureEntry(
Spinbox *sbPtr = (Spinbox *) entryPtr;
/* Only used when this widget is of type
* TK_SPINBOX */
char *oldValues = NULL;
Tcl_Obj *oldValues = NULL;
Tcl_Obj *oldFormat = NULL;
int error;
int oldExport = 0;
Expand Down Expand Up @@ -1147,7 +1144,7 @@ ConfigureEntry(

oldExport = (entryPtr->exportSelection) && (!Tcl_IsSafe(entryPtr->interp));
if (entryPtr->type == TK_SPINBOX) {
oldValues = sbPtr->valueStr;
oldValues = sbPtr->valueObj;
oldFormat = sbPtr->reqFormatObj;
oldFrom = sbPtr->fromValue;
oldTo = sbPtr->toValue;
Expand Down Expand Up @@ -1267,16 +1264,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;
Expand Down Expand Up @@ -1379,7 +1376,7 @@ ConfigureEntry(
*/

EntryValueChanged(entryPtr, Tcl_GetString(objPtr));
} else if ((sbPtr->valueStr == NULL)
} else if ((sbPtr->valueObj == NULL)
&& !DOUBLES_EQ(sbPtr->fromValue, sbPtr->toValue)
&& (!DOUBLES_EQ(sbPtr->fromValue, oldFrom)
|| !DOUBLES_EQ(sbPtr->toValue, oldTo))) {
Expand Down Expand Up @@ -1727,8 +1724,8 @@ DisplayEntry(
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,
(selEndX - selStartX) + 2 * entryPtr->selBorderWidth,
(fm.ascent + fm.descent) + 2 * entryPtr->selBorderWidth,
entryPtr->selBorderWidth,
#ifndef MAC_OSX_TK
TK_RELIEF_RAISED
Expand Down
2 changes: 1 addition & 1 deletion generic/tkEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ typedef struct {
* digits and other information; used for the
* value. */

char *valueStr; /* Values List. Malloc'ed. */
Tcl_Obj *valueObj; /* Values List. */
Tcl_Obj *listObj; /* Pointer to the list object being used */
int eIndex; /* Holds the current index into elements */
int nElements; /* Holds the current count of elements */
Expand Down
21 changes: 10 additions & 11 deletions generic/tkScale.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static const Tk_OptionSpec optionSpecs[] = {
DEF_SCALE_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
DEF_SCALE_COMMAND, TCL_INDEX_NONE, offsetof(TkScale, command),
DEF_SCALE_COMMAND, offsetof(TkScale, commandObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
DEF_SCALE_CURSOR, TCL_INDEX_NONE, offsetof(TkScale, cursor),
Expand Down Expand Up @@ -80,7 +80,7 @@ static const Tk_OptionSpec optionSpecs[] = {
"HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
offsetof(TkScale, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-label", "label", "Label",
DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label),
DEF_SCALE_LABEL, offsetof(TkScale, labelObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0},
Expand Down Expand Up @@ -291,10 +291,10 @@ Tk_ScaleObjCmd(
scalePtr->resolution = 1.0;
scalePtr->digits = 0;
scalePtr->bigIncrement = 0.0;
scalePtr->command = NULL;
scalePtr->commandObj = NULL;
scalePtr->repeatDelay = 0;
scalePtr->repeatInterval = 0;
scalePtr->label = NULL;
scalePtr->labelObj = NULL;
scalePtr->labelLength = 0;
scalePtr->state = STATE_NORMAL;
scalePtr->borderWidth = 0;
Expand Down Expand Up @@ -669,8 +669,6 @@ ConfigureScale(
ComputeFormat(scalePtr, 0);
ComputeFormat(scalePtr, 1);

scalePtr->labelLength = scalePtr->label ? strlen(scalePtr->label) : 0;

Tk_SetBackgroundFromBorder(scalePtr->tkwin, scalePtr->bgBorder);

if (scalePtr->highlightWidth < 0) {
Expand Down Expand Up @@ -1024,7 +1022,7 @@ ComputeScaleGeometry(
if (scalePtr->orient == ORIENT_HORIZONTAL) {
y = scalePtr->inset;
extraSpace = 0;
if (scalePtr->labelLength != 0) {
if (scalePtr->labelObj != NULL) {
scalePtr->horizLabelY = y + SPACING;
y += scalePtr->fontHeight;
extraSpace = SPACING;
Expand Down Expand Up @@ -1114,13 +1112,14 @@ ComputeScaleGeometry(
}
scalePtr->vertTroughX = x;
x += 2*scalePtr->borderWidth + scalePtr->width;
if (scalePtr->labelLength == 0) {
if (scalePtr->labelObj == NULL) {
scalePtr->vertLabelX = 0;
} else {
Tcl_Size labelLength;
const char *label= Tcl_GetStringFromObj(scalePtr->labelObj, &labelLength);
scalePtr->vertLabelX = x + fm.ascent/2;
x = scalePtr->vertLabelX + fm.ascent/2
+ Tk_TextWidth(scalePtr->tkfont, scalePtr->label,
scalePtr->labelLength);
+ Tk_TextWidth(scalePtr->tkfont, label, labelLength);
}
Tk_GeometryRequest(scalePtr->tkwin, x + scalePtr->inset,
scalePtr->length + 2*scalePtr->inset);
Expand Down Expand Up @@ -1457,7 +1456,7 @@ TkScaleSetValue(
* configuring the widget -command option even if the value did not change.
*/

if ((invokeCommand) && (scalePtr->command != NULL)) {
if ((invokeCommand) && (scalePtr->commandObj != NULL)) {
scalePtr->flags |= INVOKE_COMMAND;
}
TkEventuallyRedrawScale(scalePtr, REDRAW_SLIDER);
Expand Down
6 changes: 3 additions & 3 deletions generic/tkScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ typedef struct TkScale {
* tick interval. */
double bigIncrement; /* Amount to use for large increments to scale
* value. (0 means we pick a value). */
char *command; /* Command prefix to use when invoking Tcl
Tcl_Obj *commandObj; /* Command prefix to use when invoking Tcl
* commands because the scale value changed.
* NULL means don't invoke commands. */
int repeatDelay; /* How long to wait before auto-repeating on
* scrolling actions (in ms). */
int repeatInterval; /* Interval between autorepeats (in ms). */
char *label; /* Label to display above or to right of
Tcl_Obj *labelObj; /* Label to display above or to right of
* scale; NULL means don't display a label. */
Tcl_Size labelLength; /* Number of non-NULL chars. in label. */
Tcl_Size labelLength; /* Not used any more. */
enum state state; /* Values are active, normal, or disabled.
* Value of scale cannot be changed when
* disabled. */
Expand Down
6 changes: 3 additions & 3 deletions generic/tkTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ TestobjconfigObjCmd(
int boolValue;
int integer;
double doubleValue;
char *string;
Tcl_Obj *stringObj;
int index;
XColor *colorPtr;
Tk_Font tkfont;
Expand All @@ -851,7 +851,7 @@ TestobjconfigObjCmd(
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
TCL_INDEX_NONE, offsetof(InternalRecord, doubleValue), 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String", "foo",
TCL_INDEX_NONE, offsetof(InternalRecord, string),
offsetof(InternalRecord, stringObj), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable", "one",
Expand Down Expand Up @@ -912,7 +912,7 @@ TestobjconfigObjCmd(
recordPtr->boolValue = 0;
recordPtr->integer = 0;
recordPtr->doubleValue = 0.0;
recordPtr->string = NULL;
recordPtr->stringObj = NULL;
recordPtr->index = 0;
recordPtr->colorPtr = NULL;
recordPtr->tkfont = NULL;
Expand Down
30 changes: 15 additions & 15 deletions generic/ttk/ttkEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ typedef struct {
int exportSelection; /* Tie internal selection to X selection? */

VMODE validate; /* Validation mode */
char *validateCmd; /* Validation script template */
char *invalidCmd; /* Invalid callback script template */
Tcl_Obj *validateCmdObj; /* Validation script template */
Tcl_Obj *invalidCmdObj; /* Invalid callback script template */

char *showChar; /* Used to derive displayString */
Tcl_Obj *showCharObj; /* Used to derive displayString */

Tcl_Obj *fontObj; /* Text font to use */
Tcl_Obj *widthObj; /* Desired width of window (in avgchars) */
Expand Down Expand Up @@ -166,7 +166,7 @@ static const Tk_OptionSpec EntryOptionSpecs[] = {
DEF_ENTRY_FONT, offsetof(Entry, entry.fontObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
NULL, TCL_INDEX_NONE, offsetof(Entry, entry.invalidCmd),
NULL, offsetof(Entry, entry.invalidCmdObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
"left", TCL_INDEX_NONE, offsetof(Entry, entry.justify),
Expand All @@ -175,7 +175,7 @@ static const Tk_OptionSpec EntryOptionSpecs[] = {
NULL, offsetof(Entry, entry.placeholderObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-show", "show", "Show",
NULL, TCL_INDEX_NONE, offsetof(Entry, entry.showChar),
NULL, offsetof(Entry, entry.showCharObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-state", "state", "State",
"normal", offsetof(Entry, entry.stateObj), TCL_INDEX_NONE,
Expand All @@ -187,13 +187,13 @@ static const Tk_OptionSpec EntryOptionSpecs[] = {
"none", TCL_INDEX_NONE, offsetof(Entry, entry.validate),
TK_OPTION_ENUM_VAR, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand",
NULL, TCL_INDEX_NONE, offsetof(Entry, entry.validateCmd),
NULL, offsetof(Entry, entry.validateCmdObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-width", "width", "Width",
DEF_ENTRY_WIDTH, offsetof(Entry, entry.widthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
NULL, TCL_INDEX_NONE, offsetof(Entry, entry.xscroll.scrollCmd),
NULL, offsetof(Entry, entry.xscroll.scrollCmdObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},

/* EntryStyleData options:
Expand Down Expand Up @@ -604,7 +604,7 @@ EntryValidateChange(
VMODE vmode = entryPtr->entry.validate;
int code, change_ok;

if ((entryPtr->entry.validateCmd == NULL)
if ((entryPtr->entry.validateCmdObj == NULL)
|| (entryPtr->core.flags & VALIDATING)
|| !EntryNeedsValidation(vmode, reason))
{
Expand All @@ -616,7 +616,7 @@ EntryValidateChange(
/* Run -validatecommand and check return value:
*/
code = RunValidationScript(interp, entryPtr,
entryPtr->entry.validateCmd, "-validatecommand",
Tcl_GetString(entryPtr->entry.validateCmdObj), "-validatecommand",
newValue, index, count, reason);
if (code != TCL_OK) {
goto done;
Expand All @@ -632,9 +632,9 @@ EntryValidateChange(

/* Run the -invalidcommand if validation failed:
*/
if (!change_ok && entryPtr->entry.invalidCmd != NULL) {
if (!change_ok && entryPtr->entry.invalidCmdObj != NULL) {
code = RunValidationScript(interp, entryPtr,
entryPtr->entry.invalidCmd, "-invalidcommand",
Tcl_GetString(entryPtr->entry.invalidCmdObj), "-invalidcommand",
newValue, index, count, reason);
if (code != TCL_OK) {
goto done;
Expand Down Expand Up @@ -764,8 +764,8 @@ EntryStoreValue(Entry *entryPtr, const char *value)
entryPtr->entry.numChars = numChars;

entryPtr->entry.displayString
= entryPtr->entry.showChar
? EntryDisplayString(entryPtr->entry.showChar, numChars)
= entryPtr->entry.showCharObj
? EntryDisplayString(Tcl_GetString(entryPtr->entry.showCharObj), numChars)
: entryPtr->entry.string
;

Expand Down Expand Up @@ -1059,8 +1059,8 @@ static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
ckfree(entryPtr->entry.displayString);

entryPtr->entry.displayString
= entryPtr->entry.showChar
? EntryDisplayString(entryPtr->entry.showChar, entryPtr->entry.numChars)
= entryPtr->entry.showCharObj
? EntryDisplayString(Tcl_GetString(entryPtr->entry.showCharObj), entryPtr->entry.numChars)
: entryPtr->entry.string
;

Expand Down
4 changes: 2 additions & 2 deletions generic/ttk/ttkScroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)

h->flags &= ~SCROLL_UPDATE_REQUIRED;

if (s->scrollCmd == NULL) {
if (s->scrollCmdObj == NULL) {
return TCL_OK;
}

arg1[0] = arg2[0] = ' ';
Tcl_PrintDouble(interp, (double)s->first / s->total, arg1+1);
Tcl_PrintDouble(interp, (double)s->last / s->total, arg2+1);
Tcl_DStringInit(&buf);
Tcl_DStringAppend(&buf, s->scrollCmd, TCL_INDEX_NONE);
Tcl_DStringAppend(&buf, Tcl_GetString(s->scrollCmdObj), TCL_INDEX_NONE);
Tcl_DStringAppend(&buf, arg1, TCL_INDEX_NONE);
Tcl_DStringAppend(&buf, arg2, TCL_INDEX_NONE);

Expand Down
4 changes: 2 additions & 2 deletions generic/ttk/ttkTreeview.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,10 @@ static const Tk_OptionSpec TreeviewOptionSpecs[] = {
0, 0, GEOMETRY_CHANGED},

{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.xscroll.scrollCmd),
NULL, offsetof(Treeview, tree.xscroll.scrollCmdObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.yscroll.scrollCmd),
NULL, offsetof(Treeview, tree.yscroll.scrollCmdObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},

WIDGET_TAKEFOCUS_TRUE,
Expand Down
2 changes: 1 addition & 1 deletion generic/ttk/ttkWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ typedef struct {
int first; /* First visible item */
int last; /* Last visible item */
int total; /* Total #items */
char *scrollCmd; /* Widget option */
Tcl_Obj *scrollCmdObj; /* Widget option */
} Scrollable;

typedef struct ScrollHandleRec *ScrollHandle;
Expand Down
Loading

0 comments on commit 9b2eac7

Please sign in to comment.