
# 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

if [info exists tk_version] {
    if {[info exists gray_background] || \
	    [info exists env(ICEM_GRAY_BACKGROUND)]} {
	
	if [info exists env(ICEM_BACKGROUND_COLOR)] {
	    option add *background $env(ICEM_BACKGROUND_COLOR)
	} else {
	    option add *background #d9d9d9
	}
	option add *foreground black
	foreach t {Entry Listbox Text} {
	    option add *$t.background white
	}
	foreach t {Entry Listbox Text Label Menubutton Menu Checkbutton Radiobutton} {
	    option add *$t.foreground black
	}
	option add *selectBackground cyan
	option add *selectForeground black
	
	foreach t {Checkbutton Radiobutton} {
	    option add *$t.padX 0
	    option add *$t.padY 0
#	    option add *$t.borderWidth 0
	    option add *$t.highlightThickness 0
#	    option add *$t.selectColor white
	}
	foreach t {Button Menubutton} {
	    option add *$t.padX 0
	    option add *$t.padY 0
#	    option add *$t.borderWidth 2
#	    option add *$t.relief raised
	    option add *$t.highlightThickness 0
	}
	
#	foreach ev [bind all] { bind all $ev "" }
	
	# This modifies the standard bindings.
	bind Entry <Double-1> [bind Entry <Triple-1>]
	
	bind Menu <ButtonPress-3> "tkMenuGetRidOf %W"
	
    } elseif {!$is_win || ($tk_version < 8.0)} {
	if {![info exists black_and_white] || !$black_and_white} {
	    if ![info exists dont_reset_background] {
		catch {tk_bisque}
		option add *background #ffe4c4
		option add *Button.background #eed5b7
		option add *Button.activeBackground #ddc6a9
		option add *Menubutton.background #eed5b7
		option add *Menubutton.activeBackground #ddc6a9
		option add *selectBackground cyan
	    }
	    option add *foreground black
	}
	
	option add *Checkbutton.relief flat
	option add *Radiobutton.relief flat
	option add *Checkbutton.borderwidth 0
	option add *Radiobutton.borderwidth 0
	option add *highlightThickness 0
	option add *Entry.background white
	option add *Listbox.background white
	option add *selectForeground black
	if {[info exists small_screen_hack] && $small_screen_hack} {
	    option add *Entry.relief flat
	    option add *Entry.borderwidth 0
	    option add *Menubutton.relief flat
	    option add *Menubutton.borderwidth 0
	} else {
	    option add *Entry.relief sunken
	    option add *Entry.borderwidth 2
	}
	foreach t {Button Checkbutton Radiobutton Menubutton} {
	    if {[info exists small_screen_hack] && $small_screen_hack} {
		option add *$t.padX -1
		option add *$t.padY -1
	    } else {
		option add *$t.padX 1
		option add *$t.padY 1
	    }
	}
#	foreach ev [bind all] { bind all $ev "" }
	
	# This modifies the standard bindings.
	bind Entry <Double-1> [bind Entry <Triple-1>]
	
	bind Menu <ButtonPress-3> "tkMenuGetRidOf %W"
    } else {
	# This is for windows .......
	if {![info exists black_and_white] || !$black_and_white} {
	    if ![info exists dont_reset_background] {
		# This is a subset of tk_bisque
		option add *background #ffe4c4
		option add *activeBackground #e6ceb1
		option add *disabledForeground #b0b0b0
		option add *foreground black
		option add *troughColor #cdb79e
		option add *selectBackground cyan
		option add *selectForeground black
	    }
	}
	option add *Entry.background white
	option add *Listbox.background white
	option add *Text.background white
	
	foreach t {Checkbutton Radiobutton} {
	    option add *$t.padX 0
	    option add *$t.padY 0
	    option add *$t.borderWidth 0
	    option add *$t.highlightThickness 0
	    option add *$t.selectColor white
	}
	foreach t {Button Menubutton} {
	    option add *$t.padX 0
	    option add *$t.padY 0
	    option add *$t.borderWidth 2
	    option add *$t.relief raised
	    option add *$t.highlightThickness 0
	}
	option add *Menu.activeForeground black

#	foreach ev [bind all] { bind all $ev "" }
	
	# This modifies the standard bindings.
	bind Entry <Double-1> [bind Entry <Triple-1>]
	
	bind Menu <ButtonPress-3> "tkMenuGetRidOf %W"
    }
}

proc tkMenuGetRidOf {w} {
    if {[$w cget -type] == "tearoff"} {
	top_destroy $w
    } else {
	tkMenuEscape $w
    }
}
