
# This code is shared by all the ICEM CFD GUI's.
#
# Copyright (c) 1993 - 1995 Pacific Marketing and Consulting, Inc,
#       and ICEM Systems, GmbH.  All rights reserved.
# Author:  Wayne A. Christopher, wayne@icemcfd.com

# but is the name of the button
# var is the name of the color
# deflab is the string which, if the value of var is "none", gets put
#	on the button -- if it is never none then this can be ""
# what is the message that gets printed on top of the array of buttons
# after is the command that gets executed when a color is selected
# geo is the geometry
# act is the active spec
# one_row put everything in one row

proc futil_colorentry {w var tabgeo {act ""} {otheropt ""} {otheroptvar ""}
		       {after_set ""} { one_row 0 } } {
    catch {
	form_frame $w flat 0 $tabgeo
	if {$otheropt != ""} {
	    form_radiobutton $w.def $otheropt $otheroptvar 1 {0 0}
	    if { $one_row } {
		set tabdata "0 1"
	    } else {
		set tabdata "1 0"
	    }
	    form_radiobutton $w.sel "selected" $otheroptvar 0 $tabdata
	    lappend act [list $otheroptvar 0]
	}
	SelectColor $w.col -type menubutton -variable $var \
	    -command $after_set
	$w.col configure -width 16 -height 16
	if $one_row {
	    set tabdata "0 2"
	} else {
	    set tabdata "1 1"
	}
	form_dotab $w.col $tabdata news
	if {$act != ""} { form_doactive $w.col colorbutton $act }
	return $w.col
    }
    return ""
}


proc form_colorbutton_setstate {w on} {
    if $on {
	set var [$w cget -variable]
	upvar \#0 $var lvar
	::$w:cmd configure -background $lvar -relief raised
    } else {
	::$w:cmd configure -background [[winfo parent $w] cget -background] \
	    -relief flat
    }
}

proc edit_one_color {message default {allow_names 1} {otheropts ""}} {
    # this should be removed -type dialog
    set col [SelectColor .select_color \
		 -color $default -title $message]
    if {$col != ""} {
	return $col
    } else {
	return $default
    }
}
