Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29731
Modified Files: Tag: desiredata desire.tk Log Message: more on find....
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.142 retrieving revision 1.1.2.600.2.143 diff -C2 -d -r1.1.2.600.2.142 -r1.1.2.600.2.143 *** desire.tk 28 Dec 2006 00:03:50 -0000 1.1.2.600.2.142 --- desire.tk 28 Dec 2006 02:51:00 -0000 1.1.2.600.2.143 *************** *** 1751,1759 **** #-----------------------------------------------------------------------------------# def Canvas find {} { ! FindModel new_as findmodel $self ! FindView new $self } def Canvas find_again {} { ! if {[info exists @find_string]} {$@find_canvas search} }
--- 1751,1761 ---- #-----------------------------------------------------------------------------------# def Canvas find {} { ! if {[info exists ::_(findmodel:_class)]} {focus .$self.find.find} else { ! FindModel new_as findmodel $self ! FindView new $self ! } } def Canvas find_again {} { ! if {[info exists ::_(findmodel:_class)]} {findmodel search} }
*************** *** 2851,2854 **** --- 2853,2859 ---- set @find_string "" set @find_break 0 + set @lastcanvas "" + set @result "" + set @resultcanvas "" set @views {} } *************** *** 2860,2895 **** def FindModel find_string= {s} {set @find_string $s} def FindModel find_string {} {return $@find_string} ! def FindModel find_break {} {return $@find_break} ! def FindModel find_break= {val} {set @find_break $val} def FindModel views+ {view} {lappend @views $view} def FindModel views {} {return $@views}
! def FindModel search {canvas} { ! set children [$canvas children] ! if {[findmodel find_break] == [llength $children]} {findmodel find_break= 0} ! set i [findmodel find_break] ! for {} {[findmodel find_break] < [llength $children]} {incr i} { set child [lindex $children $i] if {[[$child class] <= TextBox]} { ! if {[string first [findmodel find_string] [$child text] 0] >= 0} { ! set c [$canvas widget] ! if {[winfo exists $c]} {raise $c} else {$canvas popup_open} ! $canvas deselect_all ! $canvas selection= $child ! incr i ! break ! } else { ! if {[$child class] == "Canvas"} { ! #$self find_canvas= $child ! #$child find_break= 0 ! #$child find_string= $@find_string ! $self search $child ! incr i ! break ! } } } - if {$i == [llength $children]} {findmodel find_break= 0; break} } } class_new FindView {FindModel} ;# no, using View is wrong here. View is for tk canvas item collections. --- 2865,2903 ---- def FindModel find_string= {s} {set @find_string $s} def FindModel find_string {} {return $@find_string} ! def FindModel result= {s} { ! $@orig_canvas deselect_all ! $@orig_canvas selection= $s ! set @result $s ! } ! def FindModel result {} {return $@result} def FindModel views+ {view} {lappend @views $view} def FindModel views {} {return $@views}
! def FindModel search {} { ! $self search_current ! ! } ! ! def FindModel search_current {} { ! set children [$@orig_canvas children] ! if {$@result == ""} {set i 0} else {set i [expr [lsearch $children $@result]+1]} ! for {} {$i < [llength $children]} {incr i} { set child [lindex $children $i] if {[[$child class] <= TextBox]} { ! if {[string first $@find_string [$child text] 0] >= 0} { ! $self result= $child ! return 1 } } } + $self result= "" + return 0 + + } + + def FindModel search_recursive {} { + set children [$@orig_canvas children] + set canvas [$@orig_canvas get_nextchildcanvas $@lastcanvas] + if {$canvas == ""} {set @lastcanvas ""} else {set @lastcanvas $canvas} } class_new FindView {FindModel} ;# no, using View is wrong here. View is for tk canvas item collections. *************** *** 2909,2913 **** pack $f -side bottom -fill x -before $w set string [findmodel find_string] ! if {$string != ""} {$f.find insert 0 $stringy} focus $f.find } --- 2917,2921 ---- pack $f -side bottom -fill x -before $w set string [findmodel find_string] ! if {$string != ""} {$f.find insert 0 $string} focus $f.find } *************** *** 2940,2944 **** set f [$self widget] findmodel find_string= [$f.find get] ! $self search $@canvas }
--- 2948,2953 ---- set f [$self widget] findmodel find_string= [$f.find get] ! findmodel search ! focus .$@canvas.c }
*************** *** 2949,2965 **** }
- def Canvas remove_findbar {} { - set f [$@findbar widget] - destroy $f - foreach child $@children { - if {[$child class] == "Canvas" && [winfo exists .$child.c]} { - $child remove_findbar - } - } - } - def Canvas check_findbar {} { if {[info exists ::_(findmodel:_class)]} {FindView new $self} } def Canvas index {child} { # this could be O(1) if the proper database were maintained. --- 2958,2976 ---- }
def Canvas check_findbar {} { if {[info exists ::_(findmodel:_class)]} {FindView new $self} } + #returns the next child that is a Canvas + def Canvas get_nextchildcanvas {child} { + if {$child != ""} { + set i [expr [lsearch $@children $child]+1] + } else {set i 0} + for {} {$i < [llength $@children]} {incr i} { + set child [lindex $@children $i] + if {[$child class] == "Canvas"} {return $child; break} + } + + } + def Canvas index {child} { # this could be O(1) if the proper database were maintained.