[PD-cvs] pd/src desire.tk,1.1.2.600.2.141,1.1.2.600.2.142

chunlee chunlee at users.sourceforge.net
Thu Dec 28 01:03:54 CET 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31389

Modified Files:
      Tag: desiredata
	desire.tk 
Log Message:
first attempt on FindModel FindView


Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.600.2.141
retrieving revision 1.1.2.600.2.142
diff -C2 -d -r1.1.2.600.2.141 -r1.1.2.600.2.142
*** desire.tk	27 Dec 2006 19:07:43 -0000	1.1.2.600.2.141
--- desire.tk	28 Dec 2006 00:03:50 -0000	1.1.2.600.2.142
***************
*** 1750,1798 ****
  
  #-----------------------------------------------------------------------------------#
- def Canvas search {} {
- 	if {$@find_break == [llength $@children]} {set @find_break 0}
- 	set i $@find_break
- 	for {} {$@find_break < [llength $@children]} {incr @find_break} {
- 		incr i
- 		set child [lindex $@children $@find_break]
- 		if {[[$child class] <= TextBox]} {
- 			if {[string first $@find_string [$child text] 0] >= 0} {
- 				$self find_canvas= $self
- 				set c [$self widget]
- 				if {[winfo exists $c]} {raise $c} else {$self popup_open; $self changed}
- 				$self deselect_all
- 				$self selection= $child
- 				incr @find_break
- 				break
- 			} else {
- 				if {[$child class] == "Canvas"} {
- 					$self find_canvas= $child
- 					$child find_break= 0
- 					$child find_string= $@find_string
- 					$child search
- 				}
- 			}
- 		}
- 		if {$i == [llength $@children]} {set @find_break 0; break}
- 	}
- }
- def Canvas findbar {} {return $@findbar}
- def Canvas find_string= {s} {set @find_string $s}
- def Canvas find_string {} {return $@find_string}
- def Canvas find_break= {i} {set @find_break $i}; #$used for find again
- def Canvas find_canvas= {canvas} {set @find_canvas $canvas}; #used for find in nested [pd]
  def Canvas find {} {
! 	set c [$self widget]
! 	$self find_break= 0
! 	$self find_canvas= $self
! 	#FindDialog new_as find $self
! 	if {[winfo exists .$self.yscroll]} {set w .$self.yscroll} else {set w .$self.c}
! 	if {[winfo exists .$self.find]} {
! 		focus .$self.find.find
! 	} else {
! 		set @findbar [FindBar new $self]
! 		pack [$@findbar widget] -side bottom -fill x -before $w
! 	}
! 
  }
  def Canvas find_again {} {
--- 1750,1756 ----
  
  #-----------------------------------------------------------------------------------#
  def Canvas find {} {
! 	FindModel new_as findmodel $self
! 	FindView new $self
  }
  def Canvas find_again {} {
***************
*** 2887,2895 ****
  
  #-----------------------------------------------------------------------------------#
! class_new FindBar {Thing} ;# no, using View is wrong here. View is for tk canvas item collections.
  
! def FindBar widget {} {return .$@canvas.find}
  
! def FindBar addw {type name label} {
  	set f [$self widget]
  	if {$label!=""} {
--- 2845,2917 ----
  
  #-----------------------------------------------------------------------------------#
! class_new FindModel {Thing}
  
! def FindModel init {canvas} {
! 	set @orig_canvas $canvas
! 	set @find_string ""
! 	set @find_break 0
! 	set @views {}
! }
! def FindModel delete {} {
! 	foreach view $@views {destroy [$view widget]}
! 	super
! }
  
! 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.
! 
! def FindView widget {} {return .$@canvas.find}
! 
! def FindView init {canvas} {
! 	findmodel views+ $self
! 	set @canvas $canvas
! 	set @break 0
! 	set f [$self widget]
! 	frame $f -border 1 -relief ridge
! 	$self addw button "close" ""
! 	$self addw text "find" "find"
! 	$self addw checkbutton "recursive" "recursive"
! 	if {[winfo exists .$@canvas.yscroll]} {set w .$@canvas.yscroll} else {set w .$@canvas.c}
! 	pack $f -side bottom -fill x -before $w
! 	set string [findmodel find_string]
! 	if {$string != ""} {$f.find insert 0 $stringy}
! 	focus $f.find
! }
! 
! def FindView addw {type name label} {
  	set f [$self widget]
  	if {$label!=""} {
***************
*** 2900,2904 ****
  			entry $f.$name -width 10 -relief flat -bg white -borderwidth 0 \
  			    -highlightthickness 0
! 			bind $f.$name <Escape> "$self remove"
  			bind $f.$name <Return> "$self find"
  		}
--- 2922,2926 ----
  			entry $f.$name -width 10 -relief flat -bg white -borderwidth 0 \
  			    -highlightthickness 0
! 			bind $f.$name <Escape> "findmodel delete"
  			bind $f.$name <Return> "$self find"
  		}
***************
*** 2907,2912 ****
  		}
  		button {
! 			button $f.$name -border 1 -command "$self remove" -image icon_close -width 9 -height 9
! 			if {$name == "close"} {bind $f.$name <Return> "$self remove"}
  		}
  	}
--- 2929,2934 ----
  		}
  		button {
! 			button $f.$name -border 1 -command "findmodel delete" -image icon_close -width 9 -height 9
! 			if {$name == "close"} {bind $f.$name <Return> "findmodel delete"}
  		}
  	}
