diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tk.h | 3 | ||||
-rw-r--r-- | generic/tkButton.c | 8 | ||||
-rw-r--r-- | generic/tkConfig.c | 38 | ||||
-rw-r--r-- | generic/tkMenubutton.c | 2 | ||||
-rw-r--r-- | generic/ttk/ttkButton.c | 7 | ||||
-rw-r--r-- | generic/ttk/ttkFrame.c | 5 | ||||
-rw-r--r-- | generic/ttk/ttkLabel.c | 16 | ||||
-rw-r--r-- | generic/ttk/ttkNotebook.c | 3 |
8 files changed, 63 insertions, 19 deletions
diff --git a/generic/tk.h b/generic/tk.h index cec87b3..8875eea 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -170,7 +170,8 @@ typedef enum { TK_OPTION_WINDOW, TK_OPTION_END, TK_OPTION_CUSTOM, - TK_OPTION_STYLE + TK_OPTION_STYLE, + TK_OPTION_INDEX } Tk_OptionType; /* diff --git a/generic/tkButton.c b/generic/tkButton.c index 8056f31..211fdac 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_INT, "-underline", "underline", "Underline", + {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 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_INT, "-underline", "underline", "Underline", + {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 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_INT, "-underline", "underline", "Underline", + {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 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_INT, "-underline", "underline", "Underline", + {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0}, {TK_OPTION_STRING, "-value", "value", "Value", DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0}, diff --git a/generic/tkConfig.c b/generic/tkConfig.c index d4ffa7c..fad4f94 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -635,6 +635,30 @@ DoObjConfig( } break; } + case TK_OPTION_INDEX: { + TkSizeT newIndex; + + /* TODO: don't bother handling "end" yet */ + if (TkGetIntForIndex(valuePtr, INT_MAX - 1, 0, &newIndex) != TCL_OK) { + if (interp) { + Tcl_AppendResult(interp, "bad index \"", Tcl_GetString(valuePtr), + "\": must be integer?[+-]integer?, end?[+-]integer? or none", NULL); + } + return TCL_ERROR; + } + if (valuePtr->internalRep.wideValue < INT_MIN) { + newIndex = (TkSizeT)INT_MIN; + } else if (valuePtr->internalRep.wideValue > INT_MAX) { + newIndex = (TkSizeT)INT_MAX; + } else if (valuePtr->internalRep.wideValue < 0) { + newIndex = (TkSizeT)valuePtr->internalRep.wideValue; + } + if (internalPtr != NULL) { + *((int *) oldInternalPtr) = *((int *) internalPtr); + *((int *) internalPtr) = (int)newIndex; + } + break; + } case TK_OPTION_DOUBLE: { double newDbl; @@ -1410,6 +1434,9 @@ Tk_RestoreSavedOptions( case TK_OPTION_INT: *((int *) internalPtr) = *((int *) ptr); break; + case TK_OPTION_INDEX: + *((int *) internalPtr) = *((int *) ptr); + break; case TK_OPTION_DOUBLE: *((double *) internalPtr) = *((double *) ptr); break; @@ -1883,6 +1910,17 @@ GetObjectForOption( case TK_OPTION_INT: objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); break; + case TK_OPTION_INDEX: + if (*((int *) internalPtr) >= 0 && *((int *) internalPtr) < INT_MAX) { + objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); + } else { +#if TCL_MAJOR_VERSION > 8 || defined(TK_NO_DEPRECATED) + objPtr = Tcl_NewStringObj("none", -1); +#else + objPtr = Tcl_NewWideIntObj(-1); +#endif + } + break; case TK_OPTION_DOUBLE: objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); break; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 4b7a492..7d6086f 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -145,7 +145,7 @@ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, - {TK_OPTION_INT, "-underline", "underline", "Underline", + {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_MENUBUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuButton, underline), 0, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 9712c66..efb53b7 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -7,6 +7,7 @@ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" +#include "default.h" /* Bit fields for OptionSpec mask field: */ @@ -24,7 +25,7 @@ typedef struct Tcl_Obj *textObj; Tcl_Obj *justifyObj; Tcl_Obj *textVariableObj; - Tcl_Obj *underlineObj; + Tcl_Obj *underlineObj1; Tcl_Obj *widthObj; Ttk_TraceHandle *textVariableTrace; @@ -65,8 +66,8 @@ static const Tk_OptionSpec BaseOptionSpecs[] = {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "", offsetof(Base,base.textVariableObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, - {TK_OPTION_INT, "-underline", "underline", "Underline", - "-1", offsetof(Base,base.underlineObj), TCL_INDEX_NONE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", + DEF_BUTTON_UNDERLINE, offsetof(Base,base.underlineObj1), TCL_INDEX_NONE, 0,0,0 }, /* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */ {TK_OPTION_STRING, "-width", "width", "Width", diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index 7c43bce..6fea538 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -8,6 +8,7 @@ #include "ttkTheme.h" #include "ttkWidget.h" #include "ttkManager.h" +#include "default.h" /* ====================================================================== * +++ Frame widget: @@ -257,8 +258,8 @@ static const Tk_OptionSpec LabelframeOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(Labelframe,label.textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, - {TK_OPTION_INT, "-underline", "underline", "Underline", - "-1", offsetof(Labelframe,label.underlineObj), TCL_INDEX_NONE, + {TK_OPTION_INDEX, "-underline", "underline", "Underline", + DEF_BUTTON_UNDERLINE, offsetof(Labelframe,label.underlineObj), TCL_INDEX_NONE, 0,0,0 }, {TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL, TCL_INDEX_NONE, offsetof(Labelframe,label.labelWidget), 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, diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 7ad46a4..6b185c1 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -6,6 +6,7 @@ #include "ttkTheme.h" #include "ttkWidget.h" #include "ttkManager.h" +#include "default.h" #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -67,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_INT, "-underline", "underline", "Underline", "-1", + {TK_OPTION_INDEX, "-underline", "underline", "Underline", DEF_BUTTON_UNDERLINE, offsetof(Tab,underlineObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 } }; |