aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorN.N. <krzyszcz@users.sourceforge.net>2004-03-16 12:13:54 +0000
committerN.N. <krzyszcz@users.sourceforge.net>2004-03-16 12:13:54 +0000
commit88b4da18ab484ea55f4a58174bf0ccebe0088f24 (patch)
treed11d880101338a255fabd9754cc88d5a67d63656 /test
parent8371b58732b1368c59966e68f9eb16b5d9210921 (diff)
toxy alpha8
svn path=/trunk/externals/miXed/; revision=1425
Diffstat (limited to 'test')
-rw-r--r--test/toxy/kb.wid2
-rw-r--r--test/toxy/multiscale-test.pd24
-rw-r--r--test/toxy/multiscale.wid18
-rw-r--r--test/toxy/setup.wid155
4 files changed, 101 insertions, 98 deletions
diff --git a/test/toxy/kb.wid b/test/toxy/kb.wid
index 9a64d70..bfba5ac 100644
--- a/test/toxy/kb.wid
+++ b/test/toxy/kb.wid
@@ -59,5 +59,5 @@ proc ::toxy::kbset {path target remote value} {
::toxy::kb .- .| . .#oct .#size
-# undo the "bind Canvas <1> {+focus %W}" in the setup part above
+# undo the "bind Canvas <1> {+focus %W}" from the setup.wid
bind .- <FocusIn> {focus .^.c}
diff --git a/test/toxy/multiscale-test.pd b/test/toxy/multiscale-test.pd
index cde36a8..9776d27 100644
--- a/test/toxy/multiscale-test.pd
+++ b/test/toxy/multiscale-test.pd
@@ -1,33 +1,35 @@
#N canvas 39 49 800 548 12;
#X obj 25 84 widget multiscale m1 #n 50 #dx 15 #dy 90;
-#X obj 25 260 widget multiscale m2 #bg red #dy 120;
+#X obj 25 326 widget multiscale m2 #bg red #dy 120;
#X msg 25 52 #n \$1;
#X floatatom 25 23 5 0 0 0 - - -;
#N canvas 0 0 450 300 graph1 0;
#X array t 50 float 0;
-#X coords 0 1 49 0 400 140 1;
+#X coords 0 100 49 0 400 140 1;
#X restore 296 206 graph;
-#X obj 265 509 tabwrite t;
-#X obj 27 408 unpack;
-#X floatatom 27 445 5 0 0 0 - - -;
-#X floatatom 100 445 5 0 0 0 - - -;
-#X floatatom 109 196 5 0 0 0 - - -;
-#X obj 589 509 tabread t;
+#X obj 265 511 tabwrite t;
+#X obj 25 474 unpack;
+#X floatatom 25 511 5 0 0 0 - - -;
+#X floatatom 98 511 5 0 0 0 - - -;
+#X floatatom 94 199 5 0 0 0 - - -;
+#X obj 589 511 tabread t;
#X obj 589 477 t 0 0;
#X obj 589 413 until;
#X obj 265 477 tow . multiscale m1;
#X obj 589 381 r rcount;
#X obj 589 445 int;
#X obj 629 445 + 1;
-#X obj 527 510 pack;
+#X obj 527 511 pack;
#X msg 265 445 tot pd [concat rcount .#n .`.:];
#X obj 265 408 t b b;
-#X msg 653 414 0;
+#X msg 653 413 0;
#X obj 127 23 widget button b -command .<.> -bg yellow -width 3 -height
2;
#X obj 265 372 tow . button b;
#X obj 25 228 pack;
#X floatatom 25 199 5 0 0 0 - - -;
+#X msg 95 282 #hi \$1;
+#X floatatom 95 246 5 0 0 0 - - -;
#X connect 1 0 6 0;
#X connect 2 0 0 0;
#X connect 3 0 2 0;
@@ -52,3 +54,5 @@
#X connect 22 0 19 0;
#X connect 23 0 1 0;
#X connect 24 0 23 0;
+#X connect 25 0 1 0;
+#X connect 26 0 25 0;
diff --git a/test/toxy/multiscale.wid b/test/toxy/multiscale.wid
index be56d2b..18f5603 100644
--- a/test/toxy/multiscale.wid
+++ b/test/toxy/multiscale.wid
@@ -1,4 +1,4 @@
-proc ::toxy::multiscalecommand {target sel ndx v} {
+proc ::toxy::multiscale_command {target sel ndx v} {
pd [concat $target $sel $v $ndx \;]
}
@@ -14,7 +14,7 @@ proc ::toxy::multiscale_list {path count ndx v} {
}
}
-proc ::toxy::multiscale {path target remote count dx dy bg} {
+proc ::toxy::multiscale {path cvpath target remote count lo hi res dx dy bg} {
if {[winfo exists $path.s0]} {
# puts stderr [concat $path.s0 exists]
} else {
@@ -25,9 +25,9 @@ proc ::toxy::multiscale {path target remote count dx dy bg} {
set py 5
for {set ndx 0} {$ndx < $count} {incr ndx} {
scale $path.s$ndx -width $dx -length $dy \
- -from 1 -to 0 -resolution 0.01 \
+ -from $hi -to $lo -resolution $res \
-bg $bg -highlightthickness 0 \
- -command [concat ::toxy::multiscalecommand $target _cb $ndx]
+ -command [concat ::toxy::multiscale_command $target _cb $ndx]
if {$dx < 50} {
$path.s$ndx config -showvalue 0 -relief flat
} else {
@@ -35,19 +35,21 @@ proc ::toxy::multiscale {path target remote count dx dy bg} {
}
set id [$path create window $px $py -width $dx -height $dy \
-anchor nw -window $path.s$ndx -tags $path.s$ndx]
- ::toxy::masterinit $path.s$ndx $target $path
+ ::toxy::master $path.s$ndx $path $cvpath $target
incr px $dx
}
}
}
#> multiscale canvas
-#. #n 3 #dx 60 #dy 90
+# FIXME fractional resolution: scalePtr->value == value fails in TkScaleSetValue
+#. #n 3 #lo 0 #hi 100 #res 1
+#. #dx 60 #dy 90
#. #bg yellow
#. @float ::toxy::multiscale_float .- .| .#n .#1
#. @list ::toxy::multiscale_list .- .#n .#2 .#1
-::toxy::multiscale .- .| . .#n .#dx .#dy .#bg
+::toxy::multiscale .- .^.c .| . .#n .#lo .#hi .#res .#dx .#dy .#bg
-# undo the "bind Canvas <1> {+focus %W}" in the setup part above
+# undo the "bind Canvas <1> {+focus %W}" from the setup.wid
bind .- <FocusIn> {focus .^.c}
diff --git a/test/toxy/setup.wid b/test/toxy/setup.wid
index 9f66b61..f5aff1c 100644
--- a/test/toxy/setup.wid
+++ b/test/toxy/setup.wid
@@ -11,21 +11,21 @@ bind Canvas <1> {+focus %W}
# (i.e. our subpatch closed) -- use 'store' and 'restore' handlers,
# if defined, otherwise try setting -variable and -textvariable traces.
-proc ::toxy::itemdotrace {target varname ndxname op} {
+proc ::toxy::item_dotrace {target varname ndxname op} {
if {[catch {set v [set $varname]} res] == 0} {
if {$v != [set $varname.last]} {
# FIXME activate this on demand (for explicit traces)
# pd $target.rp _value $v \;
set $varname.last $v
}
- } else { puts stderr [concat failed ::toxy::itemdotrace: $res] }
+ } else { puts stderr [concat failed ::toxy::item_dotrace: $res] }
}
-proc ::toxy::itembindtrace {varname mastername ndxname op} {
+proc ::toxy::item_bindtrace {varname mastername ndxname op} {
set $varname [set $mastername]
}
-proc ::toxy::itemsettrace {op path target varname} {
+proc ::toxy::item_settrace {op path target varname} {
if {[catch {$path cget $op} res] == 0} {
if {$res == ""} {
if {[catch {$path config $op $varname} err]} {
@@ -33,23 +33,23 @@ proc ::toxy::itemsettrace {op path target varname} {
}
} else {
if {[info tclversion] < 8.4} {
- trace variable $res w "::toxy::itembindtrace $varname"
+ trace variable $res w "::toxy::item_bindtrace $varname"
} else {
- trace add variable $res write "::toxy::itembindtrace $varname"
+ trace add variable $res write "::toxy::item_bindtrace $varname"
}
}
if {![info exists $varname.last]} { set $varname.last "" }
if {[info tclversion] < 8.4} {
- trace variable $varname w "::toxy::itemdotrace $target"
+ trace variable $varname w "::toxy::item_dotrace $target"
} else {
- trace add variable $varname write "::toxy::itemdotrace $target"
+ trace add variable $varname write "::toxy::item_dotrace $target"
}
return
} else { return 0 }
}
# LATER revisit -- seems clumsy and fragile
-proc ::toxy::itemremovetrace {op path varname} {
+proc ::toxy::item_removetrace {op path varname} {
if {[catch {$path cget $op} res] == 0} {
if {$res == $varname} {
if {[catch {$path config $op ""} err]} {
@@ -57,18 +57,18 @@ proc ::toxy::itemremovetrace {op path varname} {
}
} elseif {$res != ""} {
if {[info tclversion] < 8.4} {
- catch { trace vdelete $res w "::toxy::itembindtrace $varname" }
+ catch { trace vdelete $res w "::toxy::item_bindtrace $varname" }
} else {
catch { trace remove variable \
- $res write "::toxy::itembindtrace $varname" }
+ $res write "::toxy::item_bindtrace $varname" }
}
}
}
}
-proc ::toxy::itemdestroy {path varname} {
- ::toxy::itemremovetrace -variable $path $varname.var
- ::toxy::itemremovetrace -textvariable $path $varname.txt
+proc ::toxy::item_destroy {path varname} {
+ ::toxy::item_removetrace -variable $path $varname.var
+ ::toxy::item_removetrace -textvariable $path $varname.txt
if {[info tclversion] < 8.4} {
catch { unset $varname.last $varname.var $varname.txt $varname }
} else {
@@ -77,13 +77,13 @@ proc ::toxy::itemdestroy {path varname} {
catch {destroy $path}
}
-proc ::toxy::itemgetconfig {path target} {
+proc ::toxy::item_getconfig {path target} {
pd $target.rp _config $target.rp [$path cget -bg] \
[winfo reqwidth $path] [winfo reqheight $path] \
[catch {$path config -state normal}]\;
}
-proc ::toxy::itemvisconfig {path target name varname cvpath px py} {
+proc ::toxy::item_visconfig {path target name varname cvpath px py} {
if {[info exists ::toxy::itemoptions]} {
set failed [catch {eval $path config $::toxy::itemoptions} res]
unset ::toxy::itemoptions
@@ -98,17 +98,18 @@ proc ::toxy::itemvisconfig {path target name varname cvpath px py} {
# FIXME explicit traces
set needtraces 0
} else {
- set needtraces 1
+# set needtraces 1
+ set needtraces 0
}
if {$needtraces != 0} {
- if {[catch {::toxy::itemsettrace -variable \
+ if {[catch {::toxy::item_settrace -variable \
$path $target $varname.var} res1]} {
- error [concat in ::toxy::itemsettrace: $res1]
+ error [concat in ::toxy::item_settrace: $res1]
}
- if {[catch {::toxy::itemsettrace -textvariable \
+ if {[catch {::toxy::item_settrace -textvariable \
$path $target $varname.txt} res2]} {
- error [concat in ::toxy::itemsettrace: $res2]
+ error [concat in ::toxy::item_settrace: $res2]
}
# puts stderr [concat traces: ($res1) ($res2)]
if {$res1 == 0 && $res2 == 0} {
@@ -132,12 +133,12 @@ proc ::toxy::itemvisconfig {path target name varname cvpath px py} {
if {$failed} { error [concat in ::toxy::iteminits: $res] }
}
- ::toxy::itemgetconfig $path $target
+ ::toxy::item_getconfig $path $target
return
}
-proc ::toxy::itemvis {tkclass path target name varname cvpath px py} {
+proc ::toxy::item_vis {tkclass path target name varname cvpath px py} {
if {[winfo exists $path]} {
# puts stderr [concat $path exists]
set ::toxy::itemfailure 0
@@ -145,7 +146,7 @@ proc ::toxy::itemvis {tkclass path target name varname cvpath px py} {
set ::toxy::itemfailure [catch {$tkclass $path} ::toxy::itemerrmess]
}
if {$::toxy::itemfailure == 0} {
- set ::toxy::itemfailure [catch {::toxy::itemvisconfig \
+ set ::toxy::itemfailure [catch {::toxy::item_visconfig \
$path $target $name $varname $cvpath $px $py} \
::toxy::itemerrmess]
}
@@ -156,12 +157,58 @@ proc ::toxy::itemvis {tkclass path target name varname cvpath px py} {
}
}
+# empirically, binding event coords as %X - [winfo rootx $cvpath] works
+# better, than %x + [winfo x %W], or %x + t->te_xpix, LATER investigate
+
+proc ::toxy::item_click {target cvpath x y b f} {
+ pd $target.rp _click \
+ [$cvpath canvasx [expr {$x - [winfo rootx $cvpath]}]] \
+ [$cvpath canvasy [expr {$y - [winfo rooty $cvpath]}]] $b $f\;
+}
+
+proc ::toxy::item_inout {target v} {
+ pd [concat $target.rp _inout $v \;]
+}
+
+proc ::toxy::master_release {target cvpath x y b} {
+ ::toxy::item_inout $target 3
+# pdtk_canvas_mouseup is a hack, which we must call anyway
+ pdtk_canvas_mouseup $cvpath \
+ [expr {$x - [winfo rootx $cvpath]}] \
+ [expr {$y - [winfo rooty $cvpath]}] $b
+}
+
+proc ::toxy::master_motion {target cvpath x y} {
+ pd $target.rp _motion \
+ [$cvpath canvasx [expr {$x - [winfo rootx $cvpath]}]] \
+ [$cvpath canvasy [expr {$y - [winfo rooty $cvpath]}]] 0 \;
+}
+
+proc ::toxy::master {path toppath cvpath target} {
+# FIXME subitem handling in megawidgets
+ bind $path <ButtonRelease> "::toxy::master_release $target $cvpath %X %Y %b"
+ bind $path <1> "::toxy::item_click $target $cvpath %X %Y %b 0"
+ bind $path <Shift-1> "::toxy::item_click $target $cvpath %X %Y %b 1"
+ bind $path <Control-1> "::toxy::item_click $target $cvpath %X %Y %b 2"
+ bind $path <Control-Shift-1> "::toxy::item_click $target $cvpath %X %Y %b 3"
+ bind $path <Alt-1> "::toxy::item_click $target $cvpath %X %Y %b 4"
+ bind $path <Alt-Shift-1> "::toxy::item_click $target $cvpath %X %Y %b 5"
+ bind $path <Alt-Control-1> "::toxy::item_click $target $cvpath %X %Y %b 6"
+ bind $path <Alt-Control-Shift-1> \
+ "::toxy::item_click $target $cvpath %X %Y %b 7"
+ bind $path <3> "::toxy::item_click $target $cvpath %X %Y %b 8"
+
+ bind $path <Motion> "::toxy::master_motion $target $cvpath %X %Y"
+ bind $path <Enter> "::toxy::item_inout $target 1"
+ bind $path <Leave> "::toxy::item_inout $target 0"
+}
+
# FIXME
-proc ::toxy::scalecommand {target sel v} {
+proc ::toxy::scale_command {target sel v} {
pd [concat $target $sel $v \;]
}
-proc ::toxy::popupcommand {path target remote i text} {
+proc ::toxy::popup_command {path target remote i text} {
set [$path cget -textvariable] $text
pd [concat $target _cb $i \;]
if {$remote != "."} {
@@ -180,7 +227,7 @@ proc ::toxy::popup {path target remote entries args} {
} else {
incr i
$path.pop add command -label [lindex $e 0] \
- -command [concat ::toxy::popupcommand \
+ -command [concat ::toxy::popup_command \
$path $target $remote $i \
[lindex $e [expr {[llength $e] > 1}]]]
}
@@ -188,60 +235,10 @@ proc ::toxy::popup {path target remote entries args} {
} else { error [concat in ::toxy::popup: $err] }
}
-# empirically, binding event coords as %X - [winfo rootx $cvpath] works
-# better, than %x + [winfo x %W], or %x + t->te_xpix, LATER investigate
-
-proc ::toxy::itemclick {target cvpath x y b f} {
- pd $target.rp _click \
- [$cvpath canvasx [expr {$x - [winfo rootx $cvpath]}]] \
- [$cvpath canvasy [expr {$y - [winfo rooty $cvpath]}]] $b $f\;
-}
-
-proc ::toxy::iteminout {target v} {
- pd [concat $target.rp _inout $v \;]
-}
-
-proc ::toxy::masterrelease {target cvpath x y b} {
- ::toxy::iteminout $target 3
-# pdtk_canvas_mouseup is a hack, which we must call anyway
- pdtk_canvas_mouseup $cvpath \
- [expr {$x - [winfo rootx $cvpath]}] \
- [expr {$y - [winfo rooty $cvpath]}] $b
-}
-
-proc ::toxy::mastermotion {target cvpath x y} {
- pd $target.rp _motion \
- [$cvpath canvasx [expr {$x - [winfo rootx $cvpath]}]] \
- [$cvpath canvasy [expr {$y - [winfo rooty $cvpath]}]] 0 \;
-}
-
-proc ::toxy::masterinit {path target cvpath} {
- set topitem [expr {[string index $cvpath end-1] == "."}]
-# FIXME subitem handling
- if {$topitem} {
- bind $path <ButtonRelease> \
- "::toxy::masterrelease $target $cvpath %X %Y %b"
- }
- bind $path <1> "::toxy::itemclick $target $cvpath %X %Y %b 0"
- bind $path <Shift-1> "::toxy::itemclick $target $cvpath %X %Y %b 1"
- bind $path <Control-1> "::toxy::itemclick $target $cvpath %X %Y %b 2"
- bind $path <Control-Shift-1> "::toxy::itemclick $target $cvpath %X %Y %b 3"
- bind $path <Alt-1> "::toxy::itemclick $target $cvpath %X %Y %b 4"
- bind $path <Alt-Shift-1> "::toxy::itemclick $target $cvpath %X %Y %b 5"
- bind $path <Alt-Control-1> "::toxy::itemclick $target $cvpath %X %Y %b 6"
- bind $path <Alt-Control-Shift-1> \
- "::toxy::itemclick $target $cvpath %X %Y %b 7"
- bind $path <3> "::toxy::itemclick $target $cvpath %X %Y %b 8"
-
- bind $path <Motion> "::toxy::mastermotion $target $cvpath %X %Y"
- bind $path <Enter> "::toxy::iteminout $target 1"
- bind $path <Leave> "::toxy::iteminout $target 0"
-}
-
# master initializer
#> master
-::toxy::masterinit .- .| .^.c
+::toxy::master .- .- .^.c .|
# standard widget types
@@ -251,7 +248,7 @@ proc ::toxy::masterinit {path target cvpath} {
#. @bang .- flash .: .- invoke
#> float scale
-#. -command [concat ::toxy::scalecommand .| _cb]
+#. -command [concat ::toxy::scale_command .| _cb]
#. -bg pink -activebackground red -length 200
#. @float .- set .#1