***************
*** 2915,2944 ****
  }
  
! def FindBar remove {} {
! 	[$@canvas get_topcanvas] remove_findbar
! 	focus .$@canvas.c
! }
! 
! def FindBar init {canvas} {
! 	super
! 	set @canvas $canvas
! 	set @break 0
! 	set f [$self widget]
! 	frame $f -border 1 -relief ridge
! 	$self addw button "close" ""
! 	$self addw text "find" "find"
! 	$self addw checkbutton "recursive" "recursive"
! 	focus $f.find
! }
! 
! def FindBar find {} {
  	set f [$self widget]
! 	set @string [$f.find get] 
! 	$@canvas find_string= $@string
! 	$@canvas search
! 	focus .$@canvas.c
  }
  
! def FindBar traversal {k w direction} {
  	set f [$self widget]
  	if {$w == "$f.recursive"} {set next $f.close} else {set next [tk_focusNext $w]}
--- 2937,2947 ----
  }
  
! def FindView find {} {
  	set f [$self widget]
! 	findmodel find_string= [$f.find get]
! 	$self search $@canvas
  }
  
! def FindView traversal {k w direction} {
  	set f [$self widget]
  	if {$w == "$f.recursive"} {set next $f.close} else {set next [tk_focusNext $w]}
***************
*** 2957,2969 ****
  
  def Canvas check_findbar {} {
! 	if {$@canvas == "" || [winfo exists .$self.find]} {return}
! 	set topcan [$self get_topcanvas]
! 	if {[$topcan findbar] != ""} {
! 		if {[winfo exists .$self.yscroll]} {set w .$self.yscroll} else {set w .$self.c}
! 		set @findbar [FindBar new $self]
! 		set fw [$@findbar widget]
! 		${fw}.find insert 0 [$topcan find_string]
! 		pack [$@findbar widget] -side bottom -fill x -before $w
! 	}
  }
  def Canvas index {child} {
--- 2960,2964 ----
  
  def Canvas check_findbar {} {
! 	if {[info exists ::_(findmodel:_class)]} {FindView new $self}
  }
  def Canvas index {child} {
***************
*** 3146,3151 ****
  
  def Canvas popup_open {} {
! 	$self init_window
! 	set @mapped 1
  	netsend [list .$self vis 1]
  	netsend [list .$self map 1]
--- 3141,3146 ----
  
  def Canvas popup_open {} {
! 	#$self init_window
! 	#set @mapped 1
  	netsend [list .$self vis 1]
  	netsend [list .$self map 1]





More information about the Pd-cvs mailing list