slide: Components
The hush API
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
As explained in the previous section, the
hush library contains the classes
providing the interface to the embedded script
interpreter(s) and the classes allowing for
a smooth interaction with the underlying window
system.
(Currently, only X-windows is supported.
An MS-windows implementation is on its way.)
The hush library contains the classes
kit, event, handler,
widget and item.
In addition to these, hush provides
the class session.
Application programmers are minimally required
to derive a class, say application,
from session and redefine the function main.
When the program is to be used as a script interpreter,
the function prelude may be redefined
to allow for initializing external packages or other
components of the DejaVu framework.
As a comment, the hush library originated
as a collection of classes
giving the C++ programmer convenient access
to the Tcl/Tk window programming toolkit.
Its design has been inspired by the Interviews library.
However, although less powerful wit respect
to device-independent graphics,
its class structure is less complex
and, as experience shows, much easier to employ
by undergraduate students.
In addition, it offers a rich collection of
user interface widgets.
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
User interface widgets
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
The (hush) widget library contains
classes for a variety of user interface widgets,
including the classes button,
menu, text, canvas,
filechooser and many more.
As explained before,
a widget allows for binding an independently defined
handler to user actions.
This may result in a code fragment like:
button* b = new button(".b");
handler* h = new help_handler(b);
b->text("Help");
b->bind(h);
We assume that help_handler does something
meaningful, like displaying a hypertext help file.
Alternatively, a widget may declare itself to be its
own handler.
In that case we derive a new class from button
and define the functionality (previously defined externally
in the help_handler) in the new class itself,
as illustrated below:
class help_button : public button {
public:
help_button( char* path ) : button( path ) {
this->text("help");
this->bind(this);
}
int operator()(); // does what help_handler did
};
Dependent on circumstances, either one of the approaches
may be the most convenient.
Allowing for delegating to an external handler
helps to avoid cluttering the class name space.
On the other hand, employing inheritance may result
in a significant reuse of initialization code.
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
Basic hypertext functionality
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
One of the components extending the hush
widget library is a hypertext widget
offering basic hypertext functionality by allowing
the programmer to embed (Tcl) script code in plain text.
A hypertext widget, as any other widget
of the hush widget library, can be created
from an absolute path name (as in Tk) or,
relative to a parent widget, with a path extending
the path of the parent widget.
The hypertext widget allows for a number of configuration
commands, for setting font size, background, foreground and the like.
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
Software sound facilities
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
Sound facilities are an essential ingredient
of a framework supporting multimedia.
Sound may be produced from a stored audio file or,
provided that real-time sound synthesis facilities
are available, from some high level representation
in a sound or music description language.
Apart from a reduction in the storage capacity needed
(and correspondingly, the network traffic load
in a distributed environment),
employing a high level music/sound description language
has as an additional advantage that improved
synchronization and linking facilities may be offered.
The DejaVu framework supports both MIDI and the
sound synthesis facilities offered by Csound [XX].
When creating an instance of the icsound class
a process is created
which is capable of receiving sound events,
as defined by the Csound numerical score language, and
converting these events to data for the audio device.
(The icsound class inherits from
a wrapper class providing the functionality
for spawning of a new process that communicates with
the original process via pipes.)
Care is taken that the audio device is connected only once.
However, multiple instances of the icsound
class may exist.
In addition to the icsound class, which accepts
only low level sound events, instances of player
may be used which accept musical events defined in
the high level music description language Scot,
that comes with Csound.
The player class is also an event.
This allows instances of player to be embedded
in scripts, as well as being activated
as user-defined events.
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
Digital video
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
Digital video may be considered as another
standard ingredient of hypermedia and multimedia
framworks.
To employ digital video, our framework offers
the class video.
Apart from the usual widget creation commands,
the class video has functions for reading
in a video file, to play (forward)
and to rewind.
In addition, it offers a function
to bind a framenumber to an event.
Binding framenumbers to events
allows for both synchronization and hyperlinking,
albeit in a low level fashion.
Our video extension is based on the public domain xanim
package and includes support
for MPEG, AVI and Quicktime.
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
Connecting to the WWW
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
In addition to the basic hypertext facility mentioned before,
the DejaVu framework also provides support
(in the form of the web widget)
for hypertext files written in HTML.
The web widget displays HTML files and allows for
following links defined by URLs.
In addition to the standard widget functions,
it offers a function loadhome, to load
a home page.
In a similar way as the basic hypertext widget,
the web widget allows for embedding
(Tcl) script code, by using the
special (non-HTML) tag hush,
as illustrated below:
<h1>Digital video for HushWWW</h1>
<hush tcl=source [urlfile www.cs.vu.nl/~se/mpeg.tcl>
You need the hush browser to play this MPEG demo
</hush>
The actual script code itself may be obtained
from some site by using the special command
urlfile.
The text inbetween the hush begin and end tag
will be displayed by 'ordinary' browsers, such as Mosaic
and Netscape.
Evaluating the script code may, similar as
for the hypertext widget, result in packing
additional widgets to the browser (widget),
as for example a video widget showing an mpeg movie.
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references
introduction,
concepts,
components,
examples,
patterns,
experience,
conclusions,
references