#f teabout.tcl - procedures for dealing with rich text
# 
# Copyright 1992-1994 by Jay Sekora.  All rights reserved, except 
# that this file may be freely redistributed in whole or in part 
# for non­profit, noncommercial use.
# 
# 
# these procedures are required by
#     help.tk
#     edit.tk
#     browser.tk
#     people.tk
# they may be located in the file "~/.tk/jabout.tcl" (where they will
# be source'd by those applications on startup), or in the site-wide
# tk library directory, where they will be found (and loaded) by the
# default tk  unknown  procedure.
#
# IMPORTANT: the procedures in jabout.tcl also rely on procedures in
#   jlibrary.tcl and jrichtext.tcl
# 

package provide stead 2.0


# te:about name richtext - create an about box containing richtext
# te:about:button aboutbox label richtext - add a button to an about box
# te:about_jay - return richtext describing me
# te:about_tktcl - return richtext describing Tk and Tcl

## te:about name richtext - create an about box containing richtext
# 
proc te:about { name args } {

    Parsarg_fullSpec opt {
        title About
    }
    set w $name  
    set richtext [lindex $args 0]
    
    set old_focus [focus]         ;# so we can restore original focus
    
    if [winfo exists $w] {destroy $w}
    toplevel $w
    wm title $w $opt(-title)
    
    text $w.t -width 75 -height 45 -bd 2
    te:rt text $w.t
    eval $richtext
    te:rt:done
    
    frame $w.b
    button $w.b.ok -text OK -width 8 -command "
      focus $old_focus
      destroy $w
    "
    frame $w.b.ok-border -relief sunken -borderwidth 1
    raise $w.b.ok
    pack $w.b.ok -in $w.b.ok-border -padx 2 -pady 2
  
    pack append $w.b \
          [xtk_filler $w.b] {left} \
          [xtk_filler $w.b] {right}
      
    pack $w.b.ok-border -side right -pady 10
    pack $w.t -in $w -side top -fill both
    pack [xtk_rule $w -width 200] -in $w -side top -fill x
    pack $w.b -in $w -side top -fill x
    
    xtk_placeWindow $w
  
    focus $w
    bind $w <Key-Return> "$w.b.ok invoke"
    bind $w.t <Key-Return> "$w.b.ok invoke"
}

## te:about:button aboutbox label richtext - add a button to an about box
# 
proc te:about:button { aboutbox label richtext } {
    global te:about:button:count
        if {[info exists te:about:button:count]} then {
        set te:about:button:count [expr {${te:about:button:count} + 1}]
    } else {
        set te:about:button:count 0
    }
  
    set parent $aboutbox.b        ;# name of frame with buttons
    set button $parent.${te:about:button:count}
    set border $button-border
  
    set min_width [expr {[string length $label] + 2}]
    set width [expr {$min_width > 8 ? $min_width : 8}]
    
    button $button -text $label -width $width \
      -command "te:rt text $aboutbox.t; $richtext; te:rt:done"
    frame $border
    raise $button
    pack $button -in $border -padx 2 -pady 2
    pack [xtk_filler $parent] $border -in $parent -side right
}
  
  

## te:about_jay - talk about myself
# 
proc te:about_jay {} {
  return {
    te:rt:hl "Jay Sekora"
    te:rt:cr
    te:rt:tt "js@it.bu.edu"
    te:rt:cr
    te:rt:tt "http://www.bu.edu/DSG/js/home.html"
    te:rt:par
    te:rt:rm "I'm a Unix systems administrator at Boston University."
    te:rt:par
    te:rt:rm "I was a linguistics major in college.  "
    te:rt:rm "I like spicy food, Celtic folk music, bad puns, New England "
    te:rt:rm "contra dancing, and "
    te:rt:it "Winnie the Pooh."
  }
}

## te:about_tktcl - describe tk and tcl
# 
proc te:about_tktcl {} {
  return {
    te:rt:hl "Tk and Tcl"
    te:rt:par
    te:rt:rm "This application is written in "
    te:rt:tt "wish"
    te:rt:rm ", a scripting shell for X Windows applications based on the "
    te:rt:rm "Tk toolkit, which in turn is based on the Tcl"
    te:rt:rm " language and scripting library, all amazingly useful tools "
    te:rt:rm "by John Ousterhout of Berkeley."
    te:rt:par
    te:rt:rm "The Internet newsgroup "
    te:rt:tt "comp.lang.tcl"
    te:rt:rm " is devoted to Tcl and related tools, and a Tk/Tcl FAQ "
    te:rt:rm "(`Frequently Asked Questions') is periodically posted.  "
    te:rt:rm "The latest distributions are available on the FTP site "
    te:rt:tt "ftp.cs.berkeley.edu"
    te:rt:rm ", and "
    te:rt:tt "harbor.ecn.purdue.edu"
    te:rt:rm " has the FAQ and user\255contributed scripts."
  }
}
# ./
