summaryrefslogtreecommitdiffstats
path: root/demos/span.tcl
diff options
context:
space:
mode:
authortreectrl <treectrl>2006-07-11 00:11:29 (GMT)
committertreectrl <treectrl>2006-07-11 00:11:29 (GMT)
commit5b2a3fc32fbcec70ba19513c091ad00b9bf246bc (patch)
treea522ecdadde368ad05a83dde6bf7debb33bc5641 /demos/span.tcl
parent5731c1a90ae97c63c5e29128439ef8331f346ff7 (diff)
downloadtktreectrl-5b2a3fc32fbcec70ba19513c091ad00b9bf246bc.zip
tktreectrl-5b2a3fc32fbcec70ba19513c091ad00b9bf246bc.tar.gz
tktreectrl-5b2a3fc32fbcec70ba19513c091ad00b9bf246bc.tar.bz2
Add column-span demo.
Diffstat (limited to 'demos/span.tcl')
-rw-r--r--demos/span.tcl68
1 files changed, 68 insertions, 0 deletions
diff --git a/demos/span.tcl b/demos/span.tcl
new file mode 100644
index 0000000..fb9cb07
--- /dev/null
+++ b/demos/span.tcl
@@ -0,0 +1,68 @@
+# RCS: @(#) $Id: span.tcl,v 1.1 2006/07/11 00:11:54 treectrl Exp $
+
+#
+# Demo: Column span
+#
+proc DemoSpan {} {
+
+ set T .f2.f1.t
+
+ #
+ # Configure the treectrl widget
+ #
+
+ $T configure \
+ -showbuttons no \
+ -showlines no \
+ -showroot no \
+ -xscrollincrement 40
+
+ #
+ # Create columns
+ #
+
+ for {set i 0} {$i < 100} {incr i} {
+ $T column create -text "$i" -tag C$i -width 40
+ }
+
+ #
+ # Create elements
+ #
+
+ for {set i 1} {$i <= 20} {incr i} {
+ set color gray[expr {50 + $i * 2}]
+ $T element create e$i rect -width [expr {$i * 40}] -height 20 \
+ -fill $color -outlinewidth 1 -outline gray70
+ $T element create t$i text -text "Span $i"
+ }
+
+ #
+ # Create styles using the elements
+ #
+
+ for {set i 1} {$i <= 20} {incr i} {
+ set S [$T style create s$i]
+ $T style elements $S [list e$i t$i]
+ $T style layout $S e$i -detach yes
+ $T style layout $S t$i -expand ns -padx 2
+ }
+
+ #
+ # Create items and assign styles
+ #
+
+ foreach I [$T item create -count 100 -parent root] {
+ for {set i 0} {$i < [$T column count]} {} {
+ set span [expr {int(rand() * 20) + 1}]
+ if {$span > [$T column count] - $i} {
+ set span [expr {[$T column count] - $i}]
+ }
+ $T item style set $I C$i s$span
+ $T item span $I C$i $span
+ incr i $span
+ }
+ }
+
+ return
+}
+