Changeset 5468 for branches/uq
- Timestamp:
- May 7, 2015, 2:17:22 PM (9 years ago)
- Location:
- branches/uq
- Files:
-
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/uq/gui/scripts/balloon.tcl
r5315 r5468 47 47 48 48 protected method _createStems {} 49 protected method _place {where placement w h sw sh} 49 50 50 51 protected variable _stems ;# windows for cartoon balloon stems … … 123 124 } 124 125 126 127 # ---------------------------------------------------------------------- 128 # USAGE: _place <where> <place> <pw> <ph> <screenw> <screenh> 129 # 130 # Called by activate. Returns the exact location information given 131 # the parameters. If the window will not fit on the screen with the 132 # requested placement, will loop through all possible placements to 133 # find the best alternative. 134 # ---------------------------------------------------------------------- 135 itcl::body Rappture::Balloon::_place {where place pw ph screenw screenh} { 136 # pw and ph are requested balloon window size 137 138 # set placement preference order 139 switch $place { 140 left {set plist {left above below right}} 141 right {set plist {right above below left}} 142 above {set plist {above below right left}} 143 below {set plist {below above right left}} 144 } 145 146 set ph_orig $ph 147 set pw_orig $pw 148 149 foreach placement $plist { 150 set pw $pw_orig 151 set ph $ph_orig 152 if {[winfo exists $where]} { 153 # location of top-left corner of root window 154 set rx [winfo rootx $where] 155 set ry [winfo rooty $where] 156 157 # size of widget we want to popup over 158 set width [winfo width $where] 159 set height [winfo height $where] 160 161 # x and y will be location for popup 162 set x [expr {$rx + $width/2}] 163 set y [expr {$ry + $height/2}] 164 165 switch -- $placement { 166 left { set x [expr {$rx + 5}] } 167 right { set x [expr {$rx + $width - 5}] } 168 above { set y [expr {$ry + 5}] } 169 below { set y [expr {$ry + $height - 5}] } 170 } 171 } elseif {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} { 172 # got x and y 173 } else { 174 error "bad location \"$where\": should be widget or @x,y" 175 } 176 177 # compute stem image size 178 set s $_stems($placement) 179 set sw [image width $_fills($placement)] 180 set sh [image height $_fills($placement)] 181 set offscreen 0 182 183 switch -- $placement { 184 left { 185 set sx [expr {$x-$sw+3}] 186 set sy [expr {$y-$sh/2}] 187 set px [expr {$sx-$pw+3}] 188 set py [expr {$y-$ph/2}] 189 190 # make sure that the panel doesn't go off-screen 191 if {$py < 0} { 192 incr offscreen [expr -$py] 193 set py 0 194 } 195 if {$py+$ph > $screenh} { 196 incr offscreen [expr {$py + $ph - $screenh}] 197 set py [expr {$screenh - $ph}] 198 } 199 if {$px < 0} { 200 incr offscreen [expr -$px] 201 set pw [expr {$pw + $px}] 202 set px 0 203 } 204 } 205 right { 206 set sx $x 207 set sy [expr {$y-$sh/2}] 208 set px [expr {$x+$sw-3}] 209 set py [expr {$y-$ph/2}] 210 211 # make sure that the panel doesn't go off-screen 212 if {$py < 0} { 213 incr offscreen [expr -$py] 214 set py 0 215 } 216 if {$py+$ph > $screenh} { 217 incr offscreen [expr {$py + $ph - $screenh}] 218 set py [expr {$screenh-$ph}] 219 } 220 if {$px+$pw > $screenw} { 221 incr offscreen [expr {$px + $pw - $screenw}] 222 set pw [expr {$screenw-$px}] 223 } 224 } 225 above { 226 set sx [expr {$x-$sw/2}] 227 set sy [expr {$y-$sh+3}] 228 set px [expr {$x-$pw/2}] 229 set py [expr {$sy-$ph+3}] 230 231 # make sure that the panel doesn't go off-screen 232 if {$px < 0} { 233 incr offscreen [expr -$px] 234 set px 0 235 } 236 if {$px+$pw > $screenw} { 237 incr offscreen [expr {$px + $pw - $screenw}] 238 set px [expr {$screenw-$pw}] 239 } 240 if {$py < 0} { 241 incr offscreen [expr -$py] 242 set ph [expr {$ph+$py}] 243 set py 0 244 } 245 } 246 below { 247 set sx [expr {$x-$sw/2}] 248 set sy $y 249 set px [expr {$x-$pw/2}] 250 set py [expr {$y+$sh-3}] 251 252 # make sure that the panel doesn't go off-screen 253 if {$px < 0} { 254 incr offscreen [expr -$px] 255 set px 0 256 } 257 if {$px+$pw > $screenw} { 258 incr offscreen [expr {$px + $pw - $screenw}] 259 set px [expr {$screenw-$pw}] 260 } 261 if {$py+$ph > $screenh} { 262 incr offscreen [expr {$py + $py - $screenh}] 263 set ph [expr {$screenh-$py}] 264 } 265 } 266 } 267 set res($placement) [list $placement $offscreen $pw $ph $px $py $sx $sy] 268 if {$offscreen == 0} { 269 return "$placement $pw $ph $px $py $sx $sy" 270 } 271 } 272 273 # In the unlikely event that we arrived here, it is because no 274 # placement allowed the entire balloon window to be displayed. 275 # Loop through the results and return the best-case placement. 276 set _min 10000 277 foreach pl $plist { 278 set offscreen [lindex $res($pl) 1] 279 if {$offscreen < $_min} { 280 set _min $offscreen 281 set _min_pl $pl 282 } 283 } 284 return "$_min_pl [lrange $res($_min_pl) 2 end]" 285 } 286 125 287 # ---------------------------------------------------------------------- 126 288 # USAGE: activate <where> <placement> … … 129 291 # <where> location, which should be a widget name or @X,Y. The 130 292 # <placement> indicates whether the panel should be left, right, 131 # above, or below the <where> coordinate. 293 # above, or below the <where> coordinate. Plecement is considered 294 # a suggestion and may be changed to fit the popup in the screen. 132 295 # ---------------------------------------------------------------------- 133 296 itcl::body Rappture::Balloon::activate {where placement} { … … 135 298 error "bad placement \"$placement\": should be [join [lsort [array names _stems]] {, }]" 136 299 } 137 set s $_stems($placement)138 set sw [image width $_fills($placement)]139 set sh [image height $_fills($placement)]140 set p $itk_component(hull)141 142 # set screenw [winfo screenwidth $p]143 # set screenh [winfo screenheight $p]144 foreach {screenw screenh} [Rappture::ScreenSize] break145 146 if {[winfo exists $where]} {147 set x [expr {[winfo rootx $where]+[winfo width $where]/2}]148 set y [expr {[winfo rooty $where]+[winfo height $where]/2}]149 switch -- $placement {150 left { set x [expr {[winfo rootx $where]+5}] }151 right { set x [expr {[winfo rootx $where]+[winfo width $where]-5}] }152 above { set y [expr {[winfo rooty $where]+5}] }153 below { set y [expr {[winfo rooty $where]+[winfo height $where]-5}] }154 }155 } elseif {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} {156 # got x and y157 } else {158 error "bad location \"$where\": should be widget or @x,y"159 }160 300 161 301 # if the panel is already up, take it down 162 302 deactivate 303 304 set p $itk_component(hull) 305 set screenw [winfo screenwidth $p] 306 set screenh [winfo screenheight $p] 163 307 164 308 set pw [winfo reqwidth $p] … … 167 311 if {$ph > $screenh} { set ph [expr {$screenh-10}] } 168 312 169 switch -- $placement { 170 left { 171 set sx [expr {$x-$sw+3}] 172 set sy [expr {$y-$sh/2}] 173 set px [expr {$sx-$pw+3}] 174 set py [expr {$y-$ph/2}] 175 176 # make sure that the panel doesn't go off-screen 177 if {$py < 0} { set py 0 } 178 if {$py+$ph > $screenh} { set py [expr {$screenh-$ph}] } 179 if {$px < 0} { set pw [expr {$pw+$px}]; set px 0 } 180 } 181 right - 182 above { 183 if {$placement == "right"} { 184 set sx $x 185 set sy [expr {$y-$sh/2}] 186 set px [expr {$x+$sw-3}] 187 set py [expr {$y-$ph/2}] 188 189 # make sure that the panel doesn't go off-screen 190 if {$py < 0} { set py 0 } 191 if {$py+$ph > $screenh} { set py [expr {$screenh-$ph}] } 192 if {$px+$pw > $screenw} { set placement above } 193 } 194 if {$placement == "above"} { 195 set sx [expr {$x-$sw/2}] 196 set sy [expr {$y-$sh+3}] 197 set px [expr {$x-$pw/2}] 198 set py [expr {$sy-$ph+3}] 199 200 # make sure that the panel doesn't go off-screen 201 if {$px < 0} { set px 0 } 202 if {$px+$pw > $screenw} { set px [expr {$screenw-$pw}] } 203 if {$py < 0} { set ph [expr {$ph+$py}]; set py 0 } 204 } 205 } 206 below { 207 set sx [expr {$x-$sw/2}] 208 set sy $y 209 set px [expr {$x-$pw/2}] 210 set py [expr {$y+$sh-3}] 211 212 # make sure that the panel doesn't go off-screen 213 if {$px < 0} { set px 0 } 214 if {$px+$pw > $screenw} { set px [expr {$screenw-$pw}] } 215 if {$py+$ph > $screenh} { set ph [expr {$screenh-$py}] } 216 } 217 } 218 if {[info exists _masks($placement)]} { 219 shape set $s -bound photo $_masks($placement) 220 } 313 foreach {place pw ph px py sx sy} [_place $where $placement $pw $ph $screenw $screenh] break 314 315 set s $_stems($place) 316 if {[info exists _masks($place)]} { 317 shape set $s -bound photo $_masks($place) 318 } 319 221 320 if { $pw < 1 || $ph < 1 } { 222 321 # I really don't know why this is happenning. I believe this occurs -
branches/uq/gui/scripts/dropdown.tcl
r5315 r5468 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: dropdown - base class for drop-down panels … … 84 84 set w [winfo width $itk_component(hull)] 85 85 set h [winfo height $itk_component(hull)] 86 # set sw [winfo screenwidth $itk_component(hull)] 87 # set sh [winfo screenheight $itk_component(hull)] 88 foreach {sw sh} [Rappture::ScreenSize] break 86 set sw [winfo screenwidth $itk_component(hull)] 87 set sh [winfo screenheight $itk_component(hull)] 89 88 90 89 if {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} { -
branches/uq/gui/scripts/editor.tcl
r5315 r5468 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: editor - pop-up editor for little bits of text … … 59 59 protected variable _loc ;# array of editor location parameters 60 60 } 61 61 62 62 itk::usual Editor { 63 63 keep -cursor -font … … 276 276 set fnt [$e cget -font] 277 277 278 foreach {screenw screenh} [Rappture::ScreenSize] break279 278 set w [expr {[font measure $fnt $str]+20}] 280 279 set w [expr {($w < $_loc(w)) ? $_loc(w) : $w}] 281 if {$w+$_loc(x) >= $screenw} {282 set w [expr { $screenw-$_loc(x)}]280 if {$w+$_loc(x) >= [winfo screenwidth $e]} { 281 set w [expr {[winfo screenwidth $e]-$_loc(x)}] 283 282 } 284 283 285 284 set h [expr {[font metrics $fnt -linespace]+4}] 286 285 set h [expr {($h < $_loc(h)) ? $_loc(h) : $h}] 287 if {$h+$_loc(y) >= $screenh} {288 set h [expr { $screenh-$_loc(y)}]289 } 286 if {$h+$_loc(y) >= [winfo screenheight $e]} { 287 set h [expr {[winfo screenheight $e]-$_loc(y)}] 288 } 290 289 # Temporary fix to prevent Opps. Don't deal with negative dimensions. 291 290 if { $w <= 0 || $h <= 0 } { -
branches/uq/gui/scripts/main.tcl
r5315 r5468 354 354 } elseif {[llength [$win.pager page]] == 2} { 355 355 set style [string trim [$xmlobj get tool.layout]] 356 357 # set screenw [winfo screenwidth .] 358 foreach {screenw screenh} [Rappture::ScreenSize] break 356 set screenw [winfo screenwidth .] 359 357 360 358 update idletasks -
branches/uq/gui/scripts/mainwin.tcl
r5315 r5468 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: mainwin - main application window for Rappture … … 89 89 private variable _bgparser "" ;# parser for bgscript 90 90 } 91 91 92 92 itk::usual MainWin { 93 93 keep -background -cursor foreground -font … … 260 260 itcl::body Rappture::MainWin::draw {option args} { 261 261 set w $itk_component(hull) 262 foreach {screenw screenh} [Rappture::ScreenSize] break 263 regsub -all {<w>} $args $screenw args 264 regsub -all {<h>} $args $screenh args 262 regsub -all {<w>} $args [winfo screenwidth $w] args 263 regsub -all {<h>} $args [winfo screenheight $w] args 265 264 eval $itk_component(area) create $option $args 266 265 } … … 365 364 component hull configure -menu "" 366 365 pack forget $itk_component(app) 367 foreach {wx wy} [Rappture::ScreenSize] break 366 set wx [winfo screenwidth $itk_component(hull)] 367 set wy [winfo screenheight $itk_component(hull)] 368 368 wm geometry $itk_component(hull) ${wx}x${wy}+0+0 369 369 _redraw -
branches/uq/gui/scripts/pager.tcl
r5315 r5468 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: pager - notebook for displaying pages of widgets … … 56 56 public method current {args} 57 57 58 public method busy { bool } 58 public method busy { bool } 59 59 60 60 protected method _layout {} … … 68 68 private variable _current "" ;# page currently shown 69 69 } 70 70 71 71 itk::usual Pager { 72 72 } … … 412 412 # ---------------------------------------------------------------------- 413 413 itcl::body Rappture::Pager::_fixSize {} { 414 foreach {screenw screenh} [Rappture::ScreenSize] break 415 set sw [expr {$screenw-200}] 416 set sh [expr {$screenh-200}] 414 set sw [expr {[winfo screenwidth $itk_component(hull)]-200}] 415 set sh [expr {[winfo screenheight $itk_component(hull)]-200}] 417 416 418 417 update ;# force layout changes so sizes are correct … … 643 642 # 644 643 # If true (this indicates a simulation is occurring), the widget 645 # should prevent the user from 646 # 1) clicking an item previous in the breadcrumbs, and 644 # should prevent the user from 645 # 1) clicking an item previous in the breadcrumbs, and 647 646 # 2) using the "back" button. 648 647 # 649 648 itcl::body Rappture::Pager::busy { bool } { 650 649 if { $bool } { 651 blt::busy hold $itk_component(breadcrumbs) 650 blt::busy hold $itk_component(breadcrumbs) 652 651 $itk_component(back) configure -state disabled 653 } else { 654 blt::busy release $itk_component(breadcrumbs) 652 } else { 653 blt::busy release $itk_component(breadcrumbs) 655 654 $itk_component(back) configure -state normal 656 655 } -
branches/uq/gui/scripts/tooltip.tcl
r5315 r5468 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 2 # ---------------------------------------------------------------------- 3 3 # COMPONENT: tooltip - help information that pops up beneath a widget … … 160 160 # 161 161 update idletasks 162 foreach {screenw screenh} [Rappture::ScreenSize] break163 162 if {$signx == "+"} { 164 if {$xpos+[winfo reqwidth $hull] > $screenw} {165 set xpos [expr { $screenw-[winfo reqwidth $hull]}]163 if {$xpos+[winfo reqwidth $hull] > [winfo screenwidth $hull]} { 164 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 166 165 } 167 166 if {$xpos < 0} { set xpos 0 } 168 167 } else { 169 168 if {$xpos-[winfo reqwidth $hull] < 0} { 170 set xpos [expr { $screenw-[winfo reqwidth $hull]}]171 } 172 set xpos [expr { $screenw-$xpos}]169 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 170 } 171 set xpos [expr {[winfo screenwidth $hull]-$xpos}] 173 172 } 174 173 175 174 if {$signy == "+"} { 176 if {$ypos+[winfo reqheight $hull] > $screenh} {177 set ypos [expr { $screenh-[winfo reqheight $hull]}]175 if {$ypos+[winfo reqheight $hull] > [winfo screenheight $hull]} { 176 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 178 177 } 179 178 if {$ypos < 0} { set ypos 0 } 180 179 } else { 181 180 if {$ypos-[winfo reqheight $hull] < 0} { 182 set ypos [expr { $screenh-[winfo reqheight $hull]}]183 } 184 set ypos [expr { $screenh-$ypos}]181 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 182 } 183 set ypos [expr {[winfo screenheight $hull]-$ypos}] 185 184 } 186 185 … … 195 194 && $py >= $ypos && $py <= $ypos+[winfo reqheight $hull]} { 196 195 197 if {$px > $screenw/2} {196 if {$px > [winfo screenwidth $hull]/2} { 198 197 set signx "-" 199 set xpos [expr { $screenw-$px+4}]198 set xpos [expr {[winfo screenwidth $hull]-$px+4}] 200 199 } else { 201 200 set signx "+" 202 201 set xpos [expr {$px+4}] 203 202 } 204 if {$py > $screenh/2} {203 if {$py > [winfo screenheight $hull]/2} { 205 204 set signy "-" 206 set ypos [expr { $screenh-$py+4}]205 set ypos [expr {[winfo screenheight $hull]-$py+4}] 207 206 } else { 208 207 set signy "+" -
branches/uq/lang/tcl/src/Rappture_Init.c
r5222 r5468 30 30 extern Tcl_AppInitProc RpDaemon_Init; 31 31 extern Tcl_AppInitProc RpCurses_Init; 32 extern Tcl_AppInitProc RpScreenSize_Init; 32 33 33 #ifdef notdef 34 34 extern Tcl_AppInitProc RpLibrary_Init; … … 79 79 return TCL_ERROR; 80 80 } 81 if (RpScreenSize_Init(interp) != TCL_OK) {82 return TCL_ERROR;83 }84 81 if (RpSysinfo_Init(interp) != TCL_OK) { 85 82 return TCL_ERROR; -
branches/uq/puq/puq_analyze.py
r5419 r5468 320 320 xy.text = pts 321 321 322 323 h5 = h5py.File(sys.argv[1], 'r+')324 del h5['/output']325 h5.close()326 322 327 323 sw = load_from_hdf5(sys.argv[1])
Note: See TracChangeset
for help on using the changeset viewer.