# This software is distributed under the Lesser General Public License
#
# inspector/stipple_ctl.tcl
#
# Control for selecting stipple
#
#------------------------------------------ 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/stipple_ctl.tcl,v $
# $Author: forster $
# $Revision: 1.2 $
# $Date: 1999/02/09 14:44:08 $
# $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::stipple_ctl {

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

    image create bitmap inspector/stipple/gray100 -data {
	\#define _width 16
	\#define _height 16
	static unsigned char _bits[] = {
	    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
	    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
	    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
	    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
	};
    }
    
    proc create { IS ctl attrs } {
	define_attrs $IS $ctl $attrs { stipple }

	# creation
	
	frame $ctl

	foreach value { 100 75 50 25 12 } {

	    set but [Flatbutton::create $ctl.gray$value \
			 -command [namespace code "ev_changed $IS $ctl $value"] \
			]	
	    
	    if { $value == 100 } {
		$but configure -image inspector/stipple/gray100
	    } else {
		$but configure -bitmap gray$value
	    }

	    GT::tooltips $but "$value%"
	}

	# layout

	grid $ctl.gray100 $ctl.gray75 $ctl.gray50 $ctl.gray25 $ctl.gray12

	global tcl_platform
	if { $tcl_platform(platform) == "windows" } {
	    eval grid [grid slaves $ctl] \
		-padx 1 -pady 1
	}

	# events

	return $ctl
    }

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

	foreach j { gray12 gray25 gray50 gray75 gray100 } {
	    if { $stipple == $j } {
		$ctl.$j select
	    } else {
		$ctl.$j deselect
	    }
	}

	foreach widget {
	    gray12 gray25 gray50 gray75 gray100
	} {
	    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 stipple gray$value
	
	update $IS $ctl
    }
}

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