viewHtml()having sourced the files gtkhtml.S and command.S in the examples directory. Run this from the directory above examples/.
|A PNG file||A JPEG file||A JPEG via a remote URL|
|This is a slider that is created by R code that retrieves the parameters min, max and value to get the settings for the slider.|
|This object is created by returning a function from the init parameter and this is called with the embedded object as an argument. From that object, we can get access to the additional parameters such as the file. This example creates a button with the value of the file parameter as the label. When this button is clicked, we call viewHtml() with that file name, creating a second window.|
The next step is that the rendering engine generates a signal for the object-request callback type. Any function registered for that signal is called and is given the HTML widget and one additional argument, the GtkHTMLEmbedded widget. From this, one can get access to the recognized attributes of the <OBJECT> tag and also the "options" specified via the <PARAM> tags within the <OBJECT> tag. The callback function can do whatever it wants at this point. Typically it will create other widgets and add them to the GtkHTMLEmbedded widget. In this way, they will be visible in the HTML page when it is rendered. Additionally, callbacks can be registered for the signals emitted by these new widgets and everything behaves as expected.
embeddedObjectHandler() in gtkhtml.S provides an example of how one can
handle embedded object tags. This behaves much like a factory
object that produces embedded objects on request. It examines the
type attribute of the GtkHTMLEmbedded widget passed to
it. It uses this to process any types that it understands. This can
be done via an
if-else sequence or via a lookup in a
table for a handler function. Each of these sub-handlers can examine
the attributes and parameters to look for non-default values. For
example, the first button example of type
provides its own label in a parameter named name!
This approach alone would necessitate having registered all types
ahead of time. We can make this more flexible and exploit the fact
that we have an interpreted programming language underlying this
interface. One can specify a type, say
and provide an init parameter that contains an R script. This
is evaluated and can do as it chooses to create the contents of the
embedded object. If it returns a widget, that object is added to the
GtkHTMLEmbedded widget. (This can be prohibited by specifying
a value of FALSE for a parameter named addWidget.)
In some scenarios, the actions in the script will need access to the top-level HTML widget or the GtkHTMLEmbedded widget. For example, the script may need to read additional parameter values from the PARAM tags. In such cases, the script should return a function that takes two arguments: the HTML widget and the embedded widget, in that order. Then, it has access to all the parameters, etc.
Soon, we will add the Gtk graphics device for R as an embeddable component.
This interface is very trivial. The user specifies a command in the text/entry box. Hitting return or clicking on the evaluate button. The output is most easily printed on the R console. There are two other obvious alternatives.
This approach is implemented via the function
We can embed grpahics devices and other controls
It is very easy to modify this interface since there is no ``programming'' involved. We simply reorganize the text. With some minimal additions to the underlying R code that displays this, we can embed the HTML component within a larger GUI. Additionally we can have it display R help, show the search path, etc. See some of the examples in the SNetscape package.