Ignore:
File:
1 edited

Legend:

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

    r11 r24  
    9090        ignore -highlightthickness -highlightbackground -highlightcolor
    9191    }
    92     pack $itk_component(area) -fill both
     92    pack $itk_component(area) -expand yes -fill both
    9393    bind $itk_component(area) <Configure> \
    9494        [list $_dispatcher event -idle !redraw]
    9595
    9696    eval itk_initialize $args
     97
     98    set _sizes(header) 1
     99    set _sizes(bararea) 1
    97100}
    98101
     
    163166# ----------------------------------------------------------------------
    164167itcl::body Rappture::DeviceLayout1D::_layout {} {
    165     # first, recompute the overall height of this widget
    166     set h [expr {$_sizes(bar)+$_sizes(bar45)+2}]
     168    #
     169    # First, recompute the overall height of this widget...
     170    #
     171    # size of an ordinary material bar:
     172    set hmax [expr {$_sizes(bar)+$_sizes(bar45)+2}]
     173
     174    # add the maximum size of any embedded icons:
     175    if {$_device != ""} {
     176        foreach nn [$_device children components] {
     177            set icon [$_device get components.$nn.about.icon]
     178            if {"" != $icon} {
     179                if {[info exists _icons($icon)]} {
     180                    set imh $_icons($icon)
     181                } else {
     182                    set imh [image create photo -data $icon]
     183                    set _icons($icon) $imh
     184                }
     185
     186                set h [image height $_icons($icon)]
     187                if {$h > $hmax} {
     188                    set hmax $h
     189                }
     190            }
     191        }
     192    }
     193    set _sizes(bararea) $hmax
    167194
    168195    set fnt $itk_option(-font)
     
    171198        if {"" != $m} {
    172199            set extra [expr {1.5*[font metrics $fnt -linespace]}]
    173             set h [expr {$h+$extra}]
     200            set hmax [expr {$hmax+$extra}]
    174201            break
    175202        }
     
    181208            if {"" != [$_device get components.$nn.about.label]} {
    182209                set extra [expr {1.2*[font metrics $fnt -linespace]}]
    183                 set h [expr {$h+$extra}]
     210                set hmax [expr {$hmax+$extra}]
    184211                break
    185212            }
     
    188215
    189216    set oldh [component hull cget -height]
    190     if {$h != $oldh} {
    191         component hull configure -height $h
     217    if {$hmax != $oldh} {
     218        component hull configure -height $hmax
    192219        $_dispatcher event -idle !redraw
    193220    }
     221    set _sizes(header) [expr {$hmax - $_sizes(bararea)}]
    194222
    195223    # next, scan through the device and compute layer positions
     
    203231        # get the default system of units
    204232        set units [set defunits [$_device get units]]
    205         if {$units == "arbitrary"} {
     233        if {$units == "arbitrary" || $units == ""} {
    206234            set defunits "m"
    207235            set units "um"
     
    212240                box* {
    213241                    # get x-coord for each corner
    214                     set c0 [lindex [$_device get components.$nn.corner0] 0]
     242                    set c0 [$_device get components.$nn.corner0]
     243                    regsub -all , $c0 { } c0
     244                    set c0 [lindex $c0 0]
    215245                    set c0 [Rappture::Units::convert $c0 \
    216246                        -context $defunits -to $units -units off]
    217247
    218                     set c1 [lindex [$_device get components.$nn.corner1] 0]
     248                    set c1 [$_device get components.$nn.corner1]
     249                    regsub -all , $c1 { } c1
     250                    set c1 [lindex $c1 0]
    219251                    set c1 [Rappture::Units::convert $c1 \
    220252                        -context $defunits -to $units -units off]
     
    310342itcl::body Rappture::DeviceLayout1D::_drawLayer {index x0 x1} {
    311343    set c $itk_component(area)
    312     set h [expr {[winfo height $c]-1}]
    313 
    314     set y0 $h
     344    set h [expr {$_sizes(header) + $_sizes(bararea) - 1}]
     345
     346    set bsize [expr {$_sizes(bar)+$_sizes(bar45)+2}]
     347    set y0 [expr {$h - 0.5*$_sizes(bararea) + 0.5*$bsize}]
    315348    set y0p [expr {$y0-$_sizes(bar45)}]
    316349    set y1p [expr {$y0-$_sizes(bar)}]
     
    357390itcl::body Rappture::DeviceLayout1D::_drawIcon {index x0 x1 imh} {
    358391    set c $itk_component(area)
    359     set h [expr {[winfo height $c]-1}]
    360 
    361     set y0 $h
     392    set h [expr {$_sizes(header) + $_sizes(bararea) - 1}]
     393
     394    set bsize [expr {$_sizes(bar)+$_sizes(bar45)+2}]
     395    set y0 [expr {$h - 0.5*$_sizes(bararea) + 0.5*$bsize}]
    362396    set y0p [expr {$y0-$_sizes(bar45)}]
    363397    set y1p [expr {$y0-$_sizes(bar)}]
     
    370404    set y [expr {0.5*($y0+$y0p) + 0.5*($y1-$y0p)}]
    371405
    372     ##set lcolor $itk_option(-deviceoutline)
    373     ##$c create line $xx0 $y $xx1 $y -width 3
    374 
    375406    $c create image [expr {0.5*($xx0+$xx1)}] $y -anchor c -image $imh
    376407}
     
    385416itcl::body Rappture::DeviceLayout1D::_drawAnnotation {index x0 x1} {
    386417    set c $itk_component(area)
    387     set h [expr {[winfo height $c]-1}]
    388 
    389     set y0 $h
    390     set y1 [expr {$y0-$_sizes(bar)-$_sizes(bar45)}]
    391 
     418
     419    set ytop [expr {$_sizes(header)+1}]
    392420    set x0p [expr {$x0+$_sizes(bar45)}]
    393421    set x1p [expr {$x1+$_sizes(bar45)}]
     
    396424    set fnt $itk_option(-font)
    397425    set lh [font metrics $fnt -linespace]
    398     set ymid [expr {$y1-2-0.5*$lh}]
    399     set y [expr {$y1-4}]
     426    set ymid [expr {$ytop-2-0.5*$lh}]
     427    set y [expr {$ytop-4}]
    400428
    401429    #
Note: See TracChangeset for help on using the changeset viewer.