Debian Codegraph @

demos/hierbox4.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] -gadget yes
35 }
36 }
37
38 #blt::bltdebug 100
39
40 image create photo openFolder -file images/open.gif
41 image create photo closeFolder -file images/close.gif
42
43 option add *Hierbox.icons "closeFolder openFolder"
44
45 option add *Hierbox.cursor crosshair
46 option add *Hierbox.Button.Relief solid
47 option add *Hierbox.Button.ActiveBackground white
48 option add *Hierbox.Button.Background white
49
50 hierbox .h \
51 -yscrollcommand { .vs set } \
52 -xscrollcommand { .hs set } \
53 -activebackground lightskyblue1 \
54 -selectbackground lightskyblue2
55
56 scrollbar .vs -orient vertical -command { .h yview }
57 scrollbar .hs -orient horizontal -command { .h xview }
58 button .test -text Test -command {
59 set index [.h curselection]
60 set names [eval .h get -full $index]
61 puts "selected names are $names"
62 }
63
64 table . \
65 0,0 .h -fill both \
66 0,1 .vs -fill y \
67 1,0 .hs -fill x \
68 2,0 .test
69
70 table configure . c1 r1 -resize none
71
72 .h configure -autocreate yes -font { Helvetica 34 }
73 focus .h
74 .h insert end { The Quick Brown Fox Jumped Over the }
75 .h entry configure root -label {[Root]}
76 .h insert end { The\nQuick\nBrown\nFox\nJumped\nOver\nthe }
77
78 .h configure -focusedit yes