1 # ui-browsetime.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1997-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/mb/ui-browsetime.tcl,v 1.4 2002/02/03 04:27:17 lim Exp $
32
33
34 Class MBTimePanel
35
36 MBTimePanel instproc init {parent} {
37 $self instproc path_ slider_ timeLabel_ stopBut_ playBut_
38 set path_ [frame $parent.ts]
39 set slider_ [scale $path_.slider -orient horizontal \
40 -from 0 -to 10000 -relief groove -borderwidth 1 \
41 -showvalue false -command "$self updateLabel"]
42 #
43 # We want slightly different semantics. Instead of tracking
44 # the time slider continuously, we just update it when the
45 # button is released. (but we use updateTime to give feedback to the
46 # user
47 # E.g., it takes too long to do a fast-forward each time.
48 #
49 bind $slider_ <Button-1> "$self wait"
50 bind $slider_ <Button-2> "$self wait"
51
52 bind $slider_ <ButtonRelease-1> "$self move2time"
53 bind $slider_ <ButtonRelease-2> "$self move2time"
54
55 pack $slider_ -side left -fill x
56
57 set timeLabel_ [label $path_.timeL]
58 set stopBut_ [button $path_.stopB -text stop -command "$self stop"]
59 set playBut_ [button $path_.playB -text play -command "$self start"]
60 pack -side left $timeLabel_ $stopBut_ $playBut_ -fill x
61 }
62
63 MBTimePanel instproc formatTime {time} {
64 clock format $time "%h:%M:%S $p"
65 }
66
67 MBTimePanel instproc minTime {time} {
68 $self set mintime_ $time
69 }
70
71 MBTimePanel instproc maxTime {time} {
72 $self set maxtime_ $time
73 }
74
75 MBTimePanel instproc pack {args} {
76 eval pack $args [$self set path_]
77 }
78
79 MBTimePanel instproc unpack {} {
80 pack forget [$self set $path_]
81 }
82
83 MBTimePanel instproc updateCallBack {cmd} {
84 $self set updateCallBack_ $cmd
85 }
86
87 MBTimePanel instproc setTime {val} {
88 $self instvar updateCallBack_
89 set newtime [expr {$mintime_ + ($x/10000.0)*($maxtime_ - $mintime_)}]
90 eval $updateCallBack_ $newtime
91 }
92
93 MBTimePanel instproc updateLabel {x} {
94 $self instvar timeLabel_
95 $self set sliderVal $x
96 set newtime [expr {$mintime_ + ($x/10000.0)*($maxtime_ - $mintime_)}]
97 $timeLabel_ configure -text [$self formatTime newtime]
98 }
99
100 MBTimePanel instproc move2time {x} {
101 set newtime [expr $mintime_ + ($x/10000.0)*($maxtime_ - $mintime_)]
102 $self setTime $x
103 }
104
105
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.