- Timestamp:
- Apr 1, 2010, 10:58:58 AM (14 years ago)
- Location:
- branches/blt4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/examples/zoo/filechoice/tool.xml
r1677 r1681 70 70 <description>From the home directory</description> 71 71 <label>Choose Files</label> 72 <icon> 73 R0lGODlhGgASAKEBAAAAAP///////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgAB 74 ACwAAAAAGgASAAACLoyPqcvtD8CRj8VZrYw8h/tRn2eA4Eiaosa1qttC1EmW81qrtbYvdG8DCodE 75 RQEAOw== 76 </icon> 72 77 </about> 78 73 79 <pattern>@@input.choice(stats)@@</pattern> 74 80 </filelist> -
branches/blt4/gui/scripts/controlOwner.tcl
r1675 r1681 320 320 # send out any callback notifications 321 321 foreach owner [array names _owner2paths] { 322 puts stderr "owner=$_owner $_owner2paths($owner) path=$path"323 322 foreach pattern $_owner2paths($owner) { 324 323 if {[string match $pattern $path]} { 325 puts stderr "owner=$_owner calling $_callbacks($owner/$pattern)"326 324 uplevel #0 $_callbacks($owner/$pattern) 327 325 break … … 408 406 set i [lsearch -exact $plist $path] 409 407 if {$i < 0} { lappend _owner2paths($owner) $path } 410 puts stderr "_callbacks($owner/$path)=$cb"411 408 set _callbacks($owner/$path) $cb 412 409 } -
branches/blt4/gui/scripts/filechoiceentry.tcl
r1677 r1681 185 185 # ---------------------------------------------------------------------- 186 186 itcl::body Rappture::FileChoiceEntry::_rebuild {} { 187 puts stderr "filechoiceentry rebuild"188 187 set _rebuildPending 0 189 188 # get rid of any existing choices … … 199 198 set glob [string trim [$_owner xml get $_path.$cname]] 200 199 # Successively replace each template with its value. 201 puts stderr "before glob=$glob"202 200 while { [regexp -indices {@@[^@]*@@} $glob range] } { 203 201 foreach {first last} $range break … … 206 204 set cpath [string range $glob $i1 $i2] 207 205 set value [$_owner xml get $cpath.current] 208 puts stderr "$cpath.current: value=$value"209 206 if { $value == "" } { 210 puts stderr "$_owner xml get $cpath.default"211 207 set value [$_owner xml get $cpath.default] 212 puts stderr "$cpath.default: value=$value"213 208 } 214 209 set glob [string replace $glob $first $last $value] … … 252 247 itcl::body Rappture::FileChoiceEntry::_tooltip {} { 253 248 set tip [string trim [$_owner xml get $_path.about.description]] 254 puts stderr "tip=$tip, $_owner=$_owner path=$_path.about.description"255 249 # get the description for the current choice, if there is one 256 250 set str [$itk_component(choice) value] -
branches/blt4/gui/scripts/filelistentry.tcl
r1680 r1681 27 27 private variable _owner "" ;# thing managing this control 28 28 private variable _path "" ;# path in XML to this number 29 private variable _icon "" 29 30 30 31 constructor {owner path args} { … … 39 40 public method tooltip {} 40 41 41 private method Toggle { id }42 42 protected method _rebuild {} 43 43 protected method _newValue { args } 44 44 protected method _tooltip {} 45 45 protected method _whenidle {} 46 47 46 } 48 47 … … 87 86 -tree $_tree \ 88 87 -font "Arial 9" \ 89 -flat yes -separator / 90 } 91 $itk_component(tree) column insert 0 "show" \ 92 -text "" -weight 0.0 -pad 0 -borderwidth 0 93 $itk_component(tree) style checkbox "check" -showvalue no \ 94 -onvalue 1 -offvalue 0 88 -flat yes -separator / \ 89 -selectcommand [itcl::code $this _newValue] 90 } 95 91 $itk_component(tree) column configure "treeView" -justify left \ 96 92 -weight 1.0 -text "" -pad 0 -borderwidth 0 -edit no 97 $itk_component(tree) column configure "show" -style "check" -pad {0 0} \98 -edit no99 93 pack $itk_component(scrollset) -fill both -expand yes 100 94 101 95 blt::table $itk_interior \ 102 96 0,0 $itk_component(scrollset) -fill both 103 $_tree trace create all "show" w [itcl::code $this _newValue]104 97 bind $itk_component(tree) <<Value>> [itcl::code $this _newValue] 105 $itk_component(tree) bin Entry <Double-ButtonPress-1> \ 106 +[itcl::code $this Toggle current] 107 98 99 # Standard ButtonPress-1 100 $itk_component(tree) bind Entry <ButtonPress-1> { 101 Rappture::FileListEntry::SetSelectionAnchor %W current yes set 102 set blt::TreeView::_private(scroll) 1 103 } 104 # Standard B1-Motion 105 $itk_component(tree) bind Entry <B1-Motion> { 106 set blt::TreeView::_private(x) %x 107 set blt::TreeView::_private(y) %y 108 set index [%W nearest %x %y] 109 Rappture::FileListEntry::SetSelectionAnchor %W $index yes set 110 } 111 # Standard ButtonRelease-1 112 $itk_component(tree) button bind all <ButtonRelease-1> { 113 set index [%W nearest %x %y blt::TreeView::_private(who)] 114 if { [%W index current] == $index && 115 $blt::TreeView::_private(who) == "button" } { 116 %W see -anchor nw current 117 %W toggle current 118 } 119 } 120 # Shift-ButtonPress-1 121 $itk_component(tree) bind Entry <Shift-ButtonPress-1> { 122 Rappture::FileListEntry::SetSelectionAnchor %W current yes set 123 set blt::TreeView::_private(scroll) 1 124 } 125 # Shift-B1-Motion 126 $itk_component(tree) bind Entry <Shift-B1-Motion> { 127 set blt::TreeView::_private(x) %x 128 set blt::TreeView::_private(y) %y 129 set index [%W nearest %x %y] 130 if { [%W cget -selectmode] == "multiple" } { 131 %W selection mark $index 132 } else { 133 Rappture::FileListEntry::SetSelectionAnchor %W $index yes set 134 } 135 } 136 # Shift-ButtonRelease-1 137 $itk_component(tree) bind Entry <Shift-ButtonRelease-1> { 138 if { [%W cget -selectmode] == "multiple" } { 139 %W selection anchor current 140 } 141 after cancel $blt::TreeView::_private(afterId) 142 set blt::TreeView::_private(afterId) -1 143 set blt::TreeView::_private(scroll) 0 144 } 145 $itk_component(tree) bind Entry <Control-ButtonPress-1> { 146 Rappture::FileListEntry::SetSelectionAnchor %W current no toggle 147 set blt::TreeView::_private(scroll) 1 148 } 149 $itk_component(tree) bind Entry <Control-B1-Motion> { 150 set blt::TreeView::_private(x) %x 151 set blt::TreeView::_private(y) %y 152 set index [%W nearest %x %y] 153 if { [%W cget -selectmode] == "multiple" } { 154 %W selection mark $index 155 } else { 156 Rappture::FileListEntry::SetSelectionAnchor %W $index no toggle 157 } 158 } 159 $itk_component(tree) bind Entry <Control-ButtonRelease-1> { 160 if { [%W cget -selectmode] == "multiple" } { 161 %W selection anchor current 162 } 163 after cancel $blt::TreeView::_private(afterId) 164 set blt::TreeView::_private(afterId) -1 165 set blt::TreeView::_private(scroll) 0 166 } 108 167 # First time, parse the <pattern> elements to generate notify callbacks 109 168 # for each template found. … … 123 182 $_owner notify sync 124 183 eval itk_initialize $args 184 185 # if the control has an icon, plug it in 186 set str [$_owner xml get $path.about.icon] 187 if {$str != ""} { 188 set _icon [image create picture -data $str] 189 } 125 190 _rebuild 126 191 } … … 155 220 return 156 221 } 157 foreach id [$ _tree children root] {222 foreach id [$itk_component(tree) curselection] { 158 223 set path [$_tree get $id "path" ""] 159 224 set path2id($path) $id 160 225 } 161 226 set paths [split $newval ,] 162 $_tree set all "show" 0163 foreach path $paths {164 if { [info exists path2id($path)] } {165 $_tree set $path2id($path) "show" 1166 }167 }168 227 } elseif {[llength $args] != 0} { 169 228 error "wrong # args: should be \"value ?-check? ?newval?\"" … … 174 233 # 175 234 set list {} 176 foreach id [$_tree children root] { 177 if { [$_tree get $id "show" 0] } { 178 set path [$_tree get $id "path" ""] 179 if { $path != "" } { 180 lappend list $path 181 } 235 foreach id [$itk_component(tree) curselection] { 236 set path [$_tree get $id "path" ""] 237 if { $path != "" } { 238 lappend list $path 182 239 } 183 240 } … … 221 278 # ---------------------------------------------------------------------- 222 279 itcl::body Rappture::FileListEntry::_rebuild {} { 223 puts stderr "filelistentry rebuild"224 225 280 set _rebuildPending 0 226 281 … … 256 311 set first $tail 257 312 } 313 set tail [file root $tail] 258 314 set id [$_tree index root->"$tail"] 259 315 if { $id < 0 } { … … 266 322 if {$len > $max} { set max $len } 267 323 } 324 $itk_component(tree) entry configure all -icon $_icon 268 325 eval $_tree delete [$_tree tag nodes unused] 269 326 $itk_component(tree) configure -width $max 270 $itk_component(tree) selection set 0327 #$itk_component(tree) selection set 0 271 328 } 272 329 … … 290 347 itcl::body Rappture::FileListEntry::_tooltip {} { 291 348 set tip [string trim [$_owner xml get $_path.about.description]] 292 puts stderr "tip=$tip, $_owner=$_owner path=$_path.about.description"293 349 # get the description for the current choice, if there is one 294 350 set path "" … … 322 378 } 323 379 324 itcl::body Rappture::FileListEntry::Toggle { index } { 325 set id [$itk_component(tree) index $index] 326 set show [$_tree get $id "show" 0] 327 set show [expr $show==0] 328 $_tree set $id "show" $show 329 } 380 proc Rappture::FileListEntry::SetSelectionAnchor { w tagOrId clear how } { 381 set index [$w index $tagOrId] 382 if { $clear } { 383 $w selection clearall 384 } 385 $w see $index 386 $w focus $index 387 $w selection $how $index 388 $w selection anchor $index 389 } 390 391
Note: See TracChangeset
for help on using the changeset viewer.