diff options
author | Norbert Preining <norbert@preining.info> | 2021-04-08 03:01:42 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-04-08 03:01:42 +0000 |
commit | 31d38d879db092b485e49e1b7c79f96c312fd1fb (patch) | |
tree | 096c4e9bea16007b273f4c0d59198f3717ec7f43 /systems/texlive/tlnet/tlpkg/tltcl | |
parent | 70fe7f94e8281b0691a51754da3e2d40b1dd7732 (diff) |
CTAN sync 202104080301
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tltcl')
-rw-r--r-- | systems/texlive/tlnet/tlpkg/tltcl/tltcl.tcl | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tltcl/tltcl.tcl b/systems/texlive/tlnet/tlpkg/tltcl/tltcl.tcl index b39959013e..4e2288bef0 100644 --- a/systems/texlive/tlnet/tlpkg/tltcl/tltcl.tcl +++ b/systems/texlive/tlnet/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} +} |