4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
14 # blt::table . .g -resize both
16 # or you can import all the command into the global namespace.
18 # namespace import blt::*
20 # table . .g -resize both
22 # --------------------------------------------------------------------------
23 if { $tcl_version >= 8.0 } {
24 namespace import blt::*
25 namespace import -force blt::tile::*
27 source scripts/demo.tcl
33 image create photo bgTexture -file ./images/rain.gif
36 foreach f [glob ./images/mini-*.gif] {
37 lappend imageList [image create photo -file $f]
40 #option add *Hiertable.Tile bgTexture
41 option add *Hiertable.ScrollTile yes
42 #option add *Hiertable.Column.background grey90
43 option add *Hiertable.titleShadow { grey80 }
44 option add *Hiertable.titleFont {*-helvetica-bold-r-*-*-11-*-*-*-*-*-*-*}
46 hiertable .h -width 0\
47 -yscrollcommand { .vs set } \
48 -xscrollcommand { .hs set } \
49 -selectmode multiple \
52 #.h configure -icons "" -activeicons ""
54 .h column configure treeView -text "View"
55 .h column insert 0 mtime atime gid
56 .h column insert end nlink mode type ctime uid ino size dev
57 .h column configure uid -background \#eaeaff -style text
58 .h column configure mtime -hide no -bg \#ffeaea -style text
59 .h column configure size gid nlink uid ino dev -justify right -style text
60 .h column configure treeView -hide no -edit no -style text
62 scrollbar .vs -orient vertical -command { .h yview }
63 scrollbar .hs -orient horizontal -command { .h xview }
69 proc FormatSize { size } {
72 set rem [expr $size % 1000]
73 set size [expr $size / 1000]
75 set rem [format "%03d" $rem]
77 if { $string != "" } {
78 set string "$rem,$string"
97 proc FormatMode { mode } {
100 set mode [format %o [expr $mode & 07777]]
101 set owner $modes([string index $mode 0])
102 set group $modes([string index $mode 1])
103 set world $modes([string index $mode 2])
105 return "${owner}${group}${world}"
108 table configure . c1 r1 -resize none
109 image create photo fileImage -file images/stopsign.gif
111 proc DoFind { dir parent } {
116 foreach f [lsort [glob -nocomplain *]] {
117 set node [tree0 insert $parent -label $f]
118 if { [catch { file stat $f info }] == 0 } {
120 if { $info(type) == "file" } {
121 set info(type) @fileImage
126 set info(mtime) [clock format $info(mtime) -format "%b %d, %Y"]
127 set info(atime) [clock format $info(atime) -format "%b %d, %Y"]
128 set info(ctime) [clock format $info(ctime) -format "%b %d, %Y"]
129 set info(size) [FormatSize $info(size)]
130 set info(mode) [FormatMode $info(mode)]
131 eval tree0 set $node [array get info]
134 if { [file isdirectory $f] } {
144 catch { file stat $dir info }
147 tree0 label root [file tail $dir]
148 eval tree0 set root [array get info]
150 puts "$count entries"
153 proc GetAbsolutePath { dir } {
161 set top [GetAbsolutePath ..]
166 .h configure -tree tree0 -separator /
168 set nodes [.h find -glob -name *.c]
169 eval .h entry configure $nodes -foreground green4
170 set nodes [.h find -glob -name *.h]
171 eval .h entry configure $nodes -foreground cyan4
172 set nodes [.h find -glob -name *.o]
173 eval .h entry configure $nodes -foreground red4
177 .h column bind all <ButtonRelease-3> {
178 %W configure -flat no
181 proc SortColumn { column } {
182 set old [.h sort cget -column]
184 if { "$old" == "$column" } {
185 set decreasing [.h sort cget -decreasing]
186 set decreasing [expr !$decreasing]
188 .h sort configure -decreasing $decreasing -column $column
189 .h configure -flat yes
196 foreach column [.h column names] {
197 .h column configure $column -command [list SortColumn $column]