The Web library is designed to be easy to use for simple applications,
yet provide a flexible framework for sophisticated solutions.
The library is packaged so that all procedures and external variables
are prefixed by HM
. It is safe to run sed
over the library to globally change HM
to something else
if needed.
For the simplest use of the library
.text
HMinit_win .text
html
HMparse_html $html "HMrender .text"
proc HMlink_callback {win href} { ...} win The name of the text widget (.text) href The name of the linkPresumably this procedure will figure out how to turn the link into a tcl variable containing HTML, and then call
HMreset_win .text
to reset the text widget
HMparse_html $html "HMrender .text"
proc HMset_image {handle src} handle a handle that identifies this image src The name (or url) of the imageIts up to the application to fetch the image, and make it into a TK image, by using a call something like:
image create photo $image_name -file $srcOnce the image is loaded into TK, the application should call
HMgot_image $handle $image_namewhere
$handle
is the token passed to
HMset_image
and
$image_name
is the name of the TK image. If, for some reason the image could not
be obtained, you may set image_name
to a text string that
will be displayed instead. If you never call HMset_image
at all, the alt entry in the image parameter list will be
displayed instead.
The HTML library is programmable in several ways. This section will be expanded as time permits.
- HMset_indent $text_widget $indent_in_cm
Sets the indent spacing for list constructs
- HMset_state $text_widget -param value -param value ...
overrides the default settings for several of the
display parameters. This will get fleshed out later on.
- HMlink_setup $text_widget $href
Which is called every time a hypertext link is
first seen, to set up the link behaviors.
- HMtag_html-tag $text_widget $parameter_list text
Each HTML tag can have its own procedure that gets called
automatically when the tag is seen. New behaviors can be
associated with tags using this technique.