#!../treesh/treesh -f
#
# simple: a simple script to demonstrate tree widget
#
# This script uses the tcl routines in tree.tcl
# to simplify things.
#
# -----------------------------------------------------------------------------
# Copyright 1993 Allan Brighton.
# 
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies.  Allan
# Brighton make no representations about the suitability of this software
# for any purpose.  It is provided "as is" without express or implied
# warranty.
# -----------------------------------------------------------------------------


# called when the text of a node is double-clicked

proc text_proc {tree} {
    puts "double-clicked on text: [tree_getCurrent $tree]"
}


# called when bitmap of a node is double-clicked

proc bitmap_proc {tree} {
    puts "double-clicked on bitmap: [tree_getCurrent $tree]"
}


lappend auto_path [pwd]
wm title . "Simple Tree"
wm minsize . 10 10 

set canvas [canvas_create . .canvas]
set tree $canvas.tree
tree_create $tree "text_proc $tree" "bitmap_proc $tree"

# add the root node
tree_addNode $tree "" "Root Node" node.xbm

tree_addNode $tree "Root Node" "SubNode 1" node.xbm
tree_addNode $tree "Root Node" "SubNode 2" node.xbm
tree_addNode $tree "Root Node" "SubNode 3" node.xbm

tree_addNode $tree "SubNode 1" "LeafNode 1" node.xbm
tree_addNode $tree "SubNode 1" "LeafNode 2" node.xbm
tree_addNode $tree "SubNode 2" "LeafNode 3" node.xbm
tree_addNode $tree "SubNode 2" "LeafNode 4" node.xbm
tree_addNode $tree "SubNode 2" "LeafNode 5" node.xbm
tree_addNode $tree "SubNode 2" "LeafNode 6" node.xbm
    
$tree draw
tkwait visibility $canvas
tree_center $tree
