aboutsummaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorcarmen rocco <ix9@users.sourceforge.net>2005-06-19 08:34:31 +0000
committercarmen rocco <ix9@users.sourceforge.net>2005-06-19 08:34:31 +0000
commit864f61ad880bd12bc8ddfee2a1999ea9fe69e04a (patch)
treef0116e3eb0484fe73072e26262e38e3e3b1bafc4 /extensions
parent6e7013dbc6134aa1e6ff3672413d7033c7cbb7a2 (diff)
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur
Pos svn path=/trunk/; revision=3215
Diffstat (limited to 'extensions')
-rwxr-xr-xextensions/gui/ix/mat.wid212
1 files changed, 107 insertions, 105 deletions
diff --git a/extensions/gui/ix/mat.wid b/extensions/gui/ix/mat.wid
index f8246d6c..9d77e44d 100755
--- a/extensions/gui/ix/mat.wid
+++ b/extensions/gui/ix/mat.wid
@@ -7,113 +7,12 @@ namespace eval ::ix {
set len [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]]
set vel [$p.m itemcget $item -fillopacity]
pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len \;]}
- namespace eval actions {
- proc action {p t o} {puts gah}
- proc draw {p t o} {puts draw}
- proc resize_canvas {p t o} {}
- proc move_canvas {p t o} {puts cvda}
- proc move_object {p t o} {
- puts hiihect
- }
- }
- proc mat_click {m button action p t x y} {
+ proc mat_action {p t a x y} {puts gah}
+ proc mat_draw {p t a x y} {
variable _
- set a [$p.m itemcget mode -text]
- eval actions::$a $p $t o
- switch $m {
- control {mat_draw $action $p $t $x $y}
- "" {
- set clicked [$p.m find overlapping $x $y $x $y]
- switch $action {
- hover {
- foreach item $clicked {
- if {[lindex [$p.m itemcget $item -tags] 0] eq "item"} {
- mat_note $p $t $item
- }
- }
- if {$clicked ne "" && [lindex [$p.m itemcget $item -tags] 0] eq "item"} {
- mat_mode $p $t {move_object}
- } {mat_mode $p $t {move_canvas}}
- set junk ""
- foreach cfg [$p.m itemconfigure $clicked] {set junk "$junk\n$cfg"}
- mat_info $p $t $junk
- }
- first {
- # if {$clicked ne ""} {
- set _($t:cl) $clicked
- # }
- foreach xy {x y} {set _($t:f$xy) [set $xy]}
- switch $button {2 {mat_mode $p $t resize_canvas}}
- }
- motion {
- set mx [expr $x - $_($t:cx)]
- set my [expr $y - $_($t:cy)]
- foreach xy {x y} {
- set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]]
- switch $button {
- 1 {
- foreach ab {a b} {
- set _($t:${xy}$ab) [expr $_($t:${xy}$ab) - $mvt]
- }
- }
- 2 {
- set _($t:${xy}a) [expr $_($t:${xy}a) - $mvt]
- set _($t:${xy}b) [expr $_($t:${xy}b) + $mvt]
- }
- }
- }
- switch $button {
- 1 {
- if {$clicked ne ""} {
- set items $clicked
- } else {
- set items [$p.m find withtag item]
- mat_gridlines $p $t
- }
- foreach item $items {
- set m [$p.m itemcget $item -matrix]
- set m [list [lindex $m 0] [lindex $m 1] [list [expr [lindex [lindex $m 2] 0] + $mx] [expr [lindex [lindex $m 2] 1] + $my]]]
- $p.m itemconfigure $item -matrix $m
- }
- }
- 2 {
- foreach item [$p.m find withtag item] {
- set id [lindex [$p.m itemcget $item -tags] 1]
- set px [mat_tr $p $t x t [dict get $_($t) $id x]]
- set py [mat_tr $p $t y t [dict get $_($t) $id y]]
- set sx [mat_tr $p $t x id [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]]]
- set sy [mat_tr $p $t y id 1]
- $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]
- }
- mat_gridlines $p $t
- }
- 3 {
- set velo [expr ($x - $_($t:cx)) / 100.0]
- foreach item $_($t:cl) {
- set vel [expr $velo + [$p.m itemcget $item -fillopacity]]
- if {$vel > 1} {set vel 1}
- if {$vel < 0} {set vel 0}
- $p.m itemconfigure $item -fillopacity $vel
- }
- }
- }
- }
- release {
- switch $button {
- 2 {mat_mode $p $t move_canvas}
- }
- }
- }
- foreach xy {x y} {set _($t:c$xy) [set $xy]}
- }
- }
- }
-
- proc mat_draw {action p t x y} {
- variable _
- switch $action {
+ switch $a {
motion {
- if {$x >= $_($t:cx)} {set xa $_($t:cx);set xb $x} else {set xa $x;set xb $_($t:cx)}
+ if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)}
$p.m coords drawing [::tkpath::coords rect $xa $y [expr $xb - $xa] [mat_tr $p $t y id 1] -rx 3 -ry 3]
set yi [mat_tr $p $t y i $y]
dict set _($t) $_($t:i) x [mat_tr $p $t x i $xa]
@@ -128,6 +27,109 @@ namespace eval ::ix {
$p.m itemconfigure drawing -tags [list item $_($t:i)] -matrix {{1.0 0.0} {0.0 1.0} {0.0 0.0}}
incr _($t:i) 2}}}
+ proc mat_resize_canvas {p t a x y} {
+ variable _
+ set mx [expr $x - $_($t:cx)]
+ set my [expr $y - $_($t:cy)]
+ foreach xy {x y} {
+ set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]]
+ set _($t:${xy}a) [expr $_($t:${xy}a) - $mvt]
+ set _($t:${xy}b) [expr $_($t:${xy}b) + $mvt]
+ }
+ foreach item [$p.m find withtag item] {
+ set id [lindex [$p.m itemcget $item -tags] 1]
+ set px [mat_tr $p $t x t [dict get $_($t) $id x]]
+ set py [mat_tr $p $t y t [dict get $_($t) $id y]]
+ set sx [mat_tr $p $t x id [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]]]
+ set sy [mat_tr $p $t y id 1]
+ $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]
+ }
+ mat_gridlines $p $t
+ }
+ proc mat_object_trans {p t a x y} {
+ variable _
+ set velo [expr ($x - $_($t:cx)) / 100.0]
+ foreach item $_($t:cl) {
+ set vel [expr $velo + [$p.m itemcget $item -fillopacity]]
+ if {$vel > 1} {set vel 1}
+ if {$vel < 0} {set vel 0}
+ $p.m itemconfigure $item -fillopacity $vel
+ }
+ }
+ proc mat_move_canvas {p t a x y} {
+ variable _
+ set mx [expr $x - $_($t:cx)]
+ set my [expr $y - $_($t:cy)]
+ foreach xy {x y} {
+ set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]]
+ foreach ab {a b} {set _($t:${xy}$ab) [expr $_($t:${xy}$ab) - $mvt]}}
+ foreach item [$p.m find withtag item] {
+ set m [$p.m itemcget $item -matrix]
+ set m [list [lindex $m 0] [lindex $m 1] [list [expr [lindex [lindex $m 2] 0] + $mx] [expr [lindex [lindex $m 2] 1] + $my]]]
+ $p.m itemconfigure $item -matrix $m
+ }
+ mat_gridlines $p $t
+ }
+
+ proc mat_move_object {p t a x y} {
+ variable _
+ set mx [expr $x - $_($t:cx)]
+ set my [expr $y - $_($t:cy)]
+ foreach item $_($t:cl) {
+ set m [$p.m itemcget $item -matrix]
+ set m [list [lindex $m 0] [lindex $m 1] [list [expr [lindex [lindex $m 2] 0] + $mx] [expr [lindex [lindex $m 2] 1] + $my]]]
+ $p.m itemconfigure $item -matrix $m
+ }
+ }
+
+ proc mat_click {m button action p t x y} {
+ variable _
+ set clicked [$p.m find overlapping $x $y $x $y]
+ set a [$p.m itemcget mode -text]
+ switch $action {
+ hover {
+ foreach item $clicked {
+ if {[lindex [$p.m itemcget $item -tags] 0] eq "item"} {
+ mat_note $p $t $item
+ }
+ }
+
+ set junk ""
+ foreach cfg [$p.m itemconfigure $clicked] {set junk "$junk\n$cfg"}
+ mat_info $p $t $junk
+ }
+ first {
+ set _($t:cl) $clicked
+ foreach xy {x y} {set _($t:f$xy) [set $xy]}
+ switch $button {
+ 1 {
+# mat_mode $p $t move_canvas
+ if {$a eq "draw"} {mat_draw $p $t $action $x $y} else {
+ if {$clicked ne "" && [lindex [$p.m itemcget [lindex $clicked 0] -tags] 0] eq "item"} {
+ mat_mode $p $t move_object
+ } else {
+ mat_mode $p $t move_canvas
+ }
+ }
+ }
+ 2 {mat_mode $p $t resize_canvas}
+ 3 {mat_mode $p $t object_trans}
+ }
+ }
+ motion {eval mat_$a $p $t $action $x $y}
+ release {
+ switch $button {
+ 1 {
+ if {$a eq "draw"} {mat_draw $p $t $action $x $y}
+ }
+ 2 {mat_mode $p $t move_canvas}
+ 3 {mat_mode $p $t move_canvas}
+ }
+ }
+ }
+ foreach xy {x y} {set _($t:c$xy) [set $xy]}
+ }
+
proc mat_tr {p t d inv v} {
variable _
array set dm {x width y height}