# This software is distributed under the Lesser General Public License
#
# sample.tcl
#
# The file sample.tcl contains sample code.
#
#------------------------------------------ CVS
#
# CVS Headers -- The following headers are generated by the CVS
# version control system. Note that especially the attribute
# Author is not necessarily the author of the code.
#
# $source: /home/br/CVS/graphlet/src/gt_base/Attributes.h,v $
# $Author: himsolt $
# $Revision: 1.3 $
# $Date: 1999/03/05 20:40:20 $
# $Locker:  $
# $State: Exp $
#
#------------------------------------------ CVS
#
# (C) University of Passau 1995-1999, Graphlet Project
#


package require Graphlet
package provide Graphscript [gt_version]


namespace eval GT {
    namespace export \
	ev_foo_resize_node
}



##########################################
#
# Sample Mode Declaration
#
##########################################

# GT::add_mode Foo {
#     { NODE <ButtonPress-1> GT::ev_foo_resize_node }
#     { NODE <ButtonPress-2> { GT::ev_foo_resize_node smaller } }
# }


proc GT::ev_foo_resize_node { { mode larger} } {

    global GT GT_event

    # Get the editor in which the current event occured
    set editor $GT_event(editor)
    # Retrieve the graph of the current editor
    set graph $GT($editor,graph)

    # Find the node under the cursor
    set node [GT::find_object -node current]

    # If there is a node under the cursor, make it larger or smaller
    if { $node != {} } {

	foreach dimension { w h } {

	    # Get the value
	    set d [$graph get $node -$dimension]

	    # Change the value
	    switch $mode {
		larger {
		    $graph configure $node -$dimension [expr $d*2.0]
		}
		smaller {
		    if { $d > 2.0 } { # enough is enough
			$graph configure $node -$dimension [expr $d/2.0]
		    }
		}
	    }
	}
    }

    # Draw the graph
    $graph draw $node
}



##########################################
#
# Set emacs variables
#
##########################################

# ;;; Local Variables: ***
# ;;; mode: tcl ***
# ;;; End: ***
