Skip to content

Commit

Permalink
Revert tkTest.c (we still want to test TK_CONFIG_STRING using char *)…
Browse files Browse the repository at this point in the history
…. Make tkScale.h and tkEntry.h usable for both Tk 8.7 and 9.0
  • Loading branch information
jan.nijtmans committed Oct 23, 2024
1 parent 9b2eac7 commit 282f2b4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
30 changes: 25 additions & 5 deletions generic/tkEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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. */
Expand Down
1 change: 0 additions & 1 deletion generic/tkScale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 20 additions & 5 deletions generic/tkScale.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand All @@ -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. */
Expand All @@ -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
Expand All @@ -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. */
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;
Tcl_Obj *stringObj;
char *string;
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",
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",
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 282f2b4

Please sign in to comment.