diff options
author | treectrl <treectrl> | 2005-05-13 20:32:28 (GMT) |
---|---|---|
committer | treectrl <treectrl> | 2005-05-13 20:32:28 (GMT) |
commit | 5509c44009a1a80339cf5a5e905c1b694f5c5adc (patch) | |
tree | 934382df8f26d8bc7480591a52241108f69995af | |
parent | a14f6ea29657170ab73a735c5aed95605743ad08 (diff) | |
download | tktreectrl-5509c44009a1a80339cf5a5e905c1b694f5c5adc.zip tktreectrl-5509c44009a1a80339cf5a5e905c1b694f5c5adc.tar.gz tktreectrl-5509c44009a1a80339cf5a5e905c1b694f5c5adc.tar.bz2 |
Use column -tag instead of zero, to handle -columnprefix option if used.
Use "column compare".
-rw-r--r-- | demos/mailwasher.tcl | 12 | ||||
-rw-r--r-- | demos/random.tcl | 14 |
2 files changed, 15 insertions, 11 deletions
diff --git a/demos/mailwasher.tcl b/demos/mailwasher.tcl index 02e0835..37e4297 100644 --- a/demos/mailwasher.tcl +++ b/demos/mailwasher.tcl @@ -99,8 +99,10 @@ proc DemoMailWasher {} { set delete [expr int(rand() * 2)] set bounce [expr int(rand() * 2)] set attachments [lindex [list styNone styYes] [expr int(rand() * 2)]] - $T item style set $item 0 styCheck 1 styCheck 2 $status 3 styAny \ - 4 styAny 5 styAny 6 styAny 7 $attachments + $T item style set $item delete styCheck bounce styCheck \ + status $status size styAny \ + from styAny subject styAny received styAny \ + attachments $attachments if {$delete} { $T item state forcolumn $item delete CHECK } @@ -111,7 +113,7 @@ proc DemoMailWasher {} { set size [expr {$bytes / 1024 + 1}]KB set seconds [expr {[clock seconds] - int(rand() * 100000)}] set received [clock format $seconds -format "%d/%m/%y %I:%M %p"] - $T item text $item 3 $size 4 $from 5 $subject 6 $received + $T item text $item size $size from $from subject $subject received $received $T item lastchild root $item } } @@ -124,9 +126,9 @@ proc DemoMailWasher {} { } } - set ::SortColumn 6 + set ::SortColumn received $T notify bind $T <Header-invoke> { - if {%C == $SortColumn} { + if {[%T column compare %C == $SortColumn]} { if {[%T column cget $SortColumn -arrow] eq "down"} { set order -increasing set arrow up diff --git a/demos/random.tcl b/demos/random.tcl index e9f1a1f..f7763fd 100644 --- a/demos/random.tcl +++ b/demos/random.tcl @@ -31,6 +31,8 @@ proc DemoRandom {} { $T column create -text Parent -justify center -itembackground {gray90 {}} -tag parent $T column create -text Depth -justify center -itembackground {linen {}} -tag depth + $T configure -treecolumn item + # # Create elements # @@ -79,7 +81,7 @@ proc DemoRandom {} { # set clicks [clock clicks] - set items [$T index root] + set items [$T item id root] for {set i 1} {$i < $::RandomN} {incr i} { set itemi [$T item create] while 1 { @@ -104,13 +106,13 @@ proc DemoRandom {} { set numChildren [$T item numchildren $itemi] if {$numChildren} { $T item configure $itemi -button yes - $T item style set $itemi 0 s1 1 s3 2 s3 + $T item style set $itemi item s1 parent s3 depth s3 $T item complex $itemi \ [list [list e3 -text "Item $i"] [list e4 -text "($numChildren)"]] \ [list [list e6 -text "[$T item parent $itemi]"]] \ [list [list e6 -text "[$T depth $itemi]"]] } else { - $T item style set $itemi 1 s3 2 s3 0 s2 + $T item style set $itemi item s2 parent s3 depth s3 $T item complex $itemi \ [list [list e3 -text "Item $i"]] \ [list [list e6 -text "[$T item parent $itemi]"]] \ @@ -186,7 +188,7 @@ proc TreeCtrl::RandomButton1 {T x y} { set C [lindex $list 0] set S [lindex $list 1] set eList [lrange $list 2 end] - if {$column != [$T column index $C]} continue + if {[$T column compare $column != $C]} continue if {[$T item style set $item $C] ne $S} continue if {[lsearch -exact $eList $E] == -1} continue set ok 1 @@ -270,7 +272,7 @@ proc TreeCtrl::RandomMotion {T x y} { set C [lindex $list 0] set S [lindex $list 1] set eList [lrange $list 2 end] - if {$column != [$T column index $C]} continue + if {[$T column compare $column != $C]} continue if {[$T item style set $item $C] ne $S} continue if {[lsearch -exact $eList $E] == -1} continue set ok 1 @@ -417,7 +419,7 @@ proc RandomDrop {T target source pos} { } # Update the target that gained some children - if {[$T item style set $parent 0] ne "s1"} { + if {[$T item style set $parent item] ne "s1"} { $T item configure $parent -button yes $T item style map $parent item s1 {e3 e3} } |