
        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 %% 
set this $htext(widget)
label $this.lab -text "append " -relief sunken \
        -font *-Courier-Bold-R-Normal-*-12-120-*
$this append $this.lab 
%% command.
For example,
%% message $this.msg -relief sunken -bd 2 -aspect 10000 -font \
 *-Courier-Medium-R-Normal-*-12-* -text {set w $htext(widget)
label $w.face -bitmap @bitmaps/face \ 
  -relief sunken -borderwidth 2
$w append $w.face -padx 2 -pady 0.25i}
$this append $this.msg \
        -fill both %% added this %%
global tk_library
label $this.face \
        -bitmap @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.
Any Tk widget can be used, including %%
set whichTile 0
proc ChangeTile { w } {
   global whichTile

   if { $whichTile } {
        $w configure -tile bgTexture2
   } else {
	$w configure -tile bgTexture1
   }
}
checkbutton $this.ckbut -bg lightblue -text { check buttons } \
   -variable whichTile -command "ChangeTile $this" 
$this append $this.ckbut -justify top
%%, %%
radiobutton $this.rdbut -bg mediumseagreen -text { radio buttons } \
        -command { puts stderr { radio button pressed } } 
$this append $this.rdbut -justify bottom
%%, 
and scales %%
# -sliderforeground
scale $this.sc -showvalue true \
        -length 100 \
        -foreground 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--*-12-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 -pady 0.25i
%%

You can add you own home-grown widgets.  Here's the graph widget.
Beside it is the "color" demo.  Moving the scales, adjusts the background
color of the graph.
%%
#
# Simple script to change colors of a window.
#
global xlabel ylabel red green blue graph
set red 255
set green 215
set blue 0

option add *Scale.sliderForeground "#cdb79e"
option add *Scale.activeForeground "#ffe4c4"
set w $this.colorFrame
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"

$w.blue set $blue
$w.green set $green
$w.red set $red

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 graph xlabel ylabel
    set $which $intensity
    set rgb [format #%02x%02x%02x $red $green $blue]
    $graph config -bg $rgb
    $xlabel config -bg $rgb
    $ylabel config -bg $rgb
}

$this append $w 

%% 
%%
proc makeplot { widget } {

    graph $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 element create 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 circle -label VGS=2.0 -color blue4 -fill blue

    $widget element create 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 diamond -label VGS=3.5 -color green4 -fill green

    $widget element create 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 triangle -label VGS=5.0 -color red4 -fill red

}

option add *graph.title  "Plot Title" 
option add *graph.xTitle "X Axis Label"
option add *graph.yTitle "Y Axis Label" 
#option add *graph.legendMapped false 
option add *graph.elemPixels 8
option add *graph.relief ridge
option add *graph.borderWidth 2

set graph $this.graph
set xlabel $this.xlab
set ylabel $this.ylab
makeplot $graph
$this append $graph -padx 0.25i -pady 0.25i 

