From d0f6986345970955d6390a6953c35babf587c262 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Thu, 19 Feb 2004 22:23:18 +0000 Subject: many small improvements in toxy, plustot added svn path=/trunk/externals/miXed/; revision=1321 --- test/toxy/kb.wid | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 test/toxy/kb.wid (limited to 'test/toxy/kb.wid') diff --git a/test/toxy/kb.wid b/test/toxy/kb.wid new file mode 100644 index 0000000..e447697 --- /dev/null +++ b/test/toxy/kb.wid @@ -0,0 +1,63 @@ +proc ::toxy::kb {path target remote noctaves size} { + set lft [expr {round(5 * $size)}] + set top [expr {5 * $size}] + set bot [expr {100 * $size}] + set dx [expr {round(17 * $size)}] + set wid [expr {$dx - $size * .5}] + set blbot [expr {$bot * .65}] + + $path config -height [expr {$bot + $top}] \ + -width [expr {$dx * ($noctaves * 7 + 1) + $lft * 2 - 1}] + + for {set octave 0} {$octave <= $noctaves} {incr octave} { + set prevkey 0 + foreach key {0 2 4 5 7 9 11} { + set ndx [expr $octave * 12 + $key] + set id [$path create rect $lft $top \ + [expr {$lft + $wid}] $bot -fill white -tags $path.$ndx] + $path bind $id <1> [concat ::toxy::kbset \ + $path $target $remote $ndx] + if {$key - $prevkey > 1} { + incr ndx -1 + set x [expr {$lft - $wid * .22}] + set id [$path create rect $x $top [expr {$x + $wid * .44}] \ + $blbot -fill black -tags $path.$ndx] + $path bind $id <1> [concat ::toxy::kbset \ + $path $target $remote $ndx] + } + set prevkey $key + incr lft $dx + if {$octave == $noctaves && $key == 0} break + } + } + set ::toxy::kbval($target) 0 + set ::toxy::kbcol($target) white + $path itemconfig $path.0 -fill grey +} + +proc ::toxy::kbout {path target remote} { + pd [concat $target _cb $::toxy::kbval($target) \;] + if {$remote != "."} { + pd [concat $remote $::toxy::kbval($target) \;] + } +} + +proc ::toxy::kbset {path target remote value} { + $path itemconfig $path.$::toxy::kbval($target) \ + -fill $::toxy::kbcol($target) + set ::toxy::kbval($target) $value + set ::toxy::kbcol($target) [lindex [$path itemconfig $path.$value -fill] 4] + $path itemconfig $path.$value -fill grey + ::toxy::kbout $path $target $remote +} + +#> kb canvas +#. -bg yellow -cursor hand1 +#. #oct 4 #size .75 +#. @bang ::toxy::kbout .- .| . +#. @float ::toxy::kbset .- .| . .#1 + +::toxy::kb .- .| . .#oct .#size + +# undo the "bind Canvas <1> {+focus %W}" in the setup part above +bind .- {focus .^.c} -- cgit v1.2.1