diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-07-02 13:58:21 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-07-02 13:58:21 (GMT) |
commit | 32dfbede133921ddb52e77da15090b48ca29385b (patch) | |
tree | b9de9356180a2ab644ce083e3202801b23aa6237 | |
parent | 2c8eede9b0c6a025746f162918bf40395637119b (diff) | |
download | tk-32dfbede133921ddb52e77da15090b48ca29385b.zip tk-32dfbede133921ddb52e77da15090b48ca29385b.tar.gz tk-32dfbede133921ddb52e77da15090b48ca29385b.tar.bz2 |
Don't use constants like DEF_BUTTON_UNDERLINE any more, since the default underline should always be no underline anyway.
-rw-r--r-- | generic/tkButton.c | 8 | ||||
-rw-r--r-- | generic/tkCanvText.c | 6 | ||||
-rw-r--r-- | generic/tkMenu.c | 2 | ||||
-rw-r--r-- | generic/tkMenubutton.c | 4 | ||||
-rw-r--r-- | generic/ttk/ttkButton.c | 2 | ||||
-rw-r--r-- | generic/ttk/ttkLabel.c | 28 | ||||
-rw-r--r-- | generic/ttk/ttkNotebook.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXDefault.h | 6 | ||||
-rw-r--r-- | tests/ttk/notebook.test | 2 | ||||
-rw-r--r-- | unix/tkUnixDefault.h | 6 | ||||
-rw-r--r-- | win/tkWinDefault.h | 6 |
11 files changed, 25 insertions, 47 deletions
diff --git a/generic/tkButton.c b/generic/tkButton.c index 0c94944..8fe4169 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -143,7 +143,7 @@ static const Tk_OptionSpec labelOptionSpecs[] = { {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", NULL, TCL_INDEX_NONE, offsetof(TkButton, underline), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, @@ -244,7 +244,7 @@ static const Tk_OptionSpec buttonOptionSpecs[] = { {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", NULL, TCL_INDEX_NONE, offsetof(TkButton, underline), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, @@ -354,7 +354,7 @@ static const Tk_OptionSpec checkbuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue", DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0}, - {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", NULL, TCL_INDEX_NONE, offsetof(TkButton, underline), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE, @@ -464,7 +464,7 @@ static const Tk_OptionSpec radiobuttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue", DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0}, - {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", NULL, TCL_INDEX_NONE, offsetof(TkButton, underline), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-value", "value", "Value", DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0}, diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index cc36e70..433d129 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -152,11 +152,7 @@ UnderlinePrintProc( (void)tkwin; if (underline == INT_MIN) { -#if TCL_MAJOR_VERSION > 9 || defined(TK_NON_DEPRECATED) - p = (char *)"none"; -#else p = (char *)"-1"; -#endif *freeProcPtr = TCL_STATIC; return p; } else if (underline == INT_MAX) { @@ -211,7 +207,7 @@ static const Tk_ConfigSpec configSpecs[] = { NULL, 0, TK_CONFIG_NULL_OK, &tagsOption}, {TK_CONFIG_STRING, "-text", NULL, NULL, "", offsetof(TextItem, text), 0, NULL}, - {TK_CONFIG_CUSTOM, "-underline", NULL, NULL, DEF_BUTTON_UNDERLINE, + {TK_CONFIG_CUSTOM, "-underline", NULL, NULL, NULL, offsetof(TextItem, underline), TK_CONFIG_NULL_OK, &underlineOption}, {TK_CONFIG_PIXELS, "-width", NULL, NULL, "0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL}, diff --git a/generic/tkMenu.c b/generic/tkMenu.c index a8c81f3..bb8e62a 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -161,7 +161,7 @@ static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0, (ClientData) menuStateStrings, 0}, {TK_OPTION_INDEX, "-underline", NULL, NULL, - DEF_MENU_ENTRY_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), TK_OPTION_NULL_OK, NULL, 0}, + NULL, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0} }; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 8d512c1..d046c84 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -146,8 +146,8 @@ static const Tk_OptionSpec optionSpecs[] = { DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INDEX, "-underline", "underline", "Underline", - DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuButton, underline), - TK_OPTION_NULL_OK, 0, 0}, + NULL, TCL_INDEX_NONE, offsetof(TkMenuButton, underline), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString), 0, 0, 0}, diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index e85313e..89312c0 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -67,7 +67,7 @@ static const Tk_OptionSpec BaseOptionSpecs[] = offsetof(Base,base.textVariableObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_INDEX, "-underline", "underline", "Underline", - DEF_BUTTON_UNDERLINE, offsetof(Base,base.underlineObj), TCL_INDEX_NONE, + NULL, offsetof(Base,base.underlineObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, /* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */ {TK_OPTION_STRING, "-width", "width", "Width", diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index 0578118..a9a39bb 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -55,7 +55,7 @@ static const Ttk_ElementOptionSpec TextElementOptions[] = { { "-foreground", TK_OPTION_COLOR, offsetof(TextElement,foregroundObj), "black" }, { "-underline", TK_OPTION_INDEX, - offsetof(TextElement,underlineObj), DEF_BUTTON_UNDERLINE}, + offsetof(TextElement,underlineObj), NULL}, { "-width", TK_OPTION_INT, offsetof(TextElement,widthObj), "-1"}, { "-anchor", TK_OPTION_ANCHOR, @@ -171,19 +171,19 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1, text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/); - TkGetIntForIndex(text->underlineObj, TCL_INDEX_END, 0, &underline); - if (underline == TCL_INDEX_NONE) { - underline = (TkSizeT)INT_MIN; - } else if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { - underline++; - } - if (underline != (TkSizeT)INT_MIN) { - if (text->embossed) { - Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2, - text->textLayout, b.x+1, b.y+1, underline); + if (text->underlineObj != NULL) { + TkGetIntForIndex(text->underlineObj, TCL_INDEX_END, 0, &underline); + if (underline != TCL_INDEX_NONE) { + if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { + underline++; + } + if (text->embossed) { + Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2, + text->textLayout, b.x+1, b.y+1, underline); + } + Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1, + text->textLayout, b.x, b.y, underline); } - Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1, - text->textLayout, b.x, b.y, underline); } if (clipRegion != NULL) { @@ -470,7 +470,7 @@ static const Ttk_ElementOptionSpec LabelElementOptions[] = { { "-foreground", TK_OPTION_COLOR, offsetof(LabelElement,text.foregroundObj), "black" }, { "-underline", TK_OPTION_INDEX, - offsetof(LabelElement,text.underlineObj), DEF_BUTTON_UNDERLINE}, + offsetof(LabelElement,text.underlineObj), NULL}, { "-width", TK_OPTION_INT, offsetof(LabelElement,text.widthObj), ""}, { "-anchor", TK_OPTION_ANCHOR, diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 61f95f0..dedd158 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -68,7 +68,7 @@ static const Tk_OptionSpec TabOptionSpecs[] = {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED }, - {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", NULL, offsetof(Tab,underlineObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 } }; diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 80ea1ee..f25c69e 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -114,11 +114,6 @@ #define DEF_BUTTON_TAKE_FOCUS NULL #define DEF_BUTTON_TEXT "" #define DEF_BUTTON_TEXT_VARIABLE "" -#if TCL_MAJOR_VERSION < 9 && !defined(TK_NO_DEPRECATED) -# define DEF_BUTTON_UNDERLINE "-1" -#else -# define DEF_BUTTON_UNDERLINE NULL -#endif #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" #define DEF_BUTTON_WRAP_LENGTH "0" @@ -309,7 +304,6 @@ #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL -#define DEF_MENU_ENTRY_UNDERLINE DEF_BUTTON_UNDERLINE /* * Defaults for menus overall: diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test index ac63088..253e1cc 100644 --- a/tests/ttk/notebook.test +++ b/tests/ttk/notebook.test @@ -69,7 +69,7 @@ test notebook-2.5 "tab - get all options" -body { .nb tab .nb.foo } -result [list \ -padding 0 -sticky nsew \ - -state normal -text "Changed Foo" -image "" -compound {} -underline -1] + -state normal -text "Changed Foo" -image "" -compound {} -underline {}] test notebook-4.1 "Test .nb index end" -body { .nb index end diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index 8678d47..87af737 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -86,11 +86,6 @@ #define DEF_BUTTON_TAKE_FOCUS NULL #define DEF_BUTTON_TEXT "" #define DEF_BUTTON_TEXT_VARIABLE "" -#if TCL_MAJOR_VERSION < 9 && !defined(TK_NO_DEPRECATED) -# define DEF_BUTTON_UNDERLINE "-1" -#else -# define DEF_BUTTON_UNDERLINE NULL -#endif #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" #define DEF_BUTTON_WRAP_LENGTH "0" @@ -270,7 +265,6 @@ #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL -#define DEF_MENU_ENTRY_UNDERLINE DEF_BUTTON_UNDERLINE /* * Defaults for menus overall: diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 1631b3e..1aac782 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -91,11 +91,6 @@ #define DEF_BUTTON_TEXT "" #define DEF_BUTTON_TEXT_VARIABLE "" #define DEF_BUTTON_TRISTATE_VALUE "" -#if TCL_MAJOR_VERSION < 9 && !defined(TK_NO_DEPRECATED) -# define DEF_BUTTON_UNDERLINE "-1" -#else -# define DEF_BUTTON_UNDERLINE NULL -#endif #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" #define DEF_BUTTON_WRAP_LENGTH "0" @@ -274,7 +269,6 @@ #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL -#define DEF_MENU_ENTRY_UNDERLINE DEF_BUTTON_UNDERLINE /* * Defaults for menus overall: |