summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2021-04-07 18:35:05 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2021-04-07 18:35:05 +0000
commit4a6b085a789292bf30a3a8e05f0a55271eb9658b (patch)
tree73fb7fb002cfd20fe47e8255e524d1d33e3b04b3
parentf80d91d40cfd1d5cb379ceabaaf6dde7b31ca27a (diff)
X11 only: unicode markers for [check|radio]buttons, for better HiDPI looks
git-svn-id: svn://tug.org/texlive/trunk@58792 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/tltcl/tltcl.tcl66
1 files changed, 66 insertions, 0 deletions
diff --git a/Master/tlpkg/tltcl/tltcl.tcl b/Master/tlpkg/tltcl/tltcl.tcl
index b39959013ef..4e2288bef04 100644
--- a/Master/tlpkg/tltcl/tltcl.tcl
+++ b/Master/tlpkg/tltcl/tltcl.tcl
@@ -787,3 +787,69 @@ proc dirbrowser2widget {w} {
return 1
}
}
+
+#### Unicode check- and radiobuttons ####
+
+# on unix/linux the original indicators are hard-coded as bitmaps,
+# which cannot scale with the rest of the interface.
+# the hack below replaces them with unicode characters.
+# This is implemented by removing the original indicators and prepending
+# a unicode symbol and a unicode wide space to the text label.
+
+if $::plain_unix {
+
+ # from General Punctuation, 2000-206f
+ set ::wsp \u2001 ; # wide space
+
+ # from Geometric Shapes, 25a0-25ff
+ set ::chk0 \u25a1
+ set ::chk1 \u25a0
+ set ::rad0 \u25cb
+ set ::rad1 \u25cf
+
+ # layouts copied from default theme, with indicator removed
+ ttk::style layout TCheckbutton "Checkbutton.padding -sticky nswe -children {Checkbutton.focus -side left -sticky w -children {Checkbutton.label -sticky nswe}}"
+ ttk::style layout TRadiobutton "Radiobutton.padding -sticky nswe -children {Radiobutton.focus -side left -sticky w -children {Radiobutton.label -sticky nswe}}"
+
+ proc tlupdate_check {w} {
+ upvar [$w cget -variable] v
+ set s [$w cget -text]
+ set ck [expr {$v ? $::chk1 : $::chk0}]
+ set s0 [string index $s 0]
+ if {$s0 eq $::chk0 || $s0 eq $::chk1} {
+ set s "$ck$::wsp[string range $s 2 end]"
+ } else {
+ set s "$ck$::wsp$s"
+ }
+ $w configure -text $s
+ return $w
+ }
+ bind TCheckbutton <ButtonRelease-1> {+tlupdate_check %W}
+ bind TCheckbutton <Key-space> {+tlupdate_check %W}
+ bind TCheckbutton <Map> {+tlupdate_check %W}
+
+ proc tlupdate_radio {w} {
+ upvar [$w cget -variable] v
+ set ck [expr {$v eq [$w cget -value] ? $::rad1 : $::rad0}]
+ set s [$w cget -text]
+ set s0 [string index $s 0]
+ if {$s0 eq $::rad0 || $s0 eq $::rad1} {
+ $w configure -text "$ck$::wsp[string range $s 2 end]"
+ } else {
+ $w configure -text "$ck$::wsp$s"
+ }
+ }
+ proc tlupdate_radios {w} {
+ upvar [$w cget -variable] v
+ foreach sibling [winfo children [winfo parent $w]] {
+ if {[winfo class $sibling] eq "TRadiobutton" &&
+ [$sibling cget -variable] eq [$w cget -variable]
+ && ![$sibling instate disabled]} {
+ tlupdate_radio $sibling
+ }
+ }
+ }
+ bind TRadiobutton <ButtonRelease-1> {+tlupdate_radios %W}
+ bind TRadiobutton <Key-space> {+tlupdate_radios %W}
+ bind TRadiobutton <Map> {+tlupdate_radio %W}
+}