Ignore:
Timestamp:
Oct 22, 2010 4:06:10 PM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/controls.tcl

    r1624 r1929  
    5151    private variable _scheme ""      ;# layout scheme (tabs/hlabels)
    5252}
    53                                                                                
     53                                                                               
    5454itk::usual Controls {
    5555}
     
    7272
    7373    set _tabs [blt::tabset $f.tabs -borderwidth 0 -relief flat \
    74         -side top -tearoff 0 -highlightthickness 0 \
    75         -selectbackground $itk_option(-background) \
    76         -selectcommand [itcl::code $this _changeTabs]]
     74        -side top -tearoff 0 -highlightthickness 0 \
     75        -selectbackground $itk_option(-background) \
     76        -selectcommand [itcl::code $this _changeTabs]]
    7777
    7878    set _frame [frame $f.inner]
     
    9090    #
    9191    bind Controls-$this <Configure> \
    92         [list $_dispatcher event -idle !resize]
     92        [list $_dispatcher event -idle !resize]
    9393
    9494    eval itk_initialize $args
     
    115115itcl::body Rappture::Controls::insert {pos path} {
    116116    if {"end" == $pos} {
    117         set pos [llength $_controls]
     117        set pos [llength $_controls]
    118118    } elseif {![string is integer $pos]} {
    119         error "bad index \"$pos\": should be integer or \"end\""
     119        error "bad index \"$pos\": should be integer or \"end\""
    120120    }
    121121
     
    133133    set _name2info($name-type) $type
    134134    switch -- $type {
    135         choice {
    136             Rappture::ChoiceEntry $w $_owner $path
    137             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    138         }
    139         group {
    140             Rappture::GroupEntry $w $_owner $path
    141         }
    142         loader {
    143             Rappture::Loader $w $_owner $path -tool [$_owner tool]
    144             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    145         }
    146         number {
    147             Rappture::NumberEntry $w $_owner $path
    148             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    149         }
    150         integer {
    151             Rappture::IntegerEntry $w $_owner $path
    152             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    153         }
    154         boolean {
    155             Rappture::BooleanEntry $w $_owner $path
    156             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    157         }
    158         string {
    159             Rappture::TextEntry $w $_owner $path
    160             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    161         }
    162         image {
    163             Rappture::ImageEntry $w $_owner $path
    164         }
    165         control {
    166             set label [$_owner xml get $path.label]
    167             if {"" == $label} { set label "Simulate" }
    168             set service [$_owner xml get $path.service]
    169             button $w -text $label -command [list $service run]
    170         }
    171         separator {
    172             # no widget to create
    173             set _name2info($name-value) "--"
    174         }
    175         note {
    176             Rappture::Note $w $_owner $path
    177         }
    178         periodicelement {
    179             Rappture::PeriodicElementEntry $w $_owner $path
    180             bind $w <<Value>> [itcl::code $this _controlChanged $name]
    181         }
    182         default {
    183             error "don't know how to add control type \"$type\""
    184         }
     135        choice {
     136            Rappture::ChoiceEntry $w $_owner $path
     137            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     138        }
     139        group {
     140            Rappture::GroupEntry $w $_owner $path
     141        }
     142        loader {
     143            Rappture::Loader $w $_owner $path -tool [$_owner tool]
     144            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     145        }
     146        number {
     147            Rappture::NumberEntry $w $_owner $path
     148            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     149        }
     150        integer {
     151            Rappture::IntegerEntry $w $_owner $path
     152            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     153        }
     154        boolean {
     155            Rappture::BooleanEntry $w $_owner $path
     156            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     157        }
     158        string {
     159            Rappture::TextEntry $w $_owner $path
     160            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     161        }
     162        image {
     163            Rappture::ImageEntry $w $_owner $path
     164        }
     165        control {
     166            set label [$_owner xml get $path.label]
     167            if {"" == $label} { set label "Simulate" }
     168            set service [$_owner xml get $path.service]
     169            button $w -text $label -command [list $service run]
     170        }
     171        separator {
     172            # no widget to create
     173            set _name2info($name-value) "--"
     174        }
     175        note {
     176            Rappture::Note $w $_owner $path
     177        }
     178        periodicelement {
     179            Rappture::PeriodicElementEntry $w $_owner $path
     180            bind $w <<Value>> [itcl::code $this _controlChanged $name]
     181        }
     182        default {
     183            error "don't know how to add control type \"$type\""
     184        }
    185185    }
    186186
     
    191191    set enable [string trim [$_owner xml get $path.about.enable]]
    192192    if {"" == $enable} {
    193         set enable yes
     193        set enable yes
    194194    }
    195195    if {![string is boolean $enable]} {
    196         set re {([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\))(\.([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\)))*(:[-a-zA-Z0-9/]+)?}
    197         set rest $enable
    198         set enable ""
    199         set deps ""
    200         while {1} {
    201             if {[regexp -indices $re $rest match]} {
    202                 foreach {s0 s1} $match break
    203 
    204                 if {[string index $rest [expr {$s0-1}]] == "\""
    205                       && [string index $rest [expr {$s1+1}]] == "\""} {
    206                     # string in ""'s? then leave it alone
    207                     append enable [string range $rest 0 $s1]
    208                     set rest [string range $rest [expr {$s1+1}] end]
    209                 } else {
    210                     #
    211                     # This is a symbol which should be substituted
    212                     # it can be either:
    213                     #   input.foo.bar
    214                     #   input.foo.bar:units
    215                     #
    216                     set cpath [string range $rest $s0 $s1]
    217                     set parts [split $cpath :]
    218                     set ccpath [lindex $parts 0]
    219                     set units [lindex $parts 1]
    220 
    221                     # make sure we have the standard path notation
    222                     set stdpath [$_owner regularize $ccpath]
    223                     if {"" == $stdpath} {
    224                         puts stderr "WARNING: don't recognize parameter $cpath in <enable> expression for $path.  This may be buried in a structure that is not yet loaded."
    225                         set stdpath $ccpath
    226                     }
    227                     # substitute [_controlValue ...] call in place of path
    228                     append enable [string range $rest 0 [expr {$s0-1}]]
    229                     append enable [format {[_controlValue %s %s]} $stdpath $units]
    230                     lappend deps $stdpath
    231                     set rest [string range $rest [expr {$s1+1}] end]
    232                 }
    233             } else {
    234                 append enable $rest
    235                 break
    236             }
    237         }
    238 
    239         foreach cpath $deps {
    240             $_owner dependenciesfor $cpath $path
    241         }
     196        set re {([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\))(\.([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\)))*(:[-a-zA-Z0-9/]+)?}
     197        set rest $enable
     198        set enable ""
     199        set deps ""
     200        while {1} {
     201            if {[regexp -indices $re $rest match]} {
     202                foreach {s0 s1} $match break
     203
     204                if {[string index $rest [expr {$s0-1}]] == "\""
     205                      && [string index $rest [expr {$s1+1}]] == "\""} {
     206                    # string in ""'s? then leave it alone
     207                    append enable [string range $rest 0 $s1]
     208                    set rest [string range $rest [expr {$s1+1}] end]
     209                } else {
     210                    #
     211                    # This is a symbol which should be substituted
     212                    # it can be either:
     213                    #   input.foo.bar
     214                    #   input.foo.bar:units
     215                    #
     216                    set cpath [string range $rest $s0 $s1]
     217                    set parts [split $cpath :]
     218                    set ccpath [lindex $parts 0]
     219                    set units [lindex $parts 1]
     220
     221                    # make sure we have the standard path notation
     222                    set stdpath [$_owner regularize $ccpath]
     223                    if {"" == $stdpath} {
     224                        puts stderr "WARNING: don't recognize parameter $cpath in <enable> expression for $path.  This may be buried in a structure that is not yet loaded."
     225                        set stdpath $ccpath
     226                    }
     227                    # substitute [_controlValue ...] call in place of path
     228                    append enable [string range $rest 0 [expr {$s0-1}]]
     229                    append enable [format {[_controlValue %s %s]} $stdpath $units]
     230                    lappend deps $stdpath
     231                    set rest [string range $rest [expr {$s1+1}] end]
     232                }
     233            } else {
     234                append enable $rest
     235                break
     236            }
     237        }
     238
     239        foreach cpath $deps {
     240            $_owner dependenciesfor $cpath $path
     241        }
    242242    }
    243243    set _name2info($name-enable) $enable
     
    246246
    247247    if {[lsearch {control group separator note} $type] < 0} {
    248         # make a label for this control
    249         set label [$w label]
    250         if {"" != $label} {
    251             set _name2info($name-label) $_frame.l$name
    252             set font [option get $itk_component(hull) labelFont Font]
    253             label $_name2info($name-label) -text [_formatLabel $label] \
    254                 -font $font
    255         }
    256 
    257         # register the tooltip for this control
    258         set tip [$w tooltip]
    259         if {"" != $tip} {
    260             Rappture::Tooltip::for $w $tip
    261 
    262             # add the tooltip to the label too, if there is one
    263             if {$_name2info($name-label) != ""} {
    264                 Rappture::Tooltip::for $_name2info($name-label) $tip
    265             }
    266         }
     248        # make a label for this control
     249        set label [$w label]
     250        if {"" != $label} {
     251            set _name2info($name-label) $_frame.l$name
     252            set font [option get $itk_component(hull) labelFont Font]
     253            label $_name2info($name-label) -text [_formatLabel $label] \
     254                -font $font
     255        }
     256
     257        # register the tooltip for this control
     258        set tip [$w tooltip]
     259        if {"" != $tip} {
     260            Rappture::Tooltip::for $w $tip
     261
     262            # add the tooltip to the label too, if there is one
     263            if {$_name2info($name-label) != ""} {
     264                Rappture::Tooltip::for $_name2info($name-label) $tip
     265            }
     266        }
    267267    }
    268268
     
    290290itcl::body Rappture::Controls::delete {first {last ""}} {
    291291    if {$last == ""} {
    292         set last $first
     292        set last $first
    293293    }
    294294    if {![regexp {^[0-9]+|end$} $first]} {
    295         error "bad index \"$first\": should be integer or \"end\""
     295        error "bad index \"$first\": should be integer or \"end\""
    296296    }
    297297    if {![regexp {^[0-9]+|end$} $last]} {
    298         error "bad index \"$last\": should be integer or \"end\""
     298        error "bad index \"$last\": should be integer or \"end\""
    299299    }
    300300
    301301    foreach name [lrange $_controls $first $last] {
    302         _monitor $name off
    303 
    304         if {"" != $_name2info($name-label)} {
    305             destroy $_name2info($name-label)
    306         }
    307         if {"" != $_name2info($name-value)} {
    308             destroy $_name2info($name-value)
    309         }
    310         $_owner widgetfor $_name2info($name-path) ""
    311 
    312         unset _name2info($name-path)
    313         unset _name2info($name-label)
    314         unset _name2info($name-type)
    315         unset _name2info($name-value)
    316         unset _name2info($name-enable)
     302        _monitor $name off
     303
     304        if {"" != $_name2info($name-label)} {
     305            destroy $_name2info($name-label)
     306        }
     307        if {"" != $_name2info($name-value)} {
     308            destroy $_name2info($name-value)
     309        }
     310        $_owner widgetfor $_name2info($name-path) ""
     311
     312        unset _name2info($name-path)
     313        unset _name2info($name-label)
     314        unset _name2info($name-type)
     315        unset _name2info($name-value)
     316        unset _name2info($name-enable)
    317317    }
    318318    set _controls [lreplace $_controls $first $last]
     
    330330    set i [lsearch $_controls $name]
    331331    if {$i >= 0} {
    332         return $i
     332        return $i
    333333    }
    334334    if {[regexp {^@([0-9]+)$} $name match i]} {
    335         return $i
     335        return $i
    336336    }
    337337    if {$name == "end"} {
    338         return [expr {[llength $_controls]-1}]
     338        return [expr {[llength $_controls]-1}]
    339339    }
    340340    error "bad control name \"$name\": should be @int or one of [join [lsort $_controls] {, }]"
     
    353353itcl::body Rappture::Controls::control {args} {
    354354    if {[llength $args] == 0} {
    355         return $_controls
     355        return $_controls
    356356    }
    357357    Rappture::getopts args params {
    358         flag switch -value default
    359         flag switch -label
    360         flag switch -path
    361         flag switch -enable
     358        flag switch -value default
     359        flag switch -label
     360        flag switch -path
     361        flag switch -enable
    362362    }
    363363    if {[llength $args] == 0} {
    364         error "missing control name"
     364        error "missing control name"
    365365    }
    366366    set i [index [lindex $args 0]]
     
    394394    #
    395395    foreach name $_controls {
    396         foreach elem {label value} {
    397             set w $_name2info($name-$elem)
    398             if {$w != "" && [winfo exists $w]} {
    399                 grid forget $w
    400             }
    401         }
     396        foreach elem {label value} {
     397            set w $_name2info($name-$elem)
     398            if {$w != "" && [winfo exists $w]} {
     399                grid forget $w
     400            }
     401        }
    402402    }
    403403    if {[$_tabs size] > 0} {
    404         $_tabs delete 0 end
     404        $_tabs delete 0 end
    405405    }
    406406    grid forget $_frame.empty
     
    412412    set showing ""
    413413    foreach name $_controls {
    414         set show 1
    415         set cond $_name2info($name-enable)
    416         if {[string is boolean $cond] && !$cond} {
    417             # hard-coded "off" -- ignore completely
    418         } elseif {[catch {expr $cond} show] == 0} {
    419             set type $_name2info($name-type)
    420             set lwidget $_name2info($name-label)
    421             set vwidget $_name2info($name-value)
    422             if {[lsearch -exact {group image structure} $type] >= 0} {
    423                 if {$show} {
    424                     lappend showing $name
    425                 } else {
    426                     lappend hidden $name
    427                 }
    428             } else {
    429                 # show other objects, but enable/disable them
    430                 lappend showing $name
    431                 if {$show} {
    432                     if {[winfo exists $vwidget]} {
    433                         $vwidget configure -state normal
    434                     }
    435                     if {[winfo exists $lwidget]} {
    436                         $lwidget configure -foreground \
    437                             [lindex [$lwidget configure -foreground] 3]
    438                     }
    439                 } else {
    440                     if {[winfo exists $vwidget]} {
    441                         $vwidget configure -state disabled
    442                     }
    443                     if {[winfo exists $lwidget]} {
    444                         $lwidget configure -foreground gray
    445                     }
    446                 }
    447             }
    448         } else {
    449             bgerror "Error in <enable> expression for \"$_name2info($name-path)\":\n  $show"
    450         }
     414        set show 1
     415        set cond $_name2info($name-enable)
     416        if {[string is boolean $cond] && !$cond} {
     417            # hard-coded "off" -- ignore completely
     418        } elseif {[catch {expr $cond} show] == 0} {
     419            set type $_name2info($name-type)
     420            set lwidget $_name2info($name-label)
     421            set vwidget $_name2info($name-value)
     422            if {[lsearch -exact {group image structure} $type] >= 0} {
     423                if {$show} {
     424                    lappend showing $name
     425                } else {
     426                    lappend hidden $name
     427                }
     428            } else {
     429                # show other objects, but enable/disable them
     430                lappend showing $name
     431                if {$show} {
     432                    if {[winfo exists $vwidget]} {
     433                        $vwidget configure -state normal
     434                    }
     435                    if {[winfo exists $lwidget]} {
     436                        $lwidget configure -foreground \
     437                            [lindex [$lwidget configure -foreground] 3]
     438                    }
     439                } else {
     440                    if {[winfo exists $vwidget]} {
     441                        $vwidget configure -state disabled
     442                    }
     443                    if {[winfo exists $lwidget]} {
     444                        $lwidget configure -foreground gray
     445                    }
     446                }
     447            }
     448        } else {
     449            bgerror "Error in <enable> expression for \"$_name2info($name-path)\":\n  $show"
     450        }
    451451    }
    452452
     
    460460    #
    461461    if {[llength $showing] >= 2} {
    462         # assume tabs for multiple groups
    463         set _scheme tabs
    464         foreach name $showing {
    465             set w $_name2info($name-value)
    466 
    467             if {$w == "--" || [winfo class $w] != "GroupEntry"} {
    468                 # something other than a group? then fall back on hlabels
    469                 set _scheme hlabels
    470                 break
    471             }
    472         }
     462        # assume tabs for multiple groups
     463        set _scheme tabs
     464        foreach name $showing {
     465            set w $_name2info($name-value)
     466
     467            if {$w == "--" || [winfo class $w] != "GroupEntry"} {
     468                # something other than a group? then fall back on hlabels
     469                set _scheme hlabels
     470                break
     471            }
     472        }
    473473    } else {
    474         set _scheme hlabels
     474        set _scheme hlabels
    475475    }
    476476
    477477    switch -- $_scheme {
    478478      tabs {
    479         #
    480         # SCHEME: tabs
    481         # put a series of groups into a tabbed notebook
    482         #
    483 
    484         # use inner frame within tabs to show current group
    485         pack $_tabs -before $_frame -fill x
    486 
    487         set gn 1
    488         foreach name $showing {
    489             set wv $_name2info($name-value)
    490             $wv configure -heading no
    491 
    492             set label [$wv component heading cget -text]
    493             if {"" == $label} {
    494                 set label "Group #$gn"
    495             }
    496             set _name2info($name-label) $label
    497 
    498             $_tabs insert end $label \
    499                 -activebackground $itk_option(-background)
    500 
    501             incr gn
    502         }
    503 
    504         # compute the overall size
    505         # BE CAREFUL: do this after setting "-heading no" above
    506         $_dispatcher event -now !resize
    507 
    508         grid propagate $_frame off
    509         grid columnconfigure $_frame 0 -weight 1
    510         grid rowconfigure $_frame 0 -weight 1
    511 
    512         $_tabs select 0; _changeTabs
     479        #
     480        # SCHEME: tabs
     481        # put a series of groups into a tabbed notebook
     482        #
     483
     484        # use inner frame within tabs to show current group
     485        pack $_tabs -before $_frame -fill x
     486
     487        set gn 1
     488        foreach name $showing {
     489            set wv $_name2info($name-value)
     490            $wv configure -heading no
     491
     492            set label [$wv component heading cget -text]
     493            if {"" == $label} {
     494                set label "Group #$gn"
     495            }
     496            set _name2info($name-label) $label
     497
     498            $_tabs insert end $label \
     499                -activebackground $itk_option(-background)
     500
     501            incr gn
     502        }
     503
     504        # compute the overall size
     505        # BE CAREFUL: do this after setting "-heading no" above
     506        $_dispatcher event -now !resize
     507
     508        grid propagate $_frame off
     509        grid columnconfigure $_frame 0 -weight 1
     510        grid rowconfigure $_frame 0 -weight 1
     511
     512        $_tabs select 0; _changeTabs
    513513      }
    514514
    515515      hlabels {
    516         #
    517         # SCHEME: hlabels
    518         # simple "Label: Value" layout
    519         #
    520         pack forget $_tabs
    521         grid propagate $_frame on
    522         grid columnconfigure $_frame 0 -weight 0
    523         grid rowconfigure $_frame 0 -weight 0
    524 
    525         set expand 0  ;# most controls float to top
    526         set row 0
    527         foreach name $showing {
    528             set wl $_name2info($name-label)
    529             if {$wl != "" && [winfo exists $wl]} {
    530                 grid $wl -row $row -column 0 -sticky e
    531             }
    532 
    533             set wv $_name2info($name-value)
    534             if {$wv != "" && [winfo exists $wv]} {
    535                 if {$wl != ""} {
    536                     grid $wv -row $row -column 1 -sticky ew
    537                 } else {
    538                     grid $wv -row $row -column 0 -columnspan 2 -sticky ew
    539                 }
    540 
    541                 grid rowconfigure $_frame $row -weight 0
    542 
    543                 switch -- [winfo class $wv] {
    544                     TextEntry {
    545                         if {[regexp {[0-9]+x[0-9]+} [$wv size]]} {
    546                             grid $wl -sticky n -pady 4
    547                             grid $wv -sticky nsew
    548                             grid rowconfigure $_frame $row -weight 1
    549                             grid columnconfigure $_frame 1 -weight 1
    550                             set expand 1
    551                         }
    552                     }
    553                     GroupEntry {
    554                         $wv configure -heading yes
    555 
    556                         #
    557                         # Scan through all children in this group
    558                         # and see if any demand more space.  If the
    559                         # group contains a structure or a note, then
    560                         # make sure that the group itself is set to
    561                         # expand/fill.
    562                         #
    563                         set queue [winfo children $wv]
    564                         set expandgroup 0
    565                         while {[llength $queue] > 0} {
    566                             set w [lindex $queue 0]
    567                             set queue [lrange $queue 1 end]
    568                             set c [winfo class $w]
    569                             if {[lsearch {DeviceEditor Note} $c] >= 0} {
    570                                 set expandgroup 1
    571                                 break
    572                             }
    573                             eval lappend queue [winfo children $w]
    574                         }
    575                         if {$expandgroup} {
    576                             set expand 1
    577                             grid $wv -sticky nsew
    578                             grid rowconfigure $_frame $row -weight 1
    579                         }
    580                     }
    581                     Note {
    582                         grid $wv -sticky nsew
    583                         grid rowconfigure $_frame $row -weight 1
    584                         set expand 1
    585                     }
    586                 }
    587                 grid columnconfigure $_frame 1 -weight 1
    588             } elseif {$wv == "--"} {
    589                 grid rowconfigure $_frame $row -minsize 10
    590             }
    591 
    592             incr row
    593             grid rowconfigure $_frame $row -minsize $itk_option(-padding)
    594             incr row
    595         }
    596         grid $_frame.empty -row $row
    597 
    598         #
    599         # If there are any hidden items, then make the bottom of
    600         # this form fill up any extra space, so the form floats
    601         # to the top.  Otherwise, it will jitter around as the
    602         # hidden items come and go.
    603         #
    604         if {[llength $hidden] > 0 && !$expand} {
    605             grid rowconfigure $_frame 99 -weight 1
    606         } else {
    607             grid rowconfigure $_frame 99 -weight 0
    608         }
     516        #
     517        # SCHEME: hlabels
     518        # simple "Label: Value" layout
     519        #
     520        pack forget $_tabs
     521        grid propagate $_frame on
     522        grid columnconfigure $_frame 0 -weight 0
     523        grid rowconfigure $_frame 0 -weight 0
     524
     525        set expand 0  ;# most controls float to top
     526        set row 0
     527        foreach name $showing {
     528            set wl $_name2info($name-label)
     529            if {$wl != "" && [winfo exists $wl]} {
     530                grid $wl -row $row -column 0 -sticky e
     531            }
     532
     533            set wv $_name2info($name-value)
     534            if {$wv != "" && [winfo exists $wv]} {
     535                if {$wl != ""} {
     536                    grid $wv -row $row -column 1 -sticky ew
     537                } else {
     538                    grid $wv -row $row -column 0 -columnspan 2 -sticky ew
     539                }
     540
     541                grid rowconfigure $_frame $row -weight 0
     542
     543                switch -- [winfo class $wv] {
     544                    TextEntry {
     545                        if {[regexp {[0-9]+x[0-9]+} [$wv size]]} {
     546                            grid $wl -sticky n -pady 4
     547                            grid $wv -sticky nsew
     548                            grid rowconfigure $_frame $row -weight 1
     549                            grid columnconfigure $_frame 1 -weight 1
     550                            set expand 1
     551                        }
     552                    }
     553                    GroupEntry {
     554                        $wv configure -heading yes
     555
     556                        #
     557                        # Scan through all children in this group
     558                        # and see if any demand more space.  If the
     559                        # group contains a structure or a note, then
     560                        # make sure that the group itself is set to
     561                        # expand/fill.
     562                        #
     563                        set queue [winfo children $wv]
     564                        set expandgroup 0
     565                        while {[llength $queue] > 0} {
     566                            set w [lindex $queue 0]
     567                            set queue [lrange $queue 1 end]
     568                            set c [winfo class $w]
     569                            if {[lsearch {DeviceEditor Note} $c] >= 0} {
     570                                set expandgroup 1
     571                                break
     572                            }
     573                            eval lappend queue [winfo children $w]
     574                        }
     575                        if {$expandgroup} {
     576                            set expand 1
     577                            grid $wv -sticky nsew
     578                            grid rowconfigure $_frame $row -weight 1
     579                        }
     580                    }
     581                    Note {
     582                        grid $wv -sticky nsew
     583                        grid rowconfigure $_frame $row -weight 1
     584                        set expand 1
     585                    }
     586                }
     587                grid columnconfigure $_frame 1 -weight 1
     588            } elseif {$wv == "--"} {
     589                grid rowconfigure $_frame $row -minsize 10
     590            }
     591
     592            incr row
     593            grid rowconfigure $_frame $row -minsize $itk_option(-padding)
     594            incr row
     595        }
     596        grid $_frame.empty -row $row
     597
     598        #
     599        # If there are any hidden items, then make the bottom of
     600        # this form fill up any extra space, so the form floats
     601        # to the top.  Otherwise, it will jitter around as the
     602        # hidden items come and go.
     603        #
     604        if {[llength $hidden] > 0 && !$expand} {
     605            grid rowconfigure $_frame 99 -weight 1
     606        } else {
     607            grid rowconfigure $_frame 99 -weight 0
     608        }
    609609      }
    610610    }
     
    623623    set wv $_name2info($name-value)
    624624    if {$wv == "--" || [catch {bindtags $wv} btags]} {
    625         return
     625        return
    626626    }
    627627    set i [lsearch $btags $tag]
    628628
    629629    if {$state} {
    630         if {$i < 0} {
    631             bindtags $wv [linsert $btags 0 $tag]
    632         }
     630        if {$i < 0} {
     631            bindtags $wv [linsert $btags 0 $tag]
     632        }
    633633    } else {
    634         if {$i >= 0} {
    635             bindtags $wv [lreplace $btags $i $i]
    636         }
     634        if {$i >= 0} {
     635            bindtags $wv [lreplace $btags $i $i]
     636        }
    637637    }
    638638}
     
    651651    #
    652652    if {"" != $_owner} {
    653         $_owner changed $path
     653        $_owner changed $path
    654654    }
    655655}
     
    663663itcl::body Rappture::Controls::_controlValue {path {units ""}} {
    664664    if {"" != $_owner} {
    665         set val [$_owner valuefor $path]
    666         if {"" != $units} {
    667             set val [Rappture::Units::convert $val -to $units -units off]
    668         }
    669         return $val
     665        set val [$_owner valuefor $path]
     666        if {"" != $units} {
     667            set val [Rappture::Units::convert $val -to $units -units off]
     668        }
     669        return $val
    670670    }
    671671    return ""
     
    682682    set str [string trim $str]
    683683    if {"" != $str && [string index $str end] != ":"} {
    684         append str ":"
     684        append str ":"
    685685    }
    686686    return $str
     
    702702    set name [lindex $_showing $i]
    703703    if {"" != $name} {
    704         foreach w [grid slaves $_frame] {
    705             grid forget $w
    706         }
    707 
    708         set wv $_name2info($name-value)
    709         grid $wv -row 0 -column 0 -sticky new
     704        foreach w [grid slaves $_frame] {
     705            grid forget $w
     706        }
     707
     708        set wv $_name2info($name-value)
     709        grid $wv -row 0 -column 0 -sticky new
    710710    }
    711711}
     
    718718itcl::body Rappture::Controls::_resize {} {
    719719    switch -- $_scheme {
    720         tabs {
    721             # compute the overall size
    722             # BE CAREFUL: do this after setting "-heading no" above
    723             set maxw 0
    724             set maxh 0
    725             update idletasks
    726             foreach name $_controls {
    727                 set wv $_name2info($name-value)
    728                 set w [winfo reqwidth $wv]
    729                 if {$w > $maxw} { set maxw $w }
    730                 set h [winfo reqheight $wv]
    731                 if {$h > $maxh} { set maxh $h }
    732             }
    733             $_frame configure -width $maxw -height $maxh
    734         }
    735         hlabels {
    736             # do nothing
    737         }
     720        tabs {
     721            # compute the overall size
     722            # BE CAREFUL: do this after setting "-heading no" above
     723            set maxw 0
     724            set maxh 0
     725            update idletasks
     726            foreach name $_controls {
     727                set wv $_name2info($name-value)
     728                set w [winfo reqwidth $wv]
     729                if {$w > $maxw} { set maxw $w }
     730                set h [winfo reqheight $wv]
     731                if {$h > $maxh} { set maxh $h }
     732            }
     733            $_frame configure -width $maxw -height $maxh
     734        }
     735        hlabels {
     736            # do nothing
     737        }
    738738    }
    739739}
Note: See TracChangeset for help on using the changeset viewer.