
	This is a (for lack of a better name) hypertext widget.

	This widget combines text and other Tk widgets in the same window. 
It is sort of a cross between a read-only text widget and the pack command.  
Any widget can be attached to the hypertext window by the %% 
label $this.lab -text "append " -relief sunken \
	-font *-Courier-Bold-R-Normal-*-120-*
$this append $this.lab 
%% command.
For example, 
%% message $this.msg -relief sunken -bd 2 -font \
 *-Courier-Medium-R-Normal-*-120-* -text { 
global tk_library
label $this.face \ 
  -bitmap @bitmaps/face \ 
  -relief sunken -borderwidth 2
$this append $this.face \ 
	-padx 2 -pady 0.25i 
}
$this append $this.msg -width 3.5i -height 1.25i %% added this %%
global tk_library
label $this.face \
	-bitmap @$tk_library/demos/bitmaps/face  \
	-relief sunken -borderwidth 2
$this append $this.face -padx 2 -pady 0.25i
%%.
	There can be many types of widgets in the same document.  For example,
this is a simple %% 
button $this.but -bg pink -text { button } \
	-command { puts stderr { a stupid message } } 
$this append $this.but
%%. If you click on the button, it prints a stupid message. 
All the standard Tk widgets are available, including %%
checkbutton $this.ckbut -bg lightblue -text { check buttons } \
	-command { puts stderr { check button pressed } } 
$this append $this.ckbut
%%, %%
radiobutton $this.rdbut -bg mediumseagreen -text { radio buttons } \
	-command { puts stderr { radio button pressed } } 
$this append $this.rdbut
%%, 
and scales %%
scale $this.sc -showvalue true \
	-length 100 \
        -sliderforeground powderblue \
	-sliderlength 10 \
 	-orient horizontal  
$this append $this.sc
%%.  

	Widget trees can be also be included. The following example is 
*borrowed* from the widget demo. It is a couple of frames surrounding a 
listbox, a message, and a button widget. 
%%
    set w $this.frame 
    frame $w 
    message $w.msg -font *times-medium-r-normal--*-120* -aspect 300 \
            -text "A listbox containing the 50 states is displayed below, along with a scrollbar.  You can scan the list either using the scrollbar or by dragging in the listbox window with button 3 pressed.  Click the \"OK\" button when you've seen enough." -bg lightsteelblue -relief sunken
    frame $w.frame -borderwidth 10 
    pack append $w.frame \
        [scrollbar $w.frame.scroll -relief sunken \
            -command "$w.frame.list yview"] {right expand filly frame w} \
        [listbox $w.frame.list -yscroll "$w.frame.scroll set" -relief sunken] \
            {left expand filly frame e}
    $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \
        Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
        Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
        Massachusetts Michigan Minnesota Mississippi Missouri \
        Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
        "New York" "North Carolina" "North Dakota" \
        Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
        "South Carolina" "South Dakota" \
        Tennessee Texas Utah Vermont Virginia Washington \
        "West Virginia" Wisconsin Wyoming
    button $w.ok -text OK -command "puts stderr $w; destroy $w"

    pack append $w $w.msg {top fill} $w.frame {top expand fill} \
        $w.ok {bottom fill}
    $w config -bg lightsteelblue -relief sunken

$this append $w -padx 1.0i -pady 0.25i
%% 

	You can add you own home-grown widgets.  Here's the xygraph widget.
