From b27e2d100a754414b3dea87eb0608b07e5e371a3 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Jun 2024 07:24:53 +0000 Subject: Proposed solution for [29ba539501]: many PIXEL options don't keep their configured value --- generic/tkEntry.c | 20 ++++++++++---------- generic/tkEntry.h | 5 +++++ generic/tkFrame.c | 16 ++++++++++------ generic/tkListbox.c | 9 ++++++--- generic/tkMenubutton.c | 10 +++++----- generic/tkMenubutton.h | 6 ++++++ generic/tkPanedWindow.c | 17 +++++++++++------ generic/tkScale.c | 10 +++++----- generic/tkScale.h | 6 ++++++ generic/tkText.c | 20 ++++++++++---------- generic/tkText.h | 12 ++++++++++++ generic/tkTextImage.c | 4 ++-- generic/tkTextWind.c | 4 ++-- 13 files changed, 90 insertions(+), 49 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 477f359..2ef3772 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, borderWidthPtr), offsetof(Entry, borderWidth), 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,12 +100,12 @@ 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, + "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, offsetof(Entry, highlightWidthPtr), offsetof(Entry, highlightWidth), 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, + "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, offsetof(Entry, insertBorderWidthPtr), offsetof(Entry, insertBorderWidth), 0, DEF_ENTRY_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", @@ -114,7 +114,7 @@ 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, insertWidthPtr), offsetof(Entry, insertWidth), 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), TK_OPTION_NULL_OK, 0, 0}, @@ -138,7 +138,7 @@ 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, + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidthPtr), offsetof(Entry, selBorderWidth), 0, DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", @@ -200,7 +200,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, borderWidthPtr), offsetof(Entry, borderWidth), 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}, @@ -244,14 +244,14 @@ 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, + "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, offsetof(Entry, highlightWidthPtr), offsetof(Entry, highlightWidth), 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, + "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, offsetof(Entry, insertBorderWidthPtr), offsetof(Entry, insertBorderWidth), 0, DEF_ENTRY_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", @@ -260,7 +260,7 @@ static const Tk_OptionSpec sbOptSpec[] = { {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, insertWidthPtr), offsetof(Entry, insertWidth), 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), TK_OPTION_NULL_OK, 0, 0}, @@ -290,7 +290,7 @@ 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, + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidthPtr), offsetof(Entry, selBorderWidth), 0, DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", diff --git a/generic/tkEntry.h b/generic/tkEntry.h index fbebdaa..2e9c543 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -186,6 +186,11 @@ typedef struct { * commands. Malloc'ed. */ char *invalidCmd; /* Command called when a validation returns 0 * (successfully fails), defaults to {}. */ + Tcl_Obj *borderWidthPtr; + Tcl_Obj *highlightWidthPtr; + Tcl_Obj *insertBorderWidthPtr; + Tcl_Obj *insertWidthPtr; + Tcl_Obj *selBorderWidthPtr; } Entry; /* diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 39ac164..4ff037f 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -101,6 +101,10 @@ typedef struct { * Tk_GetImage, or NULL if bgimgPtr is * NULL. */ int tile; /* Whether to tile the bgimg. */ + Tcl_Obj *heightPtr; + Tcl_Obj *widthPtr; + Tcl_Obj *highlightWidthPtr; + Tcl_Obj *borderWidthPtr; #ifndef TK_NO_DOUBLE_BUFFERING GC copyGC; /* GC for copying when double-buffering. */ #endif /* TK_NO_DOUBLE_BUFFERING */ @@ -201,7 +205,7 @@ static const Tk_OptionSpec commonOptSpec[] = { DEF_FRAME_CURSOR, TCL_INDEX_NONE, offsetof(Frame, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-height", "height", "Height", - DEF_FRAME_HEIGHT, TCL_INDEX_NONE, offsetof(Frame, height), 0, 0, 0}, + DEF_FRAME_HEIGHT, offsetof(Frame, heightPtr), offsetof(Frame, height), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, TCL_INDEX_NONE, offsetof(Frame, highlightBgColorPtr), 0, 0, 0}, @@ -209,7 +213,7 @@ static const Tk_OptionSpec commonOptSpec[] = { DEF_FRAME_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Frame, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, + "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, offsetof(Frame, highlightWidthPtr), offsetof(Frame, highlightWidth), 0, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_FRAME_PADX, offsetof(Frame, padXPtr), @@ -224,7 +228,7 @@ static const Tk_OptionSpec commonOptSpec[] = { DEF_FRAME_VISUAL, TCL_INDEX_NONE, offsetof(Frame, visualName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", - DEF_FRAME_WIDTH, TCL_INDEX_NONE, offsetof(Frame, width), 0, 0, 0}, + DEF_FRAME_WIDTH, offsetof(Frame, widthPtr), offsetof(Frame, width), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; @@ -237,7 +241,7 @@ static const Tk_OptionSpec frameOptSpec[] = { {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0}, + DEF_FRAME_BORDER_WIDTH, offsetof(Frame, borderWidthPtr), offsetof(Frame, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-class", "class", "Class", DEF_FRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", @@ -257,7 +261,7 @@ static const Tk_OptionSpec toplevelOptSpec[] = { {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0}, + DEF_FRAME_BORDER_WIDTH, offsetof(Frame, borderWidthPtr), offsetof(Frame, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-class", "class", "Class", DEF_TOPLEVEL_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0}, {TK_OPTION_STRING, "-menu", "menu", "Menu", @@ -281,7 +285,7 @@ static const Tk_OptionSpec labelframeOptSpec[] = { {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_LABELFRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), + DEF_LABELFRAME_BORDER_WIDTH, offsetof(Frame, borderWidthPtr), offsetof(Frame, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-class", "class", "Class", DEF_LABELFRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0}, diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 4a2ea5f..4592a28 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -167,6 +167,9 @@ typedef struct { int flags; /* Various flag bits: see below for * definitions. */ Tk_Justify justify; /* Justification. */ + Tcl_Obj *borderWidthPtr; + Tcl_Obj *highlightWidthPtr; + Tcl_Obj *selBorderWidthPtr; } Listbox; /* @@ -245,7 +248,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_LISTBOX_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, borderWidth), + DEF_LISTBOX_BORDER_WIDTH, offsetof(Listbox, borderWidthPtr), offsetof(Listbox, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_LISTBOX_CURSOR, TCL_INDEX_NONE, offsetof(Listbox, cursor), @@ -271,7 +274,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_LISTBOX_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Listbox, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, + "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, offsetof(Listbox, highlightWidthPtr), offsetof(Listbox, highlightWidth), 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_LISTBOX_JUSTIFY, TCL_INDEX_NONE, offsetof(Listbox, justify), TK_OPTION_ENUM_VAR, 0, 0}, @@ -281,7 +284,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_LISTBOX_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selBorder), 0, DEF_LISTBOX_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", - "BorderWidth", DEF_LISTBOX_SELECT_BD, TCL_INDEX_NONE, + "BorderWidth", DEF_LISTBOX_SELECT_BD, offsetof(Listbox, selBorderWidthPtr), offsetof(Listbox, selBorderWidth), 0, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_LISTBOX_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selFgColorPtr), diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 3f1f4e7..735df2a 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -62,7 +62,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_MENUBUTTON_BORDER_WIDTH, TCL_INDEX_NONE, + DEF_MENUBUTTON_BORDER_WIDTH, offsetof(TkMenuButton, borderWidthPtr), offsetof(TkMenuButton, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor), @@ -91,7 +91,7 @@ static const Tk_OptionSpec optionSpecs[] = { offsetof(TkMenuButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH, - TCL_INDEX_NONE, offsetof(TkMenuButton, highlightWidth), 0, 0, 0}, + offsetof(TkMenuButton, highlightWidthPtr), offsetof(TkMenuButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_MENUBUTTON_IMAGE, TCL_INDEX_NONE, offsetof(TkMenuButton, imageString), TK_OPTION_NULL_OK, 0, 0}, @@ -104,10 +104,10 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_MENU, TCL_INDEX_NONE, offsetof(TkMenuButton, menuName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - DEF_MENUBUTTON_PADX, TCL_INDEX_NONE, offsetof(TkMenuButton, padX), + DEF_MENUBUTTON_PADX, offsetof(TkMenuButton, padXPtr), offsetof(TkMenuButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - DEF_MENUBUTTON_PADY, TCL_INDEX_NONE, offsetof(TkMenuButton, padY), + DEF_MENUBUTTON_PADY, offsetof(TkMenuButton, padYPtr), offsetof(TkMenuButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief), @@ -132,7 +132,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString), 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", - DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength), + DEF_MENUBUTTON_WRAP_LENGTH, offsetof(TkMenuButton, wrapLengthPtr), offsetof(TkMenuButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index 16ed223..f9b93dd 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -176,6 +176,12 @@ typedef struct { * scripts. Malloc'ed, but may be NULL. */ int flags; /* Various flags; see below for * definitions. */ + Tcl_Obj *borderWidthPtr; + Tcl_Obj *highlightWidthPtr; + Tcl_Obj *padXPtr; + Tcl_Obj *padYPtr; + Tcl_Obj *wrapLengthPtr; + //Tcl_Obj *; } TkMenuButton; /* diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index d7f2d45..04c78a4 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -102,6 +102,9 @@ typedef struct Pane { int handlex, handley; /* Coordinates of the sash handle. */ enum stretch stretch; /* Controls how pane grows/shrinks */ int hide; /* Controls visibility of pane */ + Tcl_Obj *padXPtr; + Tcl_Obj *padYPtr; + Tcl_Obj *minSizePtr; struct PanedWindow *containerPtr; /* Paned window managing the window. */ Tk_Window after; /* Placeholder for parsing options. */ @@ -155,6 +158,8 @@ typedef struct PanedWindow { int numPanes; /* Number of panes. */ int sizeofPanes; /* Number of elements in the panes array. */ int flags; /* Flags for widget; see below. */ + Tcl_Obj *borderWidthPtr; + Tcl_Obj *handlePadPtr; } PanedWindow; /* @@ -279,13 +284,13 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth), + DEF_PANEDWINDOW_BORDERWIDTH, offsetof(PanedWindow, borderWidthPtr), offsetof(PanedWindow, borderWidth), 0, 0, GEOMETRY}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad", - DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad), + DEF_PANEDWINDOW_HANDLEPAD, offsetof(PanedWindow, handlePadPtr), offsetof(PanedWindow, handlePad), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize", DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr), @@ -314,7 +319,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad", - DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad), + DEF_PANEDWINDOW_SASHPAD, offsetof(PanedWindow, sashPadPtr), offsetof(PanedWindow, sashPad), 0, 0, GEOMETRY}, {TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief", DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief), @@ -344,11 +349,11 @@ static const Tk_OptionSpec paneOptionSpecs[] = { {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY}, {TK_OPTION_PIXELS, "-minsize", NULL, NULL, - DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Pane, minSize), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_MINSIZE, offsetof(Pane, minSizePtr), offsetof(Pane, minSize), 0, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Pane, padx), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADX, offsetof(Pane, padXPtr), offsetof(Pane, padx), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Pane, pady), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADY, offsetof(Pane, padXPtr), offsetof(Pane, pady), 0, 0, 0}, {TK_OPTION_CUSTOM, "-sticky", NULL, NULL, DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky), 0, &stickyOption, 0}, diff --git a/generic/tkScale.c b/generic/tkScale.c index eeda9cd..ef7595e 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -49,7 +49,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_SCALE_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, borderWidth), + DEF_SCALE_BORDER_WIDTH, offsetof(TkScale, borderWidthPtr), offsetof(TkScale, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_SCALE_COMMAND, TCL_INDEX_NONE, offsetof(TkScale, command), @@ -77,13 +77,13 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkScale, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, + "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, offsetof(TkScale, highlightWidthPtr), offsetof(TkScale, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-label", "label", "Label", DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-length", "length", "Length", - DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0}, + DEF_SCALE_LENGTH, offsetof(TkScale, lengthPtr), offsetof(TkScale, length), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient), TK_OPTION_ENUM_VAR, orientStrings, 0}, @@ -102,7 +102,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_SHOW_VALUE, TCL_INDEX_NONE, offsetof(TkScale, showValue), 0, 0, 0}, {TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength", - DEF_SCALE_SLIDER_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, sliderLength), + DEF_SCALE_SLIDER_LENGTH, offsetof(TkScale, sliderLengthPtr), offsetof(TkScale, sliderLength), 0, 0, 0}, {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief", DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief), @@ -125,7 +125,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_VARIABLE, offsetof(TkScale, varNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", - DEF_SCALE_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, width), 0, 0, 0}, + DEF_SCALE_WIDTH, offsetof(TkScale, widthPtr), offsetof(TkScale, width), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; diff --git a/generic/tkScale.h b/generic/tkScale.h index 7ecf1a1..62d5f09 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -159,6 +159,12 @@ typedef struct TkScale { * scripts. May be NULL. */ int flags; /* Various flags; see below for * definitions. */ + Tcl_Obj *borderWidthPtr; + Tcl_Obj *highlightWidthPtr; + Tcl_Obj *lengthPtr; + Tcl_Obj *sliderLengthPtr; + Tcl_Obj *widthPtr; + } TkScale; /* diff --git a/generic/tkText.c b/generic/tkText.c index 23e0647..71bb012 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -130,7 +130,7 @@ static const Tk_OptionSpec optionSpecs[] = { "BlockCursor", DEF_TEXT_BLOCK_CURSOR, TCL_INDEX_NONE, offsetof(TkText, insertCursorType), 0, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_TEXT_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkText, borderWidth), + DEF_TEXT_BORDER_WIDTH, offsetof(TkText, borderWidthPtr), offsetof(TkText, borderWidth), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_TEXT_CURSOR, TCL_INDEX_NONE, offsetof(TkText, cursor), @@ -150,7 +150,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_FG, TCL_INDEX_NONE, offsetof(TkText, fgColor), 0, 0, 0}, {TK_OPTION_PIXELS, "-height", "height", "Height", - DEF_TEXT_HEIGHT, TCL_INDEX_NONE, offsetof(TkText, height), 0, 0, 0}, + DEF_TEXT_HEIGHT, offsetof(TkText, heightPtr), offsetof(TkText, height), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_TEXT_HIGHLIGHT_BG, TCL_INDEX_NONE, offsetof(TkText, highlightBgColorPtr), @@ -159,7 +159,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkText, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, + "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, offsetof(TkText, highlightWidthPtr), offsetof(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground", "Foreground", @@ -171,7 +171,7 @@ static const Tk_OptionSpec optionSpecs[] = { TCL_INDEX_NONE, offsetof(TkText, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", - "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE, + "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, offsetof(TkText, insertBorderWidthPtr), offsetof(TkText, insertBorderWidth), 0, DEF_TEXT_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", @@ -185,16 +185,16 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed), TK_OPTION_ENUM_VAR, insertUnfocussedStrings, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", - DEF_TEXT_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, insertWidth), + DEF_TEXT_INSERT_WIDTH, offsetof(TkText, insertWidthPtr), offsetof(TkText, insertWidth), 0, 0, 0}, {TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo", DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo), TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - DEF_TEXT_PADX, TCL_INDEX_NONE, offsetof(TkText, padX), 0, 0, + DEF_TEXT_PADX, offsetof(TkText, padXPtr), offsetof(TkText, padX), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - DEF_TEXT_PADY, TCL_INDEX_NONE, offsetof(TkText, padY), 0, 0, 0}, + DEF_TEXT_PADY, offsetof(TkText, padYPtr), offsetof(TkText, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_TEXT_RELIEF, TCL_INDEX_NONE, offsetof(TkText, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", @@ -211,13 +211,13 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", - DEF_TEXT_SPACING1, TCL_INDEX_NONE, offsetof(TkText, spacing1), + DEF_TEXT_SPACING1, offsetof(TkText, spacing1Ptr), offsetof(TkText, spacing1), 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing", - DEF_TEXT_SPACING2, TCL_INDEX_NONE, offsetof(TkText, spacing2), + DEF_TEXT_SPACING2, offsetof(TkText, spacing2Ptr), offsetof(TkText, spacing2), 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", - DEF_TEXT_SPACING3, TCL_INDEX_NONE, offsetof(TkText, spacing3), + DEF_TEXT_SPACING3, offsetof(TkText, spacing3Ptr), offsetof(TkText, spacing3), 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, diff --git a/generic/tkText.h b/generic/tkText.h index 90cc607..9070b32 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -122,6 +122,7 @@ typedef struct TkTextEmbWindow { * window, in pixels. */ int stretch; /* Should window stretch to fill vertical * space of line (except for pady)? 0 or 1. */ + Tcl_Obj *padXPtr, *padYPtr; /* Padding to leave around each side of window. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ TkTextEmbWindowClient *clients; @@ -156,6 +157,7 @@ typedef struct TkTextEmbImage { * image. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ + Tcl_Obj *padXPtr, *padYPtr; } TkTextEmbImage; /* @@ -806,6 +808,16 @@ typedef struct TkText { * inserted automatically. */ Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to * date */ + Tcl_Obj *borderWidthPtr; + Tcl_Obj *heightPtr; + Tcl_Obj *highlightWidthPtr; + Tcl_Obj *insertBorderWidthPtr; + Tcl_Obj *insertWidthPtr; + Tcl_Obj *padXPtr; + Tcl_Obj *padYPtr; + Tcl_Obj *spacing1Ptr; + Tcl_Obj *spacing2Ptr; + Tcl_Obj *spacing3Ptr; } TkText; /* diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index 7f292e8..d66009b 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -86,9 +86,9 @@ static const Tk_OptionSpec optionSpecs[] = { "center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align), TK_OPTION_ENUM_VAR, alignStrings, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padX), 0, 0, 0}, + "0", offsetof(TkTextEmbImage, padXPtr), offsetof(TkTextEmbImage, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padY), 0, 0, 0}, + "0", offsetof(TkTextEmbImage, padYPtr), offsetof(TkTextEmbImage, padY), 0, 0, 0}, {TK_OPTION_STRING, "-image", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageString), TK_OPTION_NULL_OK, 0, 0}, diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index 954e16f..cab335c 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -100,9 +100,9 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-create", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padX), 0, 0, 0}, + "0", offsetof(TkTextEmbWindow, padXPtr), offsetof(TkTextEmbWindow, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padY), 0, 0, 0}, + "0", offsetof(TkTextEmbWindow, padYPtr), offsetof(TkTextEmbWindow, padY), 0, 0, 0}, {TK_OPTION_BOOLEAN, "-stretch", NULL, NULL, "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, stretch), 0, 0, 0}, {TK_OPTION_WINDOW, "-window", NULL, NULL, -- cgit v0.12 From 89f79e56b820165d0d2c2e1617248b825a90376a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Jun 2024 10:10:53 +0000 Subject: Fix variable initialization and test-cases --- generic/tkMenubutton.c | 5 +++++ generic/tkMenubutton.h | 1 - generic/tkScale.c | 6 ++++++ generic/tkText.h | 2 +- generic/tkTextImage.c | 1 + generic/tkTextWind.c | 3 +++ tests/entry.test | 8 ++++---- tests/frame.test | 6 +++--- tests/listbox.test | 8 ++++---- tests/menubut.test | 2 +- tests/panedwindow.test | 8 ++++---- tests/scale.test | 2 +- tests/spinbox.test | 8 ++++---- tests/text.test | 18 +++++++++--------- 14 files changed, 46 insertions(+), 32 deletions(-) diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 735df2a..f51e6ef 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -282,6 +282,11 @@ Tk_MenubuttonObjCmd( mbPtr->cursor = NULL; mbPtr->takeFocus = NULL; mbPtr->flags = 0; + mbPtr->borderWidthPtr = NULL; + mbPtr->highlightWidthPtr = NULL; + mbPtr->padXPtr = NULL; + mbPtr->padYPtr = NULL; + mbPtr->wrapLengthPtr = NULL; Tk_CreateEventHandler(mbPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index f9b93dd..0414bb7 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -181,7 +181,6 @@ typedef struct { Tcl_Obj *padXPtr; Tcl_Obj *padYPtr; Tcl_Obj *wrapLengthPtr; - //Tcl_Obj *; } TkMenuButton; /* diff --git a/generic/tkScale.c b/generic/tkScale.c index ef7595e..3804c90 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -326,6 +326,12 @@ Tk_ScaleObjCmd( scalePtr->cursor = NULL; scalePtr->takeFocusPtr = NULL; scalePtr->flags = NEVER_SET; + scalePtr->borderWidthPtr = NULL; + scalePtr->highlightWidthPtr = NULL; + scalePtr->lengthPtr = NULL; + scalePtr->sliderLengthPtr = NULL; + scalePtr->widthPtr = NULL; + Tk_SetClassProcs(scalePtr->tkwin, &scaleClass, scalePtr); Tk_CreateEventHandler(scalePtr->tkwin, diff --git a/generic/tkText.h b/generic/tkText.h index 9070b32..dc06332 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -155,9 +155,9 @@ typedef struct TkTextEmbImage { * in pixels. */ int chunkCount; /* Number of display chunks that refer to this * image. */ + Tcl_Obj *padXPtr, *padYPtr; Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ - Tcl_Obj *padXPtr, *padYPtr; } TkTextEmbImage; /* diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index d66009b..38d6c76 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -253,6 +253,7 @@ TkTextImageCmd( eiPtr->body.ei.image = NULL; eiPtr->body.ei.align = TK_ALIGN_CENTER; eiPtr->body.ei.padX = eiPtr->body.ei.padY = 0; + eiPtr->body.ei.padXPtr = eiPtr->body.ei.padYPtr = NULL; eiPtr->body.ei.chunkCount = 0; eiPtr->body.ei.optionTable = Tk_CreateOptionTable(interp, optionSpecs); diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index cab335c..c28aaec 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -293,6 +293,9 @@ TkTextWindowCmd( ewPtr->body.ew.create = NULL; ewPtr->body.ew.align = TK_ALIGN_CENTER; ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0; + ewPtr->body.ew.padXPtr = ewPtr->body.ew.padYPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(ewPtr->body.ew.padXPtr); + Tcl_IncrRefCount(ewPtr->body.ew.padYPtr); ewPtr->body.ew.stretch = 0; ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs); diff --git a/tests/entry.test b/tests/entry.test index 1454104..7c8259f 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -110,7 +110,7 @@ test entry-1.7 {configuration option: "borderwidth" for entry} -setup { .e cget -borderwidth } -cleanup { destroy .e -} -result 1 +} -result 1.3 test entry-1.8 {configuration option: "borderwidth" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e ; update idletasks @@ -320,7 +320,7 @@ test entry-1.28 {configuration option: "highlightthickness" for entry} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result 0 +} -result -2 test entry-1.29 {configuration option: "highlightthickness" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e ; update idletasks @@ -360,7 +360,7 @@ test entry-1.32 {configuration option: "insertborderwidth" for entry} -setup { .e cget -insertborderwidth } -cleanup { destroy .e -} -result 1 +} -result 1.3 test entry-1.33 {configuration option: "insertborderwidth" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e ; update idletasks @@ -513,7 +513,7 @@ test entry-1.47 {configuration option: "selectborderwidth" for entry} -setup { .e cget -selectborderwidth } -cleanup { destroy .e -} -result 1 +} -result 1.3 test entry-1.48 {configuration option: "selectborderwidth" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e ; update idletasks diff --git a/tests/frame.test b/tests/frame.test index 74768e4..6dcbeaf 100644 --- a/tests/frame.test +++ b/tests/frame.test @@ -213,7 +213,7 @@ test frame-1.19 {frame configuration options} -body { lindex [.f configure -borderwidth] 4 } -cleanup { .f configure -borderwidth [lindex [.f configure -borderwidth] 3] -} -result 1 +} -result 1.3 test frame-1.20 {frame configuration options} -body { .f configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -514,7 +514,7 @@ test frame-2.25 {toplevel configuration options} -body { test frame-2.26 {toplevel configuration options} -body { .t configure -borderwidth 1.3 lindex [.t configure -borderwidth] 4 -} -result 1 +} -result 1.3 test frame-2.27 {toplevel configuration options} -body { .t configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -1248,7 +1248,7 @@ test frame-13.16 {labelframe configuration options} -body { lindex [.f configure -borderwidth] 4 } -cleanup { .f configure -borderwidth [lindex [.f configure -borderwidth] 3] -} -result 1 +} -result 1.3 test frame-13.17 {labelframe configuration options} -body { .f configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} diff --git a/tests/listbox.test b/tests/listbox.test index c02f389..ae7fba6 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -107,7 +107,7 @@ test listbox-1.9 {configuration options} -body { list [lindex [.l configure -borderwidth] 4] [.l cget -borderwidth] } -cleanup { .l configure -borderwidth [lindex [.l configure -borderwidth] 3] -} -result {1 1} +} -result {1.3 1.3} test listbox-1.10 {configuration options} -body { .l configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -203,7 +203,7 @@ test listbox-1.31 {configuration options} -body { list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness] } -cleanup { .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3] -} -result {0 0} +} -result {-2 -2} test listbox-1.32.1 {configuration options} -setup { set res {} } -body { @@ -242,7 +242,7 @@ test listbox-1.37 {configuration options} -body { list [lindex [.l configure -selectborderwidth] 4] [.l cget -selectborderwidth] } -cleanup { .l configure -selectborderwidth [lindex [.l configure -selectborderwidth] 3] -} -result {1 1} +} -result {1.3 1.3} test listbox-1.38 {configuration options} -body { .l configure -selectborderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -1242,7 +1242,7 @@ test listbox-4.2 {ConfigureListbox procedure} -setup { .l cget -highlightthickness } -cleanup { deleteWindows -} -result 0 +} -result -3 test listbox-4.3 {ConfigureListbox procedure} -setup { deleteWindows destroy .l diff --git a/tests/menubut.test b/tests/menubut.test index 21c0cf7..78e959f 100644 --- a/tests/menubut.test +++ b/tests/menubut.test @@ -98,7 +98,7 @@ test menubutton-1.15 {configuration options} -body { .mb cget -borderwidth } -cleanup { .mb configure -borderwidth [lindex [.mb configure -borderwidth] 3] -} -result 1 +} -result 1.3 test menubutton-1.16 {configuration options} -body { .mb configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} diff --git a/tests/panedwindow.test b/tests/panedwindow.test index 96ddce3..01f3c6b 100644 --- a/tests/panedwindow.test +++ b/tests/panedwindow.test @@ -49,7 +49,7 @@ test panedwindow-1.7 {configuration options: -borderwidth (good)} -body { list [lindex [.p configure -borderwidth] 4] [.p cget -borderwidth] } -cleanup { .p configure -borderwidth [lindex [.p configure -borderwidth] 3] -} -result {1 1} +} -result {1.3 1.3} test panedwindow-1.8 {configuration options: -borderwidth (bad)} -body { .p configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -148,7 +148,7 @@ test panedwindow-1.29 {configuration options: -sashpad (good)} -body { list [lindex [.p configure -sashpad] 4] [.p cget -sashpad] } -cleanup { .p configure -sashpad [lindex [.p configure -sashpad] 3] -} -result {1 1} +} -result {1.3 1.3} test panedwindow-1.30 {configuration options: -sashpad (bad)} -body { .p configure -sashpad badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -245,7 +245,7 @@ test panedwindow-1.49 {configuration options: -padx (good)} -body { [.p panecget .b -padx] } -cleanup { .p paneconfig .b -padx [lindex [.p paneconfig .b -padx] 3] -} -result {1 1} +} -result {1.3 1.3} test panedwindow-1.50 {configuration options: -padx (bad)} -body { .p paneconfigure .b -padx badValue } -returnCodes error -result {expected screen distance but got "badValue"} @@ -255,7 +255,7 @@ test panedwindow-1.51 {configuration options: -pady (good)} -body { [.p panecget .b -pady] } -cleanup { .p paneconfig .b -pady [lindex [.p paneconfig .b -pady] 3] -} -result {1 1} +} -result {1.3 1.3} test panedwindow-1.52 {configuration options: -pady (bad)} -body { .p paneconfigure .b -pady badValue } -returnCodes error -result {expected screen distance but got "badValue"} diff --git a/tests/scale.test b/tests/scale.test index f08015e..d303c92 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -73,7 +73,7 @@ test scale-1.11 {configuration options} -body { .s cget -borderwidth } -cleanup { .s configure -borderwidth [lindex [.s configure -borderwidth] 3] -} -result 1 +} -result 1.3 test scale-1.12 {configuration options} -body { .s configure -borderwidth badValue } -returnCodes error -result {expected screen distance but got "badValue"} diff --git a/tests/spinbox.test b/tests/spinbox.test index 6cb52e9..6ce70d0 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -138,7 +138,7 @@ test spinbox-1.9 {configuration option: "borderwidth"} -setup { .e cget -borderwidth } -cleanup { destroy .e -} -result 1 +} -result 1.3 test spinbox-1.10 {configuration option: "borderwidth" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -480,7 +480,7 @@ test spinbox-1.40 {configuration option: "highlightthickness"} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result 0 +} -result -2 test spinbox-1.41 {configuration option: "increment"} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ @@ -536,7 +536,7 @@ test spinbox-1.45 {configuration option: "insertborderwidth"} -setup { .e cget -insertborderwidth } -cleanup { destroy .e -} -result 1 +} -result 1.3 test spinbox-1.46 {configuration option: "insertborderwidth" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken @@ -758,7 +758,7 @@ test spinbox-1.65 {configuration option: "selectborderwidth"} -setup { .e cget -selectborderwidth } -cleanup { destroy .e -} -result 1 +} -result 1.3 test spinbox-1.66 {configuration option: "selectborderwidth" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken diff --git a/tests/text.test b/tests/text.test index 2303729..ce7b628 100644 --- a/tests/text.test +++ b/tests/text.test @@ -303,7 +303,7 @@ test text-1.29 {configuration option: "highlightthickness"} -setup { .t cget -highlightthickness } -cleanup { destroy .t -} -result 0 +} -result -2 test text-1.30 {configuration option: "highlightthickness"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -417,7 +417,7 @@ test text-1.41 {configuration option: "insertwidth"} -setup { .t cget -insertwidth } -cleanup { destroy .t -} -result 2 +} -result 2.3 test text-1.42 {configuration option: "insertwidth"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -464,7 +464,7 @@ test text-1.45 {configuration option: "padx"} -setup { .t cget -padx } -cleanup { destroy .t -} -result 3 +} -result 3.4 test text-1.46 {configuration option: "padx"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -597,7 +597,7 @@ test text-1.59 {configuration option: "spacing1"} -setup { .t cget -spacing1 } -cleanup { destroy .t -} -result 0 +} -result -5 test text-1.60 {configuration option: "spacing1"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -635,7 +635,7 @@ test text-1.63 {configuration option: "spacing2"} -setup { .t cget -spacing2 } -cleanup { destroy .t -} -result 0 +} -result -1 test text-1.64 {configuration option: "spacing2"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -673,7 +673,7 @@ test text-1.67 {configuration option: "spacing3"} -setup { .t cget -spacing3 } -cleanup { destroy .t -} -result 0 +} -result -10 test text-1.68 {configuration option: "spacing3"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -3312,7 +3312,7 @@ test text-14.2 {ConfigureText procedure} -setup { list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {0 1 1} +} -result {-2 1 1} test text-14.3 {ConfigureText procedure} -setup { text .t } -body { @@ -3320,7 +3320,7 @@ test text-14.3 {ConfigureText procedure} -setup { list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {1 0 1} +} -result {1 -1 1} test text-14.4 {ConfigureText procedure} -setup { text .t } -body { @@ -3328,7 +3328,7 @@ test text-14.4 {ConfigureText procedure} -setup { list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {1 1 0} +} -result {1 1 -3} test text-14.5 {ConfigureText procedure} -setup { text .t } -body { -- cgit v0.12 From ac8dc2c9fecc7541968c74ca9f70e99969e158da Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 7 Jun 2024 15:32:32 +0000 Subject: Introduce TK_OPTION_NONNEG, simplifying things --- generic/tkButton.c | 34 ++++++++++++++++++---------------- generic/tkConfig.c | 11 +++++++++++ generic/tkInt.h | 1 + generic/tkMessage.c | 10 ++++++++++ generic/tkText.c | 23 ++++++++++++++++++++--- tests/text.test | 24 ++++++++++++------------ 6 files changed, 72 insertions(+), 31 deletions(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index cbbe880..85db002 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -80,7 +80,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), 0, 0, 0}, + offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0, tkCompoundStrings, 0}, @@ -109,7 +109,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefLabelHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), 0, 0, 0}, + offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -117,10 +117,10 @@ static const Tk_OptionSpec labelOptionSpecs[] = { DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), 0, 0, 0}, + offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), 0, 0, 0}, + offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", @@ -165,7 +165,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), 0, 0, 0}, + offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -200,7 +200,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), 0, 0, 0}, + offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -211,10 +211,10 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefButtonPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), 0, 0, 0}, + offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefButtonPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), 0, 0, 0}, + offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, @@ -266,7 +266,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), 0, 0, 0}, + offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -298,7 +298,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), 0, 0, 0}, + offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -317,10 +317,10 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), 0, 0, 0}, + offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), 0, 0, 0}, + offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", @@ -379,7 +379,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), 0, 0, 0}, + offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -411,7 +411,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), 0, 0, 0}, + offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -427,10 +427,10 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), 0, 0, 0}, + offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), 0, 0, 0}, + offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", @@ -1097,6 +1097,7 @@ ConfigureButton( } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } +#if 0 if (butPtr->borderWidth < 0) { butPtr->borderWidth = 0; } @@ -1109,6 +1110,7 @@ ConfigureButton( if (butPtr->padY < 0) { butPtr->padY = 0; } +#endif if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 7362831..57b346b 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -1026,6 +1026,17 @@ DoObjConfig( Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); } return TCL_ERROR; + } else if ((newPixels < 0) && (optionPtr->specPtr->flags & (TK_OPTION_NONNEG))) { +#ifdef TK_NO_DEPRECATED + if (interp) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "expected nonnegative screen distance but got \"%.50s\"", Tcl_GetString(valuePtr))); + Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); + } + return TCL_ERROR; +#else + newPixels = 0; +#endif } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); diff --git a/generic/tkInt.h b/generic/tkInt.h index a9da4ec..6e91fd6 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1366,6 +1366,7 @@ MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, Tcl_Size, int lastOK, Tcl_Size*); # define TK_OPTION_UNDERLINE_DEF(type, field) NULL, TCL_INDEX_NONE, offsetof(type, field), TK_OPTION_NULL_OK, NULL #endif +#define TK_OPTION_NONNEG (1 << 4) #ifdef _WIN32 #define TkParseColor XParseColor diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 07dad51..c1f73c6 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -554,9 +554,19 @@ MessageWorldChanged( Tk_GetFontMetrics(msgPtr->tkfont, &fm); if (msgPtr->padX < 0) { msgPtr->padX = fm.ascent / 2; + if (msgPtr->padXPtr) { + Tcl_DecrRefCount(msgPtr->padXPtr); + } + msgPtr->padXPtr = Tcl_NewIntObj(msgPtr->padX); + Tcl_IncrRefCount(msgPtr->padXPtr); } if (msgPtr->padY < 0) { msgPtr->padY = fm.ascent / 4; + if (msgPtr->padYPtr) { + Tcl_DecrRefCount(msgPtr->padYPtr); + } + msgPtr->padYPtr = Tcl_NewIntObj(msgPtr->padY); + Tcl_IncrRefCount(msgPtr->padYPtr); } /* diff --git a/generic/tkText.c b/generic/tkText.c index 71bb012..c040b46 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -212,13 +212,13 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", DEF_TEXT_SPACING1, offsetof(TkText, spacing1Ptr), offsetof(TkText, spacing1), - 0, 0 , TK_TEXT_LINE_GEOMETRY }, + TK_OPTION_NONNEG, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing", DEF_TEXT_SPACING2, offsetof(TkText, spacing2Ptr), offsetof(TkText, spacing2), - 0, 0 , TK_TEXT_LINE_GEOMETRY }, + TK_OPTION_NONNEG, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", DEF_TEXT_SPACING3, offsetof(TkText, spacing3Ptr), offsetof(TkText, spacing3), - 0, 0 , TK_TEXT_LINE_GEOMETRY }, + TK_OPTION_NONNEG, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, &lineOption, TK_TEXT_LINE_RANGE}, @@ -2213,19 +2213,36 @@ ConfigureText( } } +#ifndef TK_NO_DEPRECATED /* * Don't allow negative spacings. */ if (textPtr->spacing1 < 0) { textPtr->spacing1 = 0; + if (textPtr->spacing1Ptr) { + Tcl_DecrRefCount(textPtr->spacing1Ptr); + } + textPtr->spacing1Ptr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->spacing1Ptr); } if (textPtr->spacing2 < 0) { textPtr->spacing2 = 0; + if (textPtr->spacing2Ptr) { + Tcl_DecrRefCount(textPtr->spacing2Ptr); + } + textPtr->spacing2Ptr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->spacing2Ptr); } if (textPtr->spacing3 < 0) { textPtr->spacing3 = 0; + if (textPtr->spacing3Ptr) { + Tcl_DecrRefCount(textPtr->spacing3Ptr); + } + textPtr->spacing3Ptr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->spacing3Ptr); } +#endif /* TK_NO_DEPRECATED */ /* * Parse tab stops. diff --git a/tests/text.test b/tests/text.test index ce7b628..eed3bb5 100644 --- a/tests/text.test +++ b/tests/text.test @@ -593,11 +593,11 @@ test text-1.59 {configuration option: "spacing1"} -setup { pack .t update } -body { - .t configure -spacing1 -5 + .t configure -spacing1 0 .t cget -spacing1 } -cleanup { destroy .t -} -result -5 +} -result 0 test text-1.60 {configuration option: "spacing1"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -631,11 +631,11 @@ test text-1.63 {configuration option: "spacing2"} -setup { pack .t update } -body { - .t configure -spacing2 -1 + .t configure -spacing2 0 .t cget -spacing2 } -cleanup { destroy .t -} -result -1 +} -result 0 test text-1.64 {configuration option: "spacing2"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -669,11 +669,11 @@ test text-1.67 {configuration option: "spacing3"} -setup { pack .t update } -body { - .t configure -spacing3 -10 + .t configure -spacing3 0 .t cget -spacing3 } -cleanup { destroy .t -} -result -10 +} -result 0 test text-1.68 {configuration option: "spacing3"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t @@ -3308,27 +3308,27 @@ test text-14.1 {ConfigureText procedure} -setup { test text-14.2 {ConfigureText procedure} -setup { text .t } -body { - .t configure -spacing1 -2 -spacing2 1 -spacing3 1 + .t configure -spacing1 0 -spacing2 1 -spacing3 1 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {-2 1 1} +} -result {0 1 1} test text-14.3 {ConfigureText procedure} -setup { text .t } -body { - .t configure -spacing1 1 -spacing2 -1 -spacing3 1 + .t configure -spacing1 1 -spacing2 0 -spacing3 1 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {1 -1 1} +} -result {1 0 1} test text-14.4 {ConfigureText procedure} -setup { text .t } -body { - .t configure -spacing1 1 -spacing2 1 -spacing3 -3 + .t configure -spacing1 1 -spacing2 1 -spacing3 0 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t -} -result {1 1 -3} +} -result {1 1 0} test text-14.5 {ConfigureText procedure} -setup { text .t } -body { -- cgit v0.12 From 2b5dd988f12b447e5f9b6b823df406e69da86292 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 8 Jun 2024 17:06:01 +0000 Subject: More progress --- generic/tkButton.c | 54 ++++++++++++++++++++++++++++++++----------------- generic/tkConfig.c | 11 ---------- generic/tkFrame.c | 15 ++++++++++++++ generic/tkInt.h | 2 -- generic/tkListbox.c | 5 +++++ generic/tkMenubutton.c | 15 ++++++++++++++ generic/tkMessage.c | 5 +++++ generic/tkPanedWindow.c | 2 +- generic/tkScale.c | 5 +++++ generic/tkText.c | 8 +++----- generic/tkTextDisp.c | 9 +++++++-- generic/tkTextTag.c | 9 +++++++-- generic/tkTextWind.c | 4 +--- tests/listbox.test | 4 ++-- tests/text.test | 2 +- 15 files changed, 103 insertions(+), 47 deletions(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index 85db002..28aaf9f 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -80,7 +80,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0, tkCompoundStrings, 0}, @@ -109,7 +109,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefLabelHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -117,10 +117,10 @@ static const Tk_OptionSpec labelOptionSpecs[] = { DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", @@ -165,7 +165,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -200,7 +200,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -211,10 +211,10 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefButtonPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefButtonPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, @@ -266,7 +266,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -298,7 +298,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -317,10 +317,10 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", @@ -379,7 +379,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), - offsetof(TkButton, borderWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -411,7 +411,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), - offsetof(TkButton, highlightWidth), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, @@ -427,10 +427,10 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), - offsetof(TkButton, padX), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), - offsetof(TkButton, padY), TK_OPTION_NONNEG, 0, 0}, + offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", @@ -1097,20 +1097,38 @@ ConfigureButton( } else { Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder); } -#if 0 if (butPtr->borderWidth < 0) { butPtr->borderWidth = 0; + if (butPtr->borderWidthPtr) { + Tcl_DecrRefCount(butPtr->borderWidthPtr); + } + butPtr->borderWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->borderWidthPtr); } if (butPtr->highlightWidth < 0) { butPtr->highlightWidth = 0; + if (butPtr->highlightWidthPtr) { + Tcl_DecrRefCount(butPtr->highlightWidthPtr); + } + butPtr->highlightWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->highlightWidthPtr); } if (butPtr->padX < 0) { butPtr->padX = 0; + if (butPtr->padXPtr) { + Tcl_DecrRefCount(butPtr->padXPtr); + } + butPtr->padXPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->padXPtr); } if (butPtr->padY < 0) { butPtr->padY = 0; + if (butPtr->padYPtr) { + Tcl_DecrRefCount(butPtr->padYPtr); + } + butPtr->padYPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->padYPtr); } -#endif if (butPtr->type >= TYPE_CHECK_BUTTON) { Tcl_Obj *valuePtr, *namePtr; diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 57b346b..7362831 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -1026,17 +1026,6 @@ DoObjConfig( Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); } return TCL_ERROR; - } else if ((newPixels < 0) && (optionPtr->specPtr->flags & (TK_OPTION_NONNEG))) { -#ifdef TK_NO_DEPRECATED - if (interp) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "expected nonnegative screen distance but got \"%.50s\"", Tcl_GetString(valuePtr))); - Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL); - } - return TCL_ERROR; -#else - newPixels = 0; -#endif } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 4ff037f..1ca50fb 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -1057,12 +1057,27 @@ ConfigureFrame( if (framePtr->highlightWidth < 0) { framePtr->highlightWidth = 0; + if (framePtr->highlightWidthPtr) { + Tcl_DecrRefCount(framePtr->highlightWidthPtr); + } + framePtr->highlightWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->highlightWidthPtr); } if (framePtr->padX < 0) { framePtr->padX = 0; + if (framePtr->padXPtr) { + Tcl_DecrRefCount(framePtr->padXPtr); + } + framePtr->padXPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->padXPtr); } if (framePtr->padY < 0) { framePtr->padY = 0; + if (framePtr->padYPtr) { + Tcl_DecrRefCount(framePtr->padYPtr); + } + framePtr->padYPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->padYPtr); } /* diff --git a/generic/tkInt.h b/generic/tkInt.h index 6e91fd6..dbb5637 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1366,8 +1366,6 @@ MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, Tcl_Size, int lastOK, Tcl_Size*); # define TK_OPTION_UNDERLINE_DEF(type, field) NULL, TCL_INDEX_NONE, offsetof(type, field), TK_OPTION_NULL_OK, NULL #endif -#define TK_OPTION_NONNEG (1 << 4) - #ifdef _WIN32 #define TkParseColor XParseColor #else diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 4592a28..a7b3f39 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -1603,6 +1603,11 @@ ConfigureListbox( if (listPtr->highlightWidth < 0) { listPtr->highlightWidth = 0; + if (listPtr->highlightWidthPtr) { + Tcl_DecrRefCount(listPtr->highlightWidthPtr); + } + listPtr->highlightWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(listPtr->highlightWidthPtr); } listPtr->inset = listPtr->highlightWidth + listPtr->borderWidth; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index f51e6ef..121c22f 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -538,13 +538,28 @@ ConfigureMenuButton( if (mbPtr->highlightWidth < 0) { mbPtr->highlightWidth = 0; + if (mbPtr->highlightWidthPtr) { + Tcl_DecrRefCount(mbPtr->highlightWidthPtr); + } + mbPtr->highlightWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(mbPtr->highlightWidthPtr); } if (mbPtr->padX < 0) { mbPtr->padX = 0; + if (mbPtr->padXPtr) { + Tcl_DecrRefCount(mbPtr->padXPtr); + } + mbPtr->padXPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(mbPtr->padXPtr); } if (mbPtr->padY < 0) { mbPtr->padY = 0; + if (mbPtr->padYPtr) { + Tcl_DecrRefCount(mbPtr->padYPtr); + } + mbPtr->padYPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(mbPtr->padYPtr); } /* diff --git a/generic/tkMessage.c b/generic/tkMessage.c index c1f73c6..2f4dca1 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -505,6 +505,11 @@ ConfigureMessage( if (msgPtr->highlightWidth < 0) { msgPtr->highlightWidth = 0; + if (msgPtr->highlightWidth) { + Tcl_DecrRefCount(msgPtr->highlightWidthObj); + } + msgPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(msgPtr->highlightWidthObj); } Tk_FreeSavedOptions(&savedOptions); diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 04c78a4..9c8500d 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -954,7 +954,7 @@ ConfigurePanes( /* * Make sure this pane wasn't already put into the inserts array, * i.e., when the user specifies the same window multiple times in a - * single add commaned. + * single add command. */ for (j = 0; j < insertIndex; j++) { if (inserts[j]->tkwin == tkwin) { diff --git a/generic/tkScale.c b/generic/tkScale.c index 3804c90..1d23eda 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -681,6 +681,11 @@ ConfigureScale( if (scalePtr->highlightWidth < 0) { scalePtr->highlightWidth = 0; + if (scalePtr->highlightWidthPtr) { + Tcl_DecrRefCount(scalePtr->highlightWidthPtr); + } + scalePtr->highlightWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(scalePtr->highlightWidthPtr); } scalePtr->inset = scalePtr->highlightWidth + scalePtr->borderWidth; break; diff --git a/generic/tkText.c b/generic/tkText.c index c040b46..3dfb768 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -212,13 +212,13 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", DEF_TEXT_SPACING1, offsetof(TkText, spacing1Ptr), offsetof(TkText, spacing1), - TK_OPTION_NONNEG, 0, TK_TEXT_LINE_GEOMETRY }, + 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing", DEF_TEXT_SPACING2, offsetof(TkText, spacing2Ptr), offsetof(TkText, spacing2), - TK_OPTION_NONNEG, 0, TK_TEXT_LINE_GEOMETRY }, + 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", DEF_TEXT_SPACING3, offsetof(TkText, spacing3Ptr), offsetof(TkText, spacing3), - TK_OPTION_NONNEG, 0, TK_TEXT_LINE_GEOMETRY }, + 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, &lineOption, TK_TEXT_LINE_RANGE}, @@ -2213,7 +2213,6 @@ ConfigureText( } } -#ifndef TK_NO_DEPRECATED /* * Don't allow negative spacings. */ @@ -2242,7 +2241,6 @@ ConfigureText( textPtr->spacing3Ptr = Tcl_NewIntObj(0); Tcl_IncrRefCount(textPtr->spacing3Ptr); } -#endif /* TK_NO_DEPRECATED */ /* * Parse tab stops. diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cc4a12c..9b94099 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -5256,8 +5256,13 @@ TkTextRelayoutWindow( * it. */ - if (textPtr->highlightWidth < 0) { - textPtr->highlightWidth = 0; + if (textPtr->highlightWidthPtr) { + if (textPtr->highlightWidth < 0) { + textPtr->highlightWidth = 0; + Tcl_DecrRefCount(textPtr->highlightWidthPtr); + textPtr->highlightWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->highlightWidthPtr); + } } dInfoPtr->x = textPtr->highlightWidth + textPtr->borderWidth + textPtr->padX; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 26b9f0c..7c100ce 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -585,8 +585,13 @@ TkTextTagCmd( * from "unspecified"). */ - if (tagPtr->borderWidth < 0) { - tagPtr->borderWidth = 0; + if (tagPtr->borderWidthPtr) { + if (tagPtr->borderWidth < 0) { + tagPtr->borderWidth = 0; + Tcl_DecrRefCount(tagPtr->borderWidthPtr); + tagPtr->borderWidthPtr = Tcl_NewIntObj(0); + Tcl_IncrRefCount(tagPtr->borderWidthPtr); + } } if (tagPtr->tabArrayPtr != NULL) { ckfree(tagPtr->tabArrayPtr); diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index c28aaec..6b99eb5 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -293,9 +293,7 @@ TkTextWindowCmd( ewPtr->body.ew.create = NULL; ewPtr->body.ew.align = TK_ALIGN_CENTER; ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0; - ewPtr->body.ew.padXPtr = ewPtr->body.ew.padYPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(ewPtr->body.ew.padXPtr); - Tcl_IncrRefCount(ewPtr->body.ew.padYPtr); + ewPtr->body.ew.padXPtr = ewPtr->body.ew.padYPtr = NULL; ewPtr->body.ew.stretch = 0; ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs); diff --git a/tests/listbox.test b/tests/listbox.test index ae7fba6..bfe5243 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -203,7 +203,7 @@ test listbox-1.31 {configuration options} -body { list [lindex [.l configure -highlightthickness] 4] [.l cget -highlightthickness] } -cleanup { .l configure -highlightthickness [lindex [.l configure -highlightthickness] 3] -} -result {-2 -2} +} -result {0 0} test listbox-1.32.1 {configuration options} -setup { set res {} } -body { @@ -1242,7 +1242,7 @@ test listbox-4.2 {ConfigureListbox procedure} -setup { .l cget -highlightthickness } -cleanup { deleteWindows -} -result -3 +} -result 0 test listbox-4.3 {ConfigureListbox procedure} -setup { deleteWindows destroy .l diff --git a/tests/text.test b/tests/text.test index eed3bb5..5ed975e 100644 --- a/tests/text.test +++ b/tests/text.test @@ -303,7 +303,7 @@ test text-1.29 {configuration option: "highlightthickness"} -setup { .t cget -highlightthickness } -cleanup { destroy .t -} -result -2 +} -result 0 test text-1.30 {configuration option: "highlightthickness"} -setup { text .t -borderwidth 2 -highlightthickness 2 -font {Courier -12 bold} pack .t -- cgit v0.12 From 35603597b8940d6b186986f5582a222b3e52194f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 8 Jun 2024 18:27:21 +0000 Subject: Finish "Entry" restructureing --- generic/tkEntry.c | 101 ++++++++++++++++++++++++++++++------------------- generic/tkEntry.h | 15 +++----- generic/tkInt.h | 1 + macosx/tkMacOSXEntry.c | 7 +++- tests/text.test | 12 +++--- tests/textImage.test | 4 +- tests/textWind.test | 2 +- 7 files changed, 82 insertions(+), 60 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 2ef3772..7642e63 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, offsetof(Entry, borderWidthPtr), 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, offsetof(Entry, highlightWidthPtr), - 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, offsetof(Entry, insertBorderWidthPtr), - 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,7 +114,7 @@ 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, offsetof(Entry, insertWidthPtr), 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), TK_OPTION_NULL_OK, 0, 0}, @@ -138,8 +138,8 @@ 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, offsetof(Entry, selBorderWidthPtr), - offsetof(Entry, selBorderWidth), + "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), @@ -200,7 +200,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, offsetof(Entry, borderWidthPtr), 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}, @@ -244,23 +244,22 @@ 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, offsetof(Entry, highlightWidthPtr), - 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, offsetof(Entry, insertBorderWidthPtr), - 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, offsetof(Entry, insertWidthPtr), 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), TK_OPTION_NULL_OK, 0, 0}, @@ -290,8 +289,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, offsetof(Entry, selBorderWidthPtr), - offsetof(Entry, selBorderWidth), + "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), @@ -1127,6 +1126,7 @@ ConfigureEntry( double oldTo = 0.0; int code; size_t formatSpace = TCL_DOUBLE_SPACE; + int borderWidth, highlightWidth, insertWidth, insertBorderWidth; /* * Eliminate any existing trace on a variable monitored by the entry. @@ -1190,11 +1190,26 @@ ConfigureEntry( } Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); - if (entryPtr->insertWidth <= 0) { - entryPtr->insertWidth = 2; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertWidthObj, &insertWidth); + if (insertWidth <= 0) { + insertWidth = 2; + Tcl_DecrRefCount(entryPtr->insertWidthObj); + entryPtr->insertWidthObj = Tcl_NewIntObj(insertWidth); + Tcl_DecrRefCount(entryPtr->insertWidthObj); + } + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); + if (insertBorderWidth > insertWidth/2) { + insertBorderWidth = insertWidth/2; + Tcl_DecrRefCount(entryPtr->insertBorderWidthObj); + entryPtr->insertBorderWidthObj = Tcl_NewIntObj(insertBorderWidth); + Tcl_DecrRefCount(entryPtr->insertBorderWidthObj); } - if (entryPtr->insertBorderWidth > entryPtr->insertWidth/2) { - entryPtr->insertBorderWidth = entryPtr->insertWidth/2; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &highlightWidth); + if (highlightWidth < 0) { + highlightWidth = 0; + Tcl_DecrRefCount(entryPtr->highlightWidthObj); + entryPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->highlightWidthObj); } if (entryPtr->type == TK_SPINBOX) { @@ -1314,13 +1329,11 @@ ConfigureEntry( * redisplayed. */ + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); 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) { @@ -1714,16 +1727,18 @@ DisplayEntry( &selStartX, NULL, NULL, NULL); selStartX += entryPtr->layoutX; } - if ((selStartX - entryPtr->selBorderWidth) < xBound) { + int selBorderWidth; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->selBorderWidthObj, &selBorderWidth); + 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 @@ -1743,21 +1758,25 @@ DisplayEntry( */ if ((entryPtr->state == STATE_NORMAL) && (entryPtr->flags & GOT_FOCUS)) { + int insertWidth; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertWidthObj, &insertWidth); 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) { + int insertBorderWidth; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); 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); } } @@ -1911,12 +1930,16 @@ DisplayEntry( if (!TkpDrawEntryBorderAndFocus(entryPtr, pixmap, (entryPtr->type == TK_SPINBOX))) { - xBound = entryPtr->highlightWidth; + int highlightWidth; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &highlightWidth); + xBound = highlightWidth; if (entryPtr->relief != TK_RELIEF_FLAT) { + int borderWidth; + Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); 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; diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 2e9c543..271fadb 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -81,7 +81,7 @@ 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. */ + Tcl_Obj *borderWidthObj; /* Width of 3-D border around window. */ Tk_Cursor cursor; /* Current cursor for window, or NULL. */ int exportSelection; /* Non-zero means tie internal entry selection * to X selection. */ @@ -91,23 +91,23 @@ 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 + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion * cursor. */ - int insertBorderWidth; /* Width of 3-D border around insert cursor. */ + Tcl_Obj *insertBorderWidthObj; /* Width of 3-D border around insert cursor. */ 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. */ + Tcl_Obj *insertWidthObj; /* Total width of insert cursor. */ 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. */ + Tcl_Obj *selBorderWidthObj; /* Width of border around selection. */ XColor *selFgColorPtr; /* Foreground color for selected text. */ int state; /* Normal or disabled. Entry is read-only when * disabled. */ @@ -186,11 +186,6 @@ typedef struct { * commands. Malloc'ed. */ char *invalidCmd; /* Command called when a validation returns 0 * (successfully fails), defaults to {}. */ - Tcl_Obj *borderWidthPtr; - Tcl_Obj *highlightWidthPtr; - Tcl_Obj *insertBorderWidthPtr; - Tcl_Obj *insertWidthPtr; - Tcl_Obj *selBorderWidthPtr; } Entry; /* diff --git a/generic/tkInt.h b/generic/tkInt.h index dbb5637..a9da4ec 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1366,6 +1366,7 @@ MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, Tcl_Size, int lastOK, Tcl_Size*); # define TK_OPTION_UNDERLINE_DEF(type, field) NULL, TCL_INDEX_NONE, offsetof(type, field), TK_OPTION_NULL_OK, NULL #endif + #ifdef _WIN32 #define TkParseColor XParseColor #else diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 286a7fe..4579528 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -100,6 +100,7 @@ TkpDrawEntryBorderAndFocus( kThemeStateActive), .isFocused = (entryPtr->flags & GOT_FOCUS ? 1 : 0), }; + int borderWidth, highlightWidth; /* * I use 6 as the borderwidth. 2 of the 5 go into the actual frame the 3 @@ -107,8 +108,10 @@ TkpDrawEntryBorderAndFocus( * than Tk does on X11. */ - if (entryPtr->borderWidth != MAC_OSX_ENTRY_BORDER - || entryPtr->highlightWidth != MAC_OSX_FOCUS_WIDTH + Tk_GetPixelsFromObj(NULL, tkwin, entryPtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, entryPtr->highlightWidthObj, &highlightWidth); + if (borderWidth != MAC_OSX_ENTRY_BORDER + || highlightWidth != MAC_OSX_FOCUS_WIDTH || entryPtr->relief != MAC_OSX_ENTRY_RELIEF) { return 0; } diff --git a/tests/text.test b/tests/text.test index 5ed975e..29c4be9 100644 --- a/tests/text.test +++ b/tests/text.test @@ -593,7 +593,7 @@ test text-1.59 {configuration option: "spacing1"} -setup { pack .t update } -body { - .t configure -spacing1 0 + .t configure -spacing1 -5 .t cget -spacing1 } -cleanup { destroy .t @@ -631,7 +631,7 @@ test text-1.63 {configuration option: "spacing2"} -setup { pack .t update } -body { - .t configure -spacing2 0 + .t configure -spacing2 -1 .t cget -spacing2 } -cleanup { destroy .t @@ -669,7 +669,7 @@ test text-1.67 {configuration option: "spacing3"} -setup { pack .t update } -body { - .t configure -spacing3 0 + .t configure -spacing3 -10 .t cget -spacing3 } -cleanup { destroy .t @@ -3308,7 +3308,7 @@ test text-14.1 {ConfigureText procedure} -setup { test text-14.2 {ConfigureText procedure} -setup { text .t } -body { - .t configure -spacing1 0 -spacing2 1 -spacing3 1 + .t configure -spacing1 -2 -spacing2 1 -spacing3 1 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t @@ -3316,7 +3316,7 @@ test text-14.2 {ConfigureText procedure} -setup { test text-14.3 {ConfigureText procedure} -setup { text .t } -body { - .t configure -spacing1 1 -spacing2 0 -spacing3 1 + .t configure -spacing1 1 -spacing2 -1 -spacing3 1 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t @@ -3324,7 +3324,7 @@ test text-14.3 {ConfigureText procedure} -setup { test text-14.4 {ConfigureText procedure} -setup { text .t } -body { - .t configure -spacing1 1 -spacing2 1 -spacing3 0 + .t configure -spacing1 1 -spacing2 1 -spacing3 -3 list [.t cget -spacing1] [.t cget -spacing2] [.t cget -spacing3] } -cleanup { destroy .t diff --git a/tests/textImage.test b/tests/textImage.test index ffc65e7..ef2ac82 100644 --- a/tests/textImage.test +++ b/tests/textImage.test @@ -206,7 +206,7 @@ test textImage-1.16 {configure} -setup { } -cleanup { destroy .t image delete small -} -result {{-align {} {} center center} {-padx {} {} 0 0} {-pady {} {} 0 0} {-image {} {} {} small} {-name {} {} {} {}}} +} -result {{-align {} {} center center} {-padx {} {} 0 {}} {-pady {} {} 0 {}} {-image {} {} {} small} {-name {} {} {} {}}} test textImage-1.17 {basic cget options} -setup { destroy .t @@ -226,7 +226,7 @@ test textImage-1.17 {basic cget options} -setup { } -cleanup { destroy .t image delete small -} -result {align:center padx:0 pady:0 image:small name:} +} -result {align:center padx: pady: image:small name:} test textImage-1.18 {basic configure options} -setup { destroy .t diff --git a/tests/textWind.test b/tests/textWind.test index ecb433e..e3721e5 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -287,7 +287,7 @@ test textWind-2.17 {TkTextWindowCmd procedure} -setup { .t delete 1.0 end } -body { list [catch {.t window create 1.0} msg] $msg [.t window configure 1.0] -} -result {0 {} {{-align {} {} center center} {-create {} {} {} {}} {-padx {} {} 0 0} {-pady {} {} 0 0} {-stretch {} {} 0 0} {-window {} {} {} {}}}} +} -result {0 {} {{-align {} {} center center} {-create {} {} {} {}} {-padx {} {} 0 {}} {-pady {} {} 0 {}} {-stretch {} {} 0 0} {-window {} {} {} {}}}} test textWind-2.18 {TkTextWindowCmd procedure} -setup { destroy .f frame .f -width 20 -height 10 -bg $color -- cgit v0.12 From 91670edfb6cd5fb9da1df66891fbfd617d346f2e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 8 Jun 2024 22:44:15 +0000 Subject: "Scale" done too --- generic/tkScale.c | 113 +++++++++++++++++++++++++++++++---------------------- generic/tkScale.h | 16 +++----- unix/tkUnixScale.c | 106 +++++++++++++++++++++++++++---------------------- 3 files changed, 132 insertions(+), 103 deletions(-) diff --git a/generic/tkScale.c b/generic/tkScale.c index 1d23eda..b15767a 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -49,7 +49,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_SCALE_BORDER_WIDTH, offsetof(TkScale, borderWidthPtr), offsetof(TkScale, borderWidth), + DEF_SCALE_BORDER_WIDTH, offsetof(TkScale, borderWidthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_SCALE_COMMAND, TCL_INDEX_NONE, offsetof(TkScale, command), @@ -77,13 +77,13 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkScale, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, offsetof(TkScale, highlightWidthPtr), - offsetof(TkScale, highlightWidth), 0, 0, 0}, + "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, offsetof(TkScale, highlightWidthObj), + TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-label", "label", "Label", DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-length", "length", "Length", - DEF_SCALE_LENGTH, offsetof(TkScale, lengthPtr), offsetof(TkScale, length), 0, 0, 0}, + DEF_SCALE_LENGTH, offsetof(TkScale, lengthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient), TK_OPTION_ENUM_VAR, orientStrings, 0}, @@ -102,7 +102,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_SHOW_VALUE, TCL_INDEX_NONE, offsetof(TkScale, showValue), 0, 0, 0}, {TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength", - DEF_SCALE_SLIDER_LENGTH, offsetof(TkScale, sliderLengthPtr), offsetof(TkScale, sliderLength), + DEF_SCALE_SLIDER_LENGTH, offsetof(TkScale, sliderLengthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief", DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief), @@ -125,7 +125,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_SCALE_VARIABLE, offsetof(TkScale, varNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", - DEF_SCALE_WIDTH, offsetof(TkScale, widthPtr), offsetof(TkScale, width), 0, 0, 0}, + DEF_SCALE_WIDTH, offsetof(TkScale, widthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -281,8 +281,8 @@ Tk_ScaleObjCmd( scalePtr, ScaleCmdDeletedProc); scalePtr->optionTable = optionTable; scalePtr->orient = ORIENT_VERTICAL; - scalePtr->width = 0; - scalePtr->length = 0; + scalePtr->widthObj = NULL; + scalePtr->lengthObj = NULL; scalePtr->value = 0.0; scalePtr->varNamePtr = NULL; scalePtr->fromValue = 0.0; @@ -297,7 +297,7 @@ Tk_ScaleObjCmd( scalePtr->label = NULL; scalePtr->labelLength = 0; scalePtr->state = STATE_NORMAL; - scalePtr->borderWidth = 0; + scalePtr->borderWidthObj = NULL; scalePtr->bgBorder = NULL; scalePtr->activeBorder = NULL; scalePtr->sliderRelief = TK_RELIEF_RAISED; @@ -308,11 +308,11 @@ Tk_ScaleObjCmd( scalePtr->textColorPtr = NULL; scalePtr->textGC = NULL; scalePtr->relief = TK_RELIEF_FLAT; - scalePtr->highlightWidth = 0; + scalePtr->highlightWidthObj = NULL; scalePtr->highlightBorder = NULL; scalePtr->highlightColorPtr = NULL; scalePtr->inset = 0; - scalePtr->sliderLength = 0; + scalePtr->sliderLengthObj = NULL; scalePtr->showValue = 0; scalePtr->horizLabelY = 0; scalePtr->horizValueY = 0; @@ -326,11 +326,7 @@ Tk_ScaleObjCmd( scalePtr->cursor = NULL; scalePtr->takeFocusPtr = NULL; scalePtr->flags = NEVER_SET; - scalePtr->borderWidthPtr = NULL; - scalePtr->highlightWidthPtr = NULL; - scalePtr->lengthPtr = NULL; - scalePtr->sliderLengthPtr = NULL; - scalePtr->widthPtr = NULL; + Tk_SetClassProcs(scalePtr->tkwin, &scaleClass, scalePtr); @@ -422,7 +418,7 @@ ScaleWidgetObjCmd( } break; case COMMAND_COORDS: { - int x, y; + int x, y, width, borderWidth; double value; Tcl_Obj *coords[2]; @@ -437,14 +433,16 @@ ScaleWidgetObjCmd( } else { value = scalePtr->value; } + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->widthObj, &width); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); if (scalePtr->orient == ORIENT_VERTICAL) { - x = scalePtr->vertTroughX + scalePtr->width/2 - + scalePtr->borderWidth; + x = scalePtr->vertTroughX + width/2 + + borderWidth; y = TkScaleValueToPixel(scalePtr, value); } else { x = TkScaleValueToPixel(scalePtr, value); - y = scalePtr->horizTroughY + scalePtr->width/2 - + scalePtr->borderWidth; + y = scalePtr->horizTroughY + width/2 + + borderWidth; } coords[0] = Tcl_NewWideIntObj(x); coords[1] = Tcl_NewWideIntObj(y); @@ -601,7 +599,7 @@ ConfigureScale( { Tk_SavedOptions savedOptions; Tcl_Obj *errorResult = NULL; - int error; + int error, highlightWidth, borderWidth; double varValue; /* @@ -679,15 +677,17 @@ ConfigureScale( Tk_SetBackgroundFromBorder(scalePtr->tkwin, scalePtr->bgBorder); - if (scalePtr->highlightWidth < 0) { - scalePtr->highlightWidth = 0; - if (scalePtr->highlightWidthPtr) { - Tcl_DecrRefCount(scalePtr->highlightWidthPtr); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->highlightWidthObj, &highlightWidth); + if (highlightWidth < 0) { + highlightWidth = 0; + if (scalePtr->highlightWidthObj) { + Tcl_DecrRefCount(scalePtr->highlightWidthObj); } - scalePtr->highlightWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(scalePtr->highlightWidthPtr); + scalePtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(scalePtr->highlightWidthObj); } - scalePtr->inset = scalePtr->highlightWidth + scalePtr->borderWidth; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + scalePtr->inset = highlightWidth + borderWidth; break; } if (!error) { @@ -768,6 +768,7 @@ ScaleWorldChanged( XGCValues gcValues; GC gc; TkScale *scalePtr = (TkScale *)instanceData; + int highlightWidth, borderWidth; gcValues.foreground = scalePtr->troughColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues); @@ -789,7 +790,9 @@ ScaleWorldChanged( scalePtr->copyGC = Tk_GetGC(scalePtr->tkwin, GCGraphicsExposures, &gcValues); } - scalePtr->inset = scalePtr->highlightWidth + scalePtr->borderWidth; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->highlightWidthObj, &highlightWidth); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + scalePtr->inset = highlightWidth + borderWidth; /* * Recompute display-related information, and let the geometry manager @@ -942,10 +945,12 @@ ComputeFormat( * value between adjacent pixels and use it for the least * significant digit. */ + int length; x = fabs(scalePtr->fromValue - scalePtr->toValue); - if (scalePtr->length > 0) { - x /= scalePtr->length; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->lengthObj, &length); + if (length > 0) { + x /= length; } if (x > 0) { leastSigDigit = ScaleDigit(x); @@ -1022,6 +1027,7 @@ ComputeScaleGeometry( char valueString[TCL_DOUBLE_SPACE]; int tmp, valuePixels, tickPixels, x, y, extraSpace; Tk_FontMetrics fm; + int length, width, borderWidth; Tk_GetFontMetrics(scalePtr->tkfont, &fm); scalePtr->fontHeight = fm.linespace + SPACING; @@ -1049,13 +1055,16 @@ ComputeScaleGeometry( } y += extraSpace; scalePtr->horizTroughY = y; - y += scalePtr->width + 2*scalePtr->borderWidth; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->lengthObj, &length); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->widthObj, &width); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + y += width + 2 * borderWidth; if (scalePtr->tickInterval != 0) { scalePtr->horizTickY = y + SPACING; y += scalePtr->fontHeight + SPACING; } Tk_GeometryRequest(scalePtr->tkwin, - scalePtr->length + 2*scalePtr->inset, y + scalePtr->inset); + length + 2*scalePtr->inset, y + scalePtr->inset); Tk_SetInternalBorder(scalePtr->tkwin, scalePtr->inset); return; } @@ -1124,7 +1133,9 @@ ComputeScaleGeometry( scalePtr->vertValueRightX = x; } scalePtr->vertTroughX = x; - x += 2*scalePtr->borderWidth + scalePtr->width; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->widthObj, &width); + x += 2 * borderWidth + width; if (scalePtr->labelLength == 0) { scalePtr->vertLabelX = 0; } else { @@ -1133,8 +1144,9 @@ ComputeScaleGeometry( + Tk_TextWidth(scalePtr->tkfont, scalePtr->label, scalePtr->labelLength); } + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->lengthObj, &length); Tk_GeometryRequest(scalePtr->tkwin, x + scalePtr->inset, - scalePtr->length + 2*scalePtr->inset); + length + 2*scalePtr->inset); Tk_SetInternalBorder(scalePtr->tkwin, scalePtr->inset); } @@ -1162,6 +1174,7 @@ ScaleEventProc( XEvent *eventPtr) /* Information about event. */ { TkScale *scalePtr = (TkScale *)clientData; + int highlightWidth; if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { TkEventuallyRedrawScale(scalePtr, REDRAW_ALL); @@ -1173,14 +1186,16 @@ ScaleEventProc( } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { scalePtr->flags |= GOT_FOCUS; - if (scalePtr->highlightWidth > 0) { + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->highlightWidthObj, &highlightWidth); + if (highlightWidth > 0) { TkEventuallyRedrawScale(scalePtr, REDRAW_ALL); } } } else if (eventPtr->type == FocusOut) { if (eventPtr->xfocus.detail != NotifyInferior) { scalePtr->flags &= ~GOT_FOCUS; - if (scalePtr->highlightWidth > 0) { + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->highlightWidthObj, &highlightWidth); + if (highlightWidth > 0) { TkEventuallyRedrawScale(scalePtr, REDRAW_ALL); } } @@ -1536,14 +1551,17 @@ TkScalePixelToValue( int x, int y) /* Coordinates of point within window. */ { double value, pixelRange; + int borderWidth, sliderLength; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->sliderLengthObj, &sliderLength); if (scalePtr->orient == ORIENT_VERTICAL) { - pixelRange = Tk_Height(scalePtr->tkwin) - scalePtr->sliderLength - - 2*scalePtr->inset - 2*scalePtr->borderWidth; + pixelRange = Tk_Height(scalePtr->tkwin) - sliderLength + - 2 * scalePtr->inset - 2 * borderWidth; value = y; } else { - pixelRange = Tk_Width(scalePtr->tkwin) - scalePtr->sliderLength - - 2*scalePtr->inset - 2*scalePtr->borderWidth; + pixelRange = Tk_Width(scalePtr->tkwin) - sliderLength + - 2 * scalePtr->inset - 2 * borderWidth; value = x; } @@ -1555,8 +1573,8 @@ TkScalePixelToValue( return scalePtr->value; } - value -= scalePtr->sliderLength/2 + scalePtr->inset - + scalePtr->borderWidth; + value -= sliderLength/2 + scalePtr->inset + + borderWidth; value /= pixelRange; if (value < 0) { value = 0; @@ -1595,11 +1613,14 @@ TkScaleValueToPixel( { int y, pixelRange; double valueRange; + int borderWidth, sliderLength; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->sliderLengthObj, &sliderLength); valueRange = scalePtr->toValue - scalePtr->fromValue; pixelRange = ((scalePtr->orient == ORIENT_VERTICAL) ? Tk_Height(scalePtr->tkwin) : Tk_Width(scalePtr->tkwin)) - - scalePtr->sliderLength - 2*scalePtr->inset - 2*scalePtr->borderWidth; + - sliderLength - 2 * scalePtr->inset - 2 * borderWidth; if (valueRange == 0) { y = 0; } else { @@ -1611,7 +1632,7 @@ TkScaleValueToPixel( y = pixelRange; } } - y += scalePtr->sliderLength/2 + scalePtr->inset + scalePtr->borderWidth; + y += sliderLength / 2 + scalePtr->inset + borderWidth; return y; } diff --git a/generic/tkScale.h b/generic/tkScale.h index 62d5f09..4a59901 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -53,9 +53,9 @@ typedef struct TkScale { * available for this widget. */ enum orient orient; /* Orientation for window (vertical or * horizontal). */ - int width; /* Desired narrow dimension of scale, in + 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. */ double value; /* Current value of scale. */ Tcl_Obj *varNamePtr; /* Name of variable or NULL. If non-NULL, @@ -96,7 +96,7 @@ typedef struct TkScale { * Information used when displaying widget: */ - int borderWidth; /* Width of 3-D border around window. */ + Tcl_Obj *borderWidthObj; /* Width of 3-D border around window. */ Tk_3DBorder bgBorder; /* Used for drawing slider and other * background areas. */ Tk_3DBorder activeBorder; /* For drawing the slider when active. */ @@ -110,7 +110,7 @@ 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 + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ Tk_3DBorder highlightBorder;/* Value of -highlightbackground option: @@ -123,7 +123,7 @@ 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 + Tcl_Obj *sliderLengthObj; /* Length of slider, measured in pixels along * long dimension of scale. */ int showValue; /* Non-zero means to display the scale value * below or to the left of the slider; zero @@ -159,12 +159,6 @@ typedef struct TkScale { * scripts. May be NULL. */ int flags; /* Various flags; see below for * definitions. */ - Tcl_Obj *borderWidthPtr; - Tcl_Obj *highlightWidthPtr; - Tcl_Obj *lengthPtr; - Tcl_Obj *sliderLengthPtr; - Tcl_Obj *widthPtr; - } TkScale; /* diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index 6e73268..b454f25 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -114,17 +114,21 @@ DisplayVerticalScale( int x, y, width, height, shadowWidth; double tickValue, tickInterval = scalePtr->tickInterval; Tk_3DBorder sliderBorder; + int scaleWidth, borderWidth, sliderLength; /* * Display the information from left to right across the window. */ + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->widthObj, &scaleWidth); + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->sliderLengthObj, &sliderLength); if (!(scalePtr->flags & REDRAW_OTHER)) { drawnAreaPtr->x = scalePtr->vertTickRightX; drawnAreaPtr->y = scalePtr->inset; - drawnAreaPtr->width = scalePtr->vertTroughX + scalePtr->width - + 2*scalePtr->borderWidth - scalePtr->vertTickRightX; - drawnAreaPtr->height -= 2*scalePtr->inset; + drawnAreaPtr->width = scalePtr->vertTroughX + scaleWidth + + 2 * borderWidth - scalePtr->vertTickRightX; + drawnAreaPtr->height -= 2 * scalePtr->inset; } Tk_Fill3DRectangle(tkwin, drawable, scalePtr->bgBorder, drawnAreaPtr->x, drawnAreaPtr->y, drawnAreaPtr->width, @@ -187,33 +191,33 @@ DisplayVerticalScale( Tk_Draw3DRectangle(tkwin, drawable, scalePtr->bgBorder, scalePtr->vertTroughX, scalePtr->inset, - scalePtr->width + 2*scalePtr->borderWidth, - Tk_Height(tkwin) - 2*scalePtr->inset, scalePtr->borderWidth, + scaleWidth + 2 * borderWidth, + Tk_Height(tkwin) - 2 * scalePtr->inset, borderWidth, TK_RELIEF_SUNKEN); XFillRectangle(scalePtr->display, drawable, scalePtr->troughGC, - scalePtr->vertTroughX + scalePtr->borderWidth, - scalePtr->inset + scalePtr->borderWidth, - (unsigned) scalePtr->width, - (unsigned) (Tk_Height(tkwin) - 2*scalePtr->inset - - 2*scalePtr->borderWidth)); + scalePtr->vertTroughX + borderWidth, + scalePtr->inset + borderWidth, + (unsigned) scaleWidth, + (unsigned) (Tk_Height(tkwin) - 2 * scalePtr->inset + - 2 * borderWidth)); if (scalePtr->state == STATE_ACTIVE) { sliderBorder = scalePtr->activeBorder; } else { sliderBorder = scalePtr->bgBorder; } - width = scalePtr->width; - height = scalePtr->sliderLength/2; - x = scalePtr->vertTroughX + scalePtr->borderWidth; + width = scaleWidth; + height = sliderLength / 2; + x = scalePtr->vertTroughX + borderWidth; y = TkScaleValueToPixel(scalePtr, scalePtr->value) - height; - shadowWidth = scalePtr->borderWidth/2; + shadowWidth = borderWidth / 2; if (shadowWidth == 0) { shadowWidth = 1; } Tk_Draw3DRectangle(tkwin, drawable, sliderBorder, x, y, width, - 2*height, shadowWidth, scalePtr->sliderRelief); + 2 * height, shadowWidth, scalePtr->sliderRelief); x += shadowWidth; y += shadowWidth; - width -= 2*shadowWidth; + width -= 2 * shadowWidth; height -= shadowWidth; Tk_Fill3DRectangle(tkwin, drawable, sliderBorder, x, y, width, height, shadowWidth, scalePtr->sliderRelief); @@ -329,17 +333,21 @@ DisplayHorizontalScale( int x, y, width, height, shadowWidth; double tickInterval = scalePtr->tickInterval; Tk_3DBorder sliderBorder; + int scaleWidth, borderWidth, sliderLength; /* * Display the information from bottom to top across the window. */ + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->widthObj, &scaleWidth); + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->sliderLengthObj, &sliderLength); if (!(scalePtr->flags & REDRAW_OTHER)) { drawnAreaPtr->x = scalePtr->inset; drawnAreaPtr->y = scalePtr->horizValueY; drawnAreaPtr->width -= 2*scalePtr->inset; - drawnAreaPtr->height = scalePtr->horizTroughY + scalePtr->width - + 2*scalePtr->borderWidth - scalePtr->horizValueY; + drawnAreaPtr->height = scalePtr->horizTroughY + scaleWidth + + 2 * borderWidth - scalePtr->horizValueY; } Tk_Fill3DRectangle(tkwin, drawable, scalePtr->bgBorder, drawnAreaPtr->x, drawnAreaPtr->y, drawnAreaPtr->width, @@ -410,25 +418,25 @@ DisplayHorizontalScale( y = scalePtr->horizTroughY; Tk_Draw3DRectangle(tkwin, drawable, scalePtr->bgBorder, scalePtr->inset, y, - Tk_Width(tkwin) - 2*scalePtr->inset, - scalePtr->width + 2*scalePtr->borderWidth, - scalePtr->borderWidth, TK_RELIEF_SUNKEN); + Tk_Width(tkwin) - 2 * scalePtr->inset, + scaleWidth + 2 * borderWidth, + borderWidth, TK_RELIEF_SUNKEN); XFillRectangle(scalePtr->display, drawable, scalePtr->troughGC, - scalePtr->inset + scalePtr->borderWidth, - y + scalePtr->borderWidth, - (unsigned) (Tk_Width(tkwin) - 2*scalePtr->inset - - 2*scalePtr->borderWidth), - (unsigned) scalePtr->width); + scalePtr->inset + borderWidth, + y + borderWidth, + (unsigned) (Tk_Width(tkwin) - 2 * scalePtr->inset + - 2 * borderWidth), + (unsigned) scaleWidth); if (scalePtr->state == STATE_ACTIVE) { sliderBorder = scalePtr->activeBorder; } else { sliderBorder = scalePtr->bgBorder; } - width = scalePtr->sliderLength/2; - height = scalePtr->width; + width = sliderLength/2; + height = scaleWidth; x = TkScaleValueToPixel(scalePtr, scalePtr->value) - width; - y += scalePtr->borderWidth; - shadowWidth = scalePtr->borderWidth/2; + y += borderWidth; + shadowWidth = borderWidth / 2; if (shadowWidth == 0) { shadowWidth = 1; } @@ -554,9 +562,10 @@ TkpDisplayScale( char string[TCL_DOUBLE_SPACE]; XRectangle drawnArea; Tcl_DString buf; + int highlightWidth, borderWidth; scalePtr->flags &= ~REDRAW_PENDING; - if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) { + if ((tkwin == NULL) || !Tk_IsMapped(tkwin)) { goto done; } @@ -624,15 +633,17 @@ TkpDisplayScale( * vertical scales: border and traversal highlight. */ + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->highlightWidthObj, &highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, scalePtr->borderWidthObj, &borderWidth); if (scalePtr->flags & REDRAW_OTHER) { if (scalePtr->relief != TK_RELIEF_FLAT) { Tk_Draw3DRectangle(tkwin, pixmap, scalePtr->bgBorder, - scalePtr->highlightWidth, scalePtr->highlightWidth, - Tk_Width(tkwin) - 2*scalePtr->highlightWidth, - Tk_Height(tkwin) - 2*scalePtr->highlightWidth, - scalePtr->borderWidth, scalePtr->relief); + highlightWidth, highlightWidth, + Tk_Width(tkwin) - 2 * highlightWidth, + Tk_Height(tkwin) - 2 * highlightWidth, + borderWidth, scalePtr->relief); } - if (scalePtr->highlightWidth != 0) { + if (highlightWidth != 0) { GC gc; if (scalePtr->flags & GOT_FOCUS) { @@ -641,7 +652,7 @@ TkpDisplayScale( gc = Tk_GCForColor( Tk_3DBorderColor(scalePtr->highlightBorder), pixmap); } - Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, pixmap); + Tk_DrawFocusHighlight(tkwin, gc, highlightWidth, pixmap); } } @@ -684,12 +695,15 @@ TkpScaleElement( TkScale *scalePtr, /* Widget record for scale. */ int x, int y) /* Coordinates within scalePtr's window. */ { - int sliderFirst; + int sliderFirst, width, borderWidth, sliderLength; + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->widthObj, &width); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->borderWidthObj, &borderWidth); + Tk_GetPixelsFromObj(NULL, scalePtr->tkwin, scalePtr->sliderLengthObj, &sliderLength); if (scalePtr->orient == ORIENT_VERTICAL) { if ((x < scalePtr->vertTroughX) - || (x >= (scalePtr->vertTroughX + 2*scalePtr->borderWidth + - scalePtr->width))) { + || (x >= (scalePtr->vertTroughX + 2 * borderWidth + + width))) { return OTHER; } if ((y < scalePtr->inset) @@ -697,19 +711,19 @@ TkpScaleElement( return OTHER; } sliderFirst = TkScaleValueToPixel(scalePtr, scalePtr->value) - - scalePtr->sliderLength/2; + - sliderLength/2; if (y < sliderFirst) { return TROUGH1; } - if (y < sliderFirst + scalePtr->sliderLength) { + if (y < sliderFirst + sliderLength) { return SLIDER; } return TROUGH2; } if ((y < scalePtr->horizTroughY) - || (y >= (scalePtr->horizTroughY + 2*scalePtr->borderWidth + - scalePtr->width))) { + || (y >= (scalePtr->horizTroughY + 2 * borderWidth + + width))) { return OTHER; } if ((x < scalePtr->inset) @@ -717,11 +731,11 @@ TkpScaleElement( return OTHER; } sliderFirst = TkScaleValueToPixel(scalePtr, scalePtr->value) - - scalePtr->sliderLength/2; + - sliderLength / 2; if (x < sliderFirst) { return TROUGH1; } - if (x < sliderFirst + scalePtr->sliderLength) { + if (x < sliderFirst + sliderLength) { return SLIDER; } return TROUGH2; -- cgit v0.12 From 5545c1f9ca88638876f527955993daa8485e7846 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 11 Jul 2024 12:22:53 +0000 Subject: Make "entry" work. No test failures any more. Many renamings of fields (*Ptr -> *Obj) --- generic/tkButton.c | 122 ++++++++++++++++++++++++------------------------ generic/tkButton.h | 30 ++++++------ generic/tkEntry.c | 90 +++++++++++++++-------------------- generic/tkEntry.h | 7 +++ generic/tkFrame.c | 57 +++++++++++----------- generic/tkListbox.c | 26 +++++------ generic/tkMenu.c | 4 +- generic/tkMenu.h | 2 +- generic/tkMenuDraw.c | 4 +- generic/tkMenubutton.c | 44 ++++++++--------- generic/tkMenubutton.h | 24 +++++----- generic/tkPanedWindow.c | 51 ++++++++++---------- generic/tkSquare.c | 10 ++-- generic/tkText.c | 61 ++++++++++++------------ generic/tkText.h | 76 +++++++++++++++++++----------- generic/tkTextDisp.c | 16 +++---- generic/tkTextImage.c | 8 ++-- generic/tkTextTag.c | 18 +++---- generic/tkTextWind.c | 8 ++-- macosx/tkMacOSXButton.c | 22 ++++----- macosx/tkMacOSXMenu.c | 2 +- tests/entry.test | 2 +- tests/spinbox.test | 2 +- unix/tkUnixButton.c | 16 +++---- unix/tkUnixMenu.c | 10 ++-- win/tkWinButton.c | 16 +++---- win/tkWinMenu.c | 6 +-- 27 files changed, 375 insertions(+), 359 deletions(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index 9d033e4..b640a5d 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -79,7 +79,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), + tkDefButtonBorderWidth, offsetof(TkButton, borderWidthObj), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), @@ -98,7 +98,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_LABEL_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", - DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_HEIGHT, offsetof(TkButton, heightObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, @@ -108,7 +108,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefLabelHighlightWidth, - offsetof(TkButton, highlightWidthPtr), + offsetof(TkButton, highlightWidthObj), offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, @@ -116,10 +116,10 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - tkDefLabelPadx, offsetof(TkButton, padXPtr), + tkDefLabelPadx, offsetof(TkButton, padXObj), offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - tkDefLabelPady, offsetof(TkButton, padYPtr), + tkDefLabelPady, offsetof(TkButton, padYObj), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, @@ -137,9 +137,9 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0}, {TK_OPTION_STRING, "-width", "width", "Width", - DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_WIDTH, offsetof(TkButton, widthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", - DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), + DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthObj), offsetof(TkButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; @@ -164,7 +164,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), + tkDefButtonBorderWidth, offsetof(TkButton, borderWidthObj), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, @@ -189,7 +189,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", - DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_HEIGHT, offsetof(TkButton, heightObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, @@ -199,7 +199,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, - offsetof(TkButton, highlightWidthPtr), + offsetof(TkButton, highlightWidthObj), offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, @@ -210,10 +210,10 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - tkDefButtonPadx, offsetof(TkButton, padXPtr), + tkDefButtonPadx, offsetof(TkButton, padXObj), offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - tkDefButtonPady, offsetof(TkButton, padYPtr), + tkDefButtonPady, offsetof(TkButton, padYObj), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), @@ -238,9 +238,9 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0}, {TK_OPTION_STRING, "-width", "width", "Width", - DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_WIDTH, offsetof(TkButton, widthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", - DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), + DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthObj), offsetof(TkButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -265,7 +265,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), + tkDefButtonBorderWidth, offsetof(TkButton, borderWidthObj), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, @@ -287,7 +287,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", - DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_HEIGHT, offsetof(TkButton, heightObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, @@ -297,7 +297,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, - offsetof(TkButton, highlightWidthPtr), + offsetof(TkButton, highlightWidthObj), offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, @@ -316,10 +316,10 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - tkDefLabelPadx, offsetof(TkButton, padXPtr), + tkDefLabelPadx, offsetof(TkButton, padXObj), offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - tkDefLabelPady, offsetof(TkButton, padYPtr), + tkDefLabelPady, offsetof(TkButton, padYObj), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, @@ -351,9 +351,9 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", - DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_WIDTH, offsetof(TkButton, widthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", - DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), + DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthObj), offsetof(TkButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -378,7 +378,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), + tkDefButtonBorderWidth, offsetof(TkButton, borderWidthObj), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, @@ -400,7 +400,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", - DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_HEIGHT, offsetof(TkButton, heightObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, @@ -410,7 +410,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, - offsetof(TkButton, highlightWidthPtr), + offsetof(TkButton, highlightWidthObj), offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, @@ -426,10 +426,10 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - tkDefLabelPadx, offsetof(TkButton, padXPtr), + tkDefLabelPadx, offsetof(TkButton, padXObj), offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - tkDefLabelPady, offsetof(TkButton, padYPtr), + tkDefLabelPady, offsetof(TkButton, padYObj), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, @@ -463,9 +463,9 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { DEF_RADIOBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", - DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, + DEF_BUTTON_WIDTH, offsetof(TkButton, widthObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", - DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), + DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthObj), offsetof(TkButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; @@ -687,10 +687,10 @@ ButtonCreate( butPtr->state = STATE_NORMAL; butPtr->normalBorder = NULL; butPtr->activeBorder = NULL; - butPtr->borderWidthPtr = NULL; + butPtr->borderWidthObj = NULL; butPtr->borderWidth = 0; butPtr->relief = TK_RELIEF_FLAT; - butPtr->highlightWidthPtr = NULL; + butPtr->highlightWidthObj = NULL; butPtr->highlightWidth = 0; butPtr->highlightBorder = NULL; butPtr->highlightColorPtr = NULL; @@ -705,15 +705,15 @@ ButtonCreate( butPtr->stippleGC = NULL; butPtr->gray = None; butPtr->copyGC = NULL; - butPtr->widthPtr = NULL; + butPtr->widthObj = NULL; butPtr->width = 0; - butPtr->heightPtr = NULL; + butPtr->heightObj = NULL; butPtr->height = 0; - butPtr->wrapLengthPtr = NULL; + butPtr->wrapLengthObj = NULL; butPtr->wrapLength = 0; - butPtr->padXPtr = NULL; + butPtr->padXObj = NULL; butPtr->padX = 0; - butPtr->padYPtr = NULL; + butPtr->padYObj = NULL; butPtr->padY = 0; butPtr->anchor = TK_ANCHOR_CENTER; butPtr->justify = TK_JUSTIFY_CENTER; @@ -1099,43 +1099,43 @@ ConfigureButton( } if (butPtr->wrapLength < 0) { butPtr->wrapLength = 0; - if (butPtr->wrapLengthPtr) { - Tcl_DecrRefCount(butPtr->wrapLengthPtr); + if (butPtr->wrapLengthObj) { + Tcl_DecrRefCount(butPtr->wrapLengthObj); } - butPtr->wrapLengthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->wrapLengthPtr); + butPtr->wrapLengthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->wrapLengthObj); } if (butPtr->borderWidth < 0) { butPtr->borderWidth = 0; - if (butPtr->borderWidthPtr) { - Tcl_DecrRefCount(butPtr->borderWidthPtr); + if (butPtr->borderWidthObj) { + Tcl_DecrRefCount(butPtr->borderWidthObj); } - butPtr->borderWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->borderWidthPtr); + butPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->borderWidthObj); } if (butPtr->highlightWidth < 0) { butPtr->highlightWidth = 0; - if (butPtr->highlightWidthPtr) { - Tcl_DecrRefCount(butPtr->highlightWidthPtr); + if (butPtr->highlightWidthObj) { + Tcl_DecrRefCount(butPtr->highlightWidthObj); } - butPtr->highlightWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->highlightWidthPtr); + butPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->highlightWidthObj); } if (butPtr->padX < 0) { butPtr->padX = 0; - if (butPtr->padXPtr) { - Tcl_DecrRefCount(butPtr->padXPtr); + if (butPtr->padXObj) { + Tcl_DecrRefCount(butPtr->padXObj); } - butPtr->padXPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->padXPtr); + butPtr->padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->padXObj); } if (butPtr->padY < 0) { butPtr->padY = 0; - if (butPtr->padYPtr) { - Tcl_DecrRefCount(butPtr->padYPtr); + if (butPtr->padYObj) { + Tcl_DecrRefCount(butPtr->padYObj); } - butPtr->padYPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(butPtr->padYPtr); + butPtr->padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(butPtr->padYObj); } if (butPtr->type >= TYPE_CHECK_BUTTON) { @@ -1283,13 +1283,13 @@ ConfigureButton( * The button must display the contents of an image or bitmap. */ - if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->widthPtr, + if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->widthObj, &butPtr->width) != TCL_OK) { widthError: Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)"); continue; } - if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->heightPtr, + if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->heightObj, &butPtr->height) != TCL_OK) { heightError: Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)"); @@ -1300,11 +1300,11 @@ ConfigureButton( * The button displays an ordinary text string. */ - if (Tcl_GetIntFromObj(interp, butPtr->widthPtr, &butPtr->width) + if (Tcl_GetIntFromObj(interp, butPtr->widthObj, &butPtr->width) != TCL_OK) { goto widthError; } - if (Tcl_GetIntFromObj(interp, butPtr->heightPtr, &butPtr->height) + if (Tcl_GetIntFromObj(interp, butPtr->heightObj, &butPtr->height) != TCL_OK) { goto heightError; } @@ -1491,7 +1491,7 @@ ButtonEventProc( } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { butPtr->flags |= GOT_FOCUS; - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); if (butPtr->highlightWidth > 0) { goto redraw; } @@ -1499,7 +1499,7 @@ ButtonEventProc( } else if (eventPtr->type == FocusOut) { if (eventPtr->xfocus.detail != NotifyInferior) { butPtr->flags &= ~GOT_FOCUS; - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); if (butPtr->highlightWidth > 0) { goto redraw; } diff --git a/generic/tkButton.h b/generic/tkButton.h index 52e861a..592e2dc 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -110,10 +110,8 @@ typedef struct { Tk_3DBorder activeBorder; /* Value of -activebackground option: this is * the color used to draw 3-D border and * background when widget is active. */ - Tcl_Obj *borderWidthPtr; /* Value of -borderWidth option: specifies + Tcl_Obj *borderWidthObj; /* Value of -borderWidth option: specifies * width of border in pixels. */ - int borderWidth; /* Integer value corresponding to - * borderWidthPtr. Always >= 0. */ int relief; /* Value of -relief option: specifies 3-d * effect for border, such as * TK_RELIEF_RAISED. */ @@ -126,12 +124,10 @@ typedef struct { * TK_RELIEF_RAISED, to be used when a * checkbutton or radiobutton without * indicator is off. */ - Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option: + Tcl_Obj *highlightWidthObj; /* Value of -highlightthickness option: * specifies width in pixels of highlight to * draw around widget when it has the focus. * <= 0 means don't draw a highlight. */ - int highlightWidth; /* Integer value corresponding to - * highlightWidthPtr. Always >= 0. */ Tk_3DBorder highlightBorder;/* Value of -highlightbackground option: * specifies background with which to draw 3-D * default ring and focus highlight area when @@ -166,26 +162,20 @@ typedef struct { * disabledFg is NULL. */ GC copyGC; /* Used for copying information from an * off-screen pixmap to the screen. */ - Tcl_Obj *widthPtr; /* Value of -width option. */ - int width; /* Integer value corresponding to widthPtr. */ - Tcl_Obj *heightPtr; /* Value of -height option. */ - int height; /* Integer value corresponding to heightPtr. */ - Tcl_Obj *wrapLengthPtr; /* Value of -wraplength option: specifies line + Tcl_Obj *widthObj; /* Value of -width option. */ + Tcl_Obj *heightObj; /* Value of -height option. */ + Tcl_Obj *wrapLengthObj; /* Value of -wraplength option: specifies line * length (in pixels) at which to wrap onto * next line. <= 0 means don't wrap except at * newlines. */ - int wrapLength; /* Integer value corresponding to - * wrapLengthPtr. */ - Tcl_Obj *padXPtr; /* Value of -padx option: specifies how many + Tcl_Obj *padXObj; /* Value of -padx option: specifies how many * pixels of extra space to leave on left and * right of text. Ignored for bitmaps and * images. */ - int padX; /* Integer value corresponding to padXPtr. */ - Tcl_Obj *padYPtr; /* Value of -padx option: specifies how many + Tcl_Obj *padYObj; /* Value of -padx option: specifies how many * pixels of extra space to leave above and * below text. Ignored for bitmaps and * images. */ - int padY; /* Integer value corresponding to padYPtr. */ Tk_Anchor anchor; /* Value of -anchor option: specifies where * text/bitmap should be displayed inside * button region. */ @@ -255,6 +245,12 @@ typedef struct { * invocataions of the button command. */ int flags; /* Various flags; see below for * definitions. */ +#ifdef BUILD_tk + int padX, padY; + int borderWidth; + int highlightWidth; + int width, height, wrapLength; +#endif } TkButton; /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 210ede0..431cd67 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, offsetof(Entry, borderWidthObj), TCL_INDEX_NONE, 0, 0, 0}, + DEF_ENTRY_BORDER_WIDTH, offsetof(Entry, borderWidthObj), offsetof(Entry, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), TK_OPTION_NULL_OK, 0, 0}, @@ -101,12 +101,12 @@ static const Tk_OptionSpec entryOptSpec[] = { DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, offsetof(Entry, highlightWidthObj), - TCL_INDEX_NONE, 0, 0, 0}, + offsetof(Entry, highlightWidth), 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, offsetof(Entry, insertBorderWidthObj), - TCL_INDEX_NONE, 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), @@ -114,7 +114,7 @@ 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, offsetof(Entry, insertWidthObj), TCL_INDEX_NONE, 0, 0, 0}, + DEF_ENTRY_INSERT_WIDTH, offsetof(Entry, insertWidthObj), offsetof(Entry, insertWidth), 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), TK_OPTION_NULL_OK, 0, 0}, @@ -139,7 +139,7 @@ static const Tk_OptionSpec entryOptSpec[] = { 0, DEF_ENTRY_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidthObj), - TCL_INDEX_NONE, + 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), @@ -200,7 +200,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, offsetof(Entry, borderWidthObj), TCL_INDEX_NONE, 0, 0, 0}, + DEF_ENTRY_BORDER_WIDTH, offsetof(Entry, borderWidthObj), offsetof(Entry, borderWidth), 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}, @@ -245,21 +245,22 @@ static const Tk_OptionSpec sbOptSpec[] = { DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, offsetof(Entry, highlightWidthObj), - TCL_INDEX_NONE, 0, 0, 0}, + offsetof(Entry, highlightWidth), 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, offsetof(Entry, insertBorderWidthObj), - TCL_INDEX_NONE, 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}, {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, offsetof(Entry, insertWidthObj), TCL_INDEX_NONE, 0, 0, 0}, + DEF_ENTRY_INSERT_WIDTH, offsetof(Entry, insertWidthObj), offsetof(Entry, insertWidth), 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), TK_OPTION_NULL_OK, 0, 0}, @@ -289,8 +290,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, offsetof(Entry, selBorderWidthObj), - TCL_INDEX_NONE, + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidth), + 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), @@ -1126,7 +1127,6 @@ ConfigureEntry( double oldTo = 0.0; int code; size_t formatSpace = TCL_DOUBLE_SPACE; - int borderWidth, highlightWidth, insertWidth, insertBorderWidth; /* * Eliminate any existing trace on a variable monitored by the entry. @@ -1190,23 +1190,20 @@ ConfigureEntry( } Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertWidthObj, &insertWidth); - if (insertWidth <= 0) { - insertWidth = 2; - Tcl_DecrRefCount(entryPtr->insertWidthObj); - entryPtr->insertWidthObj = Tcl_NewIntObj(insertWidth); + if (entryPtr->insertWidth < 0) { + entryPtr->insertWidth = 0; Tcl_DecrRefCount(entryPtr->insertWidthObj); + entryPtr->insertWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->insertWidthObj); } - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); - if (insertBorderWidth > insertWidth/2) { - insertBorderWidth = insertWidth/2; - Tcl_DecrRefCount(entryPtr->insertBorderWidthObj); - entryPtr->insertBorderWidthObj = Tcl_NewIntObj(insertBorderWidth); - Tcl_DecrRefCount(entryPtr->insertBorderWidthObj); + if ((entryPtr->insertBorderWidth < 0) || (entryPtr->insertBorderWidth > entryPtr->insertWidth/2)) { + entryPtr->insertBorderWidth = entryPtr->insertWidth/2; + Tcl_DecrRefCount(entryPtr->insertWidthObj); + entryPtr->insertWidthObj = Tcl_NewIntObj(entryPtr->insertBorderWidth); + Tcl_IncrRefCount(entryPtr->insertWidthObj); } - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &highlightWidth); - if (highlightWidth < 0) { - highlightWidth = 0; + if (entryPtr->highlightWidth < 0) { + entryPtr->highlightWidth = 0; Tcl_DecrRefCount(entryPtr->highlightWidthObj); entryPtr->highlightWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(entryPtr->highlightWidthObj); @@ -1329,11 +1326,10 @@ ConfigureEntry( * redisplayed. */ - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); Tk_SetInternalBorder(entryPtr->tkwin, - borderWidth + highlightWidth); - entryPtr->inset = highlightWidth - + borderWidth + XPAD; + entryPtr->borderWidth + entryPtr->highlightWidth); + entryPtr->inset = entryPtr->highlightWidth + + entryPtr->borderWidth + XPAD; break; } if (!error) { @@ -1727,18 +1723,16 @@ DisplayEntry( &selStartX, NULL, NULL, NULL); selStartX += entryPtr->layoutX; } - int selBorderWidth; - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->selBorderWidthObj, &selBorderWidth); - if ((selStartX - selBorderWidth) < xBound) { + if ((selStartX - entryPtr->selBorderWidth) < xBound) { Tk_CharBbox(entryPtr->textLayout, entryPtr->selectLast, &selEndX, NULL, NULL, NULL); selEndX += entryPtr->layoutX; Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->selBorder, - selStartX - selBorderWidth, - baseY - fm.ascent - selBorderWidth, - (selEndX - selStartX) + 2 * selBorderWidth, - (fm.ascent + fm.descent) + 2 * selBorderWidth, - selBorderWidth, + selStartX - entryPtr->selBorderWidth, + baseY - fm.ascent - entryPtr->selBorderWidth, + (selEndX - selStartX) + 2*entryPtr->selBorderWidth, + (fm.ascent + fm.descent) + 2*entryPtr->selBorderWidth, + entryPtr->selBorderWidth, #ifndef MAC_OSX_TK TK_RELIEF_RAISED #else @@ -1758,25 +1752,21 @@ DisplayEntry( */ if ((entryPtr->state == STATE_NORMAL) && (entryPtr->flags & GOT_FOCUS)) { - int insertWidth; - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertWidthObj, &insertWidth); Tk_CharBbox(entryPtr->textLayout, entryPtr->insertPos, &cursorX, NULL, NULL, NULL); cursorX += entryPtr->layoutX; - cursorX -= (insertWidth == 1) ? 1 : insertWidth/2; + cursorX -= (entryPtr->insertWidth <= 1) ? 1 : (entryPtr->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) { - int insertBorderWidth; - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->insertBorderWidthObj, &insertBorderWidth); Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder, - cursorX, baseY - fm.ascent, insertWidth, - fm.ascent + fm.descent, insertBorderWidth, + cursorX, baseY - fm.ascent, entryPtr->insertWidth, + fm.ascent + fm.descent, entryPtr->insertBorderWidth, TK_RELIEF_RAISED); } else if (entryPtr->insertBorder == entryPtr->selBorder) { Tk_Fill3DRectangle(tkwin, pixmap, border, cursorX, - baseY - fm.ascent, insertWidth, + baseY - fm.ascent, entryPtr->insertWidth, fm.ascent + fm.descent, 0, TK_RELIEF_FLAT); } } @@ -1930,16 +1920,12 @@ DisplayEntry( if (!TkpDrawEntryBorderAndFocus(entryPtr, pixmap, (entryPtr->type == TK_SPINBOX))) { - int highlightWidth; - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &highlightWidth); - xBound = highlightWidth; + xBound = entryPtr->highlightWidth; if (entryPtr->relief != TK_RELIEF_FLAT) { - int borderWidth; - Tk_GetPixelsFromObj(NULL, entryPtr->tkwin, entryPtr->borderWidthObj, &borderWidth); Tk_Draw3DRectangle(tkwin, pixmap, border, xBound, xBound, Tk_Width(tkwin) - 2 * xBound, Tk_Height(tkwin) - 2 * xBound, - borderWidth, entryPtr->relief); + entryPtr->borderWidth, entryPtr->relief); } if (xBound > 0) { GC fgGC, bgGC; diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 271fadb..72bffcf 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -186,6 +186,13 @@ typedef struct { * commands. Malloc'ed. */ char *invalidCmd; /* Command called when a validation returns 0 * (successfully fails), defaults to {}. */ +#ifdef BUILD_tk + int borderWidth; + int highlightWidth; + int insertWidth; + int insertBorderWidth; + int selBorderWidth; +#endif } Entry; /* diff --git a/generic/tkFrame.c b/generic/tkFrame.c index c8af55c..02ccfb4 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -86,14 +86,12 @@ typedef struct { * windows this is NULL. */ int flags; /* Various flags; see below for * definitions. */ - Tcl_Obj *padXPtr; /* Value of -padx option: specifies how many + Tcl_Obj *padXObj; /* Value of -padx option: specifies how many * pixels of extra space to leave on left and * right of child area. */ - int padX; /* Integer value corresponding to padXPtr. */ - Tcl_Obj *padYPtr; /* Value of -padx option: specifies how many + Tcl_Obj *padYObj; /* Value of -padx option: specifies how many * pixels of extra space to leave above and * below child area. */ - int padY; /* Integer value corresponding to padYPtr. */ Tcl_Obj *bgimgPtr; /* Value of -backgroundimage option: specifies * image to display on window's background, or * NULL if none. */ @@ -101,13 +99,16 @@ typedef struct { * Tk_GetImage, or NULL if bgimgPtr is * NULL. */ int tile; /* Whether to tile the bgimg. */ - Tcl_Obj *heightPtr; - Tcl_Obj *widthPtr; - Tcl_Obj *highlightWidthPtr; - Tcl_Obj *borderWidthPtr; + Tcl_Obj *heightObj; + Tcl_Obj *widthObj; + Tcl_Obj *highlightWidthObj; + Tcl_Obj *borderWidthObj; #ifndef TK_NO_DOUBLE_BUFFERING GC copyGC; /* GC for copying when double-buffering. */ #endif /* TK_NO_DOUBLE_BUFFERING */ +#ifdef BUILD_tk + int padX, padY; +#endif } Frame; /* @@ -205,7 +206,7 @@ static const Tk_OptionSpec commonOptSpec[] = { DEF_FRAME_CURSOR, TCL_INDEX_NONE, offsetof(Frame, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-height", "height", "Height", - DEF_FRAME_HEIGHT, offsetof(Frame, heightPtr), offsetof(Frame, height), 0, 0, 0}, + DEF_FRAME_HEIGHT, offsetof(Frame, heightObj), offsetof(Frame, height), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, TCL_INDEX_NONE, offsetof(Frame, highlightBgColorPtr), 0, 0, 0}, @@ -213,13 +214,13 @@ static const Tk_OptionSpec commonOptSpec[] = { DEF_FRAME_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Frame, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, offsetof(Frame, highlightWidthPtr), + "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, offsetof(Frame, highlightWidthObj), offsetof(Frame, highlightWidth), 0, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - DEF_FRAME_PADX, offsetof(Frame, padXPtr), + DEF_FRAME_PADX, offsetof(Frame, padXObj), offsetof(Frame, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - DEF_FRAME_PADY, offsetof(Frame, padYPtr), + DEF_FRAME_PADY, offsetof(Frame, padYObj), offsetof(Frame, padY), 0, 0, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_FRAME_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Frame, takeFocus), @@ -228,7 +229,7 @@ static const Tk_OptionSpec commonOptSpec[] = { DEF_FRAME_VISUAL, TCL_INDEX_NONE, offsetof(Frame, visualName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", - DEF_FRAME_WIDTH, offsetof(Frame, widthPtr), offsetof(Frame, width), 0, 0, 0}, + DEF_FRAME_WIDTH, offsetof(Frame, widthObj), offsetof(Frame, width), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; @@ -241,7 +242,7 @@ static const Tk_OptionSpec frameOptSpec[] = { {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_FRAME_BORDER_WIDTH, offsetof(Frame, borderWidthPtr), offsetof(Frame, borderWidth), 0, 0, 0}, + DEF_FRAME_BORDER_WIDTH, offsetof(Frame, borderWidthObj), offsetof(Frame, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-class", "class", "Class", DEF_FRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", @@ -261,7 +262,7 @@ static const Tk_OptionSpec toplevelOptSpec[] = { {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_FRAME_BORDER_WIDTH, offsetof(Frame, borderWidthPtr), offsetof(Frame, borderWidth), 0, 0, 0}, + DEF_FRAME_BORDER_WIDTH, offsetof(Frame, borderWidthObj), offsetof(Frame, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-class", "class", "Class", DEF_TOPLEVEL_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0}, {TK_OPTION_STRING, "-menu", "menu", "Menu", @@ -285,7 +286,7 @@ static const Tk_OptionSpec labelframeOptSpec[] = { {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_LABELFRAME_BORDER_WIDTH, offsetof(Frame, borderWidthPtr), offsetof(Frame, borderWidth), + DEF_LABELFRAME_BORDER_WIDTH, offsetof(Frame, borderWidthObj), offsetof(Frame, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-class", "class", "Class", DEF_LABELFRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0}, @@ -999,27 +1000,27 @@ ConfigureFrame( if (framePtr->highlightWidth < 0) { framePtr->highlightWidth = 0; - if (framePtr->highlightWidthPtr) { - Tcl_DecrRefCount(framePtr->highlightWidthPtr); + if (framePtr->highlightWidthObj) { + Tcl_DecrRefCount(framePtr->highlightWidthObj); } - framePtr->highlightWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->highlightWidthPtr); + framePtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->highlightWidthObj); } if (framePtr->padX < 0) { framePtr->padX = 0; - if (framePtr->padXPtr) { - Tcl_DecrRefCount(framePtr->padXPtr); + if (framePtr->padXObj) { + Tcl_DecrRefCount(framePtr->padXObj); } - framePtr->padXPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->padXPtr); + framePtr->padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->padXObj); } if (framePtr->padY < 0) { framePtr->padY = 0; - if (framePtr->padYPtr) { - Tcl_DecrRefCount(framePtr->padYPtr); + if (framePtr->padYObj) { + Tcl_DecrRefCount(framePtr->padYObj); } - framePtr->padYPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(framePtr->padYPtr); + framePtr->padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(framePtr->padYObj); } /* diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 984958d..34828b9 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -61,9 +61,9 @@ typedef struct { Tk_3DBorder normalBorder; /* Used for drawing border around whole * window, plus used for background. */ - int borderWidth; /* Width of 3-D border around window. */ + Tcl_Obj *borderWidthObj; /* Width of 3-D border around window. */ int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ - int highlightWidth; /* Width in pixels of highlight to draw around + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ XColor *highlightBgColorPtr; @@ -81,7 +81,7 @@ typedef struct { GC textGC; /* For drawing normal text. */ Tk_3DBorder selBorder; /* Borders and backgrounds for selected * elements. */ - int selBorderWidth; /* Width of border around selection. */ + Tcl_Obj *selBorderWidthObj; /* Width of border around selection. */ XColor *selFgColorPtr; /* Foreground color for selected elements. */ GC selTextGC; /* For drawing selected text. */ int width; /* Desired width of window, in characters. */ @@ -167,9 +167,9 @@ typedef struct { int flags; /* Various flag bits: see below for * definitions. */ Tk_Justify justify; /* Justification. */ - Tcl_Obj *borderWidthPtr; - Tcl_Obj *highlightWidthPtr; - Tcl_Obj *selBorderWidthPtr; +#ifdef BUILD_tk + int borderWidth, selBorderWidth, highlightWidth; +#endif } Listbox; /* @@ -248,7 +248,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_LISTBOX_BORDER_WIDTH, offsetof(Listbox, borderWidthPtr), offsetof(Listbox, borderWidth), + DEF_LISTBOX_BORDER_WIDTH, offsetof(Listbox, borderWidthObj), offsetof(Listbox, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_LISTBOX_CURSOR, TCL_INDEX_NONE, offsetof(Listbox, cursor), @@ -274,7 +274,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_LISTBOX_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Listbox, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, offsetof(Listbox, highlightWidthPtr), + "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, offsetof(Listbox, highlightWidthObj), offsetof(Listbox, highlightWidth), 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_LISTBOX_JUSTIFY, TCL_INDEX_NONE, offsetof(Listbox, justify), TK_OPTION_ENUM_VAR, 0, 0}, @@ -284,7 +284,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_LISTBOX_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selBorder), 0, DEF_LISTBOX_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", - "BorderWidth", DEF_LISTBOX_SELECT_BD, offsetof(Listbox, selBorderWidthPtr), + "BorderWidth", DEF_LISTBOX_SELECT_BD, offsetof(Listbox, selBorderWidthObj), offsetof(Listbox, selBorderWidth), 0, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_LISTBOX_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selFgColorPtr), @@ -1603,11 +1603,11 @@ ConfigureListbox( if (listPtr->highlightWidth < 0) { listPtr->highlightWidth = 0; - if (listPtr->highlightWidthPtr) { - Tcl_DecrRefCount(listPtr->highlightWidthPtr); + if (listPtr->highlightWidthObj) { + Tcl_DecrRefCount(listPtr->highlightWidthObj); } - listPtr->highlightWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(listPtr->highlightWidthPtr); + listPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(listPtr->highlightWidthObj); } listPtr->inset = listPtr->highlightWidth + listPtr->borderWidth; diff --git a/generic/tkMenu.c b/generic/tkMenu.c index be60f2a..6e80002 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -260,7 +260,7 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = { NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MENU_BORDER_WIDTH, - offsetof(TkMenu, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0}, + offsetof(TkMenu, borderWidthObj), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENU_CURSOR, offsetof(TkMenu, cursorPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, @@ -3039,7 +3039,7 @@ GetIndexFromCoords( TkRecomputeMenu(menuPtr); p = string + 1; Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, - menuPtr->borderWidthPtr, &borderwidth); + menuPtr->borderWidthObj, &borderwidth); rest = strchr(p, ','); if (rest) { Tcl_DString ds; diff --git a/generic/tkMenu.h b/generic/tkMenu.h index fdb9ae9..5f77128 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -279,7 +279,7 @@ typedef struct TkMenu { Tcl_Obj *borderPtr; /* Structure used to draw 3-D border and * background for menu. */ - Tcl_Obj *borderWidthPtr; /* Width of border around whole menu. */ + Tcl_Obj *borderWidthObj; /* Width of border around whole menu. */ Tcl_Obj *activeBorderPtr; /* Used to draw background and border for * active element (if any). */ Tcl_Obj *activeBorderWidthPtr; diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 275b9f5..24d3383 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -633,7 +633,7 @@ DisplayMenu( return; } - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr); @@ -989,7 +989,7 @@ AdjustMenuCoords( } else { int borderWidth, activeBorderWidth; - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 0214663..b08ab4c 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -62,7 +62,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_MENUBUTTON_BORDER_WIDTH, offsetof(TkMenuButton, borderWidthPtr), + DEF_MENUBUTTON_BORDER_WIDTH, offsetof(TkMenuButton, borderWidthObj), offsetof(TkMenuButton, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor), @@ -91,7 +91,7 @@ static const Tk_OptionSpec optionSpecs[] = { offsetof(TkMenuButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH, - offsetof(TkMenuButton, highlightWidthPtr), offsetof(TkMenuButton, highlightWidth), 0, 0, 0}, + offsetof(TkMenuButton, highlightWidthObj), offsetof(TkMenuButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_MENUBUTTON_IMAGE, TCL_INDEX_NONE, offsetof(TkMenuButton, imageString), TK_OPTION_NULL_OK, 0, 0}, @@ -104,10 +104,10 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_MENU, TCL_INDEX_NONE, offsetof(TkMenuButton, menuName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - DEF_MENUBUTTON_PADX, offsetof(TkMenuButton, padXPtr), offsetof(TkMenuButton, padX), + DEF_MENUBUTTON_PADX, offsetof(TkMenuButton, padXObj), offsetof(TkMenuButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - DEF_MENUBUTTON_PADY, offsetof(TkMenuButton, padYPtr), offsetof(TkMenuButton, padY), + DEF_MENUBUTTON_PADY, offsetof(TkMenuButton, padYObj), offsetof(TkMenuButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief), @@ -132,7 +132,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString), 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", - DEF_MENUBUTTON_WRAP_LENGTH, offsetof(TkMenuButton, wrapLengthPtr), offsetof(TkMenuButton, wrapLength), + DEF_MENUBUTTON_WRAP_LENGTH, offsetof(TkMenuButton, wrapLengthObj), offsetof(TkMenuButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; @@ -282,11 +282,11 @@ Tk_MenubuttonObjCmd( mbPtr->cursor = NULL; mbPtr->takeFocus = NULL; mbPtr->flags = 0; - mbPtr->borderWidthPtr = NULL; - mbPtr->highlightWidthPtr = NULL; - mbPtr->padXPtr = NULL; - mbPtr->padYPtr = NULL; - mbPtr->wrapLengthPtr = NULL; + mbPtr->borderWidthObj = NULL; + mbPtr->highlightWidthObj = NULL; + mbPtr->padXObj = NULL; + mbPtr->padYObj = NULL; + mbPtr->wrapLengthObj = NULL; Tk_CreateEventHandler(mbPtr->tkwin, ExposureMask|StructureNotifyMask|FocusChangeMask, @@ -538,28 +538,28 @@ ConfigureMenuButton( if (mbPtr->highlightWidth < 0) { mbPtr->highlightWidth = 0; - if (mbPtr->highlightWidthPtr) { - Tcl_DecrRefCount(mbPtr->highlightWidthPtr); + if (mbPtr->highlightWidthObj) { + Tcl_DecrRefCount(mbPtr->highlightWidthObj); } - mbPtr->highlightWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->highlightWidthPtr); + mbPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(mbPtr->highlightWidthObj); } if (mbPtr->padX < 0) { mbPtr->padX = 0; - if (mbPtr->padXPtr) { - Tcl_DecrRefCount(mbPtr->padXPtr); + if (mbPtr->padXObj) { + Tcl_DecrRefCount(mbPtr->padXObj); } - mbPtr->padXPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->padXPtr); + mbPtr->padXObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(mbPtr->padXObj); } if (mbPtr->padY < 0) { mbPtr->padY = 0; - if (mbPtr->padYPtr) { - Tcl_DecrRefCount(mbPtr->padYPtr); + if (mbPtr->padYObj) { + Tcl_DecrRefCount(mbPtr->padYObj); } - mbPtr->padYPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(mbPtr->padYPtr); + mbPtr->padYObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(mbPtr->padYObj); } /* diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index 0414bb7..1c8d175 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -89,10 +89,10 @@ typedef struct { Tk_3DBorder activeBorder; /* Structure used to draw 3-D border and * background when window is active. NULL * means no such border exists. */ - int borderWidth; /* Width of border. */ + Tcl_Obj *borderWidthObj; /* Width of border. */ int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */ - int highlightWidth; /* Width in pixels of highlight to draw around - * widget when it has the focus. <= 0 means + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around + * widget when it has the focus. 0 means * don't draw a highlight. */ XColor *highlightBgColorPtr;/* Color for drawing traversal highlight area * when highlight is off. */ @@ -129,10 +129,10 @@ typedef struct { * size of the text string or bitmap is * ignored in computing desired window * size. */ - int wrapLength; /* Line length (in pixels) at which to wrap - * onto next line. <= 0 means don't wrap + Tcl_Obj *wrapLengthObj; /* Line length (in pixels) at which to wrap + * onto next line. 0 means don't wrap * except at newlines. */ - int padX, padY; /* Extra space around text or bitmap (pixels + Tcl_Obj *padXObj, *padYObj; /* Extra space around text or bitmap (pixels * on each side). */ Tk_Anchor anchor; /* Where text/bitmap should be displayed * inside window region. */ @@ -176,11 +176,13 @@ typedef struct { * scripts. Malloc'ed, but may be NULL. */ int flags; /* Various flags; see below for * definitions. */ - Tcl_Obj *borderWidthPtr; - Tcl_Obj *highlightWidthPtr; - Tcl_Obj *padXPtr; - Tcl_Obj *padYPtr; - Tcl_Obj *wrapLengthPtr; +#ifdef BUILD_tk + int borderWidth; + int highlightWidth; + int padX; + int padY; + int wrapLength; +#endif } TkMenuButton; /* diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index b700331..f5208f6 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -80,11 +80,11 @@ typedef struct { typedef struct Pane { Tk_Window tkwin; /* Window being managed. */ - int minSize; /* Minimum size of this pane, on the relevant + Tcl_Obj *minSizeObj; /* Minimum size of this pane, on the relevant * axis, in pixels. */ - int padx; /* Additional padding requested for pane, in + Tcl_Obj *padXObj; /* Additional padding requested for pane, in * the x dimension. */ - int pady; /* Additional padding requested for pane, in + Tcl_Obj *padYObj; /* Additional padding requested for pane, in * the y dimension. */ Tcl_Obj *widthObj, *heightObj; /* Tcl_Obj rep's of pane width/height, to @@ -102,13 +102,14 @@ typedef struct Pane { int handlex, handley; /* Coordinates of the sash handle. */ enum stretch stretch; /* Controls how pane grows/shrinks */ int hide; /* Controls visibility of pane */ - Tcl_Obj *padXPtr; - Tcl_Obj *padYPtr; - Tcl_Obj *minSizePtr; struct PanedWindow *containerPtr; /* Paned window managing the window. */ Tk_Window after; /* Placeholder for parsing options. */ Tk_Window before; /* Placeholder for parsing options. */ +#ifdef BUILD_tk + int padX, padY; + int minSize; +#endif } Pane; /* @@ -158,7 +159,7 @@ typedef struct PanedWindow { int numPanes; /* Number of panes. */ int sizeofPanes; /* Number of elements in the panes array. */ int flags; /* Flags for widget; see below. */ - Tcl_Obj *borderWidthPtr; + Tcl_Obj *borderWidthObj; Tcl_Obj *handlePadPtr; } PanedWindow; @@ -284,7 +285,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_PANEDWINDOW_BORDERWIDTH, offsetof(PanedWindow, borderWidthPtr), offsetof(PanedWindow, borderWidth), + DEF_PANEDWINDOW_BORDERWIDTH, offsetof(PanedWindow, borderWidthObj), offsetof(PanedWindow, borderWidth), 0, 0, GEOMETRY}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor), @@ -349,11 +350,11 @@ static const Tk_OptionSpec paneOptionSpecs[] = { {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY}, {TK_OPTION_PIXELS, "-minsize", NULL, NULL, - DEF_PANEDWINDOW_PANE_MINSIZE, offsetof(Pane, minSizePtr), offsetof(Pane, minSize), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_MINSIZE, offsetof(Pane, minSizeObj), offsetof(Pane, minSize), 0, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADX, offsetof(Pane, padXPtr), offsetof(Pane, padx), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADX, offsetof(Pane, padXObj), offsetof(Pane, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - DEF_PANEDWINDOW_PANE_PADY, offsetof(Pane, padXPtr), offsetof(Pane, pady), 0, 0, 0}, + DEF_PANEDWINDOW_PANE_PADY, offsetof(Pane, padYObj), offsetof(Pane, padY), 0, 0, 0}, {TK_OPTION_CUSTOM, "-sticky", NULL, NULL, DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky), 0, &stickyOption, 0}, @@ -1799,14 +1800,14 @@ ArrangePanes( } else { paneSize = panePtr->paneWidth; } - stretchReserve -= paneSize + (2 * panePtr->padx); + stretchReserve -= paneSize + (2 * panePtr->padX); } else { if (panePtr->height > 0) { paneSize = panePtr->height; } else { paneSize = panePtr->paneHeight; } - stretchReserve -= paneSize + (2 * panePtr->pady); + stretchReserve -= paneSize + (2 * panePtr->padY); } if (IsStretchable(panePtr->stretch,i,first,last) && Tk_IsMapped(pwPtr->tkwin)) { @@ -1904,9 +1905,9 @@ ArrangePanes( } if (horizontal) { paneWidth = paneSize; - paneHeight = pwHeight - (2 * panePtr->pady); + paneHeight = pwHeight - (2 * panePtr->padY); } else { - paneWidth = pwWidth - (2 * panePtr->padx); + paneWidth = pwWidth - (2 * panePtr->padX); paneHeight = paneSize; } @@ -1950,7 +1951,7 @@ ArrangePanes( */ if (horizontal) { - x += paneWidth + (2 * panePtr->padx); + x += paneWidth + (2 * panePtr->padX); if (x < internalBW) { x = internalBW; } @@ -1960,7 +1961,7 @@ ArrangePanes( panePtr->handley = y + pwPtr->handlePad; x += sashWidth; } else { - y += paneHeight + (2 * panePtr->pady); + y += paneHeight + (2 * panePtr->padY); if (y < internalBW) { y = internalBW; } @@ -1980,8 +1981,8 @@ ArrangePanes( AdjustForSticky(panePtr->sticky, paneWidth, paneHeight, &paneX, &paneY, &newPaneWidth, &newPaneHeight); - paneX += panePtr->padx; - paneY += panePtr->pady; + paneX += panePtr->padX; + paneY += panePtr->padY; /* * Now put the window in the proper spot. @@ -2263,14 +2264,14 @@ ComputeGeometry( */ if (horizontal) { - x += panePtr->paneWidth + (2 * panePtr->padx); + x += panePtr->paneWidth + (2 * panePtr->padX); panePtr->sashx = x + sashOffset; panePtr->sashy = y; panePtr->handlex = x + handleOffset; panePtr->handley = y + pwPtr->handlePad; x += sashWidth; } else { - y += panePtr->paneHeight + (2 * panePtr->pady); + y += panePtr->paneHeight + (2 * panePtr->padY); panePtr->sashx = x; panePtr->sashy = y + sashOffset; panePtr->handlex = x + pwPtr->handlePad; @@ -2295,7 +2296,7 @@ ComputeGeometry( doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; dim = Tk_ReqHeight(panePtr->tkwin) + doubleBw; } - dim += 2 * panePtr->pady; + dim += 2 * panePtr->padY; if (dim > reqHeight) { reqHeight = dim; } @@ -2311,7 +2312,7 @@ ComputeGeometry( doubleBw = 2 * Tk_Changes(panePtr->tkwin)->border_width; dim = Tk_ReqWidth(panePtr->tkwin) + doubleBw; } - dim += 2 * panePtr->padx; + dim += 2 * panePtr->padX; if (dim > reqWidth) { reqWidth = dim; } @@ -2640,10 +2641,10 @@ MoveSash( } if (horizontal) { panePtr->paneWidth = panePtr->width = panePtr->sashx - - sashOffset - panePtr->x - (2 * panePtr->padx); + - sashOffset - panePtr->x - (2 * panePtr->padX); } else { panePtr->paneHeight = panePtr->height = panePtr->sashy - - sashOffset - panePtr->y - (2 * panePtr->pady); + - sashOffset - panePtr->y - (2 * panePtr->padY); } } diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 3ba32b5..2c58e3f 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -48,7 +48,7 @@ typedef struct { * Information used when displaying widget: */ - Tcl_Obj *borderWidthPtr; /* Width of 3-D border around whole widget. */ + Tcl_Obj *borderWidthObj; /* Width of 3-D border around whole widget. */ Tcl_Obj *bgBorderPtr; Tcl_Obj *fgBorderPtr; Tcl_Obj *reliefPtr; @@ -74,7 +74,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - "2", offsetof(Square, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0}, + "2", offsetof(Square, borderWidthObj), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-dbl", "doubleBuffer", "DoubleBuffer", "1", TCL_INDEX_NONE, offsetof(Square, doubleBuffer), TK_OPTION_VAR(bool) , NULL, 0}, {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, @@ -346,7 +346,7 @@ SquareConfigure( */ Tk_GeometryRequest(squarePtr->tkwin, 200, 150); - Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthObj, &borderWidth); Tk_SetInternalBorder(squarePtr->tkwin, borderWidth); if (!squarePtr->updatePending) { @@ -499,7 +499,7 @@ SquareDisplay( * Redraw the widget's background and border. */ - Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthObj, &borderWidth); bgBorder = Tk_Get3DBorderFromObj(squarePtr->tkwin, squarePtr->bgBorderPtr); @@ -554,7 +554,7 @@ KeepInWindow( int i, bd, relief; int borderWidth, size; - Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, squarePtr->tkwin, squarePtr->xPtr, &squarePtr->x); diff --git a/generic/tkText.c b/generic/tkText.c index cdfd2c0..7c01740 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -120,7 +120,7 @@ static const Tk_OptionSpec optionSpecs[] = { "BlockCursor", DEF_TEXT_BLOCK_CURSOR, TCL_INDEX_NONE, offsetof(TkText, insertCursorType), 0, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - DEF_TEXT_BORDER_WIDTH, offsetof(TkText, borderWidthPtr), offsetof(TkText, borderWidth), + DEF_TEXT_BORDER_WIDTH, offsetof(TkText, borderWidthObj), offsetof(TkText, borderWidth), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_TEXT_CURSOR, TCL_INDEX_NONE, offsetof(TkText, cursor), @@ -140,7 +140,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_FG, TCL_INDEX_NONE, offsetof(TkText, fgColor), 0, 0, 0}, {TK_OPTION_PIXELS, "-height", "height", "Height", - DEF_TEXT_HEIGHT, offsetof(TkText, heightPtr), offsetof(TkText, height), 0, 0, 0}, + DEF_TEXT_HEIGHT, offsetof(TkText, heightObj), offsetof(TkText, height), 0, 0, 0}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_TEXT_HIGHLIGHT_BG, TCL_INDEX_NONE, offsetof(TkText, highlightBgColorPtr), @@ -149,7 +149,7 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkText, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", - "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, offsetof(TkText, highlightWidthPtr), + "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, offsetof(TkText, highlightWidthObj), offsetof(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground", "Foreground", @@ -161,7 +161,7 @@ static const Tk_OptionSpec optionSpecs[] = { TCL_INDEX_NONE, offsetof(TkText, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", - "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, offsetof(TkText, insertBorderWidthPtr), + "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, offsetof(TkText, insertBorderWidthObj), offsetof(TkText, insertBorderWidth), 0, DEF_TEXT_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", @@ -175,16 +175,16 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed), TK_OPTION_ENUM_VAR, insertUnfocussedStrings, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", - DEF_TEXT_INSERT_WIDTH, offsetof(TkText, insertWidthPtr), offsetof(TkText, insertWidth), + DEF_TEXT_INSERT_WIDTH, offsetof(TkText, insertWidthObj), offsetof(TkText, insertWidth), 0, 0, 0}, {TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo", DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo), TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", - DEF_TEXT_PADX, offsetof(TkText, padXPtr), offsetof(TkText, padX), 0, 0, + DEF_TEXT_PADX, offsetof(TkText, padXObj), offsetof(TkText, padX), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", - DEF_TEXT_PADY, offsetof(TkText, padYPtr), offsetof(TkText, padY), 0, 0, 0}, + DEF_TEXT_PADY, offsetof(TkText, padYObj), offsetof(TkText, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_TEXT_RELIEF, TCL_INDEX_NONE, offsetof(TkText, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", @@ -192,8 +192,7 @@ static const Tk_OptionSpec optionSpecs[] = { 0, DEF_TEXT_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_TEXT_SELECT_BD_COLOR, - offsetof(TkText, selBorderWidthPtr), - offsetof(TkText, selBorderWidth), + offsetof(TkText, selBorderWidthObj), offsetof(TkText, selBorderWidth), TK_OPTION_NULL_OK, DEF_TEXT_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", DEF_TEXT_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(TkText, selFgColorPtr), @@ -201,13 +200,13 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0}, {TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing", - DEF_TEXT_SPACING1, offsetof(TkText, spacing1Ptr), offsetof(TkText, spacing1), + DEF_TEXT_SPACING1, offsetof(TkText, spacing1Obj), offsetof(TkText, spacing1), 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing", - DEF_TEXT_SPACING2, offsetof(TkText, spacing2Ptr), offsetof(TkText, spacing2), + DEF_TEXT_SPACING2, offsetof(TkText, spacing2Obj), offsetof(TkText, spacing2), 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing", - DEF_TEXT_SPACING3, offsetof(TkText, spacing3Ptr), offsetof(TkText, spacing3), + DEF_TEXT_SPACING3, offsetof(TkText, spacing3Obj), offsetof(TkText, spacing3), 0, 0, TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, @@ -604,7 +603,7 @@ CreateWidget( textPtr->selBorder = NULL; textPtr->inactiveSelBorder = NULL; textPtr->selBorderWidth = 0; - textPtr->selBorderWidthPtr = NULL; + textPtr->selBorderWidthObj = NULL; textPtr->selFgColorPtr = NULL; /* @@ -2206,27 +2205,27 @@ ConfigureText( if (textPtr->spacing1 < 0) { textPtr->spacing1 = 0; - if (textPtr->spacing1Ptr) { - Tcl_DecrRefCount(textPtr->spacing1Ptr); + if (textPtr->spacing1Obj) { + Tcl_DecrRefCount(textPtr->spacing1Obj); } - textPtr->spacing1Ptr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->spacing1Ptr); + textPtr->spacing1Obj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->spacing1Obj); } if (textPtr->spacing2 < 0) { textPtr->spacing2 = 0; - if (textPtr->spacing2Ptr) { - Tcl_DecrRefCount(textPtr->spacing2Ptr); + if (textPtr->spacing2Obj) { + Tcl_DecrRefCount(textPtr->spacing2Obj); } - textPtr->spacing2Ptr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->spacing2Ptr); + textPtr->spacing2Obj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->spacing2Obj); } if (textPtr->spacing3 < 0) { textPtr->spacing3 = 0; - if (textPtr->spacing3Ptr) { - Tcl_DecrRefCount(textPtr->spacing3Ptr); + if (textPtr->spacing3Obj) { + Tcl_DecrRefCount(textPtr->spacing3Obj); } - textPtr->spacing3Ptr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->spacing3Ptr); + textPtr->spacing3Obj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->spacing3Obj); } /* @@ -2259,8 +2258,8 @@ ConfigureText( } else { textPtr->selTagPtr->selBorder = textPtr->selBorder; } - if (textPtr->selTagPtr->borderWidthPtr != textPtr->selBorderWidthPtr) { - textPtr->selTagPtr->borderWidthPtr = textPtr->selBorderWidthPtr; + if (textPtr->selTagPtr->borderWidthObj != textPtr->selBorderWidthObj) { + textPtr->selTagPtr->borderWidthObj = textPtr->selBorderWidthObj; textPtr->selTagPtr->borderWidth = textPtr->selBorderWidth; } if (textPtr->selTagPtr->selFgColor == NULL) { @@ -2283,7 +2282,9 @@ ConfigureText( || (textPtr->selTagPtr->tabStringPtr != NULL) || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR) - || (textPtr->selTagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { + || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_CHAR) + || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_NONE) + || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_WORD)) { textPtr->selTagPtr->affectsDisplay = 1; textPtr->selTagPtr->affectsDisplayGeometry = 1; } @@ -2489,7 +2490,7 @@ TextEventProc( } } else if (eventPtr->type == DestroyNotify) { /* - * NOTE: we must zero out selBorder, selBorderWidthPtr and + * NOTE: we must zero out selBorder, selBorderWidthObj and * selFgColorPtr: they are duplicates of information in the "sel" tag, * which will be freed up when we delete all tags. Hence we don't want * the automatic config options freeing process to delete them as @@ -2497,7 +2498,7 @@ TextEventProc( */ textPtr->selBorder = NULL; - textPtr->selBorderWidthPtr = NULL; + textPtr->selBorderWidthObj = NULL; textPtr->selBorderWidth = 0; textPtr->selFgColorPtr = NULL; if (textPtr->setGrid) { diff --git a/generic/tkText.h b/generic/tkText.h index b8cbbff..53412be 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -116,18 +116,27 @@ typedef struct TkTextEmbWindow { * window. */ char *create; /* Script to create window on-demand. NULL * means no such script. Malloc-ed. */ +#if TCL_MAJOR_VERSION > 8 TkAlignMode align; /* How to align window in vertical space. See * definitions in tkTextWind.c. */ - int padX, padY; /* Padding to leave around each side of - * window, in pixels. */ + Tcl_Obj *padXObj, *padYObj; /* Padding to leave around each side of window. */ +#else + int align; + int padX, padY; +#endif int stretch; /* Should window stretch to fill vertical * space of line (except for pady)? 0 or 1. */ - Tcl_Obj *padXPtr, *padYPtr; /* Padding to leave around each side of window. */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ TkTextEmbWindowClient *clients; /* Linked list of peer-widget specific * information for this embedded window. */ +#if TCL_MAJOR_VERSION < 9 + Tcl_Obj *padXObj, *padYObj; +#elif defined(BUILD_tk) + int padX, padY; /* Padding to leave around each side of + * window, in pixels. */ +#endif } TkTextEmbWindow; /* @@ -149,15 +158,25 @@ typedef struct TkTextEmbImage { * the image. */ Tk_Image image; /* Image for this segment. NULL means that the * image hasn't been created yet. */ +#if TCL_MAJOR_VERSION > 8 TkAlignMode align; /* How to align image in vertical space. See * definitions in tkTextImage.c. */ - int padX, padY; /* Padding to leave around each side of image, + Tcl_Obj *padXObj, *padYObj; /* Padding to leave around each side of image, * in pixels. */ +#else + int align; + int padX, padY; +#endif int chunkCount; /* Number of display chunks that refer to this * image. */ - Tcl_Obj *padXPtr, *padYPtr; Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ +#if TCL_MAJOR_VERSION < 9 + Tcl_Obj *padXObj, *padYObj; +#elif defined(BUILD_tk) + int padX, padY; /* Padding to leave around each side of + * window, in pixels. */ +#endif } TkTextEmbImage; /* @@ -345,8 +364,7 @@ typedef struct TkTextTag { Tk_3DBorder border; /* Used for drawing background. NULL means no * value specified here. */ - int borderWidth; /* Width of 3-D border for background. */ - Tcl_Obj *borderWidthPtr; /* Width of 3-D border for background. */ + Tcl_Obj *borderWidthObj; /* Width of 3-D border for background. */ #if TK_MAJOR_VERSION < 9 char *reliefString; /* -relief option string (malloc-ed). NULL * means option not specified. */ @@ -483,6 +501,9 @@ typedef struct TkTextTag { * size with which information is displayed on * the screen (so need to recalculate line * dimensions if tag changes). */ +#ifdef BUILD_tk + int borderWidth; /* Width of 3-D border for background. */ +#endif } TkTextTag; #define TK_TAG_AFFECTS_DISPLAY 0x1 @@ -711,12 +732,12 @@ typedef struct TkText { Tk_3DBorder border; /* Structure used to draw 3-D border and * default background. */ - int borderWidth; /* Width of 3-D border to draw around entire + Tcl_Obj *borderWidthObj; /* Width of 3-D border to draw around entire * widget. */ - int padX, padY; /* Padding between text and window border. */ + Tcl_Obj *padXObj, *padYObj; /* Padding between text and window border. */ int relief; /* 3-d effect for border around entire widget: * TK_RELIEF_RAISED etc. */ - int highlightWidth; /* Width in pixels of highlight to draw around + Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw around * widget when it has the focus. <= 0 means * don't draw a highlight. */ XColor *highlightBgColorPtr; @@ -730,11 +751,11 @@ typedef struct TkText { * font. */ int charHeight; /* Height of average character in default * font, including line spacing. */ - int spacing1; /* Default extra spacing above first display + Tcl_Obj *spacing1Obj; /* Default extra spacing above first display * line for each text line. */ - int spacing2; /* Default extra spacing between display lines + Tcl_Obj *spacing2Obj; /* Default extra spacing between display lines * for the same text line. */ - int spacing3; /* Default extra spacing below last display + Tcl_Obj *spacing3Obj; /* Default extra spacing below last display * line for each text line. */ Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */ TkTextTabArray *tabArrayPtr; @@ -751,7 +772,7 @@ typedef struct TkText { * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or * TEXT_WRAPMODE_WORD, or TEXT_WRAPMODE_NULL to * use wrapmode for whole widget. */ - int width, height; /* Desired dimensions for window, measured in + int width; Tcl_Obj *heightObj; /* Desired dimensions for window, measured in * characters. */ int setGrid; /* Non-zero means pass gridding information to * window manager. */ @@ -775,8 +796,7 @@ typedef struct TkText { /* Border and background for selected * characters when they don't have the * focus. */ - int selBorderWidth; /* Width of border around selection. */ - Tcl_Obj *selBorderWidthPtr; /* Width of border around selection. */ + Tcl_Obj *selBorderWidthObj; /* Width of border around selection. */ XColor *selFgColorPtr; /* Foreground color for selected text. This is * a copy of information in *selTagPtr, so it * shouldn't be explicitly freed. */ @@ -795,8 +815,8 @@ typedef struct TkText { /* Points to segment for "insert" mark. */ Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion * cursor. */ - int insertWidth; /* Total width of insert cursor. */ - int insertBorderWidth; /* Width of 3-D border around insert cursor */ + Tcl_Obj *insertWidthObj; /* Total width of insert cursor. */ + Tcl_Obj *insertBorderWidthObj; /* Width of 3-D border around insert cursor */ TkTextInsertUnfocussed insertUnfocussed; /* How to display the insert cursor when the * text widget does not have the focus. */ @@ -863,16 +883,16 @@ typedef struct TkText { * inserted automatically. */ Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to * date */ - Tcl_Obj *borderWidthPtr; - Tcl_Obj *heightPtr; - Tcl_Obj *highlightWidthPtr; - Tcl_Obj *insertBorderWidthPtr; - Tcl_Obj *insertWidthPtr; - Tcl_Obj *padXPtr; - Tcl_Obj *padYPtr; - Tcl_Obj *spacing1Ptr; - Tcl_Obj *spacing2Ptr; - Tcl_Obj *spacing3Ptr; +#ifdef BUILD_tk + int padX, padY; + int selBorderWidth; + int highlightWidth; + int borderWidth; + int spacing1, spacing2, spacing3; + int height; + int insertBorderWidth; + int insertWidth; +#endif } TkText; /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 120e534..6956fbd 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -867,8 +867,8 @@ GetStyle( styleValues.border = border; borderPrio = tagPtr->priority; } - if ((tagPtr->borderWidthPtr != NULL) - && (Tcl_GetString(tagPtr->borderWidthPtr)[0] != '\0') + if ((tagPtr->borderWidthObj != NULL) + && (Tcl_GetString(tagPtr->borderWidthObj)[0] != '\0') && (tagPtr->priority > borderWidthPrio)) { styleValues.borderWidth = tagPtr->borderWidth; borderWidthPrio = tagPtr->priority; @@ -985,8 +985,8 @@ GetStyle( styleValues.elide = tagPtr->elide > 0; elidePrio = tagPtr->priority; } - if ((tagPtr->wrapMode != TEXT_WRAPMODE_NULL) - && (tagPtr->priority > wrapPrio)) { + if (((tagPtr->wrapMode == TEXT_WRAPMODE_CHAR) || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE) + || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) && (tagPtr->priority > wrapPrio)) { styleValues.wrapMode = tagPtr->wrapMode; wrapPrio = tagPtr->priority; } @@ -5256,12 +5256,12 @@ TkTextRelayoutWindow( * it. */ - if (textPtr->highlightWidthPtr) { + if (textPtr->highlightWidthObj) { if (textPtr->highlightWidth < 0) { textPtr->highlightWidth = 0; - Tcl_DecrRefCount(textPtr->highlightWidthPtr); - textPtr->highlightWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(textPtr->highlightWidthPtr); + Tcl_DecrRefCount(textPtr->highlightWidthObj); + textPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(textPtr->highlightWidthObj); } } dInfoPtr->x = textPtr->highlightWidth + textPtr->borderWidth diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index 38d6c76..5e24e09 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -84,11 +84,11 @@ static const char *const alignStrings[] = { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING_TABLE, "-align", NULL, NULL, "center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align), - TK_OPTION_ENUM_VAR, alignStrings, 0}, + (TCL_MAJOR_VERSION > 8) ? TK_OPTION_ENUM_VAR : 0, alignStrings, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - "0", offsetof(TkTextEmbImage, padXPtr), offsetof(TkTextEmbImage, padX), 0, 0, 0}, + "0", offsetof(TkTextEmbImage, padXObj), offsetof(TkTextEmbImage, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - "0", offsetof(TkTextEmbImage, padYPtr), offsetof(TkTextEmbImage, padY), 0, 0, 0}, + "0", offsetof(TkTextEmbImage, padYObj), offsetof(TkTextEmbImage, padY), 0, 0, 0}, {TK_OPTION_STRING, "-image", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageString), TK_OPTION_NULL_OK, 0, 0}, @@ -253,7 +253,7 @@ TkTextImageCmd( eiPtr->body.ei.image = NULL; eiPtr->body.ei.align = TK_ALIGN_CENTER; eiPtr->body.ei.padX = eiPtr->body.ei.padY = 0; - eiPtr->body.ei.padXPtr = eiPtr->body.ei.padYPtr = NULL; + eiPtr->body.ei.padXObj = eiPtr->body.ei.padYObj = NULL; eiPtr->body.ei.chunkCount = 0; eiPtr->body.ei.optionTable = Tk_CreateOptionTable(interp, optionSpecs); diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 6e4f96f..c1911cc 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -22,7 +22,7 @@ static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_BITMAP, "-bgstipple", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", NULL, NULL, - NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth), + NULL, offsetof(TkTextTag, borderWidthObj), offsetof(TkTextTag, borderWidth), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-elide", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elide), @@ -363,12 +363,12 @@ TkTextTagCmd( * from "unspecified"). */ - if (tagPtr->borderWidthPtr) { + if (tagPtr->borderWidthObj) { if (tagPtr->borderWidth < 0) { tagPtr->borderWidth = 0; - Tcl_DecrRefCount(tagPtr->borderWidthPtr); - tagPtr->borderWidthPtr = Tcl_NewIntObj(0); - Tcl_IncrRefCount(tagPtr->borderWidthPtr); + Tcl_DecrRefCount(tagPtr->borderWidthObj); + tagPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(tagPtr->borderWidthObj); } } if (tagPtr->spacing1 != INT_MIN) { @@ -422,7 +422,7 @@ TkTextTagCmd( textPtr->selBorder = tagPtr->selBorder; } textPtr->selBorderWidth = tagPtr->borderWidth; - textPtr->selBorderWidthPtr = tagPtr->borderWidthPtr; + textPtr->selBorderWidthObj = tagPtr->borderWidthObj; if (tagPtr->selFgColor == NULL) { textPtr->selFgColorPtr = tagPtr->fgColor; } else { @@ -445,7 +445,9 @@ TkTextTagCmd( || (tagPtr->tabStringPtr != NULL) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR) - || (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { + || (tagPtr->wrapMode == TEXT_WRAPMODE_CHAR) + || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE) + || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) { tagPtr->affectsDisplay = 1; tagPtr->affectsDisplayGeometry = 1; } @@ -945,7 +947,7 @@ TkTextCreateTag( tagPtr->priority = textPtr->sharedTextPtr->numTags; tagPtr->border = NULL; tagPtr->borderWidth = 0; - tagPtr->borderWidthPtr = NULL; + tagPtr->borderWidthObj = NULL; tagPtr->relief = TK_RELIEF_NULL; tagPtr->bgStipple = None; tagPtr->fgColor = NULL; diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index 21da441..1ee3f46 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -96,13 +96,13 @@ static const char *const alignStrings[] = { static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING_TABLE, "-align", NULL, NULL, "center", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, align), - TK_OPTION_ENUM_VAR, alignStrings, 0}, + (TCL_MAJOR_VERSION > 8) ? TK_OPTION_ENUM_VAR : 0, alignStrings, 0}, {TK_OPTION_STRING, "-create", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", NULL, NULL, - "0", offsetof(TkTextEmbWindow, padXPtr), offsetof(TkTextEmbWindow, padX), 0, 0, 0}, + "0", offsetof(TkTextEmbWindow, padXObj), offsetof(TkTextEmbWindow, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, - "0", offsetof(TkTextEmbWindow, padYPtr), offsetof(TkTextEmbWindow, padY), 0, 0, 0}, + "0", offsetof(TkTextEmbWindow, padYObj), offsetof(TkTextEmbWindow, padY), 0, 0, 0}, {TK_OPTION_BOOLEAN, "-stretch", NULL, NULL, "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, stretch), 0, 0, 0}, {TK_OPTION_WINDOW, "-window", NULL, NULL, @@ -293,7 +293,7 @@ TkTextWindowCmd( ewPtr->body.ew.create = NULL; ewPtr->body.ew.align = TK_ALIGN_CENTER; ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0; - ewPtr->body.ew.padXPtr = ewPtr->body.ew.padYPtr = NULL; + ewPtr->body.ew.padXObj = ewPtr->body.ew.padYObj = NULL; ewPtr->body.ew.stretch = 0; ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs); diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index c825920..1af6890 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -194,7 +194,7 @@ TkpDisplayButton( } pixmap = (Pixmap) Tk_WindowId(tkwin); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); if (TkMacOSXComputeButtonDrawParams(butPtr, dpPtr)) { macButtonPtr->useTkText = 0; @@ -315,8 +315,8 @@ TkpComputeButtonGeometry( haveImage = 1; } - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXPtr, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYPtr, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &butPtr->padX); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &butPtr->padY); if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); @@ -389,8 +389,8 @@ TkpComputeButtonGeometry( * Now figure out the size of the border decorations for the button. */ - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); butPtr->inset = butPtr->borderWidth + butPtr->highlightWidth; @@ -477,10 +477,10 @@ DrawButtonImageAndText( pressed = 1; } - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXPtr, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYPtr, &butPtr->padY); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &butPtr->padX); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */ @@ -958,8 +958,8 @@ TkMacOSXComputeButtonParams( { MacButton *mbPtr = (MacButton *) butPtr; - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); if (butPtr->borderWidth <= 2) { *btnkind = kThemeSmallBevelButton; diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index bf41d66..ac8ec6f 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1416,7 +1416,7 @@ TkpComputeStandardMenuGeometry( } menuSize = [(NSMenu *) menuPtr->platformData size]; - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); diff --git a/tests/entry.test b/tests/entry.test index a40bad8..4d2be5e 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -322,7 +322,7 @@ test entry-1.28 {configuration option: "highlightthickness" for entry} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result -2 +} -result 0 test entry-1.29 {configuration option: "highlightthickness" for entry} -setup { entry .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12 bold} pack .e ; update idletasks diff --git a/tests/spinbox.test b/tests/spinbox.test index 6ce70d0..924761b 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -480,7 +480,7 @@ test spinbox-1.40 {configuration option: "highlightthickness"} -setup { .e cget -highlightthickness } -cleanup { destroy .e -} -result -2 +} -result 0 test spinbox-1.41 {configuration option: "increment"} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 8ba2df3..c0cc5f2 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -533,10 +533,10 @@ TkpDisplayButton( imageWidth = width; imageHeight = height; - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXPtr, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYPtr, &butPtr->padY); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &butPtr->padX); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); @@ -893,10 +893,10 @@ TkpComputeButtonGeometry( int haveImage = 0, haveText = 0; Tk_FontMetrics fm; - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXPtr, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYPtr, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &butPtr->padX); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &butPtr->padY); butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index 2ed2e49..717731d 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -353,13 +353,13 @@ GetMenuIndicatorGeometry( } } } else { - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); *heightPtr = 0; *widthPtr = borderWidth; } } else { - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); *heightPtr = 0; *widthPtr = borderWidth; @@ -501,7 +501,7 @@ DrawMenuEntryAccelerator( return; } - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); @@ -1121,7 +1121,7 @@ TkpComputeMenubarGeometry( maxWindowWidth = 0x7FFFFFF; } currentRowHeight = 0; - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); x = y = borderWidth; lastRowBreak = 0; @@ -1695,7 +1695,7 @@ TkpComputeStandardMenuGeometry( return; } - Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, + Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); diff --git a/win/tkWinButton.c b/win/tkWinButton.c index e0998b5..bab4118 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -565,10 +565,10 @@ TkpDisplayButton( return; } - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXPtr, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYPtr, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padXObj, &butPtr->padX); + Tk_GetPixelsFromObj(NULL, tkwin, butPtr->padYObj, &butPtr->padY); border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { @@ -1005,8 +1005,8 @@ TkpComputeButtonGeometry( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthPtr, &butPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &butPtr->highlightWidth); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &butPtr->borderWidth); butPtr->inset = butPtr->highlightWidth + butPtr->borderWidth; butPtr->indicatorSpace = 0; @@ -1200,8 +1200,8 @@ TkpComputeButtonGeometry( * because otherwise it is not really a compound button. */ - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXPtr, &butPtr->padX); - Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYPtr, &butPtr->padY); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &butPtr->padX); + Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &butPtr->padY); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { switch ((enum compound) butPtr->compound) { diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 909237c..e284f35 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1598,7 +1598,7 @@ GetMenuIndicatorGeometry( int borderWidth; Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, - menuPtr->borderWidthPtr, &borderWidth); + menuPtr->borderWidthObj, &borderWidth); *widthPtr = indicatorDimensions[1] - borderWidth; /* @@ -1842,7 +1842,7 @@ DrawMenuEntryIndicator( rect.top = y; rect.bottom = y + mePtr->height; Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, - menuPtr->borderWidthPtr, &borderWidth); + menuPtr->borderWidthObj, &borderWidth); Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); rect.left = borderWidth + activeBorderWidth + x; @@ -2988,7 +2988,7 @@ TkpComputeStandardMenuGeometry( } Tk_GetPixelsFromObj(menuPtr->interp, menuPtr->tkwin, - menuPtr->borderWidthPtr, &borderWidth); + menuPtr->borderWidthObj, &borderWidth); x = y = borderWidth; indicatorSpace = labelWidth = accelWidth = 0; windowHeight = 0; -- cgit v0.12 From 8dbe479c2b90db57ec0730bb71363f8fdb293915 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 10 Aug 2024 22:22:10 +0000 Subject: Fix spinbox crash. Minor other fixes for frame and listbox --- generic/tkEntry.c | 34 +++++++++++++++++++++++----------- generic/tkFrame.c | 12 +++--------- generic/tkListbox.c | 16 +++++++++++++--- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 016ae40..4a28a45 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -290,7 +290,7 @@ 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, offsetof(Entry, selBorderWidth), + "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, offsetof(Entry, selBorderWidthObj), offsetof(Entry, selBorderWidth), 0, DEF_ENTRY_SELECT_BD_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", @@ -1190,11 +1190,17 @@ ConfigureEntry( } Tk_SetBackgroundFromBorder(entryPtr->tkwin, border); - if (entryPtr->insertWidth < 0) { - entryPtr->insertWidth = 0; - Tcl_DecrRefCount(entryPtr->insertWidthObj); - entryPtr->insertWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->insertWidthObj); + if (entryPtr->borderWidth < 0) { + entryPtr->borderWidth = 0; + Tcl_DecrRefCount(entryPtr->borderWidthObj); + entryPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->borderWidthObj); + } + if (entryPtr->highlightWidth < 0) { + entryPtr->highlightWidth = 0; + Tcl_DecrRefCount(entryPtr->highlightWidthObj); + entryPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->highlightWidthObj); } if (entryPtr->insertBorderWidth < 0) { entryPtr->insertBorderWidth = 0; @@ -1202,11 +1208,17 @@ ConfigureEntry( entryPtr->insertBorderWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(entryPtr->insertBorderWidthObj); } - if (entryPtr->highlightWidth < 0) { - entryPtr->highlightWidth = 0; - Tcl_DecrRefCount(entryPtr->highlightWidthObj); - entryPtr->highlightWidthObj = Tcl_NewIntObj(0); - Tcl_IncrRefCount(entryPtr->highlightWidthObj); + if (entryPtr->insertWidth < 0) { + entryPtr->insertWidth = 0; + Tcl_DecrRefCount(entryPtr->insertWidthObj); + entryPtr->insertWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->insertWidthObj); + } + if (entryPtr->selBorderWidth < 0) { + entryPtr->selBorderWidth = 0; + Tcl_DecrRefCount(entryPtr->selBorderWidthObj); + entryPtr->selBorderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(entryPtr->selBorderWidthObj); } if (entryPtr->type == TK_SPINBOX) { diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 02ccfb4..5521f38 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -1000,25 +1000,19 @@ ConfigureFrame( if (framePtr->highlightWidth < 0) { framePtr->highlightWidth = 0; - if (framePtr->highlightWidthObj) { - Tcl_DecrRefCount(framePtr->highlightWidthObj); - } + Tcl_DecrRefCount(framePtr->highlightWidthObj); framePtr->highlightWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(framePtr->highlightWidthObj); } if (framePtr->padX < 0) { framePtr->padX = 0; - if (framePtr->padXObj) { - Tcl_DecrRefCount(framePtr->padXObj); - } + Tcl_DecrRefCount(framePtr->padXObj); framePtr->padXObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(framePtr->padXObj); } if (framePtr->padY < 0) { framePtr->padY = 0; - if (framePtr->padYObj) { - Tcl_DecrRefCount(framePtr->padYObj); - } + Tcl_DecrRefCount(framePtr->padYObj); framePtr->padYObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(framePtr->padYObj); } diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 96aa364..d09b503 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -1597,14 +1597,24 @@ ConfigureListbox( Tk_SetBackgroundFromBorder(listPtr->tkwin, listPtr->normalBorder); + if (listPtr->borderWidth < 0) { + listPtr->borderWidth = 0; + Tcl_DecrRefCount(listPtr->borderWidthObj); + listPtr->borderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(listPtr->borderWidthObj); + } if (listPtr->highlightWidth < 0) { listPtr->highlightWidth = 0; - if (listPtr->highlightWidthObj) { - Tcl_DecrRefCount(listPtr->highlightWidthObj); - } + Tcl_DecrRefCount(listPtr->highlightWidthObj); listPtr->highlightWidthObj = Tcl_NewIntObj(0); Tcl_IncrRefCount(listPtr->highlightWidthObj); } + if (listPtr->selBorderWidth < 0) { + listPtr->selBorderWidth = 0; + Tcl_DecrRefCount(listPtr->selBorderWidthObj); + listPtr->selBorderWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(listPtr->selBorderWidthObj); + } listPtr->inset = listPtr->highlightWidth + listPtr->borderWidth; /* -- cgit v0.12