Changeset 26
- Timestamp:
- Jul 19, 2005 1:15:04 AM (18 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/controls.tcl
r23 r26 11 11 # ====================================================================== 12 12 package require Itk 13 package require BLT 13 14 14 15 option add *Controls.padding 4 widgetDefault … … 31 32 protected method _controlChanged {path} 32 33 protected method _formatLabel {str} 34 protected method _changeTabs {} 33 35 34 36 private variable _owner "" ;# controls belong to this owner 37 private variable _tabs "" ;# optional tabset for groups 38 private variable _frame "" ;# pack controls into this frame 35 39 private variable _counter 0 ;# counter for control names 36 40 private variable _dispatcher "" ;# dispatcher for !events … … 51 55 52 56 set _owner $owner 57 58 Rappture::Scroller $itk_interior.sc -xscrollmode none -yscrollmode auto 59 pack $itk_interior.sc -expand yes -fill both 60 set f [$itk_interior.sc contents frame] 61 62 set _tabs [blt::tabset $f.tabs -borderwidth 0 -relief flat \ 63 -side top -tearoff 0 -highlightthickness 0 \ 64 -selectbackground $itk_option(-background) \ 65 -selectcommand [itcl::code $this _changeTabs]] 66 67 set _frame [frame $f.inner] 68 pack $_frame -expand yes -fill both 53 69 54 70 eval itk_initialize $args … … 78 94 set _name2info($name-path) $path 79 95 set _name2info($name-label) "" 80 set _name2info($name-value) [set w $ itk_interior.v$name]96 set _name2info($name-value) [set w $_frame.v$name] 81 97 82 98 set type [$_owner xml element -as type $path] … … 126 142 set label [$w label] 127 143 if {"" != $label} { 128 set _name2info($name-label) $ itk_interior.l$name144 set _name2info($name-label) $_frame.l$name 129 145 set font [option get $itk_component(hull) labelFont Font] 130 146 label $_name2info($name-label) -text [_formatLabel $label] \ … … 257 273 } 258 274 } 275 if {[$_tabs size] > 0} { 276 $_tabs delete 0 end 277 } 259 278 260 279 # 261 # Lay out the widgets in a simple "Label: Value" scheme... 280 # Decide on a layout scheme: 281 # tabs ...... best if all elements within are groups 282 # hlabels ... horizontal labels (label: value) 262 283 # 263 set row 0 264 foreach name $_controls { 265 set wl $_name2info($name-label) 266 if {$wl != "" && [winfo exists $wl]} { 267 grid $wl -row $row -column 0 -sticky e 268 } 269 270 set wv $_name2info($name-value) 271 if {$wv != "" && [winfo exists $wv]} { 272 grid $wv -row $row -column 1 -sticky ew 273 274 set frame [winfo parent $wv] 275 grid rowconfigure $frame $row -weight 0 276 grid rowconfigure $frame $row -weight 0 277 278 switch -- [winfo class $wv] { 279 TextEntry { 280 if {[regexp {[0-9]+x[0-9]+} [$wv size]]} { 281 grid $wl -sticky n -pady 4 282 grid $wv -sticky nsew 283 grid rowconfigure $frame $row -weight 1 284 grid columnconfigure $frame 1 -weight 1 284 if {[llength $_controls] >= 2} { 285 # assume tabs for multiple groups 286 set scheme tabs 287 foreach name $_controls { 288 set w $_name2info($name-value) 289 290 if {[winfo class $w] != "GroupEntry"} { 291 # something other than a group? then fall back on hlabels 292 set scheme hlabels 293 break 294 } 295 } 296 } else { 297 set scheme hlabels 298 } 299 300 switch -- $scheme { 301 tabs { 302 # 303 # SCHEME: tabs 304 # put a series of groups into a tabbed notebook 305 # 306 307 # use inner frame within tabs to show current group 308 pack $_tabs -before $_frame -fill x 309 310 set gn 1 311 foreach name $_controls { 312 set wv $_name2info($name-value) 313 $wv configure -heading no 314 315 set label [$wv component heading cget -text] 316 if {"" == $label} { 317 set label "Group #$gn" 318 } 319 set _name2info($name-label) $label 320 321 $_tabs insert end $label \ 322 -activebackground $itk_option(-background) 323 324 incr gn 325 } 326 327 # compute the overall size 328 # BE CAREFUL: do this after setting "-heading no" above 329 set maxw 0 330 set maxh 0 331 update idletasks 332 foreach name $_controls { 333 set w [winfo reqwidth $wv] 334 if {$w > $maxw} { set maxw $w } 335 set h [winfo reqheight $wv] 336 if {$h > $maxh} { set maxh $h } 337 } 338 $_frame configure -width $maxw -height $maxh 339 340 grid propagate $_frame off 341 grid columnconfigure $_frame 0 -weight 1 342 grid rowconfigure $_frame 0 -weight 1 343 344 $_tabs select 0; _changeTabs 345 } 346 347 hlabels { 348 # 349 # SCHEME: hlabels 350 # simple "Label: Value" layout 351 # 352 pack forget $_tabs 353 grid propagate $_frame on 354 grid columnconfigure $_frame 0 -weight 0 355 grid rowconfigure $_frame 0 -weight 0 356 357 set row 0 358 foreach name $_controls { 359 set wl $_name2info($name-label) 360 if {$wl != "" && [winfo exists $wl]} { 361 grid $wl -row $row -column 0 -sticky e 362 } 363 364 set wv $_name2info($name-value) 365 if {$wv != "" && [winfo exists $wv]} { 366 if {$wl != ""} { 367 grid $wv -row $row -column 1 -sticky ew 368 } else { 369 grid $wv -row $row -column 0 -columnspan 2 -sticky ew 370 } 371 372 set frame [winfo parent $wv] 373 grid rowconfigure $frame $row -weight 0 374 grid rowconfigure $frame $row -weight 0 375 376 switch -- [winfo class $wv] { 377 TextEntry { 378 if {[regexp {[0-9]+x[0-9]+} [$wv size]]} { 379 grid $wl -sticky n -pady 4 380 grid $wv -sticky nsew 381 grid rowconfigure $frame $row -weight 1 382 grid columnconfigure $frame 1 -weight 1 383 } 384 } 385 GroupEntry { 386 $wv configure -heading yes 285 387 } 286 388 } 287 } 288 grid columnconfigure $frame 1 -weight 1 289 } 290 291 292 incr row 293 grid rowconfigure [winfo parent $w] $row -minsize $itk_option(-padding) 294 incr row 389 grid columnconfigure $frame 1 -weight 1 390 } 391 392 393 incr row 394 grid rowconfigure [winfo parent $w] $row \ 395 -minsize $itk_option(-padding) 396 incr row 397 } 398 } 295 399 } 296 400 } … … 325 429 326 430 # ---------------------------------------------------------------------- 431 # USAGE: _changeTabs 432 # 433 # Used internally to change tabs when the user clicks on a tab 434 # in the "tabs" layout mode. This mode is used when the widget 435 # contains nothing but groups, as a compact way of representing 436 # the groups. 437 # ---------------------------------------------------------------------- 438 itcl::body Rappture::Controls::_changeTabs {} { 439 set i [$_tabs index select] 440 set name [lindex $_controls $i] 441 if {"" != $name} { 442 foreach w [grid slaves $_frame] { 443 grid forget $w 444 } 445 446 set wv $_name2info($name-value) 447 grid $wv -row 0 -column 0 -sticky new 448 } 449 } 450 451 # ---------------------------------------------------------------------- 327 452 # OPTION: -padding 328 453 # ---------------------------------------------------------------------- -
trunk/gui/scripts/deviceViewer1D.tcl
r24 r26 205 205 if {[llength $tabs] <= 0} { 206 206 # 207 # == DEPRECATED FUNCTIONALITY == 208 # (I like the look of the tab, even if there's only one) 209 # 210 # No fields or one field? Then we don't need to bother 211 # with tabs. Just pack the inner frame directly. If 212 # there are no fields, get rid of the graph. 207 # No fields? Then we don't need to bother with tabs. 208 # Just pack the inner frame directly. If there are no 209 # fields, get rid of the graph. 213 210 # 214 211 pack $itk_component(inner) -expand yes -fill both -
trunk/gui/scripts/groupentry.tcl
r22 r26 12 12 package require Itk 13 13 14 option add *GroupEntry.headingBackground #cccccc widgetDefault 15 option add *GroupEntry.headingForeground white widgetDefault 16 option add *GroupEntry.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault 17 14 18 itcl::class Rappture::GroupEntry { 15 19 inherit itk::Widget 20 21 itk_option define -heading heading Heading 1 16 22 17 23 constructor {owner path args} { # defined below } … … 21 27 public method label {} 22 28 public method tooltip {} 29 30 protected method _fixheading {} 23 31 24 32 private variable _owner "" ;# thing managing this control … … 42 50 set _owner $owner 43 51 set _path $path 52 53 itk_component add heading { 54 ::label $itk_interior.heading -anchor w 55 } { 56 usual 57 rename -background -headingbackground headingBackground Background 58 rename -foreground -headingforeground headingForeground Foreground 59 } 60 61 $itk_component(heading) configure \ 62 -text [$_owner xml get $_path.about.label] 63 Rappture::Tooltip::for $itk_component(heading) \ 64 [$_owner xml get $_path.about.description] 65 66 itk_component add outline { 67 frame $itk_interior.outline -borderwidth 1 68 } { 69 usual 70 ignore -borderwidth 71 rename -background -headingbackground headingBackground Background 72 } 73 pack $itk_component(outline) -expand yes -fill both 74 75 itk_component add inner { 76 frame $itk_component(outline).inner -borderwidth 3 77 } { 78 usual 79 ignore -borderwidth 80 } 81 pack $itk_component(inner) -expand yes -fill both 44 82 45 83 eval itk_initialize $args … … 67 105 # ---------------------------------------------------------------------- 68 106 itcl::body Rappture::GroupEntry::label {} { 69 return [$_owner xml get $_path.about.label]107 return "" ;# manage the label inside this group 70 108 } 71 109 … … 81 119 return [$_owner xml get $_path.about.description] 82 120 } 121 122 # ---------------------------------------------------------------------- 123 # CONFIGURATION OPTION: -heading 124 # Turns the heading bar at the top of this group on/off. 125 # ---------------------------------------------------------------------- 126 itcl::configbody Rappture::GroupEntry::heading { 127 if {![string is boolean -strict $itk_option(-heading)]} { 128 error "bad value \"$itk_option(-heading)\": should be boolean" 129 } 130 131 set str [$itk_component(heading) cget -text] 132 if {$itk_option(-heading) && "" != $str} { 133 eval pack forget [pack slaves $itk_component(hull)] 134 pack $itk_component(heading) -side top -fill x 135 pack $itk_component(outline) -expand yes -fill both 136 $itk_component(outline) configure -borderwidth 1 137 $itk_component(inner) configure -borderwidth 3 138 } else { 139 pack forget $itk_component(heading) 140 $itk_component(outline) configure -borderwidth 0 141 $itk_component(inner) configure -borderwidth 0 142 } 143 } -
trunk/gui/scripts/page.tcl
r23 r26 201 201 error $c "$c\n (while building control for $path.$cname)" 202 202 } else { 203 set w [$frame.cntls control $c] 203 set gentry [$frame.cntls control $c] 204 set w [$gentry component inner] 204 205 } 205 206 } -
trunk/gui/scripts/pager.tcl
r24 r26 401 401 # ---------------------------------------------------------------------- 402 402 itcl::body Rappture::Pager::_fixSize {} { 403 set sw [expr {[winfo screenwidth $itk_component(hull)]-200}] 404 set sh [expr {[winfo screenheight $itk_component(hull)]-200}] 405 403 406 switch -- $itk_option(-arrangement) { 404 407 pages { 405 408 if {$itk_option(-width) <= 0} { 406 update idletasks407 409 set maxw [expr { 408 410 [winfo reqwidth $itk_component(next)] … … 415 417 } 416 418 set maxw [expr {$maxw + 2*$itk_option(-padding)}] 419 if {$maxw > $sw} { set maxw $sw } 417 420 $itk_component(inside) configure -width $maxw 418 421 } else { … … 421 424 422 425 if {$itk_option(-height) <= 0} { 423 update idletasks424 426 set maxh 0 425 427 foreach name $_pages { … … 428 430 } 429 431 set maxh [expr {$maxh + 2*$itk_option(-padding)}] 432 if {$maxh > $sh} { set maxh $sh } 430 433 $itk_component(inside) configure -height $maxh 431 434 } else { … … 435 438 side-by-side { 436 439 if {$itk_option(-width) <= 0} { 437 update idletasks438 440 set maxw [expr { 439 441 [winfo reqwidth $itk_component(next)] … … 447 449 } 448 450 if {$wtotal > $maxw} { set maxw $wtotal } 451 if {$maxw > $sw} { set maxw $sw } 449 452 $itk_component(inside) configure -width $maxw 450 453 } else { … … 453 456 454 457 if {$itk_option(-height) <= 0} { 455 update idletasks456 458 set maxh 0 457 459 foreach name $_pages { … … 460 462 } 461 463 set maxh [expr {$maxh + 2*$itk_option(-padding)}] 464 if {$maxh > $sh} { set maxh $sh } 462 465 $itk_component(inside) configure -height $maxh 463 466 } else { -
trunk/gui/scripts/scroller.tcl
r11 r26 34 34 protected method _fixsbar {which {state ""}} 35 35 protected method _fixframe {which} 36 protected method _fixsize {} 36 37 protected method _lock {option} 37 38 39 private variable _dispatcher "" ;# dispatcher for !events 38 40 private variable _contents "" ;# widget being controlled 39 41 private variable _frame "" ;# for "contents frame" calls … … 52 54 # ---------------------------------------------------------------------- 53 55 itcl::body Rappture::Scroller::constructor {args} { 56 Rappture::dispatcher _dispatcher 57 58 $_dispatcher register !fixframe-inner 59 $_dispatcher dispatch $this !fixframe-inner \ 60 "[itcl::code $this _fixframe inner]; list" 61 62 $_dispatcher register !fixframe-outer 63 $_dispatcher dispatch $this !fixframe-outer \ 64 "[itcl::code $this _fixframe outer]; list" 65 66 $_dispatcher register !fixsize 67 $_dispatcher dispatch $this !fixsize \ 68 "[itcl::code $this _fixsize]; list" 69 54 70 itk_component add xsbar { 55 71 scrollbar $itk_interior.xsbar -orient horizontal … … 104 120 frame $_frame.f 105 121 $_frame create window 0 0 -anchor nw -window $_frame.f -tags frame 106 bind $_frame.f <Configure> [itcl::code $this _fixframe inner] 107 bind $_frame <Configure> [itcl::code $this _fixframe outer] 122 bind $_frame.f <Configure> \ 123 [itcl::code $_dispatcher event -idle !fixframe-inner] 124 bind $_frame <Configure> \ 125 [itcl::code $_dispatcher event -idle !fixframe-outer] 108 126 } 109 127 set widget $_frame … … 207 225 inner { 208 226 $_frame configure -scrollregion [$_frame bbox all] 227 $_dispatcher event -idle !fixsize 209 228 } 210 229 outer { 211 230 $_frame itemconfigure frame -width [winfo width $_frame] 212 231 } 232 } 233 } 234 235 # ---------------------------------------------------------------------- 236 # USAGE: _fixsize 237 # 238 # Used internally to update the size options for the widget 239 # whenever the -width/-height options change. 240 # ---------------------------------------------------------------------- 241 itcl::body Rappture::Scroller::_fixsize {} { 242 if {$itk_option(-width) == "0" && $itk_option(-height) == "0"} { 243 # for default size, let the frame being controlled set the size 244 grid propagate $itk_component(hull) yes 245 if {$_frame == "$itk_component(hull).ifr"} { 246 set w [winfo reqwidth $_frame.f] 247 set h [winfo reqheight $_frame.f] 248 $_frame configure -width $w -height $h 249 } 250 } else { 251 # for specific size, set the overall size of the widget 252 grid propagate $itk_component(hull) no 253 set w $itk_option(-width); if {$w == "0"} { set w 1i } 254 set h $itk_option(-height); if {$h == "0"} { set h 1i } 255 component hull configure -width $w -height $h 213 256 } 214 257 } … … 264 307 # ---------------------------------------------------------------------- 265 308 itcl::configbody Rappture::Scroller::width { 266 if {$itk_option(-width) == "0"} { 267 if {$itk_option(-height) == "0"} { 268 grid propagate $itk_component(hull) yes 269 } else { 270 component hull configure -width 1i 271 } 272 } else { 273 grid propagate $itk_component(hull) no 274 component hull configure -width $itk_option(-width) 275 } 309 # check for proper value 310 winfo pixels $itk_component(hull) $itk_option(-width) 311 312 $_dispatcher event -idle !fixsize 276 313 } 277 314 … … 280 317 # ---------------------------------------------------------------------- 281 318 itcl::configbody Rappture::Scroller::height { 282 if {$itk_option(-height) == "0"} { 283 if {$itk_option(-width) == "0"} { 284 grid propagate $itk_component(hull) yes 285 } else { 286 component hull configure -height 1i 287 } 288 } else { 289 grid propagate $itk_component(hull) no 290 component hull configure -height $itk_option(-height) 291 } 292 } 319 # check for proper value 320 winfo pixels $itk_component(hull) $itk_option(-height) 321 322 $_dispatcher event -idle !fixsize 323 } -
trunk/gui/scripts/tooltip.tcl
r14 r26 130 130 } 131 131 132 # if there's no message to show, forget it 133 if {[string length $mesg] == 0} { 134 return 135 } 136 132 137 # strings can't be too big, or they'll go off screen! 133 138 if {[string length $mesg] > 1000} {
Note: See TracChangeset
for help on using the changeset viewer.