#!../tree_wish -f
# -*-Tcl-*-
# This file contains a simple demonstration program for Itcl Tree widget class.
#
# Usage: simple
#
# Author: Allan Brighton (allan@piano.sta.sub.org) 


lappend auto_path ../library 
source ../library/compat.tcl
set_app_defaults


# This is an example of a simple "application" class, i.e.: 
# this program does nothing but create an instance of this class.

itcl_class Simple {
    inherit TopLevelWidget
    
    
    # constructor: create a toplevel window for the demo

    constructor {config} {
	TopLevelWidget::constructor
	
	wm title $this "Tree Demo"
	wm minsize $this 10 10 

	# create an instance of the Itcl "Tree" widget
	# (based on the C++ "tree" widget)
	pack [Tree $this.tree] -fill x -expand 1

	# add a row of buttons at botton
	pack [ButtonFrame $this.b -ok_cmd exit] -side bottom -fill x -expand 1

	# add some nodes to the tree
	add_nodes {} root
	add_nodes root node1 node2 node3 node4
	add_nodes node1 node1.1 node1.2 node1.3
	add_nodes node2 node2.1 node2.2 node2.3
	add_nodes node3 node3.1 node3.2

	$this.tree draw
    }


    # Add one or more subnodes to the given parent node.
    # In this case, the label is just the same as the node's tag

    method add_nodes {parent args} {
	foreach node $args {
	    $this.tree add_node $parent $node \
		    -bitmap @$bitmap \
		    -label $node
	}
    }

    # -- public variables (also program options) -- 
    
    public bitmap "bitmaps/node.xbm"
}


# Start the demo:
# Note that "start" is a "member" proc in the TopLevelWidget class.
# It creates an instance of the above class and handles options and
# error checking.

Simple :: start
