Attachment "classic-theme.diff" to
ticket [aa2dd4c1]
added by
emiliano
2024-05-03 01:05:36.
Index: generic/ttk/ttkClassicTheme.c
==================================================================
--- generic/ttk/ttkClassicTheme.c
+++ generic/ttk/ttkClassicTheme.c
@@ -17,17 +17,20 @@
*/
typedef struct {
Tcl_Obj *highlightColorObj;
Tcl_Obj *highlightThicknessObj;
+ Tcl_Obj *defaultStateObj;
} HighlightElement;
static const Ttk_ElementOptionSpec HighlightElementOptions[] = {
{ "-highlightcolor",TK_OPTION_COLOR,
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 }
};
static void HighlightElementSize(
TCL_UNUSED(void *), /* clientData */
@@ -52,16 +55,22 @@
TCL_UNUSED(Ttk_Box),
TCL_UNUSED(Ttk_State))
{
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);
+ }
}
}
static const Ttk_ElementSpec HighlightElementSpec =
{
@@ -824,21 +833,48 @@
TTK_GROUP("Entry.highlight", TTK_FILL_BOTH,
TTK_GROUP("Entry.field", TTK_FILL_BOTH|TTK_BORDER,
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("Entry.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_PACK_TOP|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.
*/
Index: generic/ttk/ttkElements.c
==================================================================
--- generic/ttk/ttkElements.c
+++ generic/ttk/ttkElements.c
@@ -357,30 +357,36 @@
* Draws a dashed focus ring, if the widget has keyboard focus.
*/
typedef struct {
Tcl_Obj *focusColorObj;
Tcl_Obj *focusThicknessObj;
+ Tcl_Obj *focusSolidObj;
} FocusElement;
/*
* DrawFocusRing --
* 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;
XGCValues gcvalues;
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);
Tk_FreeGC(Tk_Display(tkwin), gc);
}
@@ -388,10 +394,12 @@
static const Ttk_ElementOptionSpec FocusElementOptions[] = {
{ "-focuscolor",TK_OPTION_COLOR,
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 }
};
static void FocusElementSize(
TCL_UNUSED(void *), /* clientData */
@@ -416,14 +424,17 @@
Ttk_Box b,
Ttk_State state)
{
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);
}
}
static const Ttk_ElementSpec FocusElementSpec = {
TK_STYLE_VERSION_2,
Index: library/ttk/classicTheme.tcl
==================================================================
--- library/ttk/classicTheme.tcl
+++ library/ttk/classicTheme.tcl
@@ -30,11 +30,13 @@
-troughcolor $colors(-troughbg) \
-indicatorcolor $colors(-frame) \
-highlightcolor $colors(-frame) \
-highlightthickness 1 \
-selectborderwidth 1 \
- -insertwidth 2
+ -insertwidth 2 \
+ -borderwidth 1 \
+ -focuswidth 0
# To match pre-Xft X11 appearance, use:
# ttk::style configure . -font {Helvetica 12 bold}
ttk::style map "." -background \
@@ -47,20 +49,20 @@
ttk::style configure TButton \
-anchor center -padding "3m 1m" -relief raised -shiftrelief 1
ttk::style map TButton -relief {{!disabled pressed} sunken}
ttk::style configure TCheckbutton -indicatorrelief raised \
- -indicatormargin {0 1.5p 3p 1.5p}
+ -indicatormargin {0 1.5p 3p 1.5p} -borderwidth 1
ttk::style map TCheckbutton \
-indicatorcolor [list \
pressed $colors(-frame) \
alternate $colors(-altindicator) \
selected $colors(-indicator)] \
-indicatorrelief {alternate raised selected sunken pressed sunken}
ttk::style configure TRadiobutton -indicatorrelief raised \
- -indicatormargin {0 1.5p 3p 1.5p}
+ -indicatormargin {0 1.5p 3p 1.5p} -borderwidth 1
ttk::style map TRadiobutton \
-indicatorcolor [list \
pressed $colors(-frame) \
alternate $colors(-altindicator) \
selected $colors(-indicator)] \
@@ -84,23 +86,24 @@
[list readonly $colors(-frame) disabled $colors(-frame)]
ttk::style configure TLabelframe -borderwidth 2 -relief groove
ttk::style configure TScrollbar -relief raised \
- -arrowsize 11.25p -width 11.25p -troughborderwidth 2
+ -arrowsize 9p -width 9p -troughborderwidth 1
ttk::style map TScrollbar -relief {{pressed !disabled} sunken}
ttk::style configure TScale -sliderrelief raised \
- -sliderlength 22.5p -sliderthickness 11.25p -troughborderwidth 2
+ -sliderlength 22.5p -sliderthickness 11.25p -troughborderwidth 1
ttk::style map TScale -sliderrelief {{pressed !disabled} sunken}
ttk::style configure TProgressbar -background SteelBlue \
- -barsize 22.5p -thickness 11.25p -troughborderwidth 2
+ -barsize 22.5p -thickness 11.25p -troughborderwidth 1
ttk::style configure TNotebook.Tab \
-padding {3m 1m} \
- -background $colors(-troughbg)
+ -background $colors(-troughbg) \
+ -focussolid 1
ttk::style map TNotebook.Tab -background [list selected $colors(-frame)]
# Treeview:
ttk::style configure Heading -font TkHeadingFont -relief raised
ttk::style configure Item -indicatorsize 9p \