Eskil

Check-in [1cdf7d5e95]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Documented tablelist transition
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | table-list
Files: files | file ages | folders
SHA1: 1cdf7d5e957b9ac29c65f78338641a7be883e164
User & Date: peter.spjuth@gmail.com 2011-05-08 22:49:08.000
Context
2011-05-09
00:08
Minor correction to clear syntax warning. check-in: ddfc1ceec8 user: peter.spjuth@gmail.com tags: trunk
2011-05-08
22:49
Documented tablelist transition Closed-Leaf check-in: 1cdf7d5e95 user: peter.spjuth@gmail.com tags: table-list
2011-05-07
00:37
Handle links in directory diff. Changed buttons to use images in directory diff. check-in: eb61cb3ca6 user: peter.spjuth@gmail.com tags: table-list
Changes
Unified Diff Ignore Whitespace Patch
Added examples/dir1/link.


>
1
casechange
Added examples/dir2/link.


>
1
casechange
Added tablelist.txt.










































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Some notes about transitioning code from ttk::treeview to tablelist.
O: is old code with treeview.
N: is new code with tablelist.
N2: transforms hidden columns into row attributes

N: Using tablelist
package require tablelist_tile

O: Creation
ttk::treeview $win.tree -height 20 \
        -columns {type status leftfull leftname leftsize leftdate rightfull rightname rightsize rightdate} \
        -displaycolumns {leftsize leftdate rightsize rightdate}
N: Creation
tablelist::tablelist $win.tree -height 20 \
        -movablecolumns no -setgrid no -showseparators yes \
        -columns {0 "Structure" 0 "" 0 "" 0 "" 0 Name 0 Size 0 Date 0 "" 0 Name 0 Size 0 Date}
N2: Only visible columns kept
tablelist::tablelist $win.tree -height 20 \
        -movablecolumns no -setgrid no -showseparators yes \
        -columns {0 "Structure" 0 Name 0 Size 0 Date 0 Name 0 Size 0 Date}

O: Scroll
$tree configure -yscroll "$vsb set" -xscroll "$hsb set"
N: Scroll
$tree configure -yscrollcommand "$vsb set" -xscrollcommand "$hsb set"

O: treeview's heading is set in -columns in tablelist
$tree heading \#0 -text "Structure"
$tree heading leftname -text "Name"
$tree column leftsize  -stretch 0 -width 70 -anchor e
N: tablelist gives logical names to columns like this
$tree columnconfigure 0 -name structure
$tree columnconfigure 1 -name type -hide 1
$tree columnconfigure 4 -name leftname -hide 1
$tree columnconfigure 5 -name leftsize -align right
N2: No hidden columns
$tree columnconfigure 1 -name leftname -hide 0

O: Bindings
bind $tree <Button-3> "[mymethod ContextMenu] %x %y %X %Y"
bind $tree <Double-ButtonPress-1> "[mymethod DoubleClick] %x %y"
bind $tree <Key-Return> [mymethod KeyReturn]
N:
set bodyTag [$tree bodytag]
bind $bodyTag <<Button3>>  [bind TablelistBody <Button-1>]
bind $bodyTag <<Button3>> +[bind TablelistBody <ButtonRelease-1>]
bind $bodyTag <<Button3>> "+[mymethod ContextMenu] %W %x %y %X %Y"
bind $bodyTag <Double-1>   "[mymethod DoubleClick] %W %x %y"
bind $bodyTag <Key-Return> [mymethod KeyReturn]

O: Clear tree
$tree delete [$tree children {}]
N:
$tree delete 0 end

O: Configure/Create root node
$tree set {} type directory
N:
set topIndex [$tree insertchild root end {}]
$tree cellconfigure $topIndex,type -text directory

O: Node's Children
set todo [$tree children {}]
lappend todo {*}[$tree children $node]
N:
set todo [$tree childkeys root]
lappend todo {*}[$tree childkeys $node]
  
O: Getting cell info
set status [$tree set $node status]
N:
set status [$tree cellcget $node,status -text]
N2: Hidden is now row attribute
set status [$tree rowattrib $node status]

O:
A loop to open/collapse all
N:
$tree expandall
$tree collapseall

O: Handle coords in a binding
method DoubleClick {x y} {
    set node [$tree identify row $x $y]
    set col [$tree identify column $x $y]
    set colname [$tree column $col -id]
}
N:
method DoubleClick {W x y} {
    foreach {W x y} [tablelist::convEventFields $W $x $y] break
    set node [$tree index @$x,$y]
    set col [$tree columnindex @$x,$y]
    set colname [$tree columncget $col -name]
}

O: Identifying tree column
if {$col eq "#0"} 
N:
if {$colname eq "structure"}

O: Set cell valuex
$tree set $node status $status
N:
$tree cellconfigure $node,status -text $status
N2:
$tree rowattrib $node status $status

O: Set row property
$tree item $node -tags $status
N:
$tree rowconfigure $node -foreground $color($status) \
        -selectforeground $color($status)

O: Get parent, identify root
set parent [$tree parent $node]
if {$parent eq ""} { return }
N:
set parent [$tree parentkey $node]
if {$parent eq "" || $parent eq "root"} { return }

O: Creating node
set id [$tree insert $node end -text $name \
        -values $values]
N: For tablelist $name is part of $values
set id [$tree insertchild $node end $values]
N2: Also fill in rowattribs
$tree rowattrib $id type $type
$tree rowattrib $id status unknown

O: Tree column name is a row attribute in treeview
$tree item $id -text $name/
N:
$tree cellconfigure $id,structure -text $name/