Changeset 1929 for trunk/gui/scripts/tempgauge.tcl
- Timestamp:
- Oct 22, 2010 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/tempgauge.tcl
r1342 r1929 30 30 # create a spectrum to use for all temperature widgets 31 31 private common _spectrum [Rappture::Spectrum [namespace current]::#auto { 32 33 34 32 0.0 blue 33 300.0 red 34 500.0 yellow 35 35 } -units K] 36 36 } … … 59 59 60 60 if {"" == [$c find all]} { 61 62 63 64 65 66 67 68 61 # first time around, create the items 62 $c create oval 0 0 1 1 -outline "" -tags bulbfill 63 $c create oval 0 0 1 1 -outline black -tags bulboutline 64 $c create oval 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {bulbscreen screen} 65 $c create rect 0 0 1 1 -outline black -fill white -tags stickoutline 66 $c create rect 0 0 1 1 -outline "" -tags stickfill 67 $c create rect 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {stickscreen screen} 68 $c create image 0 0 -anchor w -image "" -tags bimage 69 69 } 70 70 71 71 if {"" != $itk_option(-spectrum)} { 72 73 72 set color [$itk_option(-spectrum) get [value]] 73 set frac [$itk_option(-spectrum) get -fraction [value]] 74 74 } else { 75 76 75 set color "" 76 set frac 0 77 77 } 78 78 … … 82 82 $c coords bimage 0 $y 83 83 if {$itk_option(-image) != ""} { 84 84 set x [expr {$x + [image width $itk_option(-image)] + 2}] 85 85 } 86 86 87 87 set avail [expr {$w-$x}] 88 88 if {$avail > 0} { 89 90 91 92 93 94 95 89 # 90 # If we have any space left over, draw the thermometer 91 # as a mercury bulb on the left and a stick to the right. 92 # 93 set bsize [expr {0.2*$avail}] 94 if {$bsize > 0.5*$h-2} {set bsize [expr {0.5*$h-2}]} 95 set ssize [expr {0.5*$bsize}] 96 96 97 98 99 100 101 102 97 $c coords bulboutline $x [expr {$y-$bsize}] \ 98 [expr {$x+2*$bsize}] [expr {$y+$bsize}] 99 $c coords bulbscreen [expr {$x-1}] [expr {$y-$bsize-1}] \ 100 [expr {$x+2*$bsize+1}] [expr {$y+$bsize+1}] 101 $c coords bulbfill $x [expr {$y-$bsize}] \ 102 [expr {$x+2*$bsize}] [expr {$y+$bsize}] 103 103 104 105 106 107 108 109 110 111 112 104 set x0 [expr {$x+2*$bsize+1}] 105 set x1 [expr {$w-2}] 106 set xr [expr {($x1-$x0)*$frac + $x0}] 107 $c coords stickoutline [expr {$x0-2}] [expr {$y-$ssize}] \ 108 $x1 [expr {$y+$ssize}] 109 $c coords stickscreen [expr {$x0-2}] [expr {$y-$ssize}] \ 110 [expr {$x1+1}] [expr {$y+$ssize+1}] 111 $c coords stickfill [expr {$x0-2}] [expr {$y-$ssize+1}] \ 112 $xr [expr {$y+$ssize}] 113 113 114 115 114 $c itemconfigure bulbfill -fill $color 115 $c itemconfigure stickfill -fill $color 116 116 } 117 117 118 118 if {$itk_option(-state) == "disabled"} { 119 119 $c itemconfigure screen -fill white 120 120 } else { 121 121 $c itemconfigure screen -fill "" 122 122 } 123 123 } … … 131 131 itcl::body Rappture::TemperatureGauge::_resize {} { 132 132 if {$itk_option(-samplewidth) > 0} { 133 133 set w $itk_option(-samplewidth) 134 134 } else { 135 135 set w [winfo reqheight $itk_component(value)] 136 136 } 137 137 if {$itk_option(-image) != ""} { 138 138 set w [expr {$w+[image width $itk_option(-image)]+4}] 139 139 } 140 140 141 141 if {$itk_option(-sampleheight) > 0} { 142 142 set h $itk_option(-sampleheight) 143 143 } else { 144 145 146 147 148 144 if {$itk_option(-image) != ""} { 145 set h [expr {[image height $itk_option(-image)]+4}] 146 } else { 147 set h [winfo reqheight $itk_component(value)] 148 } 149 149 } 150 150
Note: See TracChangeset
for help on using the changeset viewer.