summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkInt.h1
-rw-r--r--generic/tkUtil.c32
-rw-r--r--generic/ttk/ttkClamTheme.c115
-rw-r--r--generic/ttk/ttkClassicTheme.c81
-rw-r--r--generic/ttk/ttkDefaultTheme.c89
-rw-r--r--generic/ttk/ttkElements.c178
-rw-r--r--generic/ttk/ttkEntry.c12
-rw-r--r--library/demos/ttkmenu.tcl2
-rw-r--r--library/ttk/altTheme.tcl2
-rw-r--r--library/ttk/clamTheme.tcl3
-rw-r--r--library/ttk/classicTheme.tcl2
-rw-r--r--library/ttk/defaults.tcl5
-rw-r--r--unix/tkUnixButton.c14
-rw-r--r--unix/tkUnixMenu.c32
-rw-r--r--win/tkWinButton.c17
-rw-r--r--win/ttkWinTheme.c14
16 files changed, 336 insertions, 263 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 50829aa..ec6d243 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -1402,6 +1402,7 @@ MODULE_SCOPE int TkBackgroundEvalObjv(Tcl_Interp *interp,
MODULE_SCOPE Tcl_Command TkMakeEnsemble(Tcl_Interp *interp,
const char *nsname, const char *name,
void *clientData, const TkEnsemble *map);
+MODULE_SCOPE double TkScalingLevel(Tk_Window tkwin);
MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
void *clientData);
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 4b39219..1887389 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -1181,6 +1181,38 @@ TkMakeEnsemble(
/*
*----------------------------------------------------------------------
*
+ * TkScalingLevel --
+ *
+ * Returns the display's DPI scaling level as 1.0, 1.25, 1.5, ....
+ *
+ * Results:
+ * The scaling level.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+double
+TkScalingLevel(
+ Tk_Window tkwin)
+{
+ static double level = 0.0;
+
+ if (level == 0.0) {
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ const char *scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct",
+ TCL_GLOBAL_ONLY);
+ level = (scalingPctPtr == NULL ? 1.0 : atof(scalingPctPtr) / 100);
+ }
+
+ return level;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tk_SendVirtualEvent --
*
* Send a virtual event notification to the specified target window.
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index fa015f6..ed5ab18 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -367,28 +367,19 @@ static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static double scalingFactor;
-
static void IndicatorElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
- Tcl_Interp *interp = Tk_Interp(tkwin);
- const char *scalingPctPtr;
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
+ double scalingLevel = TkScalingLevel(tkwin);
(void)paddingPtr;
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- */
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- scalingFactor = (scalingPctPtr == NULL ? 1.0 : atof(scalingPctPtr) / 100);
-
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- *widthPtr = spec->width * scalingFactor + Ttk_PaddingWidth(margins);
- *heightPtr = spec->height * scalingFactor + Ttk_PaddingHeight(margins);
+ *widthPtr = spec->width * scalingLevel + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height * scalingLevel + Ttk_PaddingHeight(margins);
}
static void ColorToStr(
@@ -414,6 +405,7 @@ static void IndicatorElementDraw(
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
char upperBdColorStr[7], lowerBdColorStr[7], bgColorStr[7], fgColorStr[7];
@@ -439,8 +431,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width * scalingFactor
- || Tk_Height(tkwin) < b.y + spec->height * scalingFactor)
+ || Tk_Width(tkwin) < b.x + spec->width * scalingLevel
+ || Tk_Height(tkwin) < b.y + spec->height * scalingLevel)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -534,8 +526,8 @@ static void IndicatorElementDraw(
/*
* Display the image
*/
- Tk_RedrawImage(img, 0, 0, spec->width * scalingFactor,
- spec->height * scalingFactor, d, b.x, b.y);
+ Tk_RedrawImage(img, 0, 0, spec->width * scalingLevel,
+ spec->height * scalingLevel, d, b.x, b.y);
Tk_FreeImage(img);
}
@@ -547,73 +539,6 @@ static const Ttk_ElementSpec IndicatorElementSpec = {
IndicatorElementDraw
};
-#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),
- STR(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
-};
-
/*------------------------------------------------------------------------
* +++ Grips.
*
@@ -927,8 +852,10 @@ static void ArrowElementDraw(
{
ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
- GC gc = Ttk_GCForColor(tkwin,sb->arrowColorObj, d);
- int h, cx, cy;
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding = Ttk_UniformPadding(round(3 * scalingLevel));
+ int cx, cy;
+ GC gc = Ttk_GCForColor(tkwin, sb->arrowColorObj, d);
(void)state;
DrawSmoothBorder(tkwin, d, b,
@@ -938,9 +865,19 @@ static void ArrowElementDraw(
Tk_Display(tkwin), d, BackgroundGC(tkwin, sb->backgroundObj),
b.x+2, b.y+2, b.width-4, b.height-4);
- b = Ttk_PadBox(b, Ttk_UniformPadding(3));
- h = b.width < b.height ? b.width : b.height;
- TtkArrowSize(h/2, direction, &cx, &cy);
+ b = Ttk_PadBox(b, padding);
+
+ switch (direction) {
+ case ARROW_UP:
+ case ARROW_DOWN:
+ TtkArrowSize(b.width/2, direction, &cx, &cy);
+ break;
+ case ARROW_LEFT:
+ case ARROW_RIGHT:
+ TtkArrowSize(b.height/2, direction, &cx, &cy);
+ break;
+ }
+
b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER);
TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
@@ -1141,8 +1078,6 @@ TtkClamTheme_Init(Tcl_Interp *interp)
&IndicatorElementSpec, (void *)&checkbutton_spec);
Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
&IndicatorElementSpec, (void *)&radiobutton_spec);
- Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
- &MenuIndicatorElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "tab", &TabElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "client", &ClientElementSpec, NULL);
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index 4b36d1c..7064fb8 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -350,6 +350,83 @@ static const Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
};
/*----------------------------------------------------------------------
+ * +++ Menubutton indicators.
+ *
+ * These aren't functional like radio/check indicators,
+ * they're just affordability indicators.
+ *
+ * Standard Tk sets the indicator size to 4.0 mm by 1.7 mm.
+ * I have no idea where these numbers came from.
+ */
+
+typedef struct {
+ Tcl_Obj *backgroundObj;
+ Tcl_Obj *widthObj;
+ Tcl_Obj *heightObj;
+ Tcl_Obj *borderWidthObj;
+ Tcl_Obj *reliefObj;
+ Tcl_Obj *marginObj;
+} MenuIndicatorElement;
+
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
+ { "-background", TK_OPTION_BORDER,
+ offsetof(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ { "-indicatorwidth", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,widthObj), "4.0m" },
+ { "-indicatorheight", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,heightObj), "1.7m" },
+ { "-borderwidth", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { "-indicatorrelief", TK_OPTION_RELIEF,
+ offsetof(MenuIndicatorElement,reliefObj),"raised" },
+ { "-indicatormargin", TK_OPTION_STRING,
+ offsetof(MenuIndicatorElement,marginObj), "5 0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+static void MenuIndicatorElementSize(
+ void *dummy, void *elementRecord, Tk_Window tkwin,
+ int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+{
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
+ Ttk_Padding margins;
+ (void)dummy;
+ (void)paddingPtr;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
+ Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
+ Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj, &margins);
+ *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 *mi = (MenuIndicatorElement *)elementRecord;
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
+ Ttk_Padding margins;
+ int borderWidth = 2;
+ (void)dummy;
+ (void)state;
+
+ Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins);
+ b = Ttk_PadBox(b, margins);
+ Tk_GetPixelsFromObj(NULL, tkwin, mi->borderWidthObj, &borderWidth);
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
+ borderWidth, TK_RELIEF_RAISED);
+}
+
+static const Ttk_ElementSpec MenuIndicatorElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(MenuIndicatorElement),
+ MenuIndicatorElementOptions,
+ MenuIndicatorElementSize,
+ MenuIndicatorElementDraw
+};
+
+/*----------------------------------------------------------------------
* +++ Arrow element(s).
*
* Draws a 3-D shaded triangle.
@@ -393,7 +470,7 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
int borderWidth = 2;
@@ -659,6 +736,8 @@ MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *interp)
&CheckbuttonIndicatorElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
&RadiobuttonIndicatorElementSpec, NULL);
+ Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
+ &MenuIndicatorElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
&ArrowElementSpec, INT2PTR(ARROW_UP));
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index f8725cf..94a3234 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -480,28 +480,19 @@ static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static double scalingFactor;
-
static void IndicatorElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
- Tcl_Interp *interp = Tk_Interp(tkwin);
- const char *scalingPctPtr;
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
+ double scalingLevel = TkScalingLevel(tkwin);
(void)paddingPtr;
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- */
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- scalingFactor = (scalingPctPtr == NULL ? 1.0 : atof(scalingPctPtr) / 100);
-
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- *widthPtr = spec->width * scalingFactor + Ttk_PaddingWidth(margins);
- *heightPtr = spec->height * scalingFactor + Ttk_PaddingHeight(margins);
+ *widthPtr = spec->width * scalingLevel + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height * scalingLevel + Ttk_PaddingHeight(margins);
}
static void ColorToStr(
@@ -527,6 +518,7 @@ static void IndicatorElementDraw(
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
char bgColorStr[7], fgColorStr[7], indicatorColorStr[7],
@@ -554,8 +546,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width * scalingFactor
- || Tk_Height(tkwin) < b.y + spec->height * scalingFactor)
+ || Tk_Width(tkwin) < b.x + spec->width * scalingLevel
+ || Tk_Height(tkwin) < b.y + spec->height * scalingLevel)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -657,8 +649,8 @@ static void IndicatorElementDraw(
/*
* Display the image
*/
- Tk_RedrawImage(img, 0, 0, spec->width * scalingFactor,
- spec->height * scalingFactor, d, b.x, b.y);
+ Tk_RedrawImage(img, 0, 0, spec->width * scalingLevel,
+ spec->height * scalingLevel, d, b.x, b.y);
Tk_FreeImage(img);
}
@@ -711,38 +703,75 @@ static void ArrowElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
- int width = SCROLLBAR_WIDTH;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ int size = SCROLLBAR_WIDTH;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
(void)paddingPtr;
- Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
- width -= Ttk_PaddingWidth(ArrowPadding);
- TtkArrowSize(width/2, direction, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(ArrowPadding);
- *heightPtr += Ttk_PaddingHeight(ArrowPadding);
+ Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
+
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.right = padding.left + 1;
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.bottom = padding.top + 1;
+
+ size -= Ttk_PaddingWidth(padding);
+ TtkArrowSize(size/2, direction, widthPtr, heightPtr);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
}
static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj);
- XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 2;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int cx = 0, cy = 0;
+ XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
+ GC gc = Tk_GCForColor(arrowColor, d);
(void)state;
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
- Tk_Fill3DRectangle(
- tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_FLAT);
- DrawBorder(tkwin,d,border,borderColor,b,borderWidth,relief);
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
+ 0, TK_RELIEF_FLAT);
+ DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
+
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.right = padding.left + 1;
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.bottom = padding.top + 1;
+
+ b = Ttk_PadBox(b, padding);
+
+ switch (direction) {
+ case ARROW_UP:
+ case ARROW_DOWN:
+ TtkArrowSize(b.width/2, direction, &cx, &cy);
+ if ((b.height - cy) % 2 == 1) {
+ ++cy;
+ }
+ break;
+ case ARROW_LEFT:
+ case ARROW_RIGHT:
+ TtkArrowSize(b.height/2, direction, &cx, &cy);
+ if ((b.width - cx) % 2 == 1) {
+ ++cx;
+ }
+ break;
+ }
+
+ b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER);
- TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
- Ttk_PadBox(b, ArrowPadding), direction);
+ TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
}
static const Ttk_ElementSpec ArrowElementSpec = {
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index d31ba64..cc424e7 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -6,7 +6,7 @@
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
#define DEFAULT_BORDERWIDTH "2"
@@ -166,7 +166,7 @@ static void BorderElementDraw(
if (border && borderWidth > 0 && relief != TK_RELIEF_FLAT) {
Tk_Draw3DRectangle(tkwin, d, border,
- b.x, b.y, b.width, b.height, borderWidth,relief);
+ b.x, b.y, b.width, b.height, borderWidth, relief);
}
}
@@ -185,6 +185,7 @@ static const Ttk_ElementSpec BorderElementSpec = {
typedef struct {
Tcl_Obj *borderObj;
Tcl_Obj *borderWidthObj;
+ Tcl_Obj *showFocusObj;
} FieldElement;
static const Ttk_ElementOptionSpec FieldElementOptions[] = {
@@ -192,9 +193,12 @@ static const Ttk_ElementOptionSpec FieldElementOptions[] = {
offsetof(FieldElement,borderObj), "white" },
{ "-borderwidth", TK_OPTION_PIXELS,
offsetof(FieldElement,borderWidthObj), "2" },
+ { "-showfocus", TK_OPTION_BOOLEAN,
+ offsetof(FieldElement,showFocusObj), "0" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
+
static void FieldElementSize(
void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
@@ -204,7 +208,6 @@ static void FieldElementSize(
(void)dummy;
(void)widthPtr;
(void)heightPtr;
-
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
@@ -215,13 +218,30 @@ static void FieldElementDraw(
{
FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
- int borderWidth = 2;
+ int showFocus = 0;
(void)dummy;
- (void)state;
- Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
- Tk_Fill3DRectangle(tkwin, d, border,
- b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_SUNKEN);
+ Tcl_GetBooleanFromObj(NULL, field->showFocusObj, &showFocus);
+ if (showFocus && (state & TTK_STATE_FOCUS)) {
+ GC gcOwnBg = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
+
+ 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);
+
+ 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);
+ } else {
+ int borderWidth = 2;
+ Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
+
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
+ borderWidth, TK_RELIEF_SUNKEN);
+ }
}
static const Ttk_ElementSpec FieldElementSpec = {
@@ -624,28 +644,19 @@ static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static double scalingFactor;
-
static void IndicatorElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
- Tcl_Interp *interp = Tk_Interp(tkwin);
- const char *scalingPctPtr;
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
+ double scalingLevel = TkScalingLevel(tkwin);
(void)paddingPtr;
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- */
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- scalingFactor = (scalingPctPtr == NULL ? 1.0 : atof(scalingPctPtr) / 100);
-
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- *widthPtr = spec->width * scalingFactor + Ttk_PaddingWidth(margins);
- *heightPtr = spec->height * scalingFactor + Ttk_PaddingHeight(margins);
+ *widthPtr = spec->width * scalingLevel + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height * scalingLevel + Ttk_PaddingHeight(margins);
}
static void ColorToStr(
@@ -671,6 +682,7 @@ static void IndicatorElementDraw(
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
char bgColorStr[7], fgColorStr[7], borderColorStr[7];
@@ -697,8 +709,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width * scalingFactor
- || Tk_Height(tkwin) < b.y + spec->height * scalingFactor)
+ || Tk_Width(tkwin) < b.x + spec->width * scalingLevel
+ || Tk_Height(tkwin) < b.y + spec->height * scalingLevel)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -796,8 +808,8 @@ static void IndicatorElementDraw(
/*
* Display the image
*/
- Tk_RedrawImage(img, 0, 0, spec->width * scalingFactor,
- spec->height * scalingFactor, d, b.x, b.y);
+ Tk_RedrawImage(img, 0, 0, spec->width * scalingLevel,
+ spec->height * scalingLevel, d, b.x, b.y);
Tk_FreeImage(img);
}
@@ -815,33 +827,23 @@ static const Ttk_ElementSpec IndicatorElementSpec = {
*
* These aren't functional like radio/check indicators,
* they're just affordability indicators.
- *
- * Standard Tk sets the indicator size to 4.0 mm by 1.7 mm.
- * I have no idea where these numbers came from.
*/
+#define MENUBUTTON_ARROW_SIZE 5
+
typedef struct {
- Tcl_Obj *backgroundObj;
- Tcl_Obj *widthObj;
- Tcl_Obj *heightObj;
- Tcl_Obj *borderWidthObj;
- Tcl_Obj *reliefObj;
- Tcl_Obj *marginObj;
+ Tcl_Obj *sizeObj;
+ Tcl_Obj *colorObj;
+ Tcl_Obj *paddingObj;
} MenuIndicatorElement;
static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
- { "-background", TK_OPTION_BORDER,
- offsetof(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
- { "-indicatorwidth", TK_OPTION_PIXELS,
- offsetof(MenuIndicatorElement,widthObj), "4.0m" },
- { "-indicatorheight", TK_OPTION_PIXELS,
- offsetof(MenuIndicatorElement,heightObj), "1.7m" },
- { "-borderwidth", TK_OPTION_PIXELS,
- offsetof(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { "-indicatorrelief", TK_OPTION_RELIEF,
- offsetof(MenuIndicatorElement,reliefObj),"raised" },
- { "-indicatormargin", TK_OPTION_STRING,
- offsetof(MenuIndicatorElement,marginObj), "5 0" },
+ { "-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 }
};
@@ -849,14 +851,15 @@ static void MenuIndicatorElementSize(
void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
Ttk_Padding margins;
+ int size = MENUBUTTON_ARROW_SIZE;
(void)dummy;
(void)paddingPtr;
- Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
- Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
- Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj, &margins);
+ 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);
}
@@ -865,18 +868,19 @@ static void MenuIndicatorElementDraw(
void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
- Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
- Ttk_Padding margins;
- int borderWidth = 2;
+ 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;
- Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins);
- b = Ttk_PadBox(b, margins);
- Tk_GetPixelsFromObj(NULL, tkwin, mi->borderWidthObj, &borderWidth);
- Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
- borderWidth, TK_RELIEF_RAISED);
+ 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 = {
@@ -924,14 +928,22 @@ static void ArrowElementSize(
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
- int width = 14;
+ int size = 14;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
(void)paddingPtr;
- Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
- width -= Ttk_PaddingWidth(ArrowMargins);
- TtkArrowSize(width/2, direction, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(ArrowMargins);
- *heightPtr += Ttk_PaddingWidth(ArrowMargins);
+ Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
+
+ padding.left = round(ArrowMargins.left * scalingLevel);
+ padding.top = round(ArrowMargins.top * scalingLevel);
+ padding.right = round(ArrowMargins.right * scalingLevel);
+ padding.bottom = round(ArrowMargins.bottom * scalingLevel);
+
+ size -= Ttk_PaddingWidth(padding);
+ TtkArrowSize(size/2, direction, widthPtr, heightPtr);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
}
static void ArrowElementDraw(
@@ -941,18 +953,48 @@ static void ArrowElementDraw(
ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
- XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 1;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int cx, cy;
+ XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
+ GC gc = Tk_GCForColor(arrowColor, d);
(void)state;
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
+ Tk_GetPixelsFromObj(NULL, tkwin, arrow->borderWidthObj, &borderWidth);
- Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height,
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
borderWidth, relief);
- TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
- Ttk_PadBox(b, ArrowMargins), direction);
+ padding.left = round(ArrowMargins.left * scalingLevel);
+ padding.top = round(ArrowMargins.top * scalingLevel);
+ padding.right = round(ArrowMargins.right * scalingLevel);
+ padding.bottom = round(ArrowMargins.bottom * scalingLevel);
+
+ b = Ttk_PadBox(b, padding);
+
+ switch (direction) {
+ case ARROW_UP:
+ case ARROW_DOWN:
+ TtkArrowSize(b.width/2, direction, &cx, &cy);
+ if ((b.height - cy) % 2 == 1) {
+ ++cy;
+ }
+ break;
+ case ARROW_LEFT:
+ case ARROW_RIGHT:
+ TtkArrowSize(b.height/2, direction, &cx, &cy);
+ if ((b.width - cx) % 2 == 1) {
+ ++cx;
+ }
+ break;
+ }
+
+ b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER);
+
+ TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
}
static const Ttk_ElementSpec ArrowElementSpec = {
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 2b1efb4..f0fe2fc 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -2123,12 +2123,12 @@ TTK_BEGIN_LAYOUT(ComboboxLayout)
TTK_END_LAYOUT
TTK_BEGIN_LAYOUT(SpinboxLayout)
- 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)))
+ 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)))
TTK_END_LAYOUT
/*------------------------------------------------------------------------
diff --git a/library/demos/ttkmenu.tcl b/library/demos/ttkmenu.tcl
index efa6688..aad5aa0 100644
--- a/library/demos/ttkmenu.tcl
+++ b/library/demos/ttkmenu.tcl
@@ -35,7 +35,7 @@ menu $w.m3.menu -tearoff 0
menu $w.m4.menu -tearoff 0
menu $w.m5.menu -tearoff 0
-foreach theme [ttk::themes] {
+foreach theme [lsort [ttk::themes]] {
$w.m1.menu add command -label $theme -command [list ttk::setTheme $theme]
$w.m2.menu add command -label $theme -command [list ttk::setTheme $theme]
$w.m3.menu add command -label $theme -command [list ttk::setTheme $theme]
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl
index fc88dee..2ef5134 100644
--- a/library/ttk/altTheme.tcl
+++ b/library/ttk/altTheme.tcl
@@ -68,7 +68,7 @@ namespace eval ttk::theme::alt {
[list readonly $colors(-frame) disabled $colors(-frame)] \
-arrowcolor [list disabled $colors(-disabledfg)]
ttk::style configure ComboboxPopdownFrame \
- -relief solid -borderwidth 1
+ -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/clamTheme.tcl b/library/ttk/clamTheme.tcl
index 6379e81..da75c35 100644
--- a/library/ttk/clamTheme.tcl
+++ b/library/ttk/clamTheme.tcl
@@ -91,7 +91,8 @@ namespace eval ttk::theme::clam {
disabled $colors(-frame)]
ttk::style configure TMenubutton \
- -width -11 -arrowsize 3.75p -padding 3.75p -relief raised
+ -width -11 -arrowsize 3.75p -arrowpadding 2.25p -padding 3.75p \
+ -relief raised
ttk::style configure TEntry -padding 1 -insertwidth 1
ttk::style map TEntry \
diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl
index 331b3ad..a482543 100644
--- a/library/ttk/classicTheme.tcl
+++ b/library/ttk/classicTheme.tcl
@@ -69,7 +69,7 @@ namespace eval ttk::theme::classic {
ttk::style configure TMenubutton -relief raised \
-indicatormargin {3.75p 0} -padding {3m 1m}
- ttk::style configure TEntry -relief sunken -padding 1 -font TkTextFont
+ ttk::style configure TEntry -padding 1 -font TkTextFont
ttk::style map TEntry -fieldbackground \
[list readonly $colors(-frame) disabled $colors(-frame)]
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl
index 6f46dfd..3f58bbb 100644
--- a/library/ttk/defaults.tcl
+++ b/library/ttk/defaults.tcl
@@ -127,10 +127,11 @@ proc ttk::theme::default::reconfigureDefaultTheme {} {
}
ttk::style configure TMenubutton \
- -relief raised -indicatormargin {3.75p 0} -padding {7.5p 2.25p}
+ -relief raised -arrowsize 3.75p -arrowpadding 2.25p \
+ -padding {7.5p 2.25p}
ttk::style configure TEntry \
- -relief sunken -fieldbackground $colors(-window) -padding 1
+ -fieldbackground $colors(-window) -padding 1 -showfocus 1
ttk::style map TEntry -fieldbackground \
[list readonly $colors(-frame) disabled $colors(-frame)]
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index c67f1fa..e4c9bf7 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -172,20 +172,19 @@ TkpDrawCheckIndicator(
{
const char *svgDataPtr;
int hasBorder, hasInterior, dim;
+ double scalingLevel = TkScalingLevel(tkwin);
TkBorder *bg_brdr = (TkBorder*)bgBorder;
char darkColorStr[7], lightColorStr[7], interiorColorStr[7], indicatorColorStr[7];
+ Tcl_Interp *interp = Tk_Interp(tkwin);
char imgName[60];
Tk_Image img;
size_t svgDataLen;
char *svgDataCopy;
char *darkColorPtr, *lightColorPtr, *interiorColorPtr, *indicatorColorPtr;
- Tcl_Interp *interp = Tk_Interp(tkwin);
const char *cmdFmt;
size_t scriptSize;
char *script;
int code;
- const char *scalingPctPtr;
- double scalingFactor;
/*
* Sanity check
@@ -235,6 +234,7 @@ TkpDrawCheckIndicator(
dim = RADIO_MENU_DIM;
break;
}
+ dim = (int)(dim * scalingLevel);
/*
* Construct the color strings darkColorStr, lightColorStr,
@@ -339,14 +339,6 @@ TkpDrawCheckIndicator(
}
/*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...) and multiply dim by it
- */
-
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- scalingFactor = (scalingPctPtr == NULL ? 1.0 : atof(scalingPctPtr) / 100);
- dim = (int)(dim * scalingFactor);
-
- /*
* Adjust the image's coordinates in the drawable and display the image
*/
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index f6442ad..7f9ad7d 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -391,22 +391,11 @@ GetMenuAccelGeometry(
int *widthPtr, /* The width of the acclerator area */
int *heightPtr) /* The height of the accelerator area */
{
- Tcl_Interp *interp = Tk_Interp(menuPtr->tkwin);
- const char *scalingPctPtr;
- double scalingFactor = 1.0;
+ double scalingLevel = TkScalingLevel(menuPtr->tkwin);
*heightPtr = fmPtr->linespace;
if (mePtr->type == CASCADE_ENTRY) {
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- */
-
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- if (scalingPctPtr != NULL) {
- scalingFactor = atof(scalingPctPtr) / 100;
- }
-
- *widthPtr = 2 * CASCADE_ARROW_WIDTH * scalingFactor;
+ *widthPtr = 2 * CASCADE_ARROW_WIDTH * scalingLevel;
} else if ((menuPtr->menuType != MENUBAR) && (mePtr->accelPtr != NULL)) {
const char *accel = Tcl_GetString(mePtr->accelPtr);
@@ -502,9 +491,7 @@ DrawMenuEntryAccelerator(
XPoint points[3];
int borderWidth, activeBorderWidth;
int arrowWidth = CASCADE_ARROW_WIDTH, arrowHeight = CASCADE_ARROW_HEIGHT;
- Tcl_Interp *interp = Tk_Interp(menuPtr->tkwin);
- const char *scalingPctPtr;
- double scalingFactor = 1.0;
+ double scalingLevel = TkScalingLevel(menuPtr->tkwin);
/*
* Draw accelerator or cascade arrow.
@@ -519,17 +506,8 @@ DrawMenuEntryAccelerator(
Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr,
&activeBorderWidth);
if ((mePtr->type == CASCADE_ENTRY) && drawArrow) {
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- * and multiply the cascade arrow's dimensions by it
- */
-
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- if (scalingPctPtr != NULL) {
- scalingFactor = atof(scalingPctPtr) / 100;
- }
- arrowWidth *= scalingFactor;
- arrowHeight *= scalingFactor;
+ arrowWidth *= scalingLevel;
+ arrowHeight *= scalingLevel;
points[0].x = x + width - borderWidth - activeBorderWidth - arrowWidth;
points[0].y = y + (height - arrowHeight)/2;
diff --git a/win/tkWinButton.c b/win/tkWinButton.c
index 9de384d..223e3ad 100644
--- a/win/tkWinButton.c
+++ b/win/tkWinButton.c
@@ -111,7 +111,7 @@ static LRESULT CALLBACK ButtonProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam);
static Window CreateProc(Tk_Window tkwin, Window parent,
void *instanceData);
-static void InitBoxes(Tcl_Interp *interp);
+static void InitBoxes(Tk_Window tkwin);
static void ColorToStr(COLORREF color, char *colorStr);
static void ImageChanged(ClientData clientData,
int x, int y, int width, int height,
@@ -149,22 +149,13 @@ const Tk_ClassProcs tkpButtonProcs = {
*/
static void
-InitBoxes(Tcl_Interp *interp)
+InitBoxes(Tk_Window tkwin)
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ double scalingLevel = TkScalingLevel(tkwin);
- const char *scalingPctPtr;
- double scalingFactor;
-
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- */
-
- scalingPctPtr = Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- scalingFactor = (scalingPctPtr == NULL ? 1.0 : atof(scalingPctPtr) / 100);
-
- tsdPtr->boxSize = (int)(16.0 * scalingFactor);
+ tsdPtr->boxSize = (int)(16.0 * scalingLevel);
tsdPtr->initialized = TRUE;
}
diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c
index 35bde14..d526bfe 100644
--- a/win/ttkWinTheme.c
+++ b/win/ttkWinTheme.c
@@ -157,17 +157,9 @@ static void FrameControlElementSize(
int cy = GETMETRIC(p->cyId);
if ((p->cxId & _FIXEDSIZE) && cx == BASE_DIM) {
- /*
- * Retrieve the scaling factor (1.0, 1.25, 1.5, ...)
- * and multiply cx and cy by it
- */
- Tcl_Interp *interp = Tk_Interp(tkwin);
- const char *scalingPctPtr =
- Tcl_GetVar(interp, "::tk::scalingPct", TCL_GLOBAL_ONLY);
- double scalingFactor = (scalingPctPtr == NULL ? 1.0 :
- atof(scalingPctPtr) / 100);
- cx *= scalingFactor;
- cy *= scalingFactor;
+ double scalingLevel = TkScalingLevel(tkwin);
+ cx *= scalingLevel;
+ cy *= scalingLevel;
/*
* Update the corresponding element of the array FrameControlElements