From 282f2b476038660c286c0e86f361c19bdf3be7f3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 23 Oct 2024 11:46:09 +0000 Subject: [PATCH] Revert tkTest.c (we still want to test TK_CONFIG_STRING using char *). Make tkScale.h and tkEntry.h usable for both Tk 8.7 and 9.0 --- generic/tkEntry.h | 30 +++++++++++++++++++++++++----- generic/tkScale.c | 1 - generic/tkScale.h | 25 ++++++++++++++++++++----- generic/tkTest.c | 6 +++--- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 5d08e3fc7..387b9e2db 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -81,7 +81,11 @@ typedef struct { Tk_3DBorder readonlyBorder; /* Used for drawing border around whole window * in readonly state, plus used for * background. */ - int borderWidth; /* Width of 3-D border around window. */ +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *borderWidthObj; /* Width of 3-D border around window. */ +#else + int borderWidth; +#endif Tk_Cursor cursor; /* Current cursor for window, or NULL. */ int exportSelection; /* Non-zero means tie internal entry selection * to X selection. */ @@ -91,23 +95,39 @@ typedef struct { XColor *highlightBgColorPtr;/* Color for drawing traversal highlight area * when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ - int highlightWidth; /* Width in pixels of highlight to draw around +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ +#else + int highlightWidth; +#endif Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion * cursor. */ - int insertBorderWidth; /* Width of 3-D border around insert cursor. */ +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *insertBorderWidthObj; /* Width of 3-D border around insert cursor. */ +#else + int insertBorderWidth; +#endif int insertOffTime; /* Number of milliseconds cursor should spend * in "off" state for each blink. */ int insertOnTime; /* Number of milliseconds cursor should spend * in "on" state for each blink. */ - int insertWidth; /* Total width of insert cursor. */ +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *insertWidthObj; /* Total width of insert cursor. */ +#else + int insertWidth; +#endif Tk_Justify justify; /* Justification to use for text within * window. */ int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ Tk_3DBorder selBorder; /* Border and background for selected * characters. */ - int selBorderWidth; /* Width of border around selection. */ +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *selBorderWidthObj; /* Width of border around selection. */ +#else + int selBorderWidth; +#endif XColor *selFgColorPtr; /* Foreground color for selected text. */ int state; /* Normal or disabled. Entry is read-only when * disabled. */ diff --git a/generic/tkScale.c b/generic/tkScale.c index 8f118c12e..bb7abd6e5 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -295,7 +295,6 @@ Tk_ScaleObjCmd( scalePtr->repeatDelay = 0; scalePtr->repeatInterval = 0; scalePtr->labelObj = NULL; - scalePtr->labelLength = 0; scalePtr->state = STATE_NORMAL; scalePtr->borderWidth = 0; scalePtr->bgBorder = NULL; diff --git a/generic/tkScale.h b/generic/tkScale.h index 3f4550d15..d5a90f552 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -53,10 +53,14 @@ typedef struct TkScale { * available for this widget. */ enum orient orient; /* Orientation for window (vertical or * horizontal). */ - int width; /* Desired narrow dimension of scale, in +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *widthObj; /* Desired narrow dimension of scale, in * pixels. */ - int length; /* Desired long dimension of scale, in + Tcl_Obj *lengthObj; /* Desired long dimension of scale, in * pixels. */ +#else + int width, length; +#endif double value; /* Current value of scale. */ Tcl_Obj *varNamePtr; /* Name of variable or NULL. If non-NULL, * scale's value tracks the contents of this @@ -87,7 +91,6 @@ typedef struct TkScale { int repeatInterval; /* Interval between autorepeats (in ms). */ Tcl_Obj *labelObj; /* Label to display above or to right of * scale; NULL means don't display a 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. */ @@ -96,7 +99,11 @@ typedef struct TkScale { * Information used when displaying widget: */ +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *borderWidthObj; /* Width of 3-D border around window. */ +#else int borderWidth; /* Width of 3-D border around window. */ +#endif Tk_3DBorder bgBorder; /* Used for drawing slider and other * background areas. */ Tk_3DBorder activeBorder; /* For drawing the slider when active. */ @@ -110,9 +117,13 @@ typedef struct TkScale { GC textGC; /* GC for drawing text in normal mode. */ int relief; /* Indicates whether window as a whole is * raised, sunken, or flat. */ - int highlightWidth; /* Width in pixels of highlight to draw around +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ +#else + int highlightWidth; +#endif Tk_3DBorder highlightBorder;/* Value of -highlightbackground option: * specifies background with which to draw 3-D * default ring and focus highlight area when @@ -123,8 +134,12 @@ typedef struct TkScale { * Indicates how much interior stuff must be * offset from outside edges to leave room for * borders. */ - int sliderLength; /* Length of slider, measured in pixels along +#if TK_MAJOR_VERSION > 8 + Tcl_Obj *sliderLengthObj; /* Length of slider, measured in pixels along * long dimension of scale. */ +#else + int sliderLength; +#endif int showValue; /* Non-zero means to display the scale value * below or to the left of the slider; zero * means don't display the value. */ diff --git a/generic/tkTest.c b/generic/tkTest.c index 20434a343..f0ee30fbd 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -824,7 +824,7 @@ TestobjconfigObjCmd( int boolValue; int integer; double doubleValue; - Tcl_Obj *stringObj; + char *string; int index; XColor *colorPtr; Tk_Font tkfont; @@ -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", - offsetof(InternalRecord, stringObj), TCL_INDEX_NONE, + TCL_INDEX_NONE, offsetof(InternalRecord, string), TK_CONFIG_NULL_OK, 0, 0x8}, {TK_OPTION_STRING_TABLE, "-stringtable", "StringTable", "stringTable", "one", @@ -912,7 +912,7 @@ TestobjconfigObjCmd( recordPtr->boolValue = 0; recordPtr->integer = 0; recordPtr->doubleValue = 0.0; - recordPtr->stringObj = NULL; + recordPtr->string = NULL; recordPtr->index = 0; recordPtr->colorPtr = NULL; recordPtr->tkfont = NULL;