From e74b92a66cb3c8d158ded0ddabf6740c1d038850 Mon Sep 17 00:00:00 2001 From: jenglish Date: Wed, 31 Dec 2008 21:25:34 +0000 Subject: * generic/ttk/ttkDefaultTheme.c: Fix color palette for radiobutton and checkbutton indicators. Fixes [Bug 2003310]; also makes "alt" theme check/radiobuttons look like Windows 98, as intended. * library/ttk/altTheme.tcl: Specify dark gray -bordercolor to soften edges. --- ChangeLog | 9 +++ generic/ttk/ttkDefaultTheme.c | 157 +++++++++++++++++------------------------- library/ttk/altTheme.tcl | 4 +- 3 files changed, 74 insertions(+), 96 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8e5621..72fb808 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-12-31 Joe English + + * generic/ttk/ttkDefaultTheme.c: Fix color palette for + radiobutton and checkbutton indicators. Fixes [Bug 2003310]; + also makes "alt" theme check/radiobuttons look like Windows 98, + as intended. + * library/ttk/altTheme.tcl: Specify dark gray -bordercolor + to soften edges. + 2008-12-28 Donal K. Fellows TIP #171 IMPLEMENTATION diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c index 95b4e38..2d7d8d0 100644 --- a/generic/ttk/ttkDefaultTheme.c +++ b/generic/ttk/ttkDefaultTheme.c @@ -1,4 +1,4 @@ -/* $Id: ttkDefaultTheme.c,v 1.13 2008/11/02 09:54:02 nijtmans Exp $ +/* $Id: ttkDefaultTheme.c,v 1.14 2008/12/31 21:25:34 jenglish Exp $ * * Copyright (c) 2003, Joe English * @@ -39,8 +39,7 @@ static const int WIN32_XDRAWLINE_HACK = 0; enum BorderColor { FLAT = 1, LITE = 2, DARK = 3, BRDR = 4 }; /* top-left outer, top-left inner, bottom-right inner, bottom-right outer */ -static int const shadowColors[6][4] = -{ +static int const shadowColors[6][4] = { { FLAT, FLAT, FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/ { DARK, LITE, DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/ { LITE, FLAT, DARK, BRDR }, /* TK_RELIEF_RAISED = 2*/ @@ -50,8 +49,7 @@ static int const shadowColors[6][4] = }; /* top-left, bottom-right */ -static int const thinShadowColors[6][4] = -{ +static int const thinShadowColors[6][4] = { { FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/ { DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/ { LITE, DARK }, /* TK_RELIEF_RAISED = 2*/ @@ -234,8 +232,7 @@ void TtkDrawArrow( * + 1 pixel padding (???) */ -typedef struct -{ +typedef struct { Tcl_Obj *borderObj; Tcl_Obj *borderColorObj; /* Extra border color */ Tcl_Obj *borderWidthObj; @@ -243,8 +240,7 @@ typedef struct Tcl_Obj *defaultStateObj; /* for buttons */ } BorderElement; -static Ttk_ElementOptionSpec BorderElementOptions[] = -{ +static Ttk_ElementOptionSpec BorderElementOptions[] = { { "-background", TK_OPTION_BORDER, Tk_Offset(BorderElement,borderObj), DEFAULT_BACKGROUND }, { "-bordercolor",TK_OPTION_COLOR, @@ -307,8 +303,7 @@ static void BorderElementDraw( DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); } -static Ttk_ElementSpec BorderElementSpec = -{ +static Ttk_ElementSpec BorderElementSpec = { TK_STYLE_VERSION_2, sizeof(BorderElement), BorderElementOptions, @@ -320,14 +315,12 @@ static Ttk_ElementSpec BorderElementSpec = * +++ Field element: * Used for editable fields. */ -typedef struct -{ +typedef struct { Tcl_Obj *borderObj; Tcl_Obj *borderColorObj; /* Extra border color */ } FieldElement; -static Ttk_ElementOptionSpec FieldElementOptions[] = -{ +static Ttk_ElementOptionSpec FieldElementOptions[] = { { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,borderObj), "white" }, { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj), @@ -355,8 +348,7 @@ static void FieldElementDraw( DrawFieldBorder(tkwin, d, border, borderColor, b); } -static Ttk_ElementSpec FieldElementSpec = -{ +static Ttk_ElementSpec FieldElementSpec = { TK_STYLE_VERSION_2, sizeof(FieldElement), FieldElementOptions, @@ -374,8 +366,7 @@ static Ttk_ElementSpec FieldElementSpec = /* * Indicator bitmap descriptor: */ -typedef struct -{ +typedef struct { int width; /* Width of each image */ int height; /* Height of each image */ int nimages; /* #images / row */ @@ -387,27 +378,27 @@ typedef struct /*XPM*/ static const char *const button_images[] = { /* width height ncolors chars_per_pixel */ - "52 26 7 1", + "52 13 8 1", /* colors */ - "A c #808000000000 s background", - "B c #000080800000 s background", - "C c #808080800000 s highlight", - "D c #000000008080 s select", - "E c #808000008080 s shadow", - "F c #000080808080 s background", - "G c #000000000000 s indicator", - "H c #000080800000 s disabled", + "A c #808000000000 s shadow", + "B c #000080800000 s highlight", + "C c #808080800000 s 3dlight", + "D c #000000008080 s window", + "E c #808000008080 s 3ddark", + "F c #000080808080 s frame", + "G c #000000000000 s foreground", + "H c #000080800000 s disabledfg", }; #endif -static Ttk_StateTable checkbutton_states[] = -{ +static Ttk_StateTable checkbutton_states[] = { { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED }, { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED }, { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED }, { 3, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 }, { 0, 0, 0 } }; + static const char *const checkbutton_pixels[] = { "AAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAAB", "AEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECB", @@ -424,15 +415,13 @@ static const char *const checkbutton_pixels[] = { "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", }; -static IndicatorSpec checkbutton_spec = -{ +static IndicatorSpec checkbutton_spec = { 13, 13, 4, /* width, height, nimages */ checkbutton_pixels, checkbutton_states }; -static Ttk_StateTable radiobutton_states[] = -{ +static Ttk_StateTable radiobutton_states[] = { { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED }, { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED }, { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED }, @@ -443,7 +432,7 @@ static Ttk_StateTable radiobutton_states[] = static const char *const radiobutton_pixels[] = { "FFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFF", "FFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFF", - "FAEEDDDDECBFFFAEEDDDDECBFFFAEEFFFFECBFFFAEEFFFFECBFF", + "FAEEDDDDEEBFFFAEEDDDDEEBFFFAEEFFFFEEBFFFAEEFFFFEEBFF", "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF", "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF", "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF", @@ -456,35 +445,35 @@ static const char *const radiobutton_pixels[] = { "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", }; -static IndicatorSpec radiobutton_spec = -{ +static IndicatorSpec radiobutton_spec = { 13, 13, 4, /* width, height, nimages */ radiobutton_pixels, radiobutton_states }; -typedef struct -{ +typedef struct { Tcl_Obj *backgroundObj; Tcl_Obj *foregroundObj; Tcl_Obj *colorObj; Tcl_Obj *lightColorObj; Tcl_Obj *shadeColorObj; + Tcl_Obj *borderColorObj; Tcl_Obj *marginObj; } IndicatorElement; -static Ttk_ElementOptionSpec IndicatorElementOptions[] = -{ - { "-background", TK_OPTION_BORDER, +static Ttk_ElementOptionSpec IndicatorElementOptions[] = { + { "-background", TK_OPTION_COLOR, Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND }, { "-foreground", TK_OPTION_COLOR, Tk_Offset(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND }, - { "-indicatorcolor", TK_OPTION_BORDER, + { "-indicatorcolor", TK_OPTION_COLOR, Tk_Offset(IndicatorElement,colorObj), "#FFFFFF" }, { "-lightcolor", TK_OPTION_COLOR, Tk_Offset(IndicatorElement,lightColorObj), "#DDDDDD" }, { "-shadecolor", TK_OPTION_COLOR, Tk_Offset(IndicatorElement,shadeColorObj), "#888888" }, + { "-bordercolor", TK_OPTION_COLOR, + Tk_Offset(IndicatorElement,borderColorObj), "black" }, { "-indicatormargin", TK_OPTION_STRING, Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" }, {NULL} @@ -509,9 +498,8 @@ static void IndicatorElementDraw( IndicatorSpec *spec = clientData; IndicatorElement *indicator = elementRecord; Display *display = Tk_Display(tkwin); - Tk_3DBorder bgBorder; Ttk_Padding padding; - XColor *fgColor, *bgColor, *lightColor, *shadeColor, *selectColor; + XColor *fgColor, *frameColor, *lightColor, *shadeColor, *indicatorColor, *borderColor; int index, ix, iy; XGCValues gcValues; @@ -540,20 +528,20 @@ static void IndicatorElementDraw( * but Tk doesn't provide easy access to these in the public API.) */ fgColor = Tk_GetColorFromObj(tkwin, indicator->foregroundObj); - bgBorder = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj); - bgColor = Tk_3DBorderColor(bgBorder); + frameColor = Tk_GetColorFromObj(tkwin, indicator->backgroundObj); lightColor = Tk_GetColorFromObj(tkwin, indicator->lightColorObj); shadeColor = Tk_GetColorFromObj(tkwin, indicator->shadeColorObj); - selectColor = Tk_GetColorFromObj(tkwin, indicator->colorObj); - - imgColors[0 /*A*/] = bgColor->pixel; - imgColors[1 /*B*/] = bgColor->pixel; - imgColors[2 /*C*/] = lightColor->pixel; - imgColors[3 /*D*/] = selectColor->pixel; - imgColors[4 /*E*/] = shadeColor->pixel; - imgColors[5 /*F*/] = bgColor->pixel; + indicatorColor = Tk_GetColorFromObj(tkwin, indicator->colorObj); + borderColor = Tk_GetColorFromObj(tkwin, indicator->borderColorObj); + + imgColors[0 /*A*/] = shadeColor->pixel; + imgColors[1 /*B*/] = indicatorColor->pixel; + imgColors[2 /*C*/] = frameColor->pixel; + imgColors[3 /*D*/] = indicatorColor->pixel; + imgColors[4 /*E*/] = borderColor->pixel; + imgColors[5 /*F*/] = frameColor->pixel; imgColors[6 /*G*/] = fgColor->pixel; - imgColors[7 /*H*/] = selectColor->pixel; + imgColors[7 /*H*/] = fgColor->pixel; /* * Create a scratch buffer to store the image: @@ -591,8 +579,7 @@ static void IndicatorElementDraw( XDestroyImage(img); } -static Ttk_ElementSpec IndicatorElementSpec = -{ +static Ttk_ElementSpec IndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(IndicatorElement), IndicatorElementOptions, @@ -608,8 +595,7 @@ static Ttk_ElementSpec IndicatorElementSpec = */ static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT }; -typedef struct -{ +typedef struct { Tcl_Obj *sizeObj; Tcl_Obj *borderObj; Tcl_Obj *borderColorObj; /* Extra color for borders */ @@ -617,8 +603,7 @@ typedef struct Tcl_Obj *colorObj; /* Arrow color */ } ArrowElement; -static Ttk_ElementOptionSpec ArrowElementOptions[] = -{ +static Ttk_ElementOptionSpec ArrowElementOptions[] = { { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) }, { "-background", TK_OPTION_BORDER, @@ -676,8 +661,7 @@ static void ArrowElementDraw( Ttk_PadBox(b, ArrowPadding), direction); } -static Ttk_ElementSpec ArrowElementSpec = -{ +static Ttk_ElementSpec ArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(ArrowElement), ArrowElementOptions, @@ -703,8 +687,7 @@ static const char *directionStrings[] = { /* See also: button.c */ }; enum { POST_ABOVE, POST_BELOW, POST_LEFT, POST_RIGHT, POST_FLUSH }; -static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = -{ +static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = { { "-direction", TK_OPTION_STRING, Tk_Offset(MenubuttonArrowElement,directionObj), "below" }, { "-arrowsize", TK_OPTION_PIXELS, @@ -759,8 +742,7 @@ static void MenubuttonArrowElementDraw( TtkFillArrow(Tk_Display(tkwin), d, gc, b, arrowDirection); } -static Ttk_ElementSpec MenubuttonArrowElementSpec = -{ +static Ttk_ElementSpec MenubuttonArrowElementSpec = { TK_STYLE_VERSION_2, sizeof(MenubuttonArrowElement), MenubuttonArrowElementOptions, @@ -781,8 +763,7 @@ static Ttk_ElementSpec MenubuttonArrowElementSpec = * */ -typedef struct -{ +typedef struct { Tcl_Obj *colorObj; Tcl_Obj *borderWidthObj; Tcl_Obj *reliefObj; @@ -790,8 +771,7 @@ typedef struct Tcl_Obj *orientObj; } TroughElement; -static Ttk_ElementOptionSpec TroughElementOptions[] = -{ +static Ttk_ElementOptionSpec TroughElementOptions[] = { { "-orient", TK_OPTION_ANY, Tk_Offset(TroughElement, orientObj), "horizontal" }, { "-troughborderwidth", TK_OPTION_PIXELS, @@ -848,8 +828,7 @@ static void TroughElementDraw( borderWidth, relief); } -static Ttk_ElementSpec TroughElementSpec = -{ +static Ttk_ElementSpec TroughElementSpec = { TK_STYLE_VERSION_2, sizeof(TroughElement), TroughElementOptions, @@ -862,8 +841,7 @@ static Ttk_ElementSpec TroughElementSpec = * +++ Thumb element. */ -typedef struct -{ +typedef struct { Tcl_Obj *sizeObj; Tcl_Obj *firstObj; Tcl_Obj *lastObj; @@ -873,8 +851,7 @@ typedef struct Tcl_Obj *orientObj; } ThumbElement; -static Ttk_ElementOptionSpec ThumbElementOptions[] = -{ +static Ttk_ElementOptionSpec ThumbElementOptions[] = { { "-width", TK_OPTION_PIXELS, Tk_Offset(ThumbElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) }, { "-background", TK_OPTION_BORDER, Tk_Offset(ThumbElement,borderObj), @@ -928,8 +905,7 @@ static void ThumbElementDraw( DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); } -static Ttk_ElementSpec ThumbElementSpec = -{ +static Ttk_ElementSpec ThumbElementSpec = { TK_STYLE_VERSION_2, sizeof(ThumbElement), ThumbElementOptions, @@ -948,8 +924,7 @@ static Ttk_ElementSpec ThumbElementSpec = * */ -typedef struct -{ +typedef struct { Tcl_Obj *lengthObj; /* Long axis dimension */ Tcl_Obj *thicknessObj; /* Short axis dimension */ Tcl_Obj *reliefObj; /* Relief for this object */ @@ -959,8 +934,7 @@ typedef struct Tcl_Obj *orientObj; /* Orientation of overall slider */ } SliderElement; -static Ttk_ElementOptionSpec SliderElementOptions[] = -{ +static Ttk_ElementOptionSpec SliderElementOptions[] = { { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj), "15" }, { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj), @@ -1021,8 +995,7 @@ static void SliderElementDraw( DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief); } -static Ttk_ElementSpec SliderElementSpec = -{ +static Ttk_ElementSpec SliderElementSpec = { TK_STYLE_VERSION_2, sizeof(SliderElement), SliderElementOptions, @@ -1037,15 +1010,13 @@ static Ttk_ElementSpec SliderElementSpec = #define TTK_STATE_OPEN TTK_STATE_USER1 /* XREF: treeview.c */ #define TTK_STATE_LEAF TTK_STATE_USER2 -typedef struct -{ +typedef struct { Tcl_Obj *colorObj; Tcl_Obj *marginObj; Tcl_Obj *diameterObj; } TreeitemIndicator; -static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = -{ +static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = { { "-foreground", TK_OPTION_COLOR, Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND }, { "-diameter", TK_OPTION_PIXELS, @@ -1101,8 +1072,7 @@ static void TreeitemIndicatorDraw( } } -static Ttk_ElementSpec TreeitemIndicatorElementSpec = -{ +static Ttk_ElementSpec TreeitemIndicatorElementSpec = { TK_STYLE_VERSION_2, sizeof(TreeitemIndicator), TreeitemIndicatorOptions, @@ -1110,9 +1080,6 @@ static Ttk_ElementSpec TreeitemIndicatorElementSpec = TreeitemIndicatorDraw }; - - - /*------------------------------------------------------------------------ * TtkAltTheme_Init -- * Install alternate theme. diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl index 20f6c53..5ed90eb 100644 --- a/library/ttk/altTheme.tcl +++ b/library/ttk/altTheme.tcl @@ -1,5 +1,5 @@ # -# $Id: altTheme.tcl,v 1.9 2008/11/29 00:43:48 patthoyts Exp $ +# $Id: altTheme.tcl,v 1.10 2008/12/31 21:25:34 jenglish Exp $ # # Ttk widget set: Alternate theme # @@ -11,6 +11,7 @@ namespace eval ttk::theme::alt { -frame "#d9d9d9" -window "#ffffff" -darker "#c3c3c3" + -border "#414141" -activebg "#ececec" -disabledfg "#a3a3a3" -selectbg "#4a6984" @@ -23,6 +24,7 @@ namespace eval ttk::theme::alt { -background $colors(-frame) \ -foreground black \ -troughcolor $colors(-darker) \ + -bordercolor $colors(-border) \ -selectbackground $colors(-selectbg) \ -selectforeground $colors(-selectfg) \ -font TkDefaultFont \ -- cgit v0.12