1 # ui-dcpreview.tcl --
2 #
3 # UI for preview pane. Handles drag/drop events which cause
4 # decoding/clearing to occur.
5 #
6 # Copyright (c) 2000-2002 The Regents of the University of California.
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions are met:
11 #
12 # A. Redistributions of source code must retain the above copyright notice,
13 # this list of conditions and the following disclaimer.
14 # B. Redistributions in binary form must reproduce the above copyright notice,
15 # this list of conditions and the following disclaimer in the documentation
16 # and/or other materials provided with the distribution.
17 # C. Neither the names of the copyright holders nor the names of its
18 # contributors may be used to endorse or promote products derived from this
19 # software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
25 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 import CDcUIVideo
33
34 Class CDcUIPreviewFrame
35
36 CDcUIPreviewFrame instproc init { appDc uiMain winFrame } {
37 $self instvar m_appDc
38 $self instvar m_uiMain
39 $self instvar m_winFrame
40 $self instvar m_iFrameCounter
41 $self instvar m_luiPreview
42
43 $self next
44
45 # initialize member variables
46 set m_iFrameCounter 0
47 set m_luiPreview ""
48
49 # copy arguments to member variables
50 set m_appDc $appDc
51 set m_uiMain $uiMain
52 set m_winFrame $winFrame
53
54 # build the ui
55 $self BuildUI
56 }
57
58 CDcUIPreviewFrame instproc BuildUI {} {
59 $self instvar m_winFrame
60
61 # the layout of this frame goes like this:
62 # Inside the main frame, there are two frames
63 # the top frame has a label in it
64 # the bottom frame has a column of previews
65
66 # the top frame
67 set f [$self get_option smallfont]
68 label $m_winFrame.title -text "Preview" -relief ridge -font $f
69 pack $m_winFrame.title -side top -fill x
70
71
72 # the bottom frame
73 frame $m_winFrame.preview -relief ridge -borderwidth 2
74 pack $m_winFrame.preview -side top -fill both
75 }
76
77 CDcUIPreviewFrame public DropThumbnail { dragNDrop uiThumbnail x y } {
78 $self instvar m_winFrame
79 $self instvar m_luiPreview
80 $self instvar m_uiMain
81
82 # first check if it was dropped within the main window
83 if { ![$m_uiMain is_in_window $m_winFrame $x $y] } {
84 return 0
85 }
86
87 set source [$uiThumbnail set m_source]
88 set service [$uiThumbnail set m_service]
89
90 # next we'll check if the uiThumbnail was dropped in a preview window
91 foreach uiPreview $m_luiPreview {
92
93 set win [$uiPreview set m_winFrame]
94 if { ![$m_uiMain is_in_window $win $x $y] } {
95 continue
96 }
97
98 # if it's in the preview window then we should switch the source
99 # for this window
100 $uiPreview SwitchSource $source $service
101 return 1
102 }
103
104 # Else we'll have to create a new preview window and add it
105 $self instvar m_appDc
106 $self instvar m_uiMain
107 $self instvar m_iFrameCounter
108
109 # create the frame for the window
110 set winFrame [frame $m_winFrame.$m_iFrameCounter]
111 pack $m_winFrame.$m_iFrameCounter -side top
112
113 # increment the frame counter
114 set m_iFrameCounter [expr "$m_iFrameCounter + 1"]
115
116 set uiPreview [new CDcUIPreview $m_appDc $m_uiMain $self $winFrame \
117 $source $service]
118
119 # add it to the list of review windows
120 lappend m_luiPreview $uiPreview
121
122 return 1
123 }
124
125 CDcUIPreviewFrame public RemovePreview { uiPreview } {
126 $self instvar m_luiPreview
127
128 # get the preview window
129 set winFrame [$uiPreview set m_winFrame]
130
131 # remote it from the list of previews
132 set luiNewPreview ""
133 foreach uiPreviewTemp $m_luiPreview {
134 if { $uiPreview != $uiPreviewTemp } {
135 lappend luiNewPreview $uiPreviewTemp
136 }
137 }
138 set m_luiPreview $luiNewPreview
139
140 # destory the preview
141 delete $uiPreview
142
143 # get the frame for this preview
144 destroy $winFrame
145 }
146
147 CDcUIPreviewFrame public getPreviewInfo {} {
148 $self instvar m_luiPreview
149
150 set arr(windows) ""
151 foreach uiPreview $m_luiPreview {
152 lappend arr(windows) $uiPreview
153 set source [$uiPreview set m_source]
154 set inetAddr [$source addr]
155 set hostname [lookup_host_name $inetAddr]
156 set hostname [string tolower $hostname]
157 set arr($uiPreview,hostname) $hostname
158 set arr($uiPreview,addr) $inetAddr
159 }
160 set retList [array get arr]
161 return $retList
162 }
163
164 #
165 # Return the CDcUIPreview object containing the source
166 #
167 CDcUIPreviewFrame public GetUIVideoWithSource { source } {
168 $self instvar m_luiPreview
169 foreach p $m_luiPreview {
170 if {[$p GetSource] == $source} {
171 return $p
172 }
173 }
174 return ""
175 }
176
177 Class CDcUIPreview -superclass CDcUIVideo
178
179 CDcUIPreview public init { appDc uiMain uiPreviewFrame winFrame \
180 source service} {
181
182 $self next $uiMain $winFrame $source $service
183
184 # member variables
185 $self instvar m_appDc
186 $self instvar m_uiPreviewFrame
187 $self instvar m_dragNDrop
188 $self instvar m_winFrame
189
190 # store away input
191 set m_appDc $appDc
192 set m_uiPreviewFrame $uiPreviewFrame
193 set m_winFrame $winFrame
194
195 set m_dragNDrop 0
196
197 $self BuildUI
198 }
199
200 CDcUIPreview public StartVideo { } {
201 $self next
202
203 $self instvar m_winFrame
204
205 # create and deal with the drag n drop object
206 set m_dragNDrop [new DragNDrop $m_winFrame.frame.video.video \
207 "$self DropPreview"]
208 }
209
210 CDcUIPreview public SwitchSource { source service } {
211 $self SwitchVideo $source
212 $self SwitchService $service
213 }
214
215 CDcUIPreview public DropPreview { dragNDrop x y } {
216 $self instvar m_uiMain
217 $self instvar m_uiPreviewFrame
218
219 #get the broadcast frame object
220 set uiBroadcastFrame [$m_uiMain set m_uiBroadcastFrame]
221
222 # check if it was dropped into the broadcast frame
223 if { [$uiBroadcastFrame DropPreview $dragNDrop $self $x $y] } {
224 return
225 }
226
227 set winFrame [$m_uiPreviewFrame set m_winFrame]
228
229 # check if it was dropped within the main window
230 if { ![$m_uiMain is_in_window $winFrame $x $y] } {
231 $m_uiPreviewFrame RemovePreview $self
232 return
233 }
234
235 $dragNDrop zoom_back
236 }
237
238
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.