
# JStrack:  copyright 1997/2010 by Jim Graham, N5IAL, all rights reserved.
#

# This file contains the Tk procedure to print out the Saffir-Simpson
# scale in both chart format and in a detailed listing of damage expected
# from each category of storm.

proc tk_sschart {} {
   global text_font pmw color
   toplevel .ssct
   set x [expr {[winfo rootx $pmw] + [winfo width $pmw]}]
   set y [expr {[winfo rooty $pmw] + [winfo height $pmw] + 60}]
   wm geometry .ssct +$x+$y
   wm title .ssct "Saffir-Simpson Scale"
   wm attributes .ssct -topmost true

   set w .ssct.text
   text $w -width 63 -height 18 -font $text_font \
      -foreground $color(dwinfg) -background $color(dwinbg) -spacing3 1.2
   pack $w -side top
   $w insert end [saff_chart]
   $w insert end "
      Use the buttons below for a more detailed description
      of the typical damage caused.
"
   $w configure -state disabled

   set w .ssct.fr
   frame $w
   pack $w -side top

   for {set i 1} {$i <= 5} {incr i} {
      button $w.cat$i -text "Cat $i" -command "tk_show_damage_cat $i $x $y"
      pack $w.cat$i -side left
   }
   button $w.refs -text "References" -command "tk_show_refs $x $y"
   pack $w.refs -side left
   button $w.done -text "Dismiss" -command { destroy .ssct }
   pack $w.done -side left
}


proc tk_show_refs {x y} {
   global text_font color

   catch {destroy .ssctref}
   toplevel .ssctref
   set x [expr {$x + 35}]
   set y [expr {$y + 35}]
   wm geometry .ssctref +$x+$y
   wm title .ssctref "Saffir-Simpson Scale (References)"
   wm attributes .ssctref -topmost true

   set w .ssctref.text
   text $w -width 72 -height 10 -font $text_font \
         -foreground $color(dwinfg) -background $color(dwinbg) -spacing3 1.2
   pack $w -side top
   $w insert end [ss_refs]
   $w configure -state disabled

   button .ssctref.done -text "Dismiss" -command { destroy .ssctref }
   pack .ssctref.done -side top
}


proc tk_show_damage_cat {cat x y} {
   global text_font color

   if {$cat == 1} {       set lines 10
   } elseif {$cat == 2} { set lines 15
   } elseif {$cat == 3} { set lines 17
   } elseif {$cat == 4} { set lines 16
   } elseif {$cat == 5} { set lines 17
   }

   catch {destroy .ssctdamage}
   toplevel .ssctdamage
   set x [expr {$x + 35}]
   set y [expr {$y + 35}]
   wm geometry .ssctdamage +$x+$y
   wm attributes .ssctdamage -topmost true
   wm title .ssctdamage "Saffir-Simpson Scale (Typical Damage for Cat $cat)"

   set w .ssctdamage.text
   text $w -width 72 -height $lines -font $text_font \
         -foreground $color(dwinfg) -background $color(dwinbg) -spacing3 1.2
   pack $w -side top

   $w insert end "Information in this description quoted from the ``Hurricanes,
Typhoons, Tropical Cyclones FAQ'' by Dr. Chris Landsea
"
   $w insert end [ss_damage $cat]
   $w configure -state disabled

   button .ssctdamage.done -text "Dismiss" -command { destroy .ssctdamage }
   pack .ssctdamage.done -side top
}

