1 # layout.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
32 #
33 # Used to aggregate info on a setup of video windows
34 # in rvic, defined by msgs:
35 # <br> "Set VideoWindowGeom CxD+A+B"
36 # <br> "Set VoiceSwitchList `vw_num list' ..."
37 # <br> "Set TimerSwitchList `vw_num list' ..."
38 # <br> "Set TimerSwitchInterval `vw_num secs' ..."
39 # <br>
40 #
41 Class RvicLayout
42
43 # create a new rvic layout
44 RvicLayout public init {{name "empty"} {msg ""}} {
45 $self instvar numWindows_ name_ windows_
46 set name_ $name
47 set numWindows_ 0
48
49 $self parse_msgs $msg
50 }
51
52 # parse a list of msgs and configure the layout appropriately
53 RvicLayout private parse_msgs {msg} {
54 set msglist [$self convert_to_msglist $msg]
55 foreach m $msglist {
56 set m [string trim $m]
57 if {[lindex $m 0] != "Set"} {
58 puts "Bad msg in RvicLayout::init -- $m"
59 continue
60 }
61 set i1 [lindex $m 1]
62 switch $i1 {
63 "VideoWindowGeom" {$self VideoWindowGeom $m}
64 "VoiceSwitchList" {$self VoiceSwitchList $m}
65 "TimerSwitchList" {$self TimerSwitchList $m}
66 "TimerSwitchInterval" {$self TimerSwitchInterval $m}
67 }
68 }
69 }
70
71 #
72 RvicLayout public num_windows {} {return [$self set numWindows_]}
73
74 #
75 RvicLayout public name {} {return [$self set name_]}
76
77 #
78 RvicLayout public get_window {idx} {
79 $self instvar windows_ numWindows_
80 if ![info exists windows_($idx)] {
81 set windows_($idx) [new RvicWindow]
82 incr numWindows_
83 }
84 return $windows_($idx)
85 }
86
87 #
88 RvicLayout private VideoWindowGeom {msg} {
89 set data [split $msg "\n"]
90 set data [lrange $data 1 end]
91 foreach line $data {
92 set line [string trim $line]
93 set idx [lindex $line 0]
94 set val [lrange $line 1 end]
95 set w [$self get_window $idx]
96 $w geom $val
97 }
98 }
99
100 #
101 RvicLayout private VoiceSwitchList {msg} {
102 set data [split $msg "\n"]
103 set data [lrange $data 1 end]
104 foreach line $data {
105 set line [string trim $line]
106 set idx [lindex $line 0]
107 set val [lrange $line 1 end]
108 set w [$self get_window $idx]
109 $w is_voice_switched 1
110 $w voice_switch_list $val
111 }
112 }
113
114 #
115 RvicLayout private TimerSwitchList {msg} {
116 set data [split $msg "\n"]
117 set data [lrange $data 1 end]
118 foreach line $data {
119 set line [string trim $line]
120 set idx [lindex $line 0]
121 set val [lrange $line 1 end]
122 set w [$self get_window $idx]
123 $w is_timer_switched 1
124 $w timer_switch_list $val
125 if ![$w timer_switch_interval] {
126 $w timer_switch_interval 5
127 }
128 }
129
130 }
131
132 #
133 RvicLayout private TimerSwitchInterval {msg} {
134 set data [split $msg "\n"]
135 set data [lrange $data 1 end]
136 foreach line $data {
137 set line [string trim $line]
138 set idx [lindex $line 0]
139 set val [lrange $line 1 end]
140 set w [$self get_window $idx]
141 $w timer_switch_interval $val
142 }
143 }
144
145 # takes a block of newline-separated "Get" and "Set" commands
146 # and parses them, returning a list of individual messages (each
147 # of which, temselves, may be multiple lines)
148 RvicLayout private convert_to_msglist {data} {
149 set msglist ""
150 set msg ""
151 foreach i [split $data \n] {
152 set i [string trim $i]
153 set getset [string range $i 0 3]
154 if {$getset == "Get " || $getset == "Set "} {
155 # dump previous buffer as cmd
156 if {$msg != ""} {
157 lappend msglist $msg
158 }
159 set msg $i
160 } else {
161 append msg "\n$i"
162 }
163 }
164 if {$msg != ""} {
165 lappend msglist $msg
166 }
167 #puts "[llength $msglist] $msglist"
168 return $msglist
169 }
170
171
172 #----------------------#----------------------#----------------------
173 #----------------------#----------------------#----------------------
174
175
176 # maintains info on a single `window' in an RvicLayout
177 #
178 Class RvicWindow
179
180 #
181 RvicWindow public init {} {
182 $self instvar geom_ is_timer_ is_voice_ tl_ t_int_ vl_
183 set geom_ "1x1+0+0"
184 set is_timer_ 0
185 set t_int_ 0
186 set is_voice_ 0
187 set tl_ ""
188 set vl_ ""
189 }
190
191 #
192 RvicWindow public geom {args} {
193 $self instvar geom_
194 if {[llength $args] == 0} {
195 return $geom_
196 } else {
197 set geom_ $args
198 }
199 }
200
201
202 #
203 RvicWindow public is_timer_switched {args} {
204 $self instvar is_timer_
205 if {[llength $args] == 0} {
206 return $is_timer_
207 } else {
208 set is_timer_ $args
209 }
210 }
211
212 #
213 RvicWindow public timer_switch_list {args} {
214 $self instvar tl_
215 if {[llength $args] == 0} {
216 return $tl_
217 } else {
218 set tl_ $args
219 }
220 }
221
222 #
223 RvicWindow public timer_switch_interval {args} {
224 $self instvar t_int_
225 if {[llength $args] == 0} {
226 return $t_int_
227 } else {
228 set t_int_ $args
229 }
230 }
231
232 #
233 RvicWindow public is_voice_switched {args} {
234 $self instvar is_voice_
235 if {[llength $args] == 0} {
236 return $is_voice_
237 } else {
238 set is_voice_ $args
239 }
240 }
241
242 #
243 RvicWindow public voice_switch_list {args} {
244 $self instvar vl_
245 if {[llength $args] == 0} {
246 return $vl_
247 } else {
248 set vl_ $args
249 }
250 }
251
252
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.