From 682e49a9cd691c15f7e37b9706781fe5190d6fd2 Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Sat, 10 Apr 2021 13:19:50 +0000 Subject: Better bindings for Linux Unicode check- and radiobuttons git-svn-id: svn://tug.org/texlive/trunk@58813 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tltcl/tltcl.tcl | 50 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'Master/tlpkg/tltcl') diff --git a/Master/tlpkg/tltcl/tltcl.tcl b/Master/tlpkg/tltcl/tltcl.tcl index 4e2288bef04..4ed73859cb4 100644 --- a/Master/tlpkg/tltcl/tltcl.tcl +++ b/Master/tlpkg/tltcl/tltcl.tcl @@ -792,10 +792,14 @@ proc dirbrowser2widget {w} { # 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. +# the hack below replaces them with unicode characters, which are scaled +# along with other text. # This is implemented by removing the original indicators and prepending # a unicode symbol and a unicode wide space to the text label. +# The combobox down arrow and the treeview triangles (directory browser) +# are still unscaled. + if $::plain_unix { # from General Punctuation, 2000-206f @@ -811,7 +815,7 @@ if $::plain_unix { 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} { + proc tlupdate_check {w n e o} { ; # n, e, o added to keep trace happy upvar [$w cget -variable] v set s [$w cget -text] set ck [expr {$v ? $::chk1 : $::chk0}] @@ -821,35 +825,39 @@ if $::plain_unix { } else { set s "$ck$::wsp$s" } + if {[string length $s] == 2} { + # indicator plus wide space plus empty string. Remove wide space. + set s [string range $s 0 0] + } $w configure -text $s - return $w } - bind TCheckbutton {+tlupdate_check %W} - bind TCheckbutton {+tlupdate_check %W} - bind TCheckbutton {+tlupdate_check %W} + bind TCheckbutton {+tlupdate_check %W n e o} + bind TCheckbutton {+trace add variable [%W cget -variable] write \ + [list tlupdate_check %W]} + bind TCheckbutton \ + {+trace remove variable [%W cget -variable] write [list tlupdate_check %W]} - proc tlupdate_radio {w} { + proc tlupdate_radio {w n e o} { 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]" + set s "$ck$::wsp[string range $s 2 end]" } else { - $w configure -text "$ck$::wsp$s" + set s "$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 - } + if {[string length $s] == 2} { + # indicator plus wide space plus empty string. Remove wide space. + set s [string range $s 0 0] } + $w configure -text $s } - bind TRadiobutton {+tlupdate_radios %W} - bind TRadiobutton {+tlupdate_radios %W} - bind TRadiobutton {+tlupdate_radio %W} + + bind TRadiobutton {+tlupdate_radio %W n e o} + bind TRadiobutton {+trace add variable [%W cget -variable] write \ + [list tlupdate_radio %W]} + bind TRadiobutton \ + {+trace remove variable [%W cget -variable] write [list tlupdate_radio %W]} } + -- cgit v1.2.3