1 # ui-extout.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1995-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31
32 package provide ExtOut
33
34 proc extout_build_thumbnail { w d } {
35 set stamp $w.stamp
36 frame $stamp -relief groove -borderwidth 2
37 create_video_widget $stamp.video 80 60
38 global win_is_slow win_use_hw extout_tn
39 set win_is_slow($stamp.video) 1
40 set extout_is_slow($d) 0
41 set extout_tn($d) $stamp.video
42 pack $stamp.video -anchor c -padx 2
43 pack $stamp -fill y
44
45 frame $w.b -background purple
46 button $w.b.rev -bitmap rev -command "switcher_prev $d"
47 button $w.b.fwd -bitmap fwd -command "switcher_next $d"
48
49 pack $w.b.rev $w.b.fwd -side left -fill x -expand 1 -padx 0
50 pack $w.b -fill x
51
52 }
53
54 proc extout_build_modes { w d } {
55 set f [$self get_option smallfont]
56 checkbutton $w.ts -text "Timer-Switched" -font $f -anchor w \
57 -variable extout_is_timed($d) \
58 -command "extout_set_timed $d"
59 checkbutton $w.vs -text "Voice-Switched" -font $f -anchor w \
60 -variable extout_is_switched($d) \
61 -command "extout_set_switched $d"
62 if ![have cb] {
63 $w.vs configure -state disabled
64 }
65 #FIXME
66 checkbutton $w.sc -text "Save-CPU" -font $f -anchor w \
67 -variable extout_is_slow($d) \
68 -command "extout_set_slow $d"
69
70 pack $w.vs $w.ts $w.sc -anchor w -fill x
71 }
72
73 proc extout_set_scale d {
74 global extout_target extout_scale
75 if [info exists extout_target($d)] {
76 $extout_target($d) scale $extout_scale($d)
77 }
78 }
79
80 proc extout_build_buttons { w d } {
81 set f [$self get_option smallfont]
82
83 set m $w.mb.menu
84 menubutton $w.mb -text Port... -menu $m \
85 -relief raised -font $f
86 #FIXME no supported devices have multiple external ports yet
87 $w.mb configure -state disabled
88
89 checkbutton $w.ext -text "Scale-Up" -font $f \
90 -relief raised -anchor w -highlightthickness 0 \
91 -variable extout_scale($d) \
92 -command "extout_set_scale $d"
93 button $w.sd -text "Shutdown" -font $f \
94 -command "extout_shutdown $d [winfo toplevel $w]" \
95 -highlightthickness 0
96
97
98 pack $w.mb $w.ext $w.sd -anchor w -fill x
99 }
100
101 proc extout_mb_post { d flag x y } {
102 if { $flag != "" } {
103 global extout_mb src_nickname
104 set menu $extout_mb($d).menu
105 if [winfo exists $menu] {
106 destroy $menu
107 }
108 menu $menu
109 foreach src [session active] {
110 $menu add command -label $src_nickname($src) \
111 -command "switcher_set $d $src"
112 }
113 tkMbPost $flag $x $y
114 }
115 }
116
117 proc extout_select d {
118
119 set w .$d
120 #FIXME use toggle_window
121 if [winfo exists $w] {
122 if [winfo ismapped $w] {
123 wm withdraw $w
124 } else {
125 wm deiconify $w
126 }
127 return
128 }
129 create_toplevel $w "[$d nickname]"
130 catch "wm resizable $w false false"
131
132 set f [$self get_option smallfont]
133
134 frame $w.title -borderwidth 2 -relief ridge
135 label $w.title.main -borderwidth 0 -anchor w \
136 -text "External Output Controls ([$d nickname])"
137 frame $w.frame -borderwidth 2 -relief ridge
138
139 frame $w.frame.v
140 frame $w.frame.v.tn
141 extout_build_thumbnail $w.frame.v.tn $d
142
143 frame $w.frame.v.modes -relief groove -borderwidth 2
144 extout_build_modes $w.frame.v.modes $d
145
146 frame $w.frame.v.buttons
147 extout_build_buttons $w.frame.v.buttons $d
148
149 #FIXME
150 pack $w.frame.v.tn $w.frame.v.modes $w.frame.v.buttons \
151 -side left -padx 2
152
153 set mb $w.frame.src
154 menubutton $mb -text "<no stream>" -menu $mb.menu \
155 -relief raised -width 20
156 global extout_mb
157 set extout_mb($d) $mb
158 bind $mb <1> "extout_mb_post $d \$tkPriv(inMenubutton) %X %Y"
159
160 pack $w.frame.v $w.frame.src -fill x -pady 2 -padx 2
161
162 pack $w.title.main -anchor w
163 pack $w.title -fill x
164 pack $w.frame -expand 1 -fill both -anchor center
165
166 wm geometry $w +[winfo pointerx .]+[winfo pointery .]
167 wm deiconify $w
168 wm protocol $w WM_DELETE_WINDOW "wm withdraw $w"
169
170 button $w.dismiss -relief raised \
171 -command "wm withdraw $w" -text Dismiss -font $f
172 pack $w.dismiss -anchor c -pady 2
173
174 switcher_register $d "" extout_switch
175 }
176
177 proc extout_switch { d src } {
178 extout_release $d
179 extout_bind $d $src
180 }
181
182 proc extout_shutdown { d w } {
183 extout_release $d
184 destroy $w
185 }
186
187 proc extout_release d {
188 global extout_target extout_src extout_tn
189 if [info exists extout_src($d)] {
190 detach_window $extout_src($d) $extout_tn($d)
191 extout_detach $d
192 unset extout_src($d)
193 }
194 }
195
196 proc extout_detach d {
197 global extout_target extout_src
198 set src $extout_src($d)
199 [$src handler] detach $extout_target($d)
200 delete $extout_target($d)
201 unset extout_target($d)
202 }
203
204 proc extout_bind { d src } {
205 extout_release $d
206 extout_attach $d $src
207 global extout_tn
208 # win_is_slow
209 attach_window $src $extout_tn($d)
210 }
211
212 proc extout_attach { d src } {
213 global extout_target extout_src extout_mb extout_scale src_nickname
214 set fmt [$src format_name]
215 if { $fmt == "jpeg" } {
216 set fmt $fmt/[[$src handler] csss]
217 }
218 set target [$d assistor $fmt]
219 if { $target == "" } {
220 set target [$d renderer [[$src handler] csss]]
221 }
222 if { $target != "" } {
223 set extout_src($d) $src
224 set extout_target($d) $target
225 $target scale $extout_scale($d)
226 [$src handler] attach $target
227 $extout_mb($d) configure -text $src_nickname($src)
228 extout_set_slow $d
229 return $target
230 }
231 #FIXME need placeholder
232 return ""
233 }
234
235 #
236 # detach $src from any external output paths that
237 # are viewing it. return list of decoders that
238 # were viewing $src.
239 #
240 proc extout_detach_src src {
241 global extout_src
242 if ![info exists extout_src] {
243 return
244 }
245 set list ""
246 foreach d [array names extout_src] {
247 if { $extout_src($d) == $src } {
248 extout_detach $d
249 set list "$list $d"
250 }
251 }
252 return $list
253 }
254
255 #
256 # attach $src to the list of external output paths in $list
257 #
258 proc extout_attach_src { src list } {
259 foreach d $list {
260 extout_attach $d $src
261 }
262 }
263
264 proc extout_set_switched d {
265 global extout_is_switched
266 if { $extout_is_switched($d) != 0 } {
267 switcher_enable $d
268 } else {
269 switcher_disable $d
270 }
271 }
272
273 proc extout_set_timed d {
274 global extout_is_timed
275 if { $extout_is_timed($d) != 0 } {
276 switcher_set_timer $d
277 } else {
278 switcher_cancel_timer $d
279 }
280 }
281
282 proc extout_set_slow d {
283 global extout_target extout_is_slow
284 if [info exists extout_target($d)] {
285 if $extout_is_slow($d) {
286 # FIXME Since stampInterval is not a global option, this will set interval to ""
287 set interval [option get . stampInterval Vic]
288 } else {
289 set interval 0
290 }
291 $extout_target($d) update-interval $interval
292 }
293 }
294
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.