summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsaba <csaba>2023-08-22 16:18:28 (GMT)
committercsaba <csaba>2023-08-22 16:18:28 (GMT)
commite79708b4b12f47f5976ed3ddb83bc8d3f7aed5fc (patch)
tree9d8c345535d273b151440515a59079eee43e3c0d
parent71b4260f05241ba1855c18ab3a0d240acf443fe1 (diff)
downloadtk-e79708b4b12f47f5976ed3ddb83bc8d3f7aed5fc.zip
tk-e79708b4b12f47f5976ed3ddb83bc8d3f7aed5fc.tar.gz
tk-e79708b4b12f47f5976ed3ddb83bc8d3f7aed5fc.tar.bz2
Improvements in the the built-in themes. See ticket [6ec00a7dc9] for details.
-rw-r--r--generic/ttk/ttkClamTheme.c14
-rw-r--r--generic/ttk/ttkClassicTheme.c116
-rw-r--r--generic/ttk/ttkDefaultTheme.c153
-rw-r--r--generic/ttk/ttkElements.c461
-rw-r--r--library/ttk/altTheme.tcl12
-rw-r--r--library/ttk/classicTheme.tcl6
-rw-r--r--library/ttk/defaults.tcl45
7 files changed, 485 insertions, 322 deletions
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index ed5ab18..7d38d0d 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -405,8 +405,10 @@ static void IndicatorElementDraw(
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
- double scalingLevel = TkScalingLevel(tkwin);
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int width = spec->width * scalingLevel;
+ int height = spec->height * scalingLevel;
char upperBdColorStr[7], lowerBdColorStr[7], bgColorStr[7], fgColorStr[7];
unsigned int selected = (state & TTK_STATE_SELECTED);
@@ -431,8 +433,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width * scalingLevel
- || Tk_Height(tkwin) < b.y + spec->height * scalingLevel)
+ || Tk_Width(tkwin) < b.x + width
+ || Tk_Height(tkwin) < b.y + height)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -526,8 +528,7 @@ static void IndicatorElementDraw(
/*
* Display the image
*/
- Tk_RedrawImage(img, 0, 0, spec->width * scalingLevel,
- spec->height * scalingLevel, d, b.x, b.y);
+ Tk_RedrawImage(img, 0, 0, width, height, d, b.x, b.y);
Tk_FreeImage(img);
}
@@ -777,7 +778,6 @@ static void SliderElementSize(
*heightPtr = thickness;
*widthPtr = length;
}
-
}
static const Ttk_ElementSpec SliderElementSpec = {
@@ -1073,6 +1073,8 @@ TtkClamTheme_Init(Tcl_Interp *interp)
theme, "leftarrow", &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp,
theme, "rightarrow", &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
+ Ttk_RegisterElement(interp,
+ theme, "arrow", &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Checkbutton.indicator",
&IndicatorElementSpec, (void *)&checkbutton_spec);
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index 7064fb8..bd02464 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -380,7 +380,7 @@ static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
{ "-indicatorrelief", TK_OPTION_RELIEF,
offsetof(MenuIndicatorElement,reliefObj),"raised" },
{ "-indicatormargin", TK_OPTION_STRING,
- offsetof(MenuIndicatorElement,marginObj), "5 0" },
+ offsetof(MenuIndicatorElement,marginObj), "5 0" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -482,7 +482,6 @@ static void ArrowElementDraw(
Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
-
/*
* @@@ There are off-by-one pixel errors in the way these are drawn;
* @@@ need to take a look at Tk_Fill3DPolygon and X11 to find the
@@ -524,6 +523,116 @@ static const Ttk_ElementSpec ArrowElementSpec =
ArrowElementDraw
};
+/*------------------------------------------------------------------------
+ * +++ Slider element.
+ *
+ * This is the moving part of the scale widget. Drawn as a raised box.
+ */
+
+typedef struct {
+ Tcl_Obj *orientObj; /* orientation of overall slider */
+ Tcl_Obj *lengthObj; /* slider length */
+ Tcl_Obj *thicknessObj; /* slider thickness */
+ Tcl_Obj *reliefObj; /* the relief for this object */
+ Tcl_Obj *borderObj; /* the background color */
+ Tcl_Obj *borderWidthObj; /* the size of the border */
+} SliderElement;
+
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
+ "30" },
+ { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
+ "15" },
+ { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
+ "raised" },
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
+ DEFAULT_BORDERWIDTH },
+ { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
+ DEFAULT_BACKGROUND },
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
+ "horizontal" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+static void SliderElementSize(
+ void *dummy, void *elementRecord, Tk_Window tkwin,
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+{
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ int length, thickness;
+ (void)dummy;
+ (void)paddingPtr;
+
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
+
+ switch (orient) {
+ case TTK_ORIENT_VERTICAL:
+ *widthPtr = thickness;
+ *heightPtr = length;
+ break;
+
+ case TTK_ORIENT_HORIZONTAL:
+ *widthPtr = length;
+ *heightPtr = thickness;
+ break;
+ }
+}
+
+static void SliderElementDraw(
+ void *dummy, void *elementRecord, Tk_Window tkwin,
+ Drawable d, Ttk_Box b, unsigned int state)
+{
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Tk_3DBorder border = NULL;
+ int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)state;
+
+ border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
+ Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
+
+ Tk_Fill3DRectangle(tkwin, d, border,
+ b.x, b.y, b.width, b.height,
+ borderWidth, relief);
+
+ if (relief != TK_RELIEF_FLAT) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
+ if (b.width > 4) {
+ b.x += b.width/2;
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
+ b.x-1, b.y+borderWidth, b.x-1, b.y+b.height-borderWidth);
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
+ b.x, b.y+borderWidth, b.x, b.y+b.height-borderWidth);
+ }
+ } else {
+ if (b.height > 4) {
+ b.y += b.height/2;
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
+ b.x+borderWidth, b.y-1, b.x+b.width-borderWidth, b.y-1);
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
+ b.x+borderWidth, b.y, b.x+b.width-borderWidth, b.y);
+ }
+ }
+ }
+}
+
+static const Ttk_ElementSpec SliderElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(SliderElement),
+ SliderElementOptions,
+ SliderElementSize,
+ SliderElementDraw
+};
/*------------------------------------------------------------------------
* +++ Sash element (for ttk::panedwindow)
@@ -750,6 +859,9 @@ MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "arrow",
&ArrowElementSpec, INT2PTR(ARROW_UP));
+ Ttk_RegisterElement(interp, theme, "slider",
+ &SliderElementSpec, NULL);
+
Ttk_RegisterElement(interp, theme, "hsash",
&SashElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vsash",
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index 03da8cf..536e2a1 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -5,7 +5,7 @@
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#if defined(_WIN32)
static const int WIN32_XDRAWLINE_HACK = 1;
@@ -326,6 +326,8 @@ static const Ttk_ElementSpec BorderElementSpec = {
typedef struct {
Tcl_Obj *borderObj;
Tcl_Obj *borderColorObj; /* Extra border color */
+ Tcl_Obj *showFocusObj;
+ Tcl_Obj *focusColorObj;
} FieldElement;
static const Ttk_ElementOptionSpec FieldElementOptions[] = {
@@ -333,6 +335,10 @@ static const Ttk_ElementOptionSpec FieldElementOptions[] = {
"white" },
{ "-bordercolor",TK_OPTION_COLOR, offsetof(FieldElement,borderColorObj),
"black" },
+ { "-showfocus", TK_OPTION_BOOLEAN, offsetof(FieldElement,showFocusObj),
+ "0" },
+ { "-focuscolor", TK_OPTION_COLOR, offsetof(FieldElement,focusColorObj),
+ "#4a6984" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -356,12 +362,27 @@ static void FieldElementDraw(
FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, field->borderColorObj);
+ int showFocus = 0;
(void)dummy;
- (void)state;
- Tk_Fill3DRectangle(
- tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_SUNKEN);
- DrawFieldBorder(tkwin, d, border, borderColor, b);
+ Tcl_GetBooleanFromObj(NULL, field->showFocusObj, &showFocus);
+
+ if (showFocus && (state & TTK_STATE_FOCUS)) {
+ Display *disp = Tk_Display(tkwin);
+
+ XColor *focusColor = Tk_GetColorFromObj(tkwin, field->focusColorObj);
+ GC gcFocus = Tk_GCForColor(focusColor, d);
+ XDrawRectangle(disp, d, gcFocus, b.x, b.y, b.width-1, b.height-1);
+ b.x += 1; b.y += 1; b.width -= 2; b.height -= 2;
+ XDrawRectangle(disp, d, gcFocus, b.x, b.y, b.width-1, b.height-1);
+
+ GC gcBg = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
+ XFillRectangle(disp, d, gcBg, b.x+1, b.y+1, b.width-2, b.height-2);
+ } else {
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
+ 0, TK_RELIEF_SUNKEN);
+ DrawFieldBorder(tkwin, d, border, borderColor, b);
+ }
}
static const Ttk_ElementSpec FieldElementSpec = {
@@ -518,8 +539,10 @@ static void IndicatorElementDraw(
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
- double scalingLevel = TkScalingLevel(tkwin);
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int width = spec->width * scalingLevel;
+ int height = spec->height * scalingLevel;
char bgColorStr[7], fgColorStr[7], indicatorColorStr[7],
shadeColorStr[7], borderColorStr[7];
@@ -546,8 +569,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width * scalingLevel
- || Tk_Height(tkwin) < b.y + spec->height * scalingLevel)
+ || Tk_Width(tkwin) < b.x + width
+ || Tk_Height(tkwin) < b.y + height)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -649,8 +672,7 @@ static void IndicatorElementDraw(
/*
* Display the image
*/
- Tk_RedrawImage(img, 0, 0, spec->width * scalingLevel,
- spec->height * scalingLevel, d, b.x, b.y);
+ Tk_RedrawImage(img, 0, 0, width, height, d, b.x, b.y);
Tk_FreeImage(img);
}
@@ -671,23 +693,23 @@ static const Ttk_ElementSpec IndicatorElementSpec = {
typedef struct {
Tcl_Obj *sizeObj;
+ Tcl_Obj *colorObj; /* Arrow color */
Tcl_Obj *borderObj;
Tcl_Obj *borderColorObj; /* Extra color for borders */
Tcl_Obj *reliefObj;
- Tcl_Obj *colorObj; /* Arrow color */
} ArrowElement;
static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-arrowsize", TK_OPTION_PIXELS,
offsetof(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
+ { "-arrowcolor", TK_OPTION_COLOR,
+ offsetof(ArrowElement,colorObj), "black"},
{ "-background", TK_OPTION_BORDER,
offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-bordercolor", TK_OPTION_COLOR,
offsetof(ArrowElement,borderColorObj), "black" },
{ "-relief", TK_OPTION_RELIEF,
- offsetof(ArrowElement,reliefObj),"raised"},
- { "-arrowcolor", TK_OPTION_COLOR,
- offsetof(ArrowElement,colorObj),"black"},
+ offsetof(ArrowElement,reliefObj), "raised"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -805,7 +827,7 @@ static const Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
offsetof(MenubuttonArrowElement,directionObj), "below" },
{ "-arrowsize", TK_OPTION_PIXELS,
offsetof(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
- { "-arrowcolor",TK_OPTION_COLOR,
+ { "-arrowcolor", TK_OPTION_COLOR,
offsetof(MenubuttonArrowElement,colorObj), "black"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -884,98 +906,6 @@ static const Ttk_ElementSpec MenubuttonArrowElementSpec = {
MenubuttonArrowElementDraw
};
-/*----------------------------------------------------------------------
- * +++ Trough element
- *
- * Used in scrollbars and the scale.
- *
- * The -groovewidth option can be used to set the size of the short axis
- * for the drawn area. This will not affect the geometry, but can be used
- * to draw a thin centered trough inside the packet alloted. This is used
- * to show a win32-style scale widget. Use -1 or a large number to use the
- * full area (default).
- *
- */
-
-typedef struct {
- Tcl_Obj *colorObj;
- Tcl_Obj *borderWidthObj;
- Tcl_Obj *reliefObj;
- Tcl_Obj *grooveWidthObj;
- Tcl_Obj *orientObj;
-} TroughElement;
-
-static const Ttk_ElementOptionSpec TroughElementOptions[] = {
- { "-orient", TK_OPTION_ANY,
- offsetof(TroughElement, orientObj), "horizontal" },
- { "-troughborderwidth", TK_OPTION_PIXELS,
- offsetof(TroughElement,borderWidthObj), "1" },
- { "-troughcolor", TK_OPTION_BORDER,
- offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
- { "-troughrelief",TK_OPTION_RELIEF,
- offsetof(TroughElement,reliefObj), "sunken" },
- { "-groovewidth", TK_OPTION_PIXELS,
- offsetof(TroughElement,grooveWidthObj), "-1" },
- { NULL, TK_OPTION_BOOLEAN, 0, NULL }
-};
-
-static void TroughElementSize(
- void *dummy, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
-{
- TroughElement *troughPtr = (TroughElement *)elementRecord;
- int borderWidth = 2, grooveWidth = 0;
- (void)dummy;
- (void)widthPtr;
- (void)heightPtr;
-
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
-
- if (grooveWidth <= 0) {
- *paddingPtr = Ttk_UniformPadding((short)borderWidth);
- }
-}
-
-static void TroughElementDraw(
- void *dummy, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
-{
- TroughElement *troughPtr = (TroughElement *)elementRecord;
- Tk_3DBorder border = NULL;
- int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1;
- Ttk_Orient orient;
- (void)dummy;
- (void)state;
-
- border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
- TtkGetOrientFromObj(NULL, troughPtr->orientObj, &orient);
- Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &groove);
-
- if (groove != -1 && groove < b.height && groove < b.width) {
- if (orient == TTK_ORIENT_HORIZONTAL) {
- b.y = b.y + b.height/2 - groove/2;
- b.height = groove;
- } else {
- b.x = b.x + b.width/2 - groove/2;
- b.width = groove;
- }
- }
-
- Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
- borderWidth, relief);
-}
-
-static const Ttk_ElementSpec TroughElementSpec = {
- TK_STYLE_VERSION_2,
- sizeof(TroughElement),
- TroughElementOptions,
- TroughElementSize,
- TroughElementDraw
-};
-
/*
*----------------------------------------------------------------------
* +++ Thumb element.
@@ -1071,7 +1001,6 @@ static const Ttk_ElementSpec ThumbElementSpec = {
*/
typedef struct {
- Tcl_Obj *lengthObj; /* Long axis dimension */
Tcl_Obj *thicknessObj; /* Short axis dimension */
Tcl_Obj *reliefObj; /* Relief for this object */
Tcl_Obj *borderObj; /* Border / background color */
@@ -1081,8 +1010,6 @@ typedef struct {
} SliderElement;
static const Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
- "11.25p" },
{ "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
"15" },
{ "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
@@ -1091,7 +1018,7 @@ static const Ttk_ElementOptionSpec SliderElementOptions[] = {
STRINGIFY(BORDERWIDTH) },
{ "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, offsetof(ThumbElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(SliderElement,borderColorObj),
"black" },
{ "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
@@ -1104,13 +1031,12 @@ static void SliderElementSize(
{
SliderElement *slider = (SliderElement *)elementRecord;
Ttk_Orient orient;
- int length, thickness, borderWidth;
+ int thickness, borderWidth;
(void)dummy;
(void)paddingPtr;
TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
switch (orient) {
@@ -1259,7 +1185,6 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "field", &FieldElementSpec, NULL);
- Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index cc424e7..c899195 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -186,6 +186,7 @@ typedef struct {
Tcl_Obj *borderObj;
Tcl_Obj *borderWidthObj;
Tcl_Obj *showFocusObj;
+ Tcl_Obj *focusColorObj;
} FieldElement;
static const Ttk_ElementOptionSpec FieldElementOptions[] = {
@@ -195,6 +196,8 @@ static const Ttk_ElementOptionSpec FieldElementOptions[] = {
offsetof(FieldElement,borderWidthObj), "2" },
{ "-showfocus", TK_OPTION_BOOLEAN,
offsetof(FieldElement,showFocusObj), "0" },
+ { "-focuscolor", TK_OPTION_COLOR,
+ offsetof(FieldElement,focusColorObj), "#4a6984" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -204,11 +207,16 @@ static void FieldElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
FieldElement *field = (FieldElement *)elementRecord;
- int borderWidth = 2;
+ int borderWidth = 2, showFocus = 0;
(void)dummy;
(void)widthPtr;
(void)heightPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
+ Tcl_GetBooleanFromObj(NULL, field->showFocusObj, &showFocus);
+ if (showFocus && borderWidth < 2) {
+ borderWidth += (2 - borderWidth);
+ }
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
@@ -222,19 +230,18 @@ static void FieldElementDraw(
(void)dummy;
Tcl_GetBooleanFromObj(NULL, field->showFocusObj, &showFocus);
+
if (showFocus && (state & TTK_STATE_FOCUS)) {
- GC gcOwnBg = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
+ Display *disp = Tk_Display(tkwin);
- Ttk_Theme theme = Ttk_GetCurrentTheme(Tk_Interp(tkwin));
- Ttk_Style rootStyle = Ttk_GetStyle(theme, ".");
- Tcl_Obj *selBorderObj = Ttk_QueryStyle(rootStyle, NULL, NULL,
- "-selectbackground", 0);
- Tk_3DBorder selBorder = Tk_Get3DBorderFromObj(tkwin, selBorderObj);
- GC gcSelBg = Tk_3DBorderGC(tkwin, selBorder, TK_3D_FLAT_GC);
+ XColor *focusColor = Tk_GetColorFromObj(tkwin, field->focusColorObj);
+ GC gcFocus = Tk_GCForColor(focusColor, d);
+ XDrawRectangle(disp, d, gcFocus, b.x, b.y, b.width-1, b.height-1);
+ b.x += 1; b.y += 1; b.width -= 2; b.height -= 2;
+ XDrawRectangle(disp, d, gcFocus, b.x, b.y, b.width-1, b.height-1);
- Display *disp = Tk_Display(tkwin);
- XFillRectangle(disp, d, gcOwnBg, b.x, b.y, b.width-1, b.height-1);
- XDrawRectangle(disp, d, gcSelBg, b.x, b.y, b.width-1, b.height-1);
+ GC gcBg = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
+ XFillRectangle(disp, d, gcBg, b.x+1, b.y+1, b.width-2, b.height-2);
} else {
int borderWidth = 2;
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
@@ -682,8 +689,10 @@ static void IndicatorElementDraw(
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
- double scalingLevel = TkScalingLevel(tkwin);
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int width = spec->width * scalingLevel;
+ int height = spec->height * scalingLevel;
char bgColorStr[7], fgColorStr[7], borderColorStr[7];
unsigned int selected = (state & TTK_STATE_SELECTED);
@@ -709,8 +718,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width * scalingLevel
- || Tk_Height(tkwin) < b.y + spec->height * scalingLevel)
+ || Tk_Width(tkwin) < b.x + width
+ || Tk_Height(tkwin) < b.y + height)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -808,8 +817,7 @@ static void IndicatorElementDraw(
/*
* Display the image
*/
- Tk_RedrawImage(img, 0, 0, spec->width * scalingLevel,
- spec->height * scalingLevel, d, b.x, b.y);
+ Tk_RedrawImage(img, 0, 0, width, height, d, b.x, b.y);
Tk_FreeImage(img);
}
@@ -821,76 +829,6 @@ static const Ttk_ElementSpec IndicatorElementSpec = {
IndicatorElementDraw
};
-/*
- *----------------------------------------------------------------------
- * +++ Menubutton indicators.
- *
- * These aren't functional like radio/check indicators,
- * they're just affordability indicators.
- */
-
-#define MENUBUTTON_ARROW_SIZE 5
-
-typedef struct {
- Tcl_Obj *sizeObj;
- Tcl_Obj *colorObj;
- Tcl_Obj *paddingObj;
-} MenuIndicatorElement;
-
-static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
- { "-arrowsize", TK_OPTION_PIXELS,
- offsetof(MenuIndicatorElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
- { "-arrowcolor",TK_OPTION_COLOR,
- offsetof(MenuIndicatorElement,colorObj), "black" },
- { "-arrowpadding",TK_OPTION_STRING,
- offsetof(MenuIndicatorElement,paddingObj), "3" },
- { NULL, TK_OPTION_BOOLEAN, 0, NULL }
-};
-
-static void MenuIndicatorElementSize(
- void *dummy, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
-{
- MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
- Ttk_Padding margins;
- int size = MENUBUTTON_ARROW_SIZE;
- (void)dummy;
- (void)paddingPtr;
-
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
- TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(margins);
- *heightPtr += Ttk_PaddingHeight(margins);
-}
-
-static void MenuIndicatorElementDraw(
- void *dummy, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
-{
- MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
- XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
- GC gc = Tk_GCForColor(arrowColor, d);
- int size = MENUBUTTON_ARROW_SIZE;
- int width, height;
- (void)dummy;
- (void)state;
-
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
-
- TtkArrowSize(size, ARROW_DOWN, &width, &height);
- b = Ttk_StickBox(b, width, height, 0);
- TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
-}
-
-static const Ttk_ElementSpec MenuIndicatorElementSpec = {
- TK_STYLE_VERSION_2,
- sizeof(MenuIndicatorElement),
- MenuIndicatorElementOptions,
- MenuIndicatorElementSize,
- MenuIndicatorElementDraw
-};
-
/*----------------------------------------------------------------------
* +++ Arrow elements.
*
@@ -899,24 +837,24 @@ static const Ttk_ElementSpec MenuIndicatorElementSpec = {
*/
typedef struct {
+ Tcl_Obj *sizeObj;
+ Tcl_Obj *colorObj;
Tcl_Obj *borderObj;
Tcl_Obj *borderWidthObj;
Tcl_Obj *reliefObj;
- Tcl_Obj *sizeObj;
- Tcl_Obj *colorObj;
} ArrowElement;
static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
+ { "-arrowsize", TK_OPTION_PIXELS,
+ offsetof(ArrowElement,sizeObj), "14" },
+ { "-arrowcolor", TK_OPTION_COLOR,
+ offsetof(ArrowElement,colorObj), "black"},
{ "-background", TK_OPTION_BORDER,
offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
- { "-relief",TK_OPTION_RELIEF,
- offsetof(ArrowElement,reliefObj),"raised"},
{ "-borderwidth", TK_OPTION_PIXELS,
offsetof(ArrowElement,borderWidthObj), "1" },
- { "-arrowcolor",TK_OPTION_COLOR,
- offsetof(ArrowElement,colorObj),"black"},
- { "-arrowsize", TK_OPTION_PIXELS,
- offsetof(ArrowElement,sizeObj), "14" },
+ { "-relief", TK_OPTION_RELIEF,
+ offsetof(ArrowElement,reliefObj), "raised"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1005,25 +943,107 @@ static const Ttk_ElementSpec ArrowElementSpec = {
ArrowElementDraw
};
-/*----------------------------------------------------------------------
+/*
+ *----------------------------------------------------------------------
+ * +++ Menubutton indicators.
+ *
+ * These aren't functional like radio/check indicators,
+ * they're just affordability indicators.
+ */
+
+#define MENUBUTTON_ARROW_SIZE 5
+
+typedef struct {
+ Tcl_Obj *sizeObj;
+ Tcl_Obj *colorObj;
+ Tcl_Obj *paddingObj;
+} MenuIndicatorElement;
+
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
+ { "-arrowsize", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
+ { "-arrowcolor", TK_OPTION_COLOR,
+ offsetof(MenuIndicatorElement,colorObj), "black" },
+ { "-arrowpadding", TK_OPTION_STRING,
+ offsetof(MenuIndicatorElement,paddingObj), "3" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+static void MenuIndicatorElementSize(
+ void *dummy, void *elementRecord, Tk_Window tkwin,
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+{
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
+ Ttk_Padding margins;
+ int size = MENUBUTTON_ARROW_SIZE;
+ (void)dummy;
+ (void)paddingPtr;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
+ TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
+ *widthPtr += Ttk_PaddingWidth(margins);
+ *heightPtr += Ttk_PaddingHeight(margins);
+}
+
+static void MenuIndicatorElementDraw(
+ void *dummy, void *elementRecord, Tk_Window tkwin,
+ Drawable d, Ttk_Box b, unsigned int state)
+{
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
+ XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
+ GC gc = Tk_GCForColor(arrowColor, d);
+ int size = MENUBUTTON_ARROW_SIZE;
+ int width, height;
+ (void)dummy;
+ (void)state;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
+
+ TtkArrowSize(size, ARROW_DOWN, &width, &height);
+ b = Ttk_StickBox(b, width, height, 0);
+ TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
+}
+
+static const Ttk_ElementSpec MenuIndicatorElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(MenuIndicatorElement),
+ MenuIndicatorElementOptions,
+ MenuIndicatorElementSize,
+ MenuIndicatorElementDraw
+};
+
+/*
+ *----------------------------------------------------------------------
* +++ Trough element.
*
* Used in scrollbars and scales in place of "border".
+ *
+ * The -groovewidth option can be used to set the size of the short axis
+ * for the drawn area. This will not affect the geometry, but can be used
+ * to draw a thin centered trough inside the packet alloted. Use -1 or a
+ * large number to use the full area (default).
*/
typedef struct {
- Tcl_Obj *colorObj;
Tcl_Obj *borderWidthObj;
Tcl_Obj *reliefObj;
+ Tcl_Obj *colorObj;
+ Tcl_Obj *grooveWidthObj;
+ Tcl_Obj *orientObj;
} TroughElement;
static const Ttk_ElementOptionSpec TroughElementOptions[] = {
- { "-borderwidth", TK_OPTION_PIXELS,
- offsetof(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { "-troughcolor", TK_OPTION_BORDER,
- offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ { "-troughborderwidth", TK_OPTION_PIXELS,
+ offsetof(TroughElement,borderWidthObj), "1" },
{ "-troughrelief",TK_OPTION_RELIEF,
offsetof(TroughElement,reliefObj), "sunken" },
+ { "-troughcolor", TK_OPTION_BORDER,
+ offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ { "-groovewidth", TK_OPTION_PIXELS,
+ offsetof(TroughElement,grooveWidthObj), "-1" },
+ { "-orient", TK_OPTION_ANY,
+ offsetof(TroughElement, orientObj), "horizontal" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1032,28 +1052,51 @@ static void TroughElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
TroughElement *troughPtr = (TroughElement *)elementRecord;
- int borderWidth = 2;
+ int borderWidth = 1, grooveWidth = -1;
(void)dummy;
(void)widthPtr;
(void)heightPtr;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
- *paddingPtr = Ttk_UniformPadding((short)borderWidth);
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
+
+ if (grooveWidth <= 0) {
+ *paddingPtr = Ttk_UniformPadding((short)borderWidth);
+ }
}
+static Ttk_Box troughInnerBox;
+
static void TroughElementDraw(
void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
TroughElement *troughPtr = (TroughElement *)elementRecord;
- Tk_3DBorder border = NULL;
- int borderWidth = 2, relief = TK_RELIEF_SUNKEN;
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
+ int borderWidth = 1, grooveWidth = -1, relief = TK_RELIEF_SUNKEN;
+ Ttk_Orient orient;
(void)dummy;
(void)state;
- border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
- Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
+ Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
+ TtkGetOrientFromObj(NULL, troughPtr->orientObj, &orient);
+
+ if (grooveWidth > 0 && grooveWidth < b.height && grooveWidth < b.width) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
+ b.y += (b.height - grooveWidth) / 2;
+ b.height = grooveWidth;
+ } else {
+ b.x += (b.width - grooveWidth) / 2;
+ b.width = grooveWidth;
+ }
+
+ troughInnerBox.x = b.x + borderWidth;
+ troughInnerBox.y = b.y + borderWidth;
+ troughInnerBox.width = b.width - 2*borderWidth;
+ troughInnerBox.height = b.height - 2*borderWidth;
+ }
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
borderWidth, relief);
@@ -1146,29 +1189,31 @@ static const Ttk_ElementSpec ThumbElementSpec = {
*----------------------------------------------------------------------
* +++ Slider element.
*
- * This is the moving part of the scale widget. Drawn as a raised box.
+ * This is the moving part of the scale widget. Drawn as a filled circle.
*/
+#define SLIDER_DIM 16
+
+static const char sliderData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <circle cx='8' cy='8' r='7.5' fill='#ffffff' stroke='#c3c3c3'/>\n\
+ <circle cx='8' cy='8' r='4' fill='#4a6984'/>\n\
+ </svg>";
+
typedef struct {
- Tcl_Obj *orientObj; /* orientation of overall slider */
- Tcl_Obj *lengthObj; /* slider length */
- Tcl_Obj *thicknessObj; /* slider thickness */
- Tcl_Obj *reliefObj; /* the relief for this object */
- Tcl_Obj *borderObj; /* the background color */
- Tcl_Obj *borderWidthObj; /* the size of the border */
+ Tcl_Obj *innerColorObj;
+ Tcl_Obj *outerColorObj;
+ Tcl_Obj *borderColorObj;
+ Tcl_Obj *orientObj; /* Orientation of overall slider */
} SliderElement;
static const Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
- "30" },
- { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
- "15" },
- { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
- "raised" },
- { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
- DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
- DEFAULT_BACKGROUND },
+ { "-innercolor", TK_OPTION_COLOR, offsetof(SliderElement,innerColorObj),
+ "#4a6984" },
+ { "-outercolor", TK_OPTION_COLOR, offsetof(SliderElement,outerColorObj),
+ "#ffffff" },
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(SliderElement,borderColorObj),
+ "#c3c3c3" },
{ "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
@@ -1178,72 +1223,144 @@ static void SliderElementSize(
void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SliderElement *slider = (SliderElement *)elementRecord;
- Ttk_Orient orient;
- int length, thickness;
(void)dummy;
+ (void)elementRecord;
(void)paddingPtr;
- TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
-
- switch (orient) {
- case TTK_ORIENT_VERTICAL:
- *widthPtr = thickness;
- *heightPtr = length;
- break;
-
- case TTK_ORIENT_HORIZONTAL:
- *widthPtr = length;
- *heightPtr = thickness;
- break;
- }
+ double scalingLevel = TkScalingLevel(tkwin);
+ *widthPtr = *heightPtr = SLIDER_DIM * scalingLevel;
}
static void SliderElementDraw(
void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SliderElement *slider = (SliderElement *)elementRecord;
- Tk_3DBorder border = NULL;
- int relief = TK_RELIEF_RAISED, borderWidth = 2;
- Ttk_Orient orient;
(void)dummy;
(void)state;
- border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
+ double scalingLevel = TkScalingLevel(tkwin);
+ int dim = SLIDER_DIM * scalingLevel;
+
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ Display *disp = Tk_Display(tkwin);
+ XColor *innerColor = Tk_GetColorFromObj(tkwin, slider->innerColorObj);
+ XColor *outerColor = Tk_GetColorFromObj(tkwin, slider->outerColorObj);
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj);
+ GC gc = Tk_GCForColor(innerColor, d);
+
+ char innerColorStr[7], outerColorStr[7], borderColorStr[7];
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ char imgName[50];
+ Tk_Image img;
+
+ const char *svgDataPtr = sliderData;
+ size_t svgDataLen;
+ char *svgDataCopy;
+ char *innerColorPtr, *outerColorPtr, *borderColorPtr;
+ const char *cmdFmt;
+ size_t scriptSize;
+ char *script;
+ int code;
+
+ /*
+ * Sanity check
+ */
+ if ( b.x < 0
+ || b.y < 0
+ || Tk_Width(tkwin) < b.x + dim
+ || Tk_Height(tkwin) < b.y + dim)
+ {
+ /* Oops! Not enough room to display the image.
+ * Don't draw anything.
+ */
+ return;
+ }
+
+ /*
+ * Fill the thin trough area preceding the
+ * slider's center with the inner color
+ */
TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
- Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
+ switch (orient) {
+ case TTK_ORIENT_HORIZONTAL:
+ XFillRectangle(disp, d, gc, troughInnerBox.x, troughInnerBox.y,
+ b.x + dim/2 - 1, troughInnerBox.height);
+ break;
- Tk_Fill3DRectangle(tkwin, d, border,
- b.x, b.y, b.width, b.height,
- borderWidth, relief);
+ case TTK_ORIENT_VERTICAL:
+ XFillRectangle(disp, d, gc, troughInnerBox.x, troughInnerBox.y,
+ troughInnerBox.width, b.y + dim/2 - 1);
+ break;
+ }
- if (relief != TK_RELIEF_FLAT) {
- if (orient == TTK_ORIENT_HORIZONTAL) {
- if (b.width > 4) {
- b.x += b.width/2;
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
- b.x-1, b.y+borderWidth, b.x-1, b.y+b.height-borderWidth);
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
- b.x, b.y+borderWidth, b.x, b.y+b.height-borderWidth);
- }
- } else {
- if (b.height > 4) {
- b.y += b.height/2;
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
- b.x+borderWidth, b.y-1, b.x+b.width-borderWidth, b.y-1);
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
- b.x+borderWidth, b.y, b.x+b.width-borderWidth, b.y);
- }
+ /*
+ * Construct the color strings innerColorStr,
+ * outerColorStr, and borderColorStr
+ */
+ ColorToStr(innerColor, innerColorStr);
+ ColorToStr(outerColor, outerColorStr);
+ ColorToStr(borderColor, borderColorStr);
+
+ /*
+ * Check whether there is an SVG image for these color strings
+ */
+ snprintf(imgName, sizeof(imgName), "::tk::icons::slider_default_%s_%s_%s",
+ innerColorStr, outerColorStr, borderColorStr);
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
+ if (img == NULL) {
+ /*
+ * Copy the string pointed to by svgDataPtr to a newly allocated memory
+ * area svgDataCopy and assign the latter's address to svgDataPtr
+ */
+ svgDataLen = strlen(svgDataPtr);
+ svgDataCopy = (char *)attemptckalloc(svgDataLen + 1);
+ if (svgDataCopy == NULL) {
+ return;
+ }
+ memcpy(svgDataCopy, svgDataPtr, svgDataLen);
+ svgDataCopy[svgDataLen] = '\0';
+ svgDataPtr = svgDataCopy;
+
+ /*
+ * Update the colors within svgDataCopy
+ */
+ innerColorPtr = strstr(svgDataPtr, "4a6984");
+ outerColorPtr = strstr(svgDataPtr, "ffffff");
+ borderColorPtr = strstr(svgDataPtr, "c3c3c3");
+ assert(innerColorPtr);
+ assert(outerColorPtr);
+ assert(borderColorPtr);
+ memcpy(innerColorPtr, innerColorStr, 6);
+ memcpy(outerColorPtr, outerColorStr, 6);
+ memcpy(borderColorPtr, borderColorStr, 6);
+
+ /*
+ * Create an SVG photo image from svgDataCopy
+ */
+ cmdFmt = "image create photo %s -format $::tk::svgFmt -data {%s}";
+ scriptSize = strlen(cmdFmt) + strlen(imgName) + svgDataLen;
+ script = (char *)attemptckalloc(scriptSize);
+ if (script == NULL) {
+ ckfree(svgDataCopy);
+ return;
+ }
+ snprintf(script, scriptSize, cmdFmt, imgName, svgDataCopy);
+ ckfree(svgDataCopy);
+ code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
+ ckfree(script);
+ if (code != TCL_OK) {
+ Tcl_BackgroundException(interp, code);
+ return;
}
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
}
+
+ /*
+ * Display the image
+ */
+ Tk_RedrawImage(img, 0, 0, dim, dim, d, b.x, b.y);
+ Tk_FreeImage(img);
}
static const Ttk_ElementSpec SliderElementSpec = {
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl
index 2ef5134..b2cfea4 100644
--- a/library/ttk/altTheme.tcl
+++ b/library/ttk/altTheme.tcl
@@ -59,16 +59,16 @@ namespace eval ttk::theme::alt {
ttk::style configure TMenubutton \
-width -11 -padding 2.25p -arrowsize 3.75p -relief raised
- ttk::style configure TEntry -padding 1
+ ttk::style configure TEntry -padding 1 -showfocus 1 \
+ -focuscolor $colors(-selectbg)
ttk::style map TEntry -fieldbackground \
- [list readonly $colors(-frame) disabled $colors(-frame)]
+ [list readonly $colors(-frame) disabled $colors(-frame)]
ttk::style configure TCombobox -padding 1 -arrowsize 10.5p
ttk::style map TCombobox -fieldbackground \
- [list readonly $colors(-frame) disabled $colors(-frame)] \
- -arrowcolor [list disabled $colors(-disabledfg)]
- ttk::style configure ComboboxPopdownFrame \
- -relief solid -borderwidth 1
+ [list readonly $colors(-frame) disabled $colors(-frame)] \
+ -arrowcolor [list disabled $colors(-disabledfg)]
+ ttk::style configure ComboboxPopdownFrame -relief solid -borderwidth 1
ttk::style configure TSpinbox -arrowsize 7.5p -padding {1.5p 0 7.5p 0}
ttk::style map TSpinbox -fieldbackground \
diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl
index a482543..30c6c8b 100644
--- a/library/ttk/classicTheme.tcl
+++ b/library/ttk/classicTheme.tcl
@@ -86,15 +86,15 @@ namespace eval ttk::theme::classic {
ttk::style configure TLabelframe -borderwidth 2 -relief groove
ttk::style configure TScrollbar -relief raised \
- -arrowsize 11.25p -width 11.25p
+ -arrowsize 11.25p -width 11.25p -troughborderwidth 2
ttk::style map TScrollbar -relief {{pressed !disabled} sunken}
ttk::style configure TScale -sliderrelief raised \
- -sliderlength 22.5p -sliderthickness 11.25p
+ -sliderlength 22.5p -sliderthickness 11.25p -troughborderwidth 2
ttk::style map TScale -sliderrelief {{pressed !disabled} sunken}
ttk::style configure TProgressbar -background SteelBlue \
- -barsize 22.5p -thickness 11.25p
+ -barsize 22.5p -thickness 11.25p -troughborderwidth 2
ttk::style configure TNotebook.Tab \
-padding {3m 1m} \
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl
index 3f58bbb..3cc34b5 100644
--- a/library/ttk/defaults.tcl
+++ b/library/ttk/defaults.tcl
@@ -90,20 +90,18 @@ proc ttk::theme::default::reconfigureDefaultTheme {} {
-foreground $colors(-foreground) \
-troughcolor $colors(-darker) \
-font TkDefaultFont \
- -selectborderwidth 1 \
+ -selectborderwidth 0 \
-selectbackground $colors(-selectbg) \
-selectforeground $colors(-selectfg) \
-insertwidth 1 \
+ -insertcolor $colors(-foreground) \
+ -focuscolor $colors(-text) \
;
ttk::style map "." -background \
[list disabled $colors(-frame) active $colors(-activebg)]
ttk::style map "." -foreground \
- [list disabled $colors(-disabledfg) !disabled $colors(-text)]
- ttk::style map "." -insertcolor \
- [list !disabled $colors(-foreground)]
- ttk::style map "." -focuscolor \
- [list !disabled $colors(-text)]
+ [list disabled $colors(-disabledfg)]
ttk::style configure TButton \
-anchor center -padding 2.25p -width -9 \
@@ -131,37 +129,46 @@ proc ttk::theme::default::reconfigureDefaultTheme {} {
-padding {7.5p 2.25p}
ttk::style configure TEntry \
- -fieldbackground $colors(-window) -padding 1 -showfocus 1
+ -fieldbackground $colors(-window) -padding 1 \
+ -showfocus 1 -focuscolor $colors(-selectbg)
ttk::style map TEntry -fieldbackground \
[list readonly $colors(-frame) disabled $colors(-frame)]
- ttk::style configure TCombobox -arrowsize 9p -padding 1
+ ttk::style configure TCombobox \
+ -arrowsize 9p -arrowcolor $colors(-text) \
+ -fieldbackground $colors(-window) -padding 1
ttk::style map TCombobox -fieldbackground \
- [list readonly $colors(-frame) disabled $colors(-frame) !disabled $colors(-window)] \
- -arrowcolor [list disabled $colors(-disabledfg) !disabled $colors(-text)]
+ [list readonly $colors(-frame) disabled $colors(-frame)] \
+ -arrowcolor [list disabled $colors(-disabledfg)]
- ttk::style configure TSpinbox -arrowsize 7.5p -padding {1.5p 0 7.5p 0}
+ ttk::style configure TSpinbox \
+ -arrowsize 7.5p -arrowcolor $colors(-text) \
+ -fieldbackground $colors(-window) -padding {1.5p 0 7.5p 0}
ttk::style map TSpinbox -fieldbackground \
- [list readonly $colors(-frame) disabled $colors(-frame) !disabled $colors(-window)] \
- -arrowcolor [list disabled $colors(-disabledfg) !disabled $colors(-text)]
+ [list readonly $colors(-frame) disabled $colors(-frame)] \
+ -arrowcolor [list disabled $colors(-disabledfg)]
ttk::style configure TLabelframe \
-relief groove -borderwidth 2
ttk::style configure TScrollbar \
- -width 9p -arrowsize 9p
+ -width 9p -arrowsize 9p -arrowcolor $colors(-text)
ttk::style map TScrollbar \
- -arrowcolor [list disabled $colors(-disabledfg) !disabled $colors(-text)]
+ -arrowcolor [list disabled $colors(-disabledfg)]
ttk::style configure TScale \
- -sliderrelief raised \
- -sliderlength 22.5p \
- -sliderthickness 11.25p
+ -innercolor $colors(-selectbg) \
+ -outercolor $colors(-window) \
+ -bordercolor $colors(-darker) \
+ -groovewidth 3p
+ ttk::style map TScale \
+ -outercolor [list active $colors(-activebg)]
ttk::style configure TProgressbar \
-background $colors(-selectbg) \
+ -borderwidth 0 \
-barsize 22.5p \
- -thickness 11.25p
+ -thickness 3p
ttk::style configure TNotebook.Tab \
-padding {3p 1.5p} -background $colors(-darker)