Beside it is the "color" demo.  Moving the scales, adjusts the background 
color of the graph.
%%
proc makeplot { widget } {

    set X { 
    	2.00000e-01 4.00000e-01 6.00000e-01 8.00000e-01 1.00000e+00 
	1.20000e+00 1.40000e+00 1.60000e+00 1.80000e+00 2.00000e+00 
	2.20000e+00 2.40000e+00 2.60000e+00 2.80000e+00 3.00000e+00 
	3.20000e+00 3.40000e+00 3.60000e+00 3.80000e+00 4.00000e+00 
	4.20000e+00 4.40000e+00 4.60000e+00 4.80000e+00 5.00000e+00 
    } 

    $widget insert Y1 -xdata $X -ydata { 
    	1.14471e+01 2.09373e+01 2.84608e+01 3.40080e+01 3.75691e+01 
	3.91345e+01 3.92706e+01 3.93474e+01 3.94242e+01 3.95010e+01 
	3.95778e+01 3.96545e+01 3.97313e+01 3.98081e+01 3.98849e+01 
	3.99617e+01 4.00384e+01 4.01152e+01 4.01920e+01 4.02688e+01 
	4.03455e+01 4.04223e+01 4.04990e+01 4.05758e+01 4.06526e+01 
    } -symbol solid -linewidth 0 -label VGS=2.0 -color blue 

    $widget insert a -xdata $X -ydata { 
	2.61825e+01 5.04696e+01 7.28517e+01 9.33192e+01 1.11863e+02 
	1.28473e+02 1.43140e+02 1.55854e+02 1.66606e+02 1.75386e+02 
	1.82185e+02 1.86994e+02 1.89802e+02 1.90683e+02 1.91047e+02 
	1.91411e+02 1.91775e+02 1.92139e+02 1.92503e+02 1.92867e+02 
	1.93231e+02 1.93595e+02 1.93958e+02 1.94322e+02 1.94686e+02 
    } -symbol cross -linewidth 0 -color brown 

    $widget insert Y2 -xdata $X -ydata { 
	2.61825e+01 5.04696e+01 7.28517e+01 9.33192e+01 1.11863e+02 
	1.28473e+02 1.43140e+02 1.55854e+02 1.66606e+02 1.75386e+02 
	1.82185e+02 1.86994e+02 1.89802e+02 1.90683e+02 1.91047e+02 
	1.91411e+02 1.91775e+02 1.92139e+02 1.92503e+02 1.92867e+02 
	1.93231e+02 1.93595e+02 1.93958e+02 1.94322e+02 1.94686e+02 
    } -symbol solid -linewidth 0 -label VGS=3.5 -color green 

    $widget insert Y3 -xdata $X -ydata { 
    	4.07008e+01 7.95658e+01 1.16585e+02 1.51750e+02 1.85051e+02 
	2.16479e+02 2.46024e+02 2.73676e+02 2.99427e+02 3.23267e+02 
	3.45187e+02 3.65177e+02 3.83228e+02 3.99331e+02 4.13476e+02 
	4.25655e+02 4.35856e+02 4.44073e+02 4.50294e+02 4.54512e+02 
	4.56716e+02 4.57596e+02 4.58448e+02 4.59299e+02 4.60151e+02 
   } -symbol solid -linewidth 0  -label VGS=5.0 -color red 

    $widget insert t -xdata $X -ydata { 
    	4.07008e+01 7.95658e+01 1.16585e+02 1.51750e+02 1.85051e+02 
	2.16479e+02 2.46024e+02 2.73676e+02 2.99427e+02 3.23267e+02 
	3.45187e+02 3.65177e+02 3.83228e+02 3.99331e+02 4.13476e+02 
	4.25655e+02 4.35856e+02 4.44073e+02 4.50294e+02 4.54512e+02 
	4.56716e+02 4.57596e+02 4.58448e+02 4.59299e+02 4.60151e+02 
   } -symbol plus -linewidth 0  -color purple 
}

xygraph $this.g \
	-title "Plot Title" \
	-xlabel "X Axis Label" \
	-ylabel "Y Axis Label" \
	-legendbackground lightsteelblue \
	-geom 200x200 -relief sunken -bd 2 -showlegend false
#-xlog true -ylog true
makeplot $this.g
$this append $this.g -padx 0.25i -pady 0.25i

%% %%
#
# Simple script to change colors of a window.
#
global xlabel ylabel red green blue grph
set xlabel $this.xlab
set ylabel $this.ylab
set grph $this.g
set w $this.cf
set red 0
set green 0
set blue 0

option add *Scale.sliderForeground "#cdb79e"
option add *Scale.activeForeground "#ffe4c4"
frame $w
scale $w.red -command "color red" -label "Red Intensity" \
	-from 0 -to 255 -orient horizontal -bg "#ffaeb9" -length 250
scale $w.green -command "color green" -label "Green Intensity" \
	-from 0 -to 255 -orient horizontal -bg "#43cd80"
scale $w.blue -command "color blue" -label "Blue Intensity"  \
	-from 0 -to 255 -orient horizontal -bg "#7ec0ee"
pack append $w $w.red {top expand fill}
pack append $w $w.green {top expand fill}
pack append $w $w.blue {top expand fill}

