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


if {[catch {class X {}}]} {
    puts "This demo requires itcl2.0/itk2.0."
    puts "Install itcl2.0 and then rerun configure and make here..."
    exit
}

# the utility classes in ../library use this namespace
namespace ::util {}; import add util

lappend auto_path ../library 


# This class creates a top level window containing an itk tree widget...

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

    constructor {args} {
	wm title $w_ {Simple [incr Tcl] Tree Demo}
	wm minsize $w_ 10 10 

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

	# add a row of buttons at botton
	pack [ButtonFrame $w_.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
    }


    # 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 {
	    $w_.tree add_node $parent $node \
		    -bitmap @$bitmap_ \
		    -label $node
	}
    }

    
    protected variable bitmap_ "../bitmaps/node.xbm"
}

# Start the application class Rtd:
#
# Note that "start" is a "member" proc in the TopLevelWidget class
# (of which Simple is a subclass). It creates an instance of the Simple 
# class and handles options and error checking.

TopLevelWidget::start Simple

