diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-11 12:14:59 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-11 12:14:59 (GMT) |
commit | b1e5b2f35860988dd0aad0342fdf06272864e30d (patch) | |
tree | e4b102a1e77fad36d58a1edbf1bcad4f42ed78a6 /generic/ttk/ttkLabel.c | |
parent | 49f7fca89164bb7a378a01aea165d82df6aad06c (diff) | |
parent | bd33c4f3a417d27aebd67b95239b3efd2238dac9 (diff) | |
download | tk-b1e5b2f35860988dd0aad0342fdf06272864e30d.zip tk-b1e5b2f35860988dd0aad0342fdf06272864e30d.tar.gz tk-b1e5b2f35860988dd0aad0342fdf06272864e30d.tar.bz2 |
Merge trunk. Add new option type TK_OPTION_INDEX. Start implementing extended index handling for -underline.
Diffstat (limited to 'generic/ttk/ttkLabel.c')
-rw-r--r-- | generic/ttk/ttkLabel.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index a4dbf96..c83c222 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -8,6 +8,7 @@ #include "tkInt.h" #include "ttkTheme.h" +#include "default.h" /*---------------------------------------------------------------------- * +++ Text element. @@ -53,8 +54,8 @@ static const Ttk_ElementOptionSpec TextElementOptions[] = { offsetof(TextElement,fontObj), DEFAULT_FONT }, { "-foreground", TK_OPTION_COLOR, offsetof(TextElement,foregroundObj), "black" }, - { "-underline", TK_OPTION_INT, - offsetof(TextElement,underlineObj), "-1"}, + { "-underline", TK_OPTION_INDEX, + offsetof(TextElement,underlineObj), DEF_BUTTON_UNDERLINE}, { "-width", TK_OPTION_INT, offsetof(TextElement,widthObj), "-1"}, { "-anchor", TK_OPTION_ANCHOR, @@ -126,7 +127,7 @@ static void TextCleanup(TextElement *text) static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) { XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj); - int underline = -1; + TkSizeT underline = TCL_INDEX_NONE; XGCValues gcValues; GC gc1, gc2; Tk_Anchor anchor = TK_ANCHOR_CENTER; @@ -170,8 +171,9 @@ 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*/); - Tcl_GetIntFromObj(NULL, text->underlineObj, &underline); - if (underline >= 0) { + /* TODO: Handle end+/- syntax */ + TkGetIntForIndex(text->underlineObj, INT_MAX - 1, TCL_INDEX_ERROR, &underline); + if ((underline != TCL_INDEX_NONE) && (underline < (TkSizeT)INT_MAX)) { if (text->embossed) { Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2, text->textLayout, b.x+1, b.y+1, underline); @@ -463,8 +465,8 @@ static const Ttk_ElementOptionSpec LabelElementOptions[] = { offsetof(LabelElement,text.fontObj), DEFAULT_FONT }, { "-foreground", TK_OPTION_COLOR, offsetof(LabelElement,text.foregroundObj), "black" }, - { "-underline", TK_OPTION_INT, - offsetof(LabelElement,text.underlineObj), "-1"}, + { "-underline", TK_OPTION_INDEX, + offsetof(LabelElement,text.underlineObj), DEF_BUTTON_UNDERLINE}, { "-width", TK_OPTION_INT, offsetof(LabelElement,text.widthObj), ""}, { "-anchor", TK_OPTION_ANCHOR, |