html.browserWindow - WIN

Class browserWindow
Inherits from window.

The browserWindow class provides a display window for a html (or plain text) document.

To create a browserWindow use it's new method:
local view = html.browserWindow:new (parent, id, x, y, width, height)


Properties

brws__doc htmlDoc The document object.
brws__map htmlMap The mapping object.

Methods

See also HTML API, API Reference, WIN.

html.browserWindow:constructor

wnd browserWindow:constructor (parent, id, x, y, width, height)

Constructs and returns the instantiated browser window.

Parameters
parent window Parent window, typically a frame.
id number Numeric id value for browser window.
x number Parent relative x position.
y number Parent relative y position.
width number The window's width.
height number The window's height.

Returns
wnd browserWindow The instantiated browser window.

Remarks


top


html.browserWindow:doc_type

format browserWindow:doc_type ()

Returns the format that the current document was loaded from.

Parameters
none


Returns
format string The format of the document; either "text" or "html".

Remarks


top


html.browserWindow:draw

browserWindow:draw (gdi, bounds)

Draws the browser window in its current state.

Parameters
gdi GDI GDI object to use for drawing.
bounds rect Invalidated area of the window.

Returns
none


Remarks


top


html.browserWindow:get_html

html browserWindow:get_html ()

Creates and returns the raw html string representation of the current document.

Parameters
none


Returns
html string The raw html representation of the document.

Remarks
The returned string is suitable for saving to a file.

See browserWindow:serialize, browserWindow:get_text.


top


html.browserWindow:get_map

map browserWindow:get_map (width)

Creates a htmlMap object and formats it to the given width, returning it. The returned map object is independent of the browserWindow object.

Parameters
width number The character width the html document is to be formatted to.

Returns
map htmlMap The map object.

Remarks
This method can be called to gain a map object for drawing to a printer.


top


html.browserWindow:get_text

plain browserWindow:get_text ()

Creates and returns the plain text string representation of the current document.

Parameters
none


Returns
plain string The plain text representation of the document.

Remarks
The returned string is suitable for saving to a file.

See browserWindow:serialize, browserWindow:get_html.


top


html.browserWindow:get_title

title browserWindow:get_title (title)

Returns the title from the html document, or default if the document has none.

Parameters
default string/nil A default title for the html document.

Returns
title string/nil The html document's title.

Remarks


top


html.browserWindow:lines

lines browserWindow:lines ()

Returns the line count of the html document.

Parameters
none


Returns
lines number The number of lines in the document.

Remarks
As the document display is free form, the number of lines can vary when the window changes size.


top


html.browserWindow:map

map browserWindow:map (width, body, color, bgcolor, linkcolor, align)

Maps the current document and returns the map.

Parameters
width number The width to format the document to.
body table The body node of the html document.
color number The body text color.
bgcolor number The body background color.
linkcolor number The body link color.
align string The body alignment.

Returns
map htmlMap The map object.

Remarks
This method is used internally by the mapping process and not called generally.


top


html.browserWindow:map_node

browserWindow:map_node (map, node, color, bgcolor, linkcolor, align, erase)

Maps the node using the inheritable properties.

Parameters
map htmlMap The map object to record the formatting.
node table The htmlDoc node to map.
color number The inheritable text color to use.
bgcolor number The inheritable background color to use.
linkcolor number The inheritable link color to use.
align string The inheritable alignment to use.
erase number/nil The inheritable erasure color to use.

Returns
none


Remarks
This method is used internally by the mapping process and not called generally.


top


html.browserWindow:merge_address

address browserWindow:merge_address (link, ref, protocol)

Merges a relative address with a full address, and returns the absolute address.

Parameters
link string The (potentially) relative address to merge, typically from a link.
reference string The address to merge with, should be starting at a top domain.
protocol string/nil The preferred protocol.

Returns
address string The full, merged address.

Remarks
If the link address is fully qualified (including protocol, or a local file path beginning with "/") it is returned as is.

If the reference address is of "file:" protocol or begins with "/" then "file:" is used, and the protocol parameter is ignored. If not a local path the protocol parameter is used. If the parameter nil "http:" is assumed.

This method can be used as a static member of the browserWindow class.

See browserWindow:split_address.


top


html.browserWindow:node_from_point

node browserWindow:node_from_point (x, y)

Returns the html node at the given point.

Parameters
x number The horizontal window relative position.
y number The vertical window relative position.

Returns
node table The node at the given point or nil if none.

Remarks


top


html.browserWindow:on_left_click

result browserWindow:on_left_click (x, y, count)

Calls the base class implementation and sends a link_click event to the parent window if a link was clicked.

Parameters
x number Window relative x position.
y number Window relative y position.
count
number The number of times this same position was repeatedly clicked, with each successive click within the double_click_time.

Returns
result boolean Always true.

Remarks
See window:on_left_click.


top


html.browserWindow:on_move

result browserWindow:on_move ()

Remaps the document's contents.

Parameters
none


Returns
result boolean Always false.

Remarks
See window:on_move.


top


html.browserWindow:on_touch

result browserWindow:on_touch (x, y)

Calls the base class implementation and sends a link_click event to the parent window if a link was touched.

Parameters
x number Window relative x position.
y number Window relative y position.

Returns
result boolean Always true.

Remarks
See window:on_touch.


top


html.browserWindow:remap

browserWindow:remap ()

Remaps the html document for the browser window, adjusting the scroll size.

Parameters
none


Returns
none


Remarks


top


html.browserWindow:serialize

raw browserWindow:serialize ()

Serializes the document object into a raw text string. If the document's type is "text" then the returned string is a plain text representation, otherwise html.

Parameters
none


Returns
raw string The raw text representation of the document.

Remarks
The returned string is suitable for saving to a file.

See browserWindow:get_html, browserWindow:get_text.


top


html.browserWindow:server_not_found

browserWindow:server_not_found (address)

Displays a server not found page in the browserWindow for the address.

Parameters
address string The failed address.

Returns
none


Remarks


top


html.browserWindow:set_text

browserWindow:set_text (source)

Parses the source as the current document for the window.

Parameters
source htmlDoc/string/nil If a htmlDoc object the document is copied. If a string it may be the raw html document (as loaded from a file) or plain text. If nil the window displays a blank document.

Returns
none


Remarks


top


html.browserWindow:split_address

path, domain, protocol browserWindow:split_address (address)

Divides an address into its components.

Parameters
address string The address to separate.

Returns
path string The path after the domain, if any.
domain string The domain, if any. For a local file this will be "".
protocol string The protocol. If missing either "file" or "http" is returned as appropriate.

Remarks
This method can be used as a static member of the browserWindow class.

See browserWindow:merge_address.


top


See also HTML API, API Reference, WIN.