# This software is distributed under the Lesser General Public License
#
# inspector/justify_ctl.tcl
#
# Control for selecting justify
#
#------------------------------------------ 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/lib/graphscript/inspector/justify_ctl.tcl,v $
# $Author: forster $
# $Revision: 1.2 $
# $Date: 1999/02/09 14:44:06 $
# $Locker:  $
# $State: Exp $
#
#------------------------------------------ CVS
#
# (C) University of Passau 1995-1999, Graphlet Project
#     Author: Michael Forster

package require Graphlet
package provide Graphscript [gt_version]

package require Flatbutton

namespace eval ::GT::IS::justify_ctl {

    namespace export create
    namespace import ::GT::IS::define_attrs
    namespace import ::GT::IS::bind_attrs

    proc create { IS ctl attrs } {
	define_attrs $IS $ctl $attrs { justify }

	# creation
	
	frame $ctl

	foreach value { left center right } {
	    
	    set but [Flatbutton::create $ctl.$value \
			 -image [GT::get_image inspector/justify/$value] \
			 -command [namespace code "ev_changed $IS $ctl $value"] \
			]	
	    
	    GT::tooltips $but "Justify: $value"
	}

	# layout

	global tcl_platform
	if { $tcl_platform(platform) == "windows" } {
	    
	    grid $ctl.left $ctl.center $ctl.right \
		-padx 1 -pady 1
	    
	} else {
	    grid $ctl.left $ctl.center $ctl.right
	}

	# events

	return $ctl
    }

    proc update { IS ctl } {
	variable ::GT::IS::_HaveNodes
	variable ::GT::IS::_HaveEdges
	bind_attrs $IS $ctl

	foreach j { left center right } {
	    if { $justify == $j } {
		$ctl.$j select
	    } else {
		$ctl.$j deselect
	    }
	}

	foreach widget { left center right } {
	    if { $_HaveNodes($IS) || $_HaveEdges($IS) } {
		$ctl.$widget configure -state normal
	    } else {
		$ctl.$widget configure -state disabled
		$ctl.$widget deselect
	    }
	}
    }

    proc ev_changed { IS ctl value } {
	bind_attrs $IS $ctl

	set justify $value
	
	update $IS $ctl
    }
}

#---------------------------------------------------------------------------
#   Set emacs variables
#---------------------------------------------------------------------------
# ;;; Local Variables: ***
# ;;; mode: tcl ***
# ;;; tcl-indent-level: 4 ***
# ;;; End: ***
#---------------------------------------------------------------------------
#   end of file
#---------------------------------------------------------------------------
