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

Open Mash Cross Reference
mash/tcl/dc/dc/ui-dcbroadcast.tcl

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

  1 # ui-dcbroadcast.tcl --
  2 #
  3 #       UI for broadcast pane.  Handles drag/drop events which cause
  4 #       broadcast/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 CDcUIBroadcastFrame
 35 
 36 CDcUIBroadcastFrame 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_luiBroadcast
 42     $self instvar m_agentBroadcast
 43 
 44     $self next
 45 
 46     # initialize member variables
 47     set m_iFrameCounter 0
 48     set m_luiBroadcast ""
 49 
 50     # copy arguments to member variables
 51     set m_appDc $appDc
 52     set m_uiMain $uiMain
 53     set m_winFrame $winFrame
 54     set m_agentBroadcast [$m_appDc get_bcast_agent]
 55 
 56     # build the ui
 57     $self BuildUI
 58 }
 59 
 60 CDcUIBroadcastFrame instproc BuildUI {} {
 61     $self instvar m_winFrame
 62 
 63     # the layout of this frame goes like this:
 64     # Inside the main frame, there are two frames
 65     # the top frame has a label in it
 66     # the bottom frame has a column of broadcasts
 67 
 68     # the top frame
 69     set f [[$self options] get_option smallfont]
 70     label $m_winFrame.title -text "Broadcast" -relief ridge -font $f
 71     pack $m_winFrame.title -side top -fill x
 72 
 73     # the bottom frame
 74     frame $m_winFrame.broadcast -relief ridge -borderwidth 2
 75     pack $m_winFrame.broadcast -side top -fill both
 76 }
 77 
 78 CDcUIBroadcastFrame public DropPreview { dragNDrop uiPreview x y } {
 79     set source [$uiPreview set m_source]
 80     set service [$uiPreview set m_service]
 81 
 82     return [$self DropSource $dragNDrop $source $service $x $y]
 83 }
 84 
 85 CDcUIBroadcastFrame public DropThumbnail { dragNDrop uiThumbnail x y } {
 86     set source [$uiThumbnail set m_source]
 87     set service [$uiThumbnail set m_service]
 88 
 89     return [$self DropSource $dragNDrop $source $service $x $y]
 90 }
 91 
 92 CDcUIBroadcastFrame public DropSource { dragNDrop source service x y } {
 93     $self instvar m_uiMain
 94     $self instvar m_winFrame
 95     $self instvar m_luiBroadcast
 96     $self instvar m_agentBroadcast
 97 
 98     # first check if it was dropped within the main window
 99     if { ![$m_uiMain is_in_window $m_winFrame $x $y] } {
100         return 0
101     }
102 
103     # next we'll check if the source was dropped in a broadcast window
104     foreach uiBroadcast $m_luiBroadcast {
105 
106         set win [$uiBroadcast set m_winFrame]
107         if { ![$m_uiMain is_in_window $win $x $y] } {
108             continue
109         }
110 
111         # if it's in the broadcast window then we should switch the source
112         # for this window
113         $uiBroadcast SwitchSource $source $service
114         return 1
115     }
116 
117     # Else we'll have to create a new broadcast window and add it
118     $self instvar m_appDc
119     $self instvar m_uiMain
120     $self instvar m_iFrameCounter
121 
122     # create the frame for the window
123     set winFrame [frame $m_winFrame.$m_iFrameCounter]
124     pack $m_winFrame.$m_iFrameCounter -side top
125 
126     # increment the frame counter
127     set m_iFrameCounter [expr "$m_iFrameCounter + 1"]
128 
129     set uiBroadcast [new CDcUIBroadcast $m_appDc $m_uiMain $self \
130             $winFrame $m_agentBroadcast $source $service]
131 
132     # add it to the list of review windows
133     lappend m_luiBroadcast $uiBroadcast
134 
135     return 1
136 }
137 
138 CDcUIBroadcastFrame public RemoveBroadcast { uiBroadcast } {
139     $self instvar m_luiBroadcast
140 
141     # get the broadcast window
142     set winFrame [$uiBroadcast set m_winFrame]
143 
144     # remote it from the list of broadcasts
145     set luiNewBroadcast ""
146     foreach uiBroadcastTemp $m_luiBroadcast {
147         if { $uiBroadcast != $uiBroadcastTemp } {
148             lappend luiNewBroadcast $uiBroadcastTemp
149         }
150     }
151     set m_luiBroadcast $luiNewBroadcast
152 
153     # destory the broadcast
154     delete $uiBroadcast 
155 
156     # get the frame for this broadcast
157     destroy $winFrame
158 }
159 
160 CDcUIBroadcastFrame public getBroadcastInfo {} {
161     $self instvar m_luiBroadcast
162 
163     set arr(windows) ""
164     foreach uiBroadcast $m_luiBroadcast {
165         lappend arr(windows) $uiBroadcast
166         set source [$uiBroadcast set m_source]
167         set inetAddr [$source addr]
168         set hostname [lookup_host_name $inetAddr]
169         set hostname [string tolower $hostname]
170         set arr($uiBroadcast,hostname) $hostname
171         set arr($uiBroadcast,addr) $inetAddr
172     }
173     set retList [array get arr]
174     return $retList
175 }
176 
177 
178 #
179 # Return the CDcUIPreview object containing the source 
180 #
181 CDcUIBroadcastFrame public GetUIVideoWithSource { source } {
182     $self instvar m_luiBroadcast
183     foreach p $m_luiBroadcast {
184         if {[$p GetSource] == $source} {
185             return $p
186         }
187     }
188     return ""
189 }
190 
191 
192 
193 Class CDcUIBroadcast -superclass CDcUIVideo
194 
195 CDcUIBroadcast public init { appDc uiMain uiBroadcastFrame winFrame \
196         agentBroadcast source service} {
197 
198     $self next $uiMain $winFrame $source $service
199 
200     # member variables
201     $self instvar m_appDc
202     $self instvar m_uiBroadcastFrame
203     $self instvar m_dragNDrop
204     $self instvar m_winFrame
205     $self instvar m_agentBroadcast
206     $self instvar m_iOutSrcId
207 
208     # store away input
209     set m_appDc $appDc
210     set m_uiBroadcastFrame $uiBroadcastFrame
211     set m_winFrame $winFrame
212     set m_agentBroadcast $agentBroadcast
213 
214     set m_dragNDrop 0
215 
216     # step the packet switcher
217     set m_iOutSrcId [$m_agentBroadcast map_source [$source srcid]]
218 
219     $self BuildUI
220 }
221 
222 CDcUIBroadcast public destroy { } {
223     $self instvar m_agentBroadcast
224     $self instvar m_iOutSrcId
225     $self instvar m_source
226 
227     # unmap the outgoing video
228     $m_agentBroadcast unmap_source [$m_source srcid] $m_iOutSrcId
229 
230     $self next
231 }
232 
233 CDcUIBroadcast public StartVideo { } {
234     $self next
235 
236     $self instvar m_winFrame
237 
238     # create and deal with the drag n drop object
239     set m_dragNDrop [new DragNDrop $m_winFrame.frame.video.video \
240             "$self DropBroadcast"]
241 }
242 
243 CDcUIBroadcast public SwitchSource { source service } {
244     $self instvar m_agentBroadcast
245     $self instvar m_iOutSrcId
246     $self instvar m_source
247 
248     # now let's deal with the video agent and the switcher
249     $m_agentBroadcast unmap_source [$m_source srcid] $m_iOutSrcId
250     $m_agentBroadcast map_source [$source srcid] $m_iOutSrcId
251 
252 
253     # first let's deal with the video object
254     $self SwitchVideo $source
255     $self SwitchService $service
256 }
257 
258 CDcUIBroadcast public DropBroadcast { dragNDrop x y } {
259     $self instvar m_uiMain
260     $self instvar m_uiBroadcastFrame
261 
262     # get the main window for the broadcast frame
263     set winFrame [$m_uiBroadcastFrame set m_winFrame]
264 
265     # check if it was dropped within the main window
266     if { ![$m_uiMain is_in_window $winFrame $x $y] } {
267         $m_uiBroadcastFrame RemoveBroadcast $self
268         return
269     }
270 
271     $dragNDrop zoom_back
272 }
273 

~ [ 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.