The hush API

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, of which the public interface is shown below:

  interface session : event {
	...
	void prelude(kit* tk, int argc, char* argv[]);
	void main(kit* tk, int argc, char* argv[]);
	int run();		// to start the main loop
	...
	int loop(int flag);
	int step(int flag);
	...
  };
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. When the function run is called, as for example in the following code fragment:
  session* s = new application();
  s->run();
the function application::main is called (by run) and the main loop is started, which results in dispatching user actions to the appropriate handlers. In case the standard main loop is not satisfactory, either the function session::loop may be redefined or for each iteration an application-defined step may be inserted. Notice that a session inherits from event, which means that a particular session object may be scheduled under explicit programmer's control.

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.