~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/vic/ui-videobox.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # ui-videobox.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1998-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 #  @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/vic/ui-videobox.tcl,v 1.10 2002/02/03 04:39:55 lim Exp $
 32 
 33 
 34 import ActiveSource WidgetClass
 35 
 36 #vbx which attribs are required
 37 
 38 #
 39 # VideoBox is a configurable widget that is, in its basic form,
 40 # a frame for displaying the VideoWidget of an ActiveSource.
 41 # <p>
 42 # As with all tk widgets, the first argument to the <i>VideoBox</i> command is the widget name.
 43 # <p>
 44 # The available attributes are as follows... <br>
 45 # <table>
 46 #            <tr><td>   -attachSource <i>src</i>       </td><td>identify the source to be displayed by the VideoWidget
 47 #  </td></tr><tr><td>   -size <i>size</i>              </td><td>set the size of the VideoWidget: thumbnail/small/medium/large
 48 #  </td></tr><tr><td>   -updateSpeed <i>speed</i>      </td><td>set the speed with which the videowidget is updated: slow/normal
 49 #  </td></tr><tr><td>   -cb <i>coordBus</i>            </td><td>identify the coordination-bus
 50 #  </td></tr><tr><td>   -switchMode <i>mode</i>        </td><td>startup a switching mode: voice/timer/voice&timer
 51 #  </td></tr><tr><td>   -switchTimer <i>timeout</i>    </td><td>set the cycle-time for sources in this VideoBox (applicable only if timer-switched)
 52 #  </td></tr><tr><td>   -switchSet <i>set</i>          </td><td>identify a set of ActiveSources through which the VideoWindow should cycle
 53 #  </td></tr><tr><td>   -outputMeter <i>bool</i>       </td><td>display an output meter for the source being displayed: true/false
 54 #  </td></tr><tr><td>   -cameraCtrls <i>bool</i>       </td><td>display camera control for the source being displayed if available: true/false
 55 #  </td></tr><tr><td>   -border <i>bool</i>            </td><td>display a border around the video window: true/false
 56 #  </td></tr><tr><td>   -nametag <i>bool</i>           </td><td>display a nametag for the source being displayed if available: true/false
 57 #  </td></tr><tr><td>   -ui <i>userInterface</i>       </td><td>ui identifies the user-interface by which this VideoBox is being displayed
 58 #  </td></tr>
 59 # </table>
 60 # <p>
 61 # To query the value of an attribute, use the get_attribute method. <br>
 62 #    (ex:   $vidbox get_attribute -size)
 63 #
 64 WidgetClass VideoBox -configspec {
 65         { -attachSource attachSource AttachSource {} attach_source get_attribute }
 66         { -size size Size medium set_size get_attribute }
 67         { -updateSpeed updateSpeed UpdateSpeed normal set_speed get_attribute }
 68         { -cb cb CB {} set_cb get_attribute }
 69         { -switchMode switchMode SwitchMode voice&timer set_switchMode get_attribute }
 70         { -switchTimer switchTimer SwitchTimer 15 set_switchTimer get_attribute }
 71         { -switchSet switchSet SwitchSet {} define_switchSet get_attribute }
 72         { -outputMeter outputMeter OutputMeter false set_outputMeter get_attribute }
 73         { -cameraCtrls cameraCtrls CameraCtrls false set_cameraCtrls get_attribute }
 74         { -border border Border true set_border get_attribute }
 75         { -nametag nametag Nametag true set_nametag get_attribute }
 76         { -ui ui UI {} set_ui get_attribute }
 77 } -default {
 78 } -alias {
 79         { -src -attachSource }
 80 }
 81 
 82 #
 83 # Returns the default setting of an attribute.
 84 # ex: $vidbox get_default_attr -size
 85 #
 86 VideoBox public get_default_attr { attributes } {
 87         $self instvar tkWidgetName_
 88 
 89         foreach attribute $attributes {
 90                 regsub {\-} $attribute ""  attributename
 91                 regsub {(.*)} $attributename &_ instvariable
 92                 $self instvar $instvariable
 93 
 94                 # yatin says this is how to get default values before build widget
 95                 # ex:  set border_ [option get $tkWidgetName border [$self info class]]
 96 
 97                 set $instvariable [option get $tkWidgetName_ $attributename [$self info class]]
 98 
 99                 # set value [option get $tkWidgetName_ $attribute [$self info class]]
100                 # puts "set $instvariable $value"
101         }
102 }
103 
104 #
105 VideoBox private build_widget { tkWidgetName } {
106         $self instvar tkWidgetName_
107         set tkWidgetName_ $tkWidgetName
108 
109         $self get_default_attr { -border -as -size -nametag }
110         $self set_dimensions
111 
112         $self instvar vw_ vbox_ width_ height_ vwPath_
113         set vbox_ [frame $tkWidgetName.vbox -relief ridge -borderwidth 2]
114         set vwPath_ $vbox_.vw
115         set vw_ [new VideoWidget $vwPath_ $width_ $height_]
116         pack $vbox_.vw -anchor c
117         pack $vbox_ -fill none -expand 0
118 
119         #$self set_label_text "Waiting for a source to fill this VideoBox"
120         $self set_label_text "Waiting for video"
121 
122         #vbx
123         $self instvar isEmpty_
124         set isEmpty_ 1
125         $self unset_manager_switched
126 }
127 
128 #
129 # If this VideoBox is managed by a VideoBoxManager, default switching policies will be instated.
130 #
131 VideoBox public set_manager_switched { } {
132         $self instvar isManagerSwitched_
133         set isManagerSwitched_ 1
134 }
135 
136 #
137 # If this VideoBox is managed by a VideoBoxManager, default switching policies will be un-instated.
138 #
139 VideoBox public unset_manager_switched { } {
140         $self instvar isManagerSwitched_
141         set isManagerSwitched_ 0
142 }
143 
144 #
145 # Accessor function to determine whether or not default switching
146 # policies are instated on this VideoBox (which only constitutes
147 # useful data if this VideoBox is managed by a VideoBoxManager.)
148 #
149 VideoBox public is_manager_switched { } {
150         $self instvar isManagerSwitched_
151         return $isManagerSwitched_
152 }
153 
154 #
155 # Return the VideoWidget being displayed in this VideoBox.
156 #
157 VideoBox public get_video_widget {} {
158         $self instvar vw_
159         return [$self set vw_]
160 }
161 
162 #
163 # Return the widget-path of the VideoWidget being displayed in this VideoBox.
164 #
165 VideoBox public get_video_widget_path {} {
166         return [$self set vwPath_]
167 }
168 
169 #
170 VideoBox private set_attribute { option value } {
171         regsub {\-} $option ""  optionname
172         regsub {(.*)} $optionname &_ instvariable
173         $self instvar $instvariable
174 
175         set $instvariable $value
176 
177         #vbx
178         puts "set_attribute: set $instvariable $value"
179 }
180 
181 #
182 # Returns the value of the specified option.
183 # This method should only be used by options that set their value to the instvar by the same name.
184 # ex: $self get_attribute -size can return the value of the -size attribute because it
185 # can be found in the instvar size_
186 #
187 VideoBox public get_attribute { option } {
188         regsub {\-} $option ""  optionname
189         regsub {(.*)} $optionname &_ instvariable
190         $self instvar $instvariable
191 
192         set val [$self set $instvariable]
193         #vbx
194         puts "get_attribute $option        returns $val"
195 
196         return [$self set $instvariable]
197 }
198 
199 #
200 VideoBox private attach_source { option src } {
201         if { $src != {} } {
202                 $self switch $src
203 #vbx            puts "$self switching to src = $src"
204         }
205 }
206 
207 #
208 VideoBox private set_size { option size } {
209         $self instvar size_
210         set size_ $size
211 
212         $self set_dimensions
213         $self resize
214 }
215 
216 #
217 VideoBox private set_dimensions {} {
218         $self instvar size_ width_ height_ border_
219 
220         if { $border_ } {
221                 switch -- $size_ {
222                         "thumbnail" {
223                                 set width_ 80
224                                 set height_ 60
225                         }
226                         "small" {
227                                 # QCIF
228                                 set width_ 176
229                                 set height_ 144
230                         }
231                         "medium" {
232                                 # CIF
233                                 set width_ 352
234                                 set height_ 288
235                         }
236                         "large" {
237                                 # SCIF
238                                 set width_ 704
239                                 set height_ 576
240                         }
241                         default {
242                                 set width_ 80
243                                 set height_ 60
244                         }
245                         "thumbnail" {
246                                 set width_ 80
247                                 set height_ 60
248                         }
249                         "small" {
250                                 # 1/16 NTSC
251                                 set width_ 160
252                                 set height_ 120
253                         }
254                         "medium" {
255                                 # 1/4 NTSC
256                                 set width_ 320
257                                 set height_ 240
258                         }
259                         "large" {
260                                 # NTSC
261                                 set width_ 640
262                                 set height_ 480
263                         }
264                         default {
265                                 set width_ 80
266                                 set height_ 60
267                         }
268                 }
269         } else {
270                 switch -- $size_ {
271                         "thumbnail" {
272                                 set width_ 80
273                                 set height_ 60
274                         }
275                         "small" {
276                                 # 1/16 NTSC
277                                 set width_ 160
278                                 set height_ 120
279                         }
280                         "medium" {
281                                 # 1/4 NTSC
282                                 set width_ 320
283                                 set height_ 240
284                         }
285                         "large" {
286                                 # NTSC
287                                 set width_ 640
288                                 set height_ 480
289                         }
290                         default {
291                                 set width_ 80
292                                 set height_ 60
293                         }
294                 }
295         }
296 }
297 
298 #
299 # resize a videobox
300 #
301 VideoBox private resize { } {
302         $self instvar width_ height_ vw_ as_
303 
304         if { $as_ != {} } {
305                 $as_ detach_videobox $self
306         }
307 
308         [$vw_ window] resize $width_ $height_
309 
310         if { $as_ != {} } {
311                 #
312                 # Force an update so the window gets mapped at
313                 # the new size before we re-bind the window
314                 # to the source.
315                 #
316                 update idletasks
317 #vbx
318                 puts "RE-ATTACHING VB"
319                 $as_ attach_videobox $self
320         }
321 
322         $self update_label
323 }
324 
325 #
326 VideoBox private set_cb { option cb } {
327         $self instvar cb_
328         set cb_ $cb
329 }
330 
331 #
332 VideoBox private set_switchMode { option mode } {
333         # voice timer voice&timer
334         $self instvar switchMode_
335         set switchMode_ $mode
336 }
337 
338 #
339 VideoBox private set_switchTimer { option timeout } {
340         $self instvar switchTimer_
341         set switchTimer_ $timeout
342 }
343 
344 #
345 VideoBox private define_switchSet { option switchset } {
346         $self instvar switchSet_
347         set switchSet_ $switchset
348 }
349 
350 #
351 # if audio is available for $src_, optionally show/hide output meter
352 #
353 VideoBox private set_outputMeter { option bool } {
354         # true (1) or false (0)
355         $self instvar outputMeter_
356         set outputMeter_ $bool
357 }
358 
359 #
360 # if camera_ctrls are available for $src_, optionally show/hide them
361 #
362 VideoBox private set_cameraCtrls { option bool } {
363         # true (1) or false (0)
364         $self instvar cameraCtrls_
365         set cameraCtrls_ $bool
366 }
367 
368 #
369 VideoBox private set_speed { option speed } {
370         # slow or normal
371         $self instvar updateSpeed_ vw_
372         set updateSpeed_ $speed
373 
374         if { $updateSpeed_ == "slow" } {
375                 $vw_ set_slow
376         } else {
377                 $vw_ set_normal
378         }
379 }
380 
381 #
382 VideoBox private set_border { option bool } {
383         # true (1) or false (0)
384         $self instvar border_ size_
385         set border_ $bool
386 
387         $self set_dimensions
388         $self resize
389 }
390 
391 #
392 VideoBox private set_ui { option ui } {
393         $self instvar ui_
394         set ui_ $ui
395 }
396 
397 #
398 VideoBox private set_nametag { option bool } {
399         # true (1) or false (0)
400         $self instvar nametag_
401         set nametag_ $bool
402 
403         $self update_label
404 }
405 
406 #
407 VideoBox private set_label_text { label_text } {
408         $self instvar vbox_ vbox_label_
409 
410         if { ![winfo exists $vbox_.label] } {
411                 set vbox_label_ [label $vbox_.label]
412         }
413 
414         $vbox_label_ config -text $label_text
415         $self update_label
416 }
417 
418 #
419 VideoBox private set_label_textvariable { label_textvariable } {
420         $self instvar vbox_ vbox_label_
421 
422         if { ![winfo exists $vbox_.label] } {
423                 set vbox_label_ [label $vbox_.label]
424         }
425 
426         $vbox_label_ config -textvariable $label_textvariable
427         $self update_label
428 }
429 
430 #
431 VideoBox private update_label {} {
432         $self instvar nametag_ vbox_ vbox_label_ vbox_label_frame_ width_
433 
434         if { ![winfo exists $vbox_.label] } {
435                 set vbox_label_ [label $vbox_.label]
436         }
437 
438         if { ![winfo exists $vbox_.label_frame] } {
439                 set vbox_label_frame_ [frame $vbox_.label_frame]
440         }
441 
442         $vbox_label_ config -font [$self get_option medfont] -pady 1 -borderwidth 0 -anchor w
443 #       -background yellow
444 
445         $vbox_label_frame_ config -width $width_ -height 15
446 
447         if { $nametag_ } {
448                 pack $vbox_label_ -anchor c -expand 0 -side top -fill none -in $vbox_label_frame_
449                 pack $vbox_label_frame_ -anchor c -expand 0 -side top -fill none
450                 raise $vbox_label_
451                 pack propagate $vbox_label_frame_ 0
452         } else {
453                 pack forget $vbox_label_
454                 pack forget $vbox_label_frame_
455         }
456 }
457 
458 #
459 VideoBox public highlight_border { } {
460 }
461 
462 #
463 VideoBox public unhighlight_border { } {
464 }
465 
466 #
467 VideoBox public highlight_nametag { } {
468 }
469 
470 #
471 VideoBox public unhighlight_nametag { } {
472 }
473 
474 #
475 VideoBox public start_border_blinking { } {
476 }
477 
478 #
479 VideoBox public stop_border_blinking { } {
480 }
481 
482 #
483 VideoBox public start_nametag_blinking { } {
484 }
485 
486 #
487 VideoBox public stop_nametag_blinking { } {
488 }
489 
490 #
491 # Display Source <i>src</i>.
492 #
493 VideoBox public switch { src } {
494         $self instvar as_ ui_ src_ isEmpty_
495 
496         set src_ $src
497 
498         #FIXME map src to active source using UI's data structure
499         set as [[$ui_ set asm_] get_activesource $src]
500 
501         if { $as_ != $as } {
502                 if { $as_ != {} } {
503                         $as_ detach_videobox $self
504                 }
505                 set as_ $as
506                 $as_ attach_videobox $self
507                 $self set_label_textvariable src_nickname($src_)
508                 set isEmpty_ 0
509         }
510 
511         # in this method, probably where to reattach output meter, camctrls, to new src
512 
513         $self instvar sequenceStamp_
514         set sequenceStamp_ [VideoBox incr_sequence_counter]
515 }
516 
517 #
518 # Increments a counter and returns this as a sequence number that is
519 # unique and higher than that returned to any existing VideoBox at
520 # any previous time during program execution.
521 # (A single sequence number space is shared among ALL VideoBoxes.)
522 #
523 VideoBox proc incr_sequence_counter {} {
524         $self instvar seqCounter_
525 
526         if {![info exist seqCounter_]} {
527                 set seqCounter_ 0
528         } else {
529                 incr seqCounter_
530         }
531 
532         return $seqCounter_
533 }
534 
535 #
536 # Accessor function to return the sequence stamp of this VideoBox.  The
537 # higher the sequence number, then the more recently this VideoBox has
538 # performed a "switch".
539 # (A single sequence number space is shared among ALL VideoBoxes.)
540 #
541 VideoBox public get_sequence_stamp {} {
542         $self instvar sequenceStamp_
543 
544         if {![info exist sequenceStamp_]} {
545                 return 0
546         } else {
547                 return $sequenceStamp_
548         }
549 }
550 
551 #
552 # Returns 0 if this VideoBox is displaying a Source.  Otherwise, returns 1.
553 #
554 VideoBox public is_empty {} {
555 #vbx
556         $self instvar isEmpty_
557         return $isEmpty_
558 }
559 
560 #
561 # If this VideoBox is displaying a Source, return it.  Otherwise return nothing.
562 #
563 VideoBox public get_src_displayed {} {
564 #vbx
565         if {[$self is_empty]} {
566                 return
567         } else {
568                 $self instvar src_
569                 return $src_
570         }
571 }
572 
573 
574 VideoBox public get_activesource {} {
575         return [$self set as_]
576 }
577 
578 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.