Changeset 606ed76 in tol for tolbase/lib/wtree/wtree.tcl
- Timestamp:
- Nov 17, 2016, 12:40:36 PM (10 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- ceea866
- Parents:
- 6d788c2
- File:
-
- 1 edited
-
tolbase/lib/wtree/wtree.tcl (modified) (36 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tolbase/lib/wtree/wtree.tcl
r6d788c2 r606ed76 8 8 package require snit 9 9 10 # 10 # 11 11 # TODO: 12 12 # … … 58 58 # pares indicando para cada tipo el valor de la propiedad 59 59 } 60 60 61 61 snit::widget wtree { 62 62 typevariable SystemButtonFace … … 79 79 option -columnfilter \ 80 80 -default "" -configuremethod "_conf-columnfilter" 81 81 82 82 variable tree 83 83 variable vscrollbar … … 109 109 delegate option -bd to hull 110 110 delegate option -relief to hull 111 111 112 112 typeconstructor { 113 113 114 114 set thisPlatform $::tcl_platform(platform) 115 115 set w [ listbox .___lb___ ] … … 156 156 } 157 157 } 158 158 159 159 if { [ lsearch -exact [ image names ] folder-closed ] == -1 } { 160 160 image create photo folder-closed -data { … … 191 191 #lassign $id where item arg1 arg2 192 192 foreach {where item arg1 arg2} $id break 193 193 194 194 if {[llength [$w item descendants $item]] == 0} { 195 195 $self notify generate <<ItemSelected>> [list T $w c $item] … … 197 197 $w item toggle $item 198 198 } 199 199 200 200 } else { 201 201 TreeCtrl::DoubleButton1 $w $x $y … … 211 211 } 212 212 } 213 213 214 214 method Button3 {w x y rootX rootY} { 215 215 … … 225 225 if {[lindex $id 0] == "item"} { 226 226 foreach {where item arg1 arg2} $id break 227 227 228 228 if {[$w selection includes $item]==0} { 229 229 $w selection clear … … 234 234 tk_popup $cmenu $rootX $rootY 235 235 } 236 236 237 237 method KeyPressEscape {} { 238 238 239 239 $self notify generate <<Escape>> 240 240 } 241 241 242 242 method SortbyColumn {t column} { 243 243 … … 291 291 grid columnconfigure $win.frameFilter.fentry 0 -weight 1 292 292 grid remove $widgets(filter,bcancel) 293 293 294 294 bind $widgets(filter,entry) <Key-Return> [ mymethod _applyFilter ] 295 295 grid $win.frameFilter.l -row 0 -column 1 -sticky "e" … … 307 307 grid rowconfigure $win.frameTree 0 -weight 1 308 308 grid columnconfigure $win.frameTree 0 -weight 1 309 309 310 310 install tree as treectrl $win.frameTree.t \ 311 311 -highlightthickness 0 -borderwidth 0 \ … … 323 323 $tree notify install <Edit-end> 324 324 $tree notify install <Edit-accept> 325 325 326 326 $tree notify bind $tree <Edit-begin> \ 327 327 [ mymethod EditCallback begin %I %C %E %t ] … … 330 330 $tree notify bind $tree <Edit-accept> \ 331 331 [ mymethod EditCallback accept %I %C %E %t ] 332 332 333 333 bind $tree <ButtonPress-1> [ mymethod OnButtonPress1 %x %y ] 334 bind $tree <Control-ButtonPress-1> { } 335 bind $tree <Shift-ButtonPress-1> { } 334 bind $tree <Control-ButtonPress-1> { } 335 bind $tree <Shift-ButtonPress-1> { } 336 336 337 337 set height [font metrics [$tree cget -font] -linespace] … … 348 348 {selected focus}] ] 349 349 set elements(check) [ $tree element create eCHK window ] 350 350 351 351 set elements(rect) [ $tree element create eRECT rect \ 352 352 -showfocus yes -open ew \ … … 377 377 378 378 focus $tree 379 379 380 380 $self _configure_bindings 381 381 $self _conf-columns -columns $options(-columns) … … 387 387 #return $win 388 388 } 389 389 390 390 method AcceptEdit { } { 391 391 ::TreeCtrl::EditClose $tree entry 1 0 … … 509 509 $self _setNormalCursor 510 510 } 511 511 512 512 method _filterNodesMatching { } { 513 513 if { [ llength $listFilterOff ] } { … … 532 532 foreach n $nodes { 533 533 # filtro el nodo 534 534 535 535 #esto es para el filtrado automatico incremental 536 536 if { $breakFilter } { … … 542 542 $self _filterNodeSet [ $tree item children $n ] \ 543 543 $positiveWords $negativeRegExp 544 544 545 545 if { 0 } { 546 546 if { [ $self _filterNode $n $positiveWords $negativeRegExp ] } { … … 569 569 # hago match, luego hago algo mas sofisticado con regexp 570 570 # set visible [ string match "*${text}*" $itemText ] 571 if { [ string length $negativeRegExp ] && 571 if { [ string length $negativeRegExp ] && 572 572 ![ regexp -nocase $negativeRegExp $itemText ] } { 573 573 # itemText contiene alguna de las palabra prohibidas … … 625 625 } 626 626 } 627 627 628 628 method _scheduleFilter { } { 629 629 after cancel $idIdleFilter … … 632 632 633 633 method _configure_bindings { } { 634 634 635 635 bind $tree <Double-ButtonPress-1> "[mymethod DoubleButton1 %W %x %y] ; break" 636 636 bind $tree <Return> "[mymethod KeyPressReturn %W] ; break" … … 639 639 640 640 bind $tree <Escape> "[mymethod KeyPressEscape] ; break" 641 641 642 642 $tree notify bind $tree <Header-invoke> [mymethod SortbyColumn %W %C] 643 643 644 644 $tree notify bind $vscrollbar <Scroll-y> { %W set %l %u } 645 645 bind $vscrollbar <ButtonPress-1> [list focus $tree] 646 646 647 647 $tree notify bind $hscrollbar <Scroll-x> { %W set %l %u } 648 648 bind $hscrollbar <ButtonPress-1> [list focus $tree] 649 649 650 650 ::autoscroll::autoscroll $vscrollbar 651 651 ::autoscroll::autoscroll $hscrollbar … … 664 664 method _conf-buttonstyle { _ bs } { 665 665 set valid_bstyles [ array names wtree::ButtonImageConf ] 666 if { [ lsearch $valid_bstyles $bs ] == -1 } { 666 if { [ lsearch $valid_bstyles $bs ] == -1 } { 667 667 error "invalid button style $bs should be one of $valid_bstyles" 668 668 } else { … … 673 673 674 674 method _conf-contextmenu { _ cmenu } { 675 set options(-contextmenu) $cmenu 675 set options(-contextmenu) $cmenu 676 676 } 677 677 678 678 method _conf-filter { _ value } { 679 679 if { [ string is boolean $value ] } { 680 if { ( $options(-filter) && $value ) || 680 if { ( $options(-filter) && $value ) || 681 681 ( !$options(-filter) && !$value ) } { 682 682 return … … 705 705 # 706 706 # columnsSpec es una lista de "columnas" y una columna puede ser 707 # 707 # 708 708 # - un unico elemento con valor: image, text o check 709 709 # … … 744 744 -image $opts(-image) \ 745 745 -itembackground "\#e0e8f0 {}" \ 746 -tags $opts(-tags) ] 746 -tags $opts(-tags) ] 747 747 # " 748 748 set column_info($idx,ID) $colID … … 902 902 } else { 903 903 return [ list $elements($etype) $def_prop($etype) "" ] 904 } 904 } 905 905 } 906 906 … … 912 912 913 913 method OnButtonPress1 { x y } { 914 914 915 915 set treeInfo [ $tree identify $x $y ] 916 916 if { $treeInfo eq "" } { … … 918 918 return 919 919 } 920 920 921 921 if { [ llength $treeInfo ] != 6 } { 922 922 return 923 923 } 924 924 925 925 foreach { item I column C elem E } $treeInfo { } 926 926 927 927 if { $item == "item" && \ 928 928 $column == "column" && \ … … 934 934 set idx_info $column_info(MAPIDX,$C) 935 935 936 if { $column_info($idx_info,-editable) && 936 if { $column_info($idx_info,-editable) && 937 937 ( $E eq "eTXT" || $E eq "eRECT" ) } { 938 938 set exists [winfo exists $tree.entry] … … 958 958 } 959 959 } 960 960 961 961 proc test_GetTextContents { T item } { 962 962 set textDump "" … … 1000 1000 grid $w.fsearch -row 0 -column 0 -sticky "snew" 1001 1001 } 1002 1002 1003 1003 set T [ wtree $w.t -table $istable -filter yes -buttonstyle mac \ 1004 1004 -columns [ list \ 1005 1005 { {image text} -tags ID -label Identifier } \ 1006 1006 { text -tags DESC -label Description -editable yes } ] ] 1007 1007 1008 1008 $T notify bind $T <Expand-before> { 1009 1009 #puts "before openning %I" … … 1023 1023 trace add variable ::wtreeSearch write "::wtree::test_ListenSearch $T" 1024 1024 } 1025 1025 1026 1026 set bugValue { 1027 1027 Serie AlgGetData( … … 1053 1053 %T CancelEdit 1054 1054 } ] 1055 grid $w.btn1 -row 1 -column 0 1056 grid $w.btn2 -row 1 -column 1 1055 grid $w.btn1 -row 1 -column 0 1056 grid $w.btn2 -row 1 -column 1 1057 1057 grid rowconfigure $w 1 -weight 1 1058 grid columnconfigure $w 0 -weight 1 1059 1058 grid columnconfigure $w 0 -weight 1 1059 1060 1060 for { set r 0 } { $r < 100 } { incr r } { 1061 1061 $T insert [list [list folder-open "node $r"] [ list "Description for node $r" ] ]
Note: See TracChangeset
for help on using the changeset viewer.
