
# 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

# Figure out what fonts to use.

# What can be smallscreen, mediumscreen, largescreen

proc compute_sizes {{what ""} {add 1}} {
    global bigfont normalfont smallfont big_dot_size italicfont nonboldfont
    global scr_width scr_height tcl_platform boldfont
    global fixedfont fixedboldfont fixednonboldfont
    global small_screen_hack is_win env whatsize default_font_weight
    
    if ![info exists default_font_weight] { set default_font_weight bold }
    
    set width [winfo screenwidth .]
    set height [winfo screenheight .]
    
    if ![info exists scr_width] {
	set scr_width [expr {$width - 200}]
    }
    if ![info exists scr_height] {
	set scr_height [expr {$height - 200}]
    }
    
    if {[info exists env(LANG)] && ($env(LANG) == "JP")} {
	if $is_win {
	    set family k16
	    set family_f k16
	    set family_fixed k16
	} else {
	    set family k16
	    set family_f k16
	    set family_fixed k16
	}
    } else {
	if $is_win {
	    set family "MS Sans Serif"
	    set family_f "MS Sans Serif"
	    set family_fixed "Courier"
	} else {
	    set family helvetica
	    set family_f helvetica
	    set family_fixed courier
	}
    }

    if {$what == ""} {
	if {($width < 850) || ($height < 700)} {
	    set what smallscreen
	    
	} elseif {($width < 1200) || ($height < 1000)} {
	    set what mediumscreen
	    
	} else {
	    set what largescreen
	}
    }
    
    set whatsize $what
    set iweight italic
    set nweight normal
    set bweight bold
    
    switch $what {
	smallscreen {
	    set bigsize 9
	    set normalsize 9
	    set smallsize 7
	    set fixedsize 9
	    set big_dot_size 3
	    set small_screen_hack 1
	    set weight normal
	}
	mediumscreen {
	    set bigsize 16
	    set normalsize 10
	    set smallsize 8
	    set fixedsize 13
	    set big_dot_size 4
	    set small_screen_hack 0
	    set weight $default_font_weight
	}
	mediumlargescreen {
	    set bigsize 18
	    set normalsize 12
	    set smallsize 10
	    set fixedsize 14
	    set big_dot_size 5
	    set small_screen_hack 0
	    set weight $default_font_weight
	}
	largescreen {
	    set bigsize 20
	    set normalsize 14
	    set smallsize 12
	    set fixedsize 15
	    set big_dot_size 6
	    set small_screen_hack 0
	    set weight $default_font_weight
	}
	verylargescreen {
	    set bigsize 28
	    set normalsize 20
	    set smallsize 16
	    set fixedsize 20
	    set big_dot_size 10
	    set small_screen_hack 0
	    set weight $default_font_weight
	}
    }
    
    set bigfont [list $family -$bigsize $weight]
    set normalfont [list $family -$normalsize $weight]
    set smallfont [list $family -$smallsize $weight]
    set italicfont [list $family -$normalsize $iweight]
    set nonboldfont [list $family -$normalsize $nweight]
    set boldfont [list $family -$normalsize $bweight]
    set fixedfont [list $family_f -$fixedsize $weight]
    set fixedboldfont [list $family_fixed -$fixedsize $nweight]
    set fixednonboldfont [list $family_fixed -$fixedsize $nweight]
    if $add { option add *font $normalfont }

    if !$is_win {
        if {[lsearch [lsort [font families -displayof .]] "helvetica"] < 0} {
            puts "Missing font family helvetica"
        }
    }
}
