Module "wsf_graph"
==================

A module which implemnts a WSF Component for displaying and editing
graphs.
 
object WsfGraph WsfComponent
----------------------------

A WSF Component for displaying and editing graphs.

In order for this component to work properly, the browser must have support
for iframes and must allow javascripts to modify the DOM tree. This is the
case with most of todays graphical web browsers.

For various technical reasons, the graph editor itself is displayed in an
iframe. This object creates an extra SPL task for this iframe.

The constructor is passed a function which returns a list of node objects
which must implement the WsfGraphNode interface. If there is any
outside change of what that function would return, the 'dirty' attribute
of the WsfGraph instance must be set to '1'.

This object is derived from WsfComponent.
 

var WsfGraph.get_list;
~~~~~~~~~~~~~~~~~~~~~~

The function which returns the node list. This is set by the
constructor to its first argument.
	 

var WsfGraph.ibase;
~~~~~~~~~~~~~~~~~~~

The (relative or absolute) URL to the directory in which the images
used by this component can be found.

This are the files 'images/wsf_graph_*' in the SPL sources.
	 

var WsfGraph.raster;
~~~~~~~~~~~~~~~~~~~~

Per default, nodes can be moved to any position. It is possible to
use a raster to align the nodes. If you want that, set this variable
to the size of the raster (e.g. 10 is a good value).
	 

var WsfGraph.iframe_header;
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Additional HTML text to be inserted in the HTML header of the iframe.
	 

var WsfGraph.iframe_footer;
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Additional HTML text to be inserted at the end of the HTML text in the
iframe.
	 

var WsfGraph.iframe_attributes;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Additional attributes to be added in the <iframe> tag. Usually this
is something like 'style="width:100%; height:100%"'.
	 

var WsfGraph.scroll_x, scroll_y;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some changes require a reload of the iframe.
The current scroll position is then preserved using this attributes.
It is also possible to adjust this values when setting the 'dirty'
variable to '1'.
	 

method WsfGraph.iframe_main();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The main method for the iframe.

This is called whenever the iframe content is reloaded and prints
the new content of the iframe.
	 

method WsfGraph.get_html();
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Overloaded WsfComponent.get_html().
	 

method WsfGraph.main();
~~~~~~~~~~~~~~~~~~~~~~~

Overloaded WsfComponent.main().
	 

method WsfGraph.destroy();
~~~~~~~~~~~~~~~~~~~~~~~~~~

Overloaded WsfComponent.destroy().
	 

method WsfGraph.init(_get_list, _ibase);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Constructor.

The parameters are copied to the get_list and ibase
variables.

The first parameter must be a function pointer. This function, when
called, must return an array of objects implementing the
WsfGraphNode interface. This objects describe the entire graph
and also provide callbacks to react on user events.
	 

interface WsfGraphNode
----------------------

The node objects used by WsfGraph must implement this interface.
Some of the methods in this interface are optional.
 

method WsfGraphNode.get_xywh();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This method returns the position and size of the node in pixel.
The return value must be a hash with the keys 'x' and 'y' for
the x- and y-coordinate of the left upper corner (0,0 is the
left upper corner of the drawing area) and 'w' and 'h' for the
width and height.
	 

method WsfGraphNode.set_xy(x, y);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When a node is moved or clicked, this callback is called. The new
x- and y-coordinates are passed as parameters.
	 

method WsfGraphNode.get_links();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This method returns an array with the IDs of the nodes this node
has connections to. The IDs must correspond with the keys in the
array returned by WsfGraph.get_list.
	 

method WsfGraphNode.set_link(trg);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This callback is called when one of the connections of the node
are clicked. The ID (see get_links) of the target node of the
connection is passed as parameter.

This method is optional. WsfGraph will not try to call it when
is is not declared.
	 

method WsfGraphNode.get_color();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This method must return the background color for this node. The
return value is a string in the usual HTML color '#RRGGBB' format.

This method is optional. WsfGraph will not try to call it when
it is not declared.
	 

method WsfGraphNode.get_html();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This method must return the HTML content for this node. Usually
this is just a label text, but it can any HTML code.

This method is optional. WsfGraph will not try to call it when
it is not declared.
	 
