Changeset 1929 for trunk/gui/scripts/mainwin.tcl
- Timestamp:
- Oct 22, 2010, 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/mainwin.tcl
r1342 r1929 38 38 bind Entry <<Paste>> { 39 39 catch { 40 41 42 43 44 40 # always replace existing selection 41 catch { %W delete sel.first sel.last } 42 43 %W insert insert [::tk::GetSelection %W CLIPBOARD] 44 tk::EntrySeeInsert %W 45 45 } 46 46 } … … 48 48 global tcl_platform 49 49 if {![catch {::tk::GetSelection $w CLIPBOARD} sel]} { 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 50 if {[catch {$w cget -autoseparators} oldSeparator]} { 51 # in case we're using an older version of Tk 52 set oldSeparator 0 53 } 54 if { $oldSeparator } { 55 $w configure -autoseparators 0 56 $w edit separator 57 } 58 59 # always replace existing selection 60 catch { $w delete sel.first sel.last } 61 $w insert insert $sel 62 63 if { $oldSeparator } { 64 $w edit separator 65 $w configure -autoseparators 1 66 } 67 67 } 68 68 } … … 88 88 private variable _bgparser "" ;# parser for bgscript 89 89 } 90 90 91 91 itk::usual MainWin { 92 92 keep -background -cursor foreground -font … … 98 98 itcl::body Rappture::MainWin::constructor {args} { 99 99 itk_component add area { 100 100 canvas $itk_interior.area 101 101 } { 102 103 102 usual 103 rename -background -bgcolor bgColor Background 104 104 } 105 105 pack $itk_component(area) -expand yes -fill both … … 107 107 108 108 itk_component add app { 109 109 frame $itk_component(area).app 110 110 } { 111 112 111 usual 112 keep -borderwidth -relief 113 113 } 114 114 bind $itk_component(app) <Configure> " 115 116 115 after cancel [itcl::code $this _redraw] 116 after idle [itcl::code $this _redraw] 117 117 " 118 118 119 119 itk_component add menu { 120 120 menu $itk_interior.menu 121 121 } 122 122 itk_component add filemenu { 123 123 menu $itk_component(menu).file 124 124 } 125 125 $itk_component(menu) add cascade -label "File" -underline 0 \ 126 126 -menu $itk_component(filemenu) 127 127 $itk_component(filemenu) add command -label "Exit" -underline 1 \ 128 128 -command {destroy .} 129 129 130 130 # … … 184 184 set mainwin $itk_component(hull) 185 185 switch -- $option { 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 186 ifneeded { 187 # 188 # See if the incoming cut buffer has changed. 189 # If so, then sync the new input to the primary selection. 190 # 191 set s [blt::cutbuffer get] 192 if {"" != $s && ![string equal $s $_sync(cutbuffer)]} { 193 # 194 # Convert any \r's in the cutbuffer to \n's. 195 # 196 if {[string first "\r" $s] >= 0} { 197 regsub -all "\r\n" $s "\n" s 198 regsub -all "\r" $s "\n" s 199 blt::cutbuffer set $s 200 } 201 202 set _sync(cutbuffer) $s 203 204 if {![string equal $s $_sync(selection)] 205 && [selection own -selection PRIMARY] != $mainwin} { 206 set _sync(selection) $s 207 208 clipboard clear 209 clipboard append -- $s 210 selection handle -selection PRIMARY $mainwin \ 211 [itcl::code $this syncCutBuffer transfer] 212 selection own -selection PRIMARY -command \ 213 [itcl::code $this syncCutBuffer lostselection] \ 214 $mainwin 215 } 216 } 217 218 # 219 # See if the selection has changed. If so, then sync 220 # the new input to the cut buffer, so it's available 221 # outside the VNC client. 222 # 223 if {[catch {selection get -selection PRIMARY} s]} { 224 set s "" 225 } 226 if {"" != $s && ![string equal $s $_sync(selection)]} { 227 set _sync(selection) $s 228 blt::cutbuffer set $s 229 } 230 231 # do this again soon 232 after 1000 [itcl::code $this syncCutBuffer ifneeded] 233 } 234 transfer { 235 if {[llength $args] != 2} { 236 error "wrong # args: should be \"syncCutBuffer transfer offset max\"" 237 } 238 set offset [lindex $args 0] 239 set maxchars [lindex $args 1] 240 return [string range $_currseln $offset [expr {$offset+$maxchars-1}]] 241 } 242 lostselection { 243 # nothing to do 244 } 245 default { 246 error "bad option \"$option\": should be ifneeded, transfer, or lostselection" 247 } 248 248 } 249 249 } … … 274 274 $itk_component(area) delete all 275 275 if {$itk_option(-mode) == "web"} { 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 276 if {[catch {$_bgparser eval $itk_option(-bgscript)} result]} { 277 bgerror "$result\n (while redrawing application background)" 278 } 279 280 set bd 0 ;# optional border 281 set sw [winfo width $itk_component(area)] 282 set sh [winfo height $itk_component(area)] 283 284 set clip 0 285 set w [winfo reqwidth $itk_component(app)] 286 set h [winfo reqheight $itk_component(app)] 287 if {$w > $sw-2*$bd} { 288 set $w [expr {$sw-2*$bd}] 289 set clip 1 290 } 291 292 set anchor $itk_option(-anchor) 293 switch -- $itk_option(-anchor) { 294 n { 295 set x [expr {$sw/2}] 296 set y $bd 297 } 298 s { 299 set x [expr {$sw/2}] 300 set y [expr {$sh-$bd}] 301 } 302 center { 303 set x [expr {$sw/2}] 304 set y [expr {$sh/2}] 305 } 306 w { 307 set x $bd 308 set y [expr {$sh/2}] 309 } 310 e { 311 set x [expr {$sw-$bd}] 312 set y [expr {$sh/2}] 313 } 314 nw { 315 set x $bd 316 set y $bd 317 } 318 ne { 319 set x [expr {$sw-$bd}] 320 set y $bd 321 } 322 sw { 323 set x $bd 324 set y [expr {$sh-$bd}] 325 } 326 se { 327 set x [expr {$sw-$bd}] 328 set y [expr {$sh-$bd}] 329 } 330 fill { 331 set anchor nw 332 set x $bd 333 set y $bd 334 set w [expr {$sw-2*$bd}] 335 set h [expr {$sh-2*$bd}] 336 set clip 1 337 } 338 } 339 340 # if the app is too big, use w/h. otherwise, 0,0 for default size 341 if {!$clip} { 342 set w 0 343 set h 0 344 } 345 346 $itk_component(area) create window $x $y \ 347 -anchor $anchor -window $itk_component(app) \ 348 -width $w -height $h 349 349 } 350 350 } … … 355 355 itcl::configbody Rappture::MainWin::mode { 356 356 switch -- $itk_option(-mode) { 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 357 desktop { 358 component hull configure -menu $itk_component(hull).menu 359 pack $itk_component(app) -expand yes -fill both 360 wm geometry $itk_component(hull) "" 361 } 362 web { 363 component hull configure -menu "" 364 pack forget $itk_component(app) 365 set wx [winfo screenwidth $itk_component(hull)] 366 set wy [winfo screenheight $itk_component(hull)] 367 wm geometry $itk_component(hull) ${wx}x${wy}+0+0 368 _redraw 369 } 370 default { 371 error "bad value \"$itk_option(-mode)\": should be desktop or web" 372 } 373 373 } 374 374 } … … 386 386 itcl::configbody Rappture::MainWin::anchor { 387 387 if {[lsearch {n s e w ne nw se sw center fill} $itk_option(-anchor)] < 0} { 388 388 error "bad anchor \"$itk_option(-anchor)\"" 389 389 } 390 390 _redraw
Note: See TracChangeset
for help on using the changeset viewer.