Debian Codegraph @

demos/hierbox2.tcl

raw
1 #!../src/bltwish
2
3 package require BLT
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.
9 #
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::"
12 #
13 # blt::graph .g
14 # blt::table . .g -resize both
15 #
16 # or you can import all the command into the global namespace.
17 #
18 # namespace import blt::*
19 # graph .g
20 # table . .g -resize both
21 #
22 # --------------------------------------------------------------------------
23 if { $tcl_version >= 8.0 } {
24 namespace import blt::*
25 namespace import -force blt::tile::*
26 }
27 source scripts/demo.tcl
28
29 proc AddDirEntries { w dir } {
30 if { [file isdirectory $dir] } {
31 set files [glob -nocomplain $dir/*]
32 eval $w insert end [lsort $files]
33 set subdirs [glob -nocomplain $dir/*/]
34 eval $w entry configure [lsort $subdirs] -button yes
35 }
36 }
37
38 set imageList {}
39 foreach f [glob ./images/mini-*.gif] {
40 lappend imageList [image create photo -file $f]
41 }
42
43 set top ../
44
45 #option add *Hierbox.Tile bgTexture
46 option add *Hierbox.TileOffset yes
47
48 option add *forceGadgets no
49 option add *Hierbox.openCommand {
50 AddDirEntries %W "$top/%P"
51 }
52 option add *Hierbox.closeCommand {
53 eval %W delete %n 0 end
54 }
55
56 #image create photo openFolder -file images/open.gif
57 #image create photo closeFolder -file images/close.gif
58 #image create photo openFolder -file images/folder_blue_open.gif
59 #image create photo closeFolder -file images/folder_blue.gif
60
61 #option add *Hierbox.icons "closeFolder openFolder"
62 #option add *Hierbox.activeIcon ""
63
64 #option add *Hierbox.Button.activeForeground red
65 #option add *Hierbox.bindTags "Label all"
66
67 hierbox .h \
68 -selectmode multiple \
69 -hideroot yes \
70 -yscrollcommand { .vs set } \
71 -xscrollcommand { .hs set }
72
73 .h button configure -activebackground grey92
74 scrollbar .vs -orient vertical -command { .h yview }
75 scrollbar .hs -orient horizontal -command { .h xview }
76 button .test -text Test -command {
77 set index [.h curselection]
78 set names [eval .h get -full $index]
79 puts "selected names are $names"
80 }
81
82 button .quit -text Quit -command { exit 0 }
83
84 table . \
85 0,0 .h -fill both \
86 2,0 .quit \
87 0,1 .vs -fill y 1,0 .hs -fill x \
88 3,0 .test
89
90 table configure . c1 r1 r2 r3 -resize none
91
92 .h configure -separator "/" -trim $top \
93 -allowduplicates no
94
95 #.h entry configure 0 -label [file tail $top]
96
97 AddDirEntries .h $top
98 focus .h
99 set nodes [.h find -glob -name *.c]
100 eval .h entry configure $nodes -labelcolor red
101
102 wm protocol . WM_DELETE_WINDOW { destroy . }
103 #blt::bltdebug 100