%%
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 $xlabel -text { ??? ??? } -relief sunken
label $ylabel -text { ??? ??? } -relief sunken
bind $graph <ButtonPress> {labelxy [ %W invtransform %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 -fill x
%% and %%
$this append $this.ylab -width 100 -fill x
%%.


There are four global variables automatically created when a hypertext
file is read. They are:

%% 
button $this.l1 -text " \$htext(widget) " \
	-command "puts $this" -bg orange
$this append $this.l1 -width 200 -pady 4
%%the pathname of the hypertext widget. 
%% 
button $this.l2 -text " \$htext(file) " \
	-command "puts $htext(file)" -bg orange
$this append $this.l2 -width 200 -pady 4
%%the file being read.
%% 
button $this.l3 -text " \$htext(line) "  \
	-command "puts $htext(line)" -bg orange
$this append $this.l3 -width 200 -pady 4
%%the current line number.
%% 
button $this.l4 -text " \$htext(index) " \
	-command "puts $htext(index)" -bg orange
$this append $this.l4 -width 200 -pady 4
%%the current index in the text.

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

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.

         ------------------------------------------------------

This is version 2.0 of the BLT library.  BLT is an extension the Tk
toolkit, adding new widgets, geometry managers, and miscellaneous
commands.  It does not require any patching of the Tcl or Tk source
files.

This release works with both Tk versions 3.6 and 4.0.  It may work
with 4.1, but I haven't it tried it yet.  

There are many changes in this release.  Not least of which is that
each command no longer has a "blt_" prefix.  This wart has been
removed since [Incr Tcl] 2.0 now includes namespaces.  There's no good
reason to "uglify" code when the right solution is now available.

BLT will automatically use namespaces if you compile with with the
itcl-2.x versions of Tcl and Tk headers and libraries.  BLT will
reside in its own namespace called "blt". All the normal BLT commands
and variables will reside there.

There are too many bug fixes and changes to list here (I'm putting
together a separate list), so check the manual pages.

The BLT library adds the following commands to Tk:

table	   A table-based geometry manager for Tk.  You specify the 
	   widget layout as row and column positions in the table.  
	   Has many options for constraining window resizing.
	 
graph	   A XY graph widget.  Plots two-variable data.  Supports
	   two sets of X and Y axes, inverted axes, custom axis
	   layout.  
	 
barchart   A barchart widget.  Plots two-variable data using bars.  
	   Supports two sets of X and Y axes, inverted axes, custom axis 
	   layout.  
	 
vector	   Creates a vector of floating point values.  The vector's 
	   components can be manipulated in three ways: through a Tcl 
	   array variable, a Tcl command, or the C API. 

spline	   Computes a spline fitting a set of data points (x and y vectors) 
	   and produces a vector of the interpolated images (y-coordinates) 
	   at a given set of x-coordinates.

busy	   For handling user-interaction when the application is "busy".
	   Manages an invisible "busy" window which prevents further 
	   user device (keyboard, mouse, button, etc.) interactions.
	   Also provides a different cursor which supersedes application
	   cursors.
	 
bgexec	   Like Tcl's "exec ... &", but collects the output, error, and 
	   status of the detached UNIX subprocesses.  Sets a Tcl variable 
	   upon completion.  Can be used with "tkwait variable" to handle 
	   expose events, etc. while waiting for subprocesses to finish.  
	 
drag&drop  Command which adds drag-n-drop capabilities to Tk.  It 
	   provides "send"-style communication between drag-drop 
	   sources and targets.  The result is a much more powerful
	   drag-and-drop mechanism than is available with OpenLook
	   or Motif.  
	 
htext	   A simple hypertext widget. Allows text and Tk widgets to
	   be combined in a scrollable text window.  Any Tk widget 
	   can be embedded and used to form hyper-links.  Other 
	   options allow for selections and text searches.
	 
bitmap	   Command for creating and manipulating bitmaps from Tcl. Lets 
	   you read and write bitmaps from Tcl. Can also define X bitmaps  
	   and create bitmaps from text strings.  Other options let
	   you rotate and scale bitmaps.
	 
winop	   Low-level Xlib calls let you raise, lower, map, or, unmap 
	   any window.  
	 
watch	   Lets you specify Tcl procedures to be run before and/or
	   after every Tcl command.  May be used for logging,
	   tracing, profiling, or debugging or Tcl code.
	 
bltdebug   Prints out each Tcl command before it's executed.  

---------

How to get and test BLT:

The following describes how to get and install the BLT library.

0. FTP the distribution from harbor.ecn.purdue.edu

	ftp ftp.aud.alcatel.com
	cd pub/tcl/extensions
	binary 
	get BLT2.0.tar.gz
	quit

1. Uncompress and untar the distribution file.  

	zcat BLT2.0.tar.gz | tar -xvf - 


   This will create a directory "blt2.0" with the following 
   subdirectories:
	
                        blt2.0
	     ______________|_____________
             |          |       |        |
           demos   library     man      src
                                         |
                                       shared

2. Run ./configure

   Go into the "blt2.0" directory 

	cd blt2.0

   and run the auto-configuration script "./configure"

	./configure 

   * If you want to use gcc, it's "./configure -with-cc=gcc"

	./configure -with-cc=gcc

   * By default, the demo program, libBLT.a, the library files, and
     manual pages will be installed in "/usr/local/blt".  You can 
     change this by giving the -prefix option to ./configure.

	./configure -prefix=/depot/stuff/blt
    
  The "configure" script will print out where is finds the X, Tcl, and Tk 
  header files and libraries.   If you see "__Edit_config.BLT__" has
  a value, you should edit the generated file "config.BLT".  Edit the
  paths to the correct values and re-run "configure".

  The configure script creates an include file "src/bltConfig.h".
  It will also generate new Makefiles from their respective templates 
  (Makefile.in).

	Makefile.in 	        ==> Makefile
	src/Makefile.in	        ==> src/Makefile
	src/shared/Makefile.in	==> src/shared/Makefile
	man/Makefile.in		==> man/Makefile
	library/Makefile.in	==> library/Makefile

  If "configure" can't find something (e.g. it can't find the X libraries),
  edit the file "config.BLT" and re-run "configure".

  Otherwise, you'll have to edit the Makefiles files by hand.


3. Compile the demonstration program "bltwish".

	make 

4. Test by running the demos. 

   Go into the demos directory 
    
	cd demos

   and run the test scripts.
	
	./graph

   If your system doesn't support "#!" in shell scripts, then it's

	../blt_wish -f ./graph


5. Installing BLT

   The following directories will be created when BLT is installed.  
   By default, the top directory is /usr/local/blt.  

       _____________|_______________
       |     |        |     |      |  
      bin  include   lib  blt2.0  man
     
   You can change the top directory by supplying the -prefix option to
   ./configure.

   * If you don't install BLT, you will need to set the BLT_LIBRARY
     environment variable or the Tcl variable "blt_library" in your
     scripts.  Otherwise, you may not be able generate PostScript 
     output for graphs and barcharts, or use the drag&drop facility 
     properly.

6. Adding BLT to your program.

   Add the following lines to your program's Tcl_AppInit routine 

	if (Blt_Init(interp) != TCL_OK) {
	    return TCL_ERROR;
        }

   Link with libBLT.a

   and that's all there's to it.

7. Send bugs reports, suggestions, etc. to

   	gah@mhcnet.att.com or ghowlett@fast.net

   Make sure you include BLT and the version number in the subject line.


%%
global endOfText
set endOfText [expr $htext(line)-1 ]

global updateInterval count barchart
global Red Green Blue
set updateInterval 2000
set count 0
set Red bb
set Green 00
set Blue 33

option add *barchart.title "Bar Chart" 
option add *barchart.xTitle "X"
option add *barchart.yTitle "Y"
option add *barchart.y2Title "Y"
option add *barchart.ySubTicks 0
option add *barchart.xTicks 0
option add *barchart.legendMapped false
option add *barchart.AxisFont *-Courier-Bold-R-Normal-*-8-80-* 
option add *barchart.y2Mapped true

set barchart $this.barchart
barchart $barchart -bd 2 -relief raised  -tile bgTexture2
$barchart y2axis use y
$this append $barchart -fill both -padx 10 -pady 10

proc AnimateBarchart {  } {
    global updateInterval
    global barchart count Red Blue Green
    
    if { [info commands $barchart] != $barchart } {
        return
    }   
    incr count
    if { $count > 16 } {
        $barchart element delete [lindex [$barchart element show] 0]
    }
    set color [format "%x" [expr $count%16]]
    set Green ${color}${color}
    $barchart element create $count -data { $count sin($count*0.1)} \
        -fg #${Red}${Green}${Blue} -bg brown 
    after $updateInterval AnimateBarchart
}
AnimateBarchart

%%

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

