diff options
author | csaba <csaba> | 2024-05-09 18:39:12 (GMT) |
---|---|---|
committer | csaba <csaba> | 2024-05-09 18:39:12 (GMT) |
commit | f30fccea2dea24ae6c8a5c323532347d1d544ba7 (patch) | |
tree | 6f34210f166ccb52665b1b3e1b1c4cb79a4032ca /generic/ttk | |
parent | 1a687a43e99778d830cc2d49ff3f9e0129d34083 (diff) | |
download | tk-f30fccea2dea24ae6c8a5c323532347d1d544ba7.zip tk-f30fccea2dea24ae6c8a5c323532347d1d544ba7.tar.gz tk-f30fccea2dea24ae6c8a5c323532347d1d544ba7.tar.bz2 |
Improvements related to the "classic" theme, submitted by Emiliano Gavilan (see ticket [aa2dd4c16d]).
Diffstat (limited to 'generic/ttk')
-rw-r--r-- | generic/ttk/ttkClassicTheme.c | 58 | ||||
-rw-r--r-- | generic/ttk/ttkElements.c | 26 |
2 files changed, 67 insertions, 17 deletions
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index 4d42448..cff6aca 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -19,6 +19,7 @@ typedef struct { Tcl_Obj *highlightColorObj; Tcl_Obj *highlightThicknessObj; + Tcl_Obj *defaultStateObj; } HighlightElement; static const Ttk_ElementOptionSpec HighlightElementOptions[] = { @@ -26,6 +27,8 @@ static const Ttk_ElementOptionSpec HighlightElementOptions[] = { offsetof(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND }, { "-highlightthickness",TK_OPTION_PIXELS, offsetof(HighlightElement,highlightThicknessObj), "0" }, + { "-default", TK_OPTION_ANY, + offsetof(HighlightElement,defaultStateObj), "disabled" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; @@ -54,12 +57,18 @@ static void HighlightElementDraw( { HighlightElement *hl = (HighlightElement *)elementRecord; int highlightThickness = 0; + Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED; XColor *highlightColor = Tk_GetColorFromObj(tkwin, hl->highlightColorObj); Tcl_GetIntFromObj(NULL,hl->highlightThicknessObj,&highlightThickness); if (highlightColor && highlightThickness > 0) { + Ttk_GetButtonDefaultStateFromObj(NULL, hl->defaultStateObj, &defaultState); GC gc = Tk_GCForColor(highlightColor, d); - Tk_DrawFocusHighlight(tkwin, gc, highlightThickness, d); + if (defaultState == TTK_BUTTON_DEFAULT_NORMAL) { + TkDrawInsetFocusHighlight(tkwin, gc, highlightThickness, d, 5); + } else { + Tk_DrawFocusHighlight(tkwin, gc, highlightThickness, d); + } } } @@ -615,8 +624,10 @@ static void SliderElementDraw( border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj); Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient); - Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth); Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief); +#if 0 + Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth); +#endif Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height, @@ -826,17 +837,44 @@ TTK_LAYOUT("TEntry", TTK_GROUP("Entry.padding", TTK_FILL_BOTH, TTK_NODE("Entry.textarea", TTK_FILL_BOTH))))) -/* Notebook tabs -- omit focus ring */ -TTK_LAYOUT("Tab", - TTK_GROUP("Notebook.tab", TTK_FILL_BOTH, - TTK_GROUP("Notebook.padding", TTK_FILL_BOTH, - TTK_NODE("Notebook.label", TTK_FILL_BOTH)))) +/* "classic" combobox, includes highlight border */ +TTK_LAYOUT("TCombobox", + TTK_GROUP("Combobox.highlight", TTK_FILL_BOTH, + TTK_GROUP("Combobox.field", TTK_FILL_BOTH, + TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) + TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, + TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))) + +/* "classic" spinbox, includes highlight border */ +TTK_LAYOUT("TSpinbox", + TTK_GROUP("Spinbox.highlight", TTK_FILL_BOTH, + TTK_GROUP("Spinbox.field", TTK_FILL_BOTH|TTK_FILL_X, + TTK_GROUP("null", TTK_PACK_RIGHT, + TTK_NODE("Spinbox.uparrow", TTK_PACK_TOP|TTK_STICK_E) + TTK_NODE("Spinbox.downarrow", TTK_PACK_BOTTOM|TTK_STICK_E)) + TTK_GROUP("Spinbox.padding", TTK_FILL_BOTH, + TTK_NODE("Spinbox.textarea", TTK_FILL_BOTH))))) + +/* "classic" scale, includes highlight border */ +TTK_LAYOUT("Vertical.TScale", + TTK_GROUP("Vertical.Scale.highlight", TTK_FILL_BOTH, + TTK_GROUP("Vertical.Scale.trough", TTK_FILL_BOTH, + TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP)))) + +TTK_LAYOUT("Horizontal.TScale", + TTK_GROUP("Horizontal.Scale.highlight", TTK_FILL_BOTH, + TTK_GROUP("Horizontal.Scale.trough", TTK_FILL_BOTH, + TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT)))) + +/* put highlight border around treeview */ +TTK_LAYOUT("Treeview", + TTK_GROUP("Treeview.highlight", TTK_FILL_BOTH, + TTK_GROUP("Treeview.field", TTK_FILL_BOTH|TTK_BORDER, + TTK_GROUP("Treeview.padding", TTK_FILL_BOTH, + TTK_NODE("Treeview.treearea", TTK_FILL_BOTH))))) TTK_END_LAYOUT_TABLE -/* POSSIBLY: include Scale layouts w/focus border - */ - /*------------------------------------------------------------------------ * TtkClassicTheme_Init -- * Install classic theme. diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c index 3791f87..d75bbe4 100644 --- a/generic/ttk/ttkElements.c +++ b/generic/ttk/ttkElements.c @@ -359,6 +359,7 @@ static const Ttk_ElementSpec PaddingElementSpec = { typedef struct { Tcl_Obj *focusColorObj; Tcl_Obj *focusThicknessObj; + Tcl_Obj *focusSolidObj; } FocusElement; /* @@ -366,7 +367,8 @@ typedef struct { * Draw a dotted rectangle to indicate focus. */ static void DrawFocusRing( - Tk_Window tkwin, Drawable d, Tcl_Obj *colorObj, Ttk_Box b) + Tk_Window tkwin, Drawable d, Tcl_Obj *colorObj, int thickness, int solid, + Ttk_Box b) { XColor *color = Tk_GetColorFromObj(tkwin, colorObj); unsigned long mask = 0UL; @@ -374,11 +376,16 @@ static void DrawFocusRing( GC gc; gcvalues.foreground = color->pixel; - gcvalues.line_style = LineOnOffDash; - gcvalues.line_width = 1; - gcvalues.dashes = 1; - gcvalues.dash_offset = 1; - mask = GCForeground | GCLineStyle | GCDashList | GCDashOffset | GCLineWidth; + gcvalues.line_width = thickness < 1 ? 1 : thickness; + if (solid) { + gcvalues.line_style = LineSolid; + mask = GCForeground | GCLineStyle | GCLineWidth; + } else { + gcvalues.line_style = LineOnOffDash; + gcvalues.dashes = 1; + gcvalues.dash_offset = 1; + mask = GCForeground | GCLineStyle | GCDashList | GCDashOffset | GCLineWidth; + } gc = Tk_GetGC(tkwin, mask, &gcvalues); XDrawRectangle(Tk_Display(tkwin), d, gc, b.x, b.y, b.width-1, b.height-1); @@ -390,6 +397,8 @@ static const Ttk_ElementOptionSpec FocusElementOptions[] = { offsetof(FocusElement,focusColorObj), "black" }, { "-focusthickness",TK_OPTION_PIXELS, offsetof(FocusElement,focusThicknessObj), "1" }, + { "-focussolid",TK_OPTION_BOOLEAN, + offsetof(FocusElement,focusSolidObj), "0" }, { NULL, TK_OPTION_BOOLEAN, 0, NULL } }; @@ -418,10 +427,13 @@ static void FocusElementDraw( { FocusElement *focus = (FocusElement *)elementRecord; int focusThickness = 0; + int focusSolid = 0; if (state & TTK_STATE_FOCUS) { Tcl_GetIntFromObj(NULL,focus->focusThicknessObj,&focusThickness); - DrawFocusRing(tkwin, d, focus->focusColorObj, b); + Tcl_GetBooleanFromObj(NULL,focus->focusSolidObj,&focusSolid); + DrawFocusRing(tkwin, d, focus->focusColorObj, focusThickness, + focusSolid, b); } } |