1 # vim: foldmarker=<<<,>>>
3 class tlc
::Stategate_target {
9 itk_option define
-stategate stateGate StateGate
""
10 itk_option define
-explain explain Explain
0
13 method attach_signal
{signal
{a_sense normal
}}
14 method detach_signal
{signal
}
16 method stategate_ref
{}
20 variable statechange_cb
{}
27 variable old_stategate
""
28 variable stategate_state
1
30 method stategate_update
{{newstate
""}}
31 method nasty_hack
{depth
}
36 configbody tlc
::Stategate_target::stategate { #<<<1
37 # puts stderr "$this -stategate: ($itk_option(-stategate))"
38 if {$old_stategate != ""} {
39 catch {$sg_gate detach_input
$old_stategate}
40 # catch {$itk_option(-stategate) detach_output [code $this stategate_update]}
43 if {$itk_option(-stategate) != ""} {
44 if {![$itk_option(-stategate) isa tlc
::Signal]} {
45 error "$itk_option(-stategate) is not a tlc::Gate"
48 $sg_gate attach_input
$itk_option(-stategate)
49 # $itk_option(-stategate) attach_output [code $this stategate_update]
52 set old_stategate
$itk_option(-stategate)
56 body tlc
::Stategate_target::constructor {} { #<<<1
59 tlc
::Gate #auto sg_gate -mode "and" -name "Stategate_target internal $itk_interior" -default 1
61 $sg_gate attach_output
[code
$this stategate_update
]
66 body tlc
::Stategate_target::destructor {} { #<<<1
67 if {$old_stategate != ""} {
68 # Our Gate dies, from going out of scope,
69 # so this should be taken care of by the Gate
70 # catch {$itk_option(-stategate) detach_output [code $this stategate_update]}
75 body tlc
::Stategate_target::stategate_update {{newstate
""}} { #<<<1
76 if {$newstate != ""} {
77 set stategate_state
$newstate
79 # puts stderr "$this stategate_update ($stategate_state)"
80 if {$itk_option(-explain)} {
81 puts stderr
[$sg_gate explain_txt
]
84 if {$stategate_state} {
85 configure
-state normal
86 foreach t
$bg_change {
87 $t configure
-background $::tlc::config(enabledbackground
)
89 foreach t
$fg_change {
90 $t configure
-foreground $::tlc::config(enabledforeground
)
93 configure
-state disabled
94 foreach t
$bg_change {
95 $t configure
-background $::tlc::config(disabledbackground
)
97 foreach t
$fg_change {
98 $t configure
-foreground $::tlc::config(disabledforeground
)
102 if {$statechange_cb != {}} {
103 uplevel #0 $statechange_cb [list $stategate_state]
108 body tlc
::Stategate_target::attach_signal {signal
{a_sense normal
}} { #<<<1
109 puts "Stategate_target::attach_signal: ($a_sense)"
110 $sg_gate attach_input
$signal $a_sense
114 body tlc
::Stategate_target::detach_signal {signal
} { #<<<1
115 $sg_gate detach_input
$signal
119 body tlc
::Stategate_target::explaingate {} { #<<<1
120 return [$sg_gate explain_txt
]
124 body tlc
::Stategate_target::stategate_ref {} { #<<<1
129 body tlc
::Stategate_target::nasty_hack {depth
} { #<<<1
132 stategate_update
[$sg_gate state
]
134 after idle
[code
$this nasty_hack
$depth]