proc color {which intensity} {
    global red green blue grph xlabel ylabel
    set $which $intensity
    set rgb [format #%02x%02x%02x $red $green $blue]
    $grph config -bg $rgb
    $xlabel config -bg $rgb
    $ylabel config -bg $rgb
}

$this append $w

%%
	If you click on any button in the graph, you will get the coordinate 
values at the pointer location.  

The current coordinate values are %%
label $this.xlab -text { ??? ??? } -relief sunken
label $this.ylab -text { ??? ??? } -relief sunken
bind $this.g <ButtonPress> {labelxy [ %W locate %x %y ]}

proc labelxy { values } {
    global xlabel ylabel
    scan $values "%e %e" x y
    $xlabel config -text $x
    $ylabel config -text $y
}
$this append $this.xlab -width 100
%% and %%
$this append $this.ylab -width 100
%%.


	There are three global variables automatically created when a hypertext
file is read:

	%% 
button $this.l1 -text "\$this" -command "puts stdout $this" 
$this append $this.l1 %% is the pathname of the hypertext widget. 
	%% 
button $this.l2 -text "\$thisFile" -command "puts stdout $thisFile" 
$this append $this.l2
%% is the file being read and 
	%% 
button $this.l3 -text "\$thisLine"  -command "puts stdout $thisLine"
$this append l3
%% is the current line number.

Click on any button and the current value is printed on standard output.

	BTW.  The hypertext widget works with plain text too. If you don't want
to read it, click on the %% 
button $this.goto -text button -fg purple -bg white \
	-command "global endOfText; $this gotoline \$endOfText"
$this append $this.goto
%% to jump to the end of the plain text.

    
    The Tk Toolkit, Version 2.0
    
    by John Ousterhout
    University of California at Berkeley
    
    1. Introduction
    ---------------
    
    This directory contains the sources and documentation for Tk, which
    is an X11 toolkit that provides the Motif look and feel and is
    implemented using the Tcl command language.
    
    For an introduction to Tcl and Tk you may wish to read two papers:
    ``Tcl:  An Embeddable Command Language'', in the Proceedings of the
    1990 Winter USENIX Conference, and ``An X11 Toolkit Based on the Tcl
    Language'', in the Proceedings of the 1991 Winter USENIX Conference.
    A copy of the first paper is present in Postscript form in the file
    "tcl/usenix.ps";  Postscript for the second paper is in "doc/usenix.ps".
    Both Tcl and Tk have evolved quite a bit since these papers were
    written so the papers are no longer complete or correct, but they will
    give you an introduction to the systems.
    
    The following things are present in this directory and its subdirectories:
    
        1. Tk, a toolkit for X11 windowing applications.
        2. Tcl, an embeddable command language on which Tk is based.
        3. Wish, a simple windowing shell that uses Tk and Tcl.
        4. A collection of demonstration programs to illustrate the use
           of various features of Tk.
    
    The enclosed code is known to run on most versions of SunOS and Ultrix
    in combination with the X11R4 and X11R5 window servers from MIT.  It
    should also run with few or no changes on H-P and IBM workstations.
    
    2. What's New In This Release
    -----------------------------
    
    The 2.0 release is a major upgrade to the system.  Here is a summary
    of some of the most important new features relative to release 1.4:
    
    - Canvas widgets have been implemented.  These display structured graphics
      such as text or lines or polygons or rectangles and allow you to create
      event bindings on the individual items.  Text items can be used to create
      a simple form of multi-line editable text.
    
    - A new geometry manager called the "placer" has been implemented.  It's
      invoked with the "place" command and supports a variety of fixed
      and rubber-sheet placements.
    
    - The binding mechanism has been extended to support class bindings
      (which automatically apply to all widgets of a class) as well as
      bindings on individual widgets.  The hard-wired default behavior
      of widgets has been eliminated for all widget types except
      scrollbars and scales.  Most widgets now use the class binding
      mechanism, and you can query and change any of these bindings.
    
    - Listboxes have been upgraded in several ways, including the ability
      to scroll in two dimensions and the ability to query the location of
      the selection.
    
    - Labels, buttons, and menu buttons have many new features, including
      the ability to display bitmaps as well as text, text that automatically
      tracks the value of a variable and the ability to position the text
      in different places inside the window.
    
    - Tk now uses the Tcl auto-load mechanism and has its own script library,
      which does things like set up class bindings.  All widgets now have
      default behavior:  you don't need procedures like "bind.menu" anymore.
    
    - All widgets now support a -cursor option to set/change the cursor for
      the widget.
    
    - New generalized screen coordinates have been implemented, which allow
      you to specify most distances in either pixel units or centimeters,
      millimeters, inches, or points.  Options like -padx and -width now
      allow generalized coordinates.
    
%%
global endOfText
set endOfText [expr $thisLine-1 ]

global updateInterval numValues barChart
global Red Green Blue
set updateInterval 2000
set numValues 0
set Red bb
set Green 00
set Blue 33

barchart $this.b \
    -geom 400x200 \
    -title "Bar Chart" \
    -ylabel {Y Axis} -xlabel {X Axis} \
        -ysubticks 0 -xticks 0 \
    -showlegend false -barwidthpct 100 \
    -numberfont *-Courier-Bold-R-Normal-*-80-* \
    -relief raised -bd 4 

$this append $this.b -padx 0.5i -pady 0.25i
set barChart $this.b

proc update.bar {  } {
 global updateInterval
 global numValues barChart Red Blue Green

 incr numValues
 if { $numValues > 16 } {
    $barChart delete [lindex  [ $barChart show ]  0]
 }
 set color [format "%x" [expr $numValues%16]]
 set Green ${color}${color}
 $barChart insert $numValues -ydata $numValues -fg #${Red}${Green}${Blue}
 update
 after $updateInterval update.bar
}

update.bar
%%

	To compile follow the instructions in the Makefile.
#
# Define the following:
#
# -DNO_EXP10    if your C math library doesn't have exp10.
# -DNO_RINT	if your C math library doesn't have rint
# -DNO_INF      if printf ("%g", HUGE_VAL); doesn't print something like "Inf".
#

	Press %%
button $this.quit -command { destroy . } -text {Quit} -bg pink
$this append quit
%% to remove the window.










