summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorcsaba <csaba>2023-08-29 09:50:33 (GMT)
committercsaba <csaba>2023-08-29 09:50:33 (GMT)
commit984415d72aa6398051b09d521697defa59fd3841 (patch)
tree28a683c9f6438026263611d37de8ac7ebb3c98a3 /generic
parentbe1ae7a67e2a1f4c587f89eed4bee3e1d72dc2f1 (diff)
downloadtk-984415d72aa6398051b09d521697defa59fd3841.zip
tk-984415d72aa6398051b09d521697defa59fd3841.tar.gz
tk-984415d72aa6398051b09d521697defa59fd3841.tar.bz2
Keep the variables tk::scalingPct and tk::svgFmt in sync with [tk scaling].
Diffstat (limited to 'generic')
-rw-r--r--generic/tkCmds.c87
-rw-r--r--generic/tkUtil.c18
-rw-r--r--generic/ttk/ttkClamTheme.c6
-rw-r--r--generic/ttk/ttkDefaultTheme.c6
-rw-r--r--generic/ttk/ttkElements.c16
5 files changed, 79 insertions, 54 deletions
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index a182ba2..e953255 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -90,7 +90,7 @@ static const TkEnsemble tkCmdMap[] = {
int
Tk_BellObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -159,7 +159,7 @@ Tk_BellObjCmd(
int
Tk_BindObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -343,7 +343,7 @@ TkBindEventProc(
int
Tk_BindtagsObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -483,7 +483,7 @@ TkFreeBindingTags(
int
Tk_DestroyObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -530,7 +530,7 @@ Tk_DestroyObjCmd(
int
Tk_LowerObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -589,7 +589,7 @@ Tk_LowerObjCmd(
int
Tk_RaiseObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -681,9 +681,9 @@ TkInitTkCmd(
int
AppnameCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -712,9 +712,9 @@ AppnameCmd(
int
CaretCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -805,16 +805,16 @@ CaretCmd(
int
ScalingCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
Screen *screenPtr;
Tcl_Size skip;
- int width, height;
- double d;
+ int width, height, intPct;
+ double d, dblPct;
skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
if (skip < 0) {
@@ -835,6 +835,7 @@ ScalingCmd(
if (Tcl_GetDoubleFromObj(interp, objv[1+skip], &d) != TCL_OK) {
return TCL_ERROR;
}
+ dblPct = d * 75;
d = (25.4 / 72) / d;
width = (int) (d * WidthOfScreen(screenPtr) + 0.5);
if (width <= 0) {
@@ -846,6 +847,28 @@ ScalingCmd(
}
WidthMMOfScreen(screenPtr) = width;
HeightMMOfScreen(screenPtr) = height;
+
+ /*
+ * Keep the variables ::tk::scalingPct and ::tk::svgFmt
+ * in sync with the new value of the scaling factor
+ */
+
+ for (intPct = 100; 1; intPct += 25) {
+ if (dblPct < intPct + 12.5) {
+ break;
+ }
+ }
+ Tcl_SetVar2Ex(interp, "::tk::scalingPct", NULL, Tcl_NewIntObj(intPct),
+ TCL_GLOBAL_ONLY);
+
+ Tcl_SetVar2Ex(interp, "::tk::svgFmt", NULL,
+ Tcl_NewStringObj("svg", TCL_INDEX_NONE), TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "::tk::svgFmt", NULL,
+ Tcl_NewStringObj("-scale", TCL_INDEX_NONE),
+ TCL_GLOBAL_ONLY | TCL_APPEND_VALUE | TCL_LIST_ELEMENT);
+ Tcl_SetVar2Ex(interp, "::tk::svgFmt", NULL,
+ Tcl_NewDoubleObj(intPct / 100.0),
+ TCL_GLOBAL_ONLY | TCL_APPEND_VALUE | TCL_LIST_ELEMENT);
} else {
Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window? ?factor?");
return TCL_ERROR;
@@ -855,9 +878,9 @@ ScalingCmd(
int
UseinputmethodsCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -901,9 +924,9 @@ UseinputmethodsCmd(
int
WindowingsystemCmd(
- TCL_UNUSED(void *), /* Main window associated with interpreter. */
+ TCL_UNUSED(void *), /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *windowingsystem;
@@ -925,9 +948,9 @@ WindowingsystemCmd(
int
InactiveCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -988,7 +1011,7 @@ InactiveCmd(
int
Tk_TkwaitObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1116,11 +1139,11 @@ Tk_TkwaitObjCmd(
static char *
WaitVariableProc(
- void *clientData, /* Pointer to integer to set to 1. */
+ void *clientData, /* Pointer to integer to set to 1. */
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *name1, /* Name of variable. */
- TCL_UNUSED(const char *), /* Second part of variable name. */
- TCL_UNUSED(int)) /* Information about what happened. */
+ TCL_UNUSED(const char *), /* Second part of variable name. */
+ TCL_UNUSED(int)) /* Information about what happened. */
{
int *donePtr = (int *)clientData;
@@ -1132,7 +1155,7 @@ WaitVariableProc(
static void
WaitVisibilityProc(
- void *clientData, /* Pointer to integer to set to 1. */
+ void *clientData, /* Pointer to integer to set to 1. */
XEvent *eventPtr) /* Information about event (not used). */
{
int *donePtr = (int *)clientData;
@@ -1146,7 +1169,7 @@ WaitVisibilityProc(
static void
WaitWindowProc(
- void *clientData, /* Pointer to integer to set to 1. */
+ void *clientData, /* Pointer to integer to set to 1. */
XEvent *eventPtr) /* Information about event. */
{
int *donePtr = (int *)clientData;
@@ -1175,7 +1198,7 @@ WaitWindowProc(
int
Tk_UpdateObjCmd(
- TCL_UNUSED(void *), /* Main window associated with interpreter. */
+ TCL_UNUSED(void *), /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1273,7 +1296,7 @@ Tk_UpdateObjCmd(
int
Tk_WinfoObjCmd(
- void *clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1852,7 +1875,7 @@ Tk_WinfoObjCmd(
Tcl_Size
TkGetDisplayOf(
Tcl_Interp *interp, /* Interpreter for error reporting. */
- Tcl_Size objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. If it is present,
* "-displayof" should be in objv[0] and
* objv[1] the name of a window. */
@@ -1909,8 +1932,8 @@ int
TkDeadAppObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
- TCL_UNUSED(int), /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument strings. */
+ TCL_UNUSED(int), /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
{
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't invoke \"%s\" command: application has been destroyed",
@@ -1939,7 +1962,7 @@ TkDeadAppObjCmd(
static TkWindow *
GetTopHierarchy(
Tk_Window tkwin) /* Window for which the top-of-hierarchy
- * ancestor should be deterined. */
+ * ancestor should be determined. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 1887389..3f07142 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -1198,16 +1198,16 @@ 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);
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ Tcl_Obj *scalingPctPtr = Tcl_GetVar2Ex(interp, "::tk::scalingPct", NULL,
+ TCL_GLOBAL_ONLY);
+ if (scalingPctPtr == NULL) {
+ return 1.0;
+ } else {
+ int scalingPct;
+ Tcl_GetIntFromObj(interp, scalingPctPtr, &scalingPct);
+ return scalingPct / 100.0;
}
-
- return level;
}
/*
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index 7d38d0d..bbf1b18 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -456,12 +456,12 @@ static void IndicatorElementDraw(
fgColorStr);
/*
- * Check whether there is an SVG image for the indicator's
+ * Check whether there is an SVG image of this size for the indicator's
* type (0 = checkbtn, 1 = radiobtn) and these color strings
*/
snprintf(imgName, sizeof(imgName),
- "::tk::icons::indicator_clam%d_%s_%s_%s_%s",
- spec->offDataPtr == radiobtnOffData,
+ "::tk::icons::indicator_clam%d_%d_%s_%s_%s_%s",
+ width, spec->offDataPtr == radiobtnOffData,
upperBdColorStr, lowerBdColorStr, bgColorStr,
selected ? fgColorStr : "XXXXXX");
img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index 6e2a518..8c3131b 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -594,12 +594,12 @@ static void IndicatorElementDraw(
borderColorStr);
/*
- * Check whether there is an SVG image for the indicator's
+ * Check whether there is an SVG image of this size for the indicator's
* type (0 = checkbtn, 1 = radiobtn) and these color strings
*/
snprintf(imgName, sizeof(imgName),
- "::tk::icons::indicator_alt%d_%s_%s_%s_%s_%s",
- spec->offDataPtr == radiobtnOffData,
+ "::tk::icons::indicator_alt%d_%d_%s_%s_%s_%s_%s",
+ width, spec->offDataPtr == radiobtnOffData,
shadeColorStr, indicatorColorStr, borderColorStr, bgColorStr,
selected ? fgColorStr : "XXXXXX");
img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index 47131b1..ad35d75 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -738,12 +738,13 @@ static void IndicatorElementDraw(
borderColorStr);
/*
- * Check whether there is an SVG image for the indicator's
- * type (0 = checkbtn, 1 = radiobtn), "state" (0 = off,
- * 1 = on, 2 = tristate), and these color strings
+ * Check whether there is an SVG image of this size for the
+ * indicator's type (0 = checkbtn, 1 = radiobtn), "state"
+ * (0 = off, 1 = on, 2 = tristate), and these color strings
*/
snprintf(imgName, sizeof(imgName),
- "::tk::icons::indicator_default%d,%d_%s_%s_%s",
+ "::tk::icons::indicator_default%d_%d,%d_%s_%s_%s",
+ width,
spec->offDataPtr == radiobtnOffData,
tristate ? 2 : (selected ? 1 : 0),
bgColorStr,
@@ -1313,10 +1314,11 @@ static void SliderElementDraw(
ColorToStr(borderColor, borderColorStr);
/*
- * Check whether there is an SVG image for these color strings
+ * Check whether there is an SVG image of this size for these color strings
*/
- snprintf(imgName, sizeof(imgName), "::tk::icons::slider_default_%s_%s_%s",
- innerColorStr, outerColorStr, borderColorStr);
+ snprintf(imgName, sizeof(imgName),
+ "::tk::icons::slider_default%d_%s_%s_%s",
+ dim, innerColorStr, outerColorStr, borderColorStr);
img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
if (img == NULL) {
/*