Changeset 1342 for trunk/gui/scripts/panes.tcl
- Timestamp:
- Mar 18, 2009, 2:59:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/panes.tcl
r1140 r1342 73 73 set pname "pane[incr _counter]" 74 74 itk_component add $pname { 75 75 frame $itk_interior.$pname 76 76 } 77 77 … … 93 93 itcl::body Rappture::Panes::insert {pos args} { 94 94 Rappture::getopts args params { 95 95 value -fraction 0.5 96 96 } 97 97 if {[llength $args] > 0} { 98 98 error "wrong # args: should be \"insert pos ?-fraction f?\"" 99 99 } 100 100 … … 102 102 set sash "${pname}sash" 103 103 itk_component add $sash { 104 104 frame $itk_interior.$sash 105 105 } { 106 107 106 usual 107 rename -cursor -sashcursor sashCursor SashCursor 108 108 } 109 109 bind $itk_component($sash) <Enter> [itcl::code $this hilite on $sash] … … 111 111 112 112 itk_component add ${sash}ridge { 113 113 frame $itk_component($sash).ridge 114 114 } { 115 116 117 118 115 usual 116 rename -cursor -sashcursor sashCursor SashCursor 117 rename -relief -sashrelief sashRelief SashRelief 118 ignore -borderwidth 119 119 } 120 120 pack $itk_component(${sash}ridge) -fill x 121 121 122 122 foreach comp [list $sash ${sash}ridge] { 123 124 125 126 127 128 123 bind $itk_component($comp) <ButtonPress-1> \ 124 [itcl::code $this _grab $pname %X %Y] 125 bind $itk_component($comp) <B1-Motion> \ 126 [itcl::code $this _drag $pname %X %Y] 127 bind $itk_component($comp) <ButtonRelease-1> \ 128 [itcl::code $this _drop $pname %X %Y] 129 129 } 130 130 131 131 132 132 itk_component add $pname { 133 133 frame $itk_interior.$pname 134 134 } 135 135 set _panes [linsert $_panes $pos $pname] … … 154 154 set pname [lindex $_panes $pos] 155 155 if {[info exists itk_component($pname)]} { 156 156 return $itk_component($pname) 157 157 } 158 158 return "" … … 167 167 itcl::body Rappture::Panes::visibility {pos {newval ""}} { 168 168 if {"" == $newval} { 169 169 return [lindex $_visibility $pos] 170 170 } 171 171 if {![string is boolean $newval]} { 172 172 error "bad value \"$newval\": should be boolean" 173 173 } 174 174 if {$pos == "end" || ($pos >= 0 && $pos < [llength $_visibility])} { 175 176 175 set _visibility [lreplace $_visibility $pos $pos [expr {$newval}]] 176 $_dispatcher event -idle !layout 177 177 } else { 178 178 error "bad index \"$pos\": out of range" 179 179 } 180 180 } … … 188 188 itcl::body Rappture::Panes::fraction {pos {newval ""}} { 189 189 if {"" == $newval} { 190 190 return [lindex $_frac $pos] 191 191 } 192 192 if {![string is double $newval]} { 193 193 error "bad value \"$newval\": should be fraction 0-1" 194 194 } 195 195 if {$pos == "end" || ($pos >= 0 && $pos < [llength $_frac])} { 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 196 set len [llength $_frac] 197 set _frac [lreplace $_frac $pos $pos xxx] 198 set total 0 199 foreach f $_frac { 200 if {"xxx" != $f} { 201 set total [expr {$total+$f}] 202 } 203 } 204 for {set i 0} {$i < $len} {incr i} { 205 set f [lindex $_frac $i] 206 if {"xxx" == $f} { 207 set f $newval 208 } else { 209 set f [expr {$f/$total - $newval/double($len-1)}] 210 } 211 set _frac [lreplace $_frac $i $i $f] 212 } 213 $_dispatcher event -idle !layout 214 214 } else { 215 215 error "bad index \"$pos\": out of range" 216 216 } 217 217 } … … 226 226 switch -- $itk_option(-sashrelief) { 227 227 sunken { 228 229 230 231 232 228 if {$state} { 229 $itk_component(${sash}ridge) configure -relief raised 230 } else { 231 $itk_component(${sash}ridge) configure -relief sunken 232 } 233 233 } 234 234 raised { 235 236 237 238 239 235 if {$state} { 236 $itk_component(${sash}ridge) configure -relief sunken 237 } else { 238 $itk_component(${sash}ridge) configure -relief raised 239 } 240 240 } 241 241 solid { 242 243 244 245 246 247 242 if {$state} { 243 $itk_component($sash) configure -background black 244 } else { 245 $itk_component($sash) configure \ 246 -background $itk_option(-background) 247 } 248 248 } 249 249 } … … 269 269 set frac [expr double($realY)/$Ymax] 270 270 if {$frac < 0.05} { 271 271 set frac 0.05 272 272 } 273 273 if {$frac > 0.95} { 274 274 set frac 0.95 275 275 } 276 276 if {[llength $_frac] == 2} { 277 277 set _frac [list $frac [expr {1-$frac}]] 278 278 } else { 279 280 281 282 279 set i [expr {[lsearch $_panes $pname]-1}] 280 if {$i >= 0} { 281 set _frac [lreplace $_frac $i $i $frac] 282 } 283 283 } 284 284 _fixLayout … … 308 308 set flist "" 309 309 foreach p $_panes f $_frac v $_visibility { 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 310 set sash ${p}sash 311 if {$v} { 312 # this pane is visible -- make room for it 313 lappend plist $p 314 lappend flist $f 315 if {[info exists itk_component($sash)]} { 316 set h [expr {$h - [winfo height $itk_component($sash)]}] 317 } 318 } else { 319 # this pane is not visible -- remove sash 320 if {[info exists itk_component($sash)]} { 321 place forget $itk_component($sash) 322 } 323 place forget $itk_component($p) 324 } 325 325 } 326 326 … … 330 330 set newflist "" 331 331 foreach f $flist { 332 332 lappend newflist [expr {double($f)/$total}] 333 333 } 334 334 set flist $newflist … … 337 337 set y 0 338 338 foreach p $plist f $flist { 339 340 341 342 343 344 345 346 347 348 349 350 339 set sash ${p}sash 340 if {[info exists itk_component($sash)]} { 341 set sh [winfo reqheight $itk_component($sash)] 342 place $itk_component($sash) -y $y -relx 0.5 -anchor n \ 343 -relwidth 1.0 -height $sh 344 set y [expr {$y + $sh}] 345 } 346 347 set ph [expr {$h*$f}] 348 place $itk_component($p) -y $y -relx 0.5 -anchor n \ 349 -relwidth 1.0 -height $ph 350 set y [expr {$y + $ph}] 351 351 } 352 352 } … … 362 362 set bd [expr {$ht/2}] 363 363 foreach pane $_panes { 364 365 366 367 368 369 370 371 372 373 374 364 set sash "${pane}sashridge" 365 if {[info exists itk_component($sash)]} { 366 $itk_component($sash) configure -height $ht -borderwidth $bd 367 if {$itk_option(-sashrelief) == "solid"} { 368 $itk_component($sash) configure -background black 369 } else { 370 $itk_component($sash) configure \ 371 -background $itk_option(-background) 372 } 373 pack $itk_component($sash) -pady $itk_option(-sashpadding) 374 } 375 375 } 376 376 }
Note: See TracChangeset
for help on using the changeset viewer.