texlive[58792] Master/tlpkg/tltcl/tltcl.tcl: X11 only: unicode

commits+siepo at tug.org commits+siepo at tug.org
Wed Apr 7 20:35:06 CEST 2021


Revision: 58792
          http://tug.org/svn/texlive?view=revision&revision=58792
Author:   siepo
Date:     2021-04-07 20:35:05 +0200 (Wed, 07 Apr 2021)
Log Message:
-----------
X11 only: unicode markers for [check|radio]buttons, for better HiDPI looks

Modified Paths:
--------------
    trunk/Master/tlpkg/tltcl/tltcl.tcl

Modified: trunk/Master/tlpkg/tltcl/tltcl.tcl
===================================================================
--- trunk/Master/tlpkg/tltcl/tltcl.tcl	2021-04-07 18:23:42 UTC (rev 58791)
+++ trunk/Master/tlpkg/tltcl/tltcl.tcl	2021-04-07 18:35:05 UTC (rev 58792)
@@ -787,3 +787,69 @@
     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}
+}



More information about the tex-live-commits mailing list.