For scripts that are passed as command line arguments, Sidewinder provides a number of classes and functions as part of its JavaScript API.
The following classes are exposed via the Sidewinder JavaScript API.
Application class
The Event class implements the Event interface.
The EventListener class is a proxy by which JavaScript functions may be nominated to handle events. Additionally, it implements the EventListener interface.
The following methods are available on the EventListener class. Additionally, it implements the EventListener interface.
Constructs an instance of the EventListener class.
Parameters: Optional JavaScript function to be called from the proxy's implementation of handleEvent.
Return Value: none
Example Usage
function handleEvent(evt)
{
...
}
...
var l = new EventListener(handleEvent);
Destroy the instance and free its resources.
Parameters: none
Return Value: none
Example Usage
function handleEvent(evt)
{
...
}
...
var l = new EventListener(handleEvent);
...
l.Destroy();
Nominates the JavaScript method to be used as an event handler by this instance. Overrides any handler nominated by preceding calls to this method or in the constructor.
Parameters: JavaScript function to be called from the proxy's implementation of handleEvent.
Return Value: none
Example Usage
function handleEvent(evt)
{
...
}
...
var l = new EventListener();
l.SetHandler(handleEvent);
ObjectParcel class
The Renderer class models a window that may contain either XHTML markup or plain text. Additionally, it implements the EventTarget interface.
Either in the constructor, or the subsequent call to Create, a number of initial settings may be specified for a Renderer instance. These settings are passed as a single parameter, using JSON syntax.
The value of this parameter dictates whether the object will automatically hide when it loses mouse focus. If this parameter is unspecified or invalid, the default setting of false is used.
Values: true | false
The value of this parameter dictates the context in which the Edge, Position and Direction parameters are to be applied. If this parameter is unspecified or invalid, the default setting of "screen" is used.
Values: "screen" | [handle]
Where [handle] represents the value returned by an object's GetHandle() method.
The value of this parameter dictates in which direction, relative to its Context, an AutoHide object will slide open. If this parameter is unspecified or invalid, the default setting of "in" is used.
Values: "in" | "out"
The value of this parameter dictates the edge of the Context area that the object will be positioned against. If this parameter is unspecified or invalid, the default setting of "none" is used.
Values: "left" | "right" | "top" | "bottom" | "none"
The value of this parameter dictates the height, in pixels, of the client area of the Renderer window. The client area includes only the rendered content; window chrome should not be accounted for here.
Values: any positive integer
The value of this parameter dictates the relative opacity of the object. A value of 100 renders the the object completely opaque, whereas a value of 0 renders the object completely transparent. If this parameter is invalid or unspecified, the default value of 100 is used.
Values: any integer in the range 0 .. 100
The value of this parameter dictates the position along an Edge of a Context, at which the object will be placed. If this parameter is unspecified or invalid, the default setting of "centred" is used.
Values: "left" | "right" | "top" | "bottom" | "centred"
The value of this parameter dictates the precise position, measured in pixels, along the x-axis of a Context, at which the object will be placed.
Values: any positive integer
The value of this parameter dictates the precise position, measured in pixels, along the y-axis of a Context, at which the object will be placed.
Values: any positive integer
The value of this parameter dictates a number of different window styles, each one set by a different bit. These bits may be specified by performing a logical or operation with the appropriate values, described in the list below. Values that are not present in the list are reserved and should not be used. In the event that other values are used, behaviour is undefined.
0x00000002: Hides the taskbar button for this window.
0x00000200: Displays a maximise button in the title bar of the window.
0x00000400: Displays a minimise button in the title bar of the window.
0x00000800: Adds a system menu for this window.
0x00001000: Displays a close button in the title bar of the window.
0x00002000: Creates the window in its maximised state.
0x00004000: Creates the window in its minimised state.
0x00008000: Forces the window to always be displayed on top of other windows.
0x00200000: Displays a window with no border.
0x02000000: Displays a border around the window.
0x20000000: Displays a title bar on the window.
The value of this parameter dictates the title that is assigned to the object. If this parameter is unspecified or invalid, the default setting of the application name is used.
Values: any string
The value of this parameter nominates, in hexadecimal rrggbb format, a colour to be rendered as transparent within the object. This has the effect of making all regions that match the nominated colour completely hidden, with other windows and applications visible "underneath". If this parameter is unspecified or invalid, no colours are nominated as transparent.
Values: any string containing a 24 bit hexadecimal value, where the 8 highest-order bits denote the level of red in the nominated colour, the 8 middle-order bits denote the level of green in the nominated colour and the 8 lowest-order bits denote the level of blue in the nominated colour
The value of this parameter dictates whether an XHTML or a text Renderer is created. If this parameter is unspecified or invalid, the default setting of "xhtml" is used.
Values: "xhtml" | "text"
The value of this parameter dictates the width, in pixels, of the client area of the Renderer window. The client area includes only the rendered content; window chrome should not be accounted for here.
Values: any positive integer
The following methods are available on the Renderer class. Additionally, it implements the EventTarget interface.
Constructs an instance of the Renderer class.
Parameters: Optional creation parameters, used to set physical properties of the window.
Return Value: none
Example Usage
var r = new Renderer(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Create();
r.Show();
Create the Renderer window.
Parameters: Optional creation parameters, used if none were specified during instantiation
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
Destroy the Renderer window and free its resources.
Parameters: none
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
...
r.Destroy();
Show the Renderer window.
Parameters: none
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
Hide the Renderer window.
Parameters: none
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
...
r.Hide();
Load and render an XHTML document.
Parameters: an RFC3986-conformant URI string
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
r.Load("http://www.formsplayer.com/");
Load and render in-memory data.
Parameters: a string containing either an XHTML document or plain text (dependent on the object's Type)
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
r.Write("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>Title</title></head><body>Body</body></html>");
On text renderers only, insert in-memory data before existing rendered data.
Parameters: a string containing plain text
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "text",
Width: 800,
Height: 600
}
);
r.Show();
r.Write("This is line two.\n");
r.Insert("This is line one.\n");
On text renderers only, append in-memory data after existing rendered data.
Parameters: a string containing plain text
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "text",
Width: 800,
Height: 600
}
);
r.Show();
r.Write("This is line one.\n");
r.Append("This is line two.\n");
Clear the rendered data.
Parameters: none
Return Value: none
Example Usage
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.Show();
r.Write("<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>Title</title></head><body>Body</body></html>");
...
r.Clear();
Retrieves the handle associated with this instance, which may be used as the value for the Context parameter.
Parameters: none
Return Value: String containing the instance handle
Example Usage
var r1 = new Renderer;
r1.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
var r2 = new Renderer;
r2.Create(
{
Type: "xhtml",
Width: 200,
Context: r1.GetHandle(),
Edge: "left",
Direction: "out"
}
);
r1.Show();
r2.Show();
Retrieves the platform-dependent implementation of this instance, which may be used when handling new window requests.
Parameters: none
Return Value: ObjectParcel containing the platform-dependent Renderer implementation.
Example Usage
function onNewWindow(evt)
{
var r = new Renderer;
r.Create( { Type:"xhtml" } );
r.Show();
evt.parameter.objectValue = r.GetRenderingImplementation();
}
function handleEvent(evt)
{
switch(evt.type)
{
case "renderer-request-newwindow":
onNewWindow(event);
break;
...
}
}
...
var l = new EventListener;
l.SetHandler(handleEvent);
var r = new Renderer;
r.Create(
{
Type: "xhtml",
Width: 800,
Height: 600
}
);
r.addEventListener("renderer-request-newwindow", l, true);
r.Show();
...
StdErr class
StdOut class
Variant class
The following functions are exposed via the Sidewinder JavaScript API.
Closes all windows and terminates the application.
Parameters: none
Return Value: none
Example Usage
Exit();