Detailed Description

Represents a HTML Document. UI.document is the main UI document. Use PowerUI.Document.innerHTML to set it's content.

Public Member Functions

void RemoveCachedElement (Element ele)
 Removes the given element from any attribute caches. You must check AttributesCached first. More...
 
void IndexAttribute (string attrib)
 Request that the given attribute will be indexed. More...
 
void StartAttributeIndex (string attrib)
 Starts indexing the given attribute right now. More...
 
 Document (Renderman renderer)
 Creates a new document which will be rendered with the given renderer. More...
 
 Document (Renderman renderer, Window parentWindow)
 Creates a new document which will be rendered with the given renderer. More...
 
 Document (Renderman renderer, Window parentWindow, bool aot)
 Creates a new document which will be rendered with the given renderer. More...
 
DynamicFont GetOrCreateFont (string fontName)
 Gets the font with the given name. May load it from the cache or generate a new one. More...
 
DynamicFont GetFont (string fontName)
 Gets the font with the given name. More...
 
void write (string text)
 Writes the given html to the end of the document. More...
 
void clear ()
 Clears the document of all it's content, including scripts and styles. More...
 
void ClearStyle ()
 Clears all css style definitions from this document. More...
 
void ClearEvents ()
 Clears all events on this document. More...
 
bool RunKeyUp (UIEvent e)
 Runs the keyup events. More...
 
bool RunMouseMove (UIEvent e)
 Called when the mouse moves over this document. More...
 
bool RunKeyDown (UIEvent e)
 Runs the keydown events. More...
 
Element createElement (string tag)
 Creates a new element in this document. You'll need to parent it to something. E.g. with thisDocument.body.appendChild(...). Alternative to innerHTML and appendInnerHTML. More...
 
object OnWindowOpen (params object[] extra)
 A shortcut for calling the nitro OnWindowOpen function. More...
 
object Run (string name, params object[] args)
 Runs a nitro function by name with optional arguments. More...
 
object RunLiteral (string name, object[] args)
 Runs a nitro function by name with a set of arguments. More...
 
object RunLiteral (string name, Element element, object[] args)
 Runs a nitro function by name with a set of arguments. More...
 
object RunLiteral (string name, object[] args, bool optional)
 Runs a nitro function by name with a set of arguments only if the method exists. More...
 
object RunLiteral (string name, Element element, object[] args, bool optional)
 Runs a nitro function by name with a set of arguments only if the method exists. More...
 
object RunOptionally (string name, Element element, params object[] args)
 Runs a nitro function by name with a set of arguments only if the method exists. More...
 
object RunOptionally (string name, params object[] args)
 Runs a nitro function by name with a set of arguments only if the method exists. More...
 
void AddStyle (string css)
 Adds the given css style to the document. Used by style tags. More...
 
void AddStyle (string css, int index)
 Adds the given css style to the document. Used by style tags. More...
 
int GetStyleIndex ()
 Gets a new style index in the StyleBuffer array. More...
 
bool TryStyle ()
 Attempts to apply any added css. It's only successful if there are no nulls in the style buffer. More...
 
void AddCode (string code)
 Adds the given nitro code to the document. Used by script tags. Note that this will not work at runtime if the code if this document has already been compiled. More...
 
void AddCode (string code, int index)
 Adds the given nitro code to the document. Used by script tags. Note that this will not work at runtime if the code if this document has already been compiled. More...
 
void ClearCode ()
 Clears all code. More...
 
int GetCodeIndex ()
 Gets a new code index in the CodeBuffer array. More...
 
bool TryCompile ()
 Attempts to compile the code then run OnWindowLoaded. It's only successful if there are no nulls in the code buffer. More...
 
Element getElementByTagName (string tag)
 Gets the first child element with the given tag. More...
 
List< ElementgetElementsByTagName (string tag)
 Gets all child elements with the given tag. More...
 
List< ElementgetElementsByAttribute (string property, string value)
 Gets all elements with the given attribute. May include this element or any of it's kids. More...
 
Element getElementByAttribute (string property, string value)
 Gets all elements with the given attribute. May include this element or any of it's kids. More...
 
List< ElementgetElementsByClassName (string className)
 Gets all elements with the given class name(s), seperated by spaces. May include this element or any of it's kids. More...
 
Element getElementById (string id)
 Gets the first html element found with the given ID attribute. More...
 
Css.SelectorStyle getStyleBySelector (string selector)
 Gets a style definition by css selector from the StyleSheet. If it's not found in the style sheet, the default stylesheet is checked. More...
 
void NewBody ()
 Called after the innerHTML of the body tag was changed. More...
 

Public Attributes

Dictionary< string,
AttributeLookup
AttributeIndex
 An attribute index, used to dramatically speed up frequently used unique attributes (like id). More...
 
Element html
 The HTML element of the document. This is the outermost tag of the document. More...
 
Element body
 The body element of the document. It's contained within the html element. Set the innerHTML of this. More...
 
Window window
 The window that this document belongs to. More...
 
FilePath location
 The current location (i.e. base URL) of this document. Originates from the src attribute of iframes. More...
 
bool AotDocument
 True if this is a Nitro AOT compilation document. More...
 
Renderman Renderer
 The renderer which will render this document. More...
 
string[] CodeBuffer
 All code in script tags is buffered and compiled in one go. This is the buffer. More...
 
UICode CodeInstance
 An instance of the compiled code on this page. May also be null of there is no script on the page. More...
 
Element DropdownBox
 A global dropdown box for showing dropdown content. Note that this is only available on the top document. See PowerUI.Window.top. More...
 
string[] StyleBuffer
 Some styles are loaded externally. Them and any styles after them are buffered to be loaded in order. More...
 
bool FinishedParsing
 True if we're done parsing and setting the innerHTML of the body tag. Used to guage when the code should be compiled. More...
 
Css.StyleSheet Style
 The css stylesheet for this document. All style tags place their content into this stylesheet. More...
 
string ScriptLocation
 Only used by Nitro AOT. The location of the html file for error reporting. More...
 
OnSizeChange OnResized
 Called when the document resizes. More...
 
TitleChange OnTitleChange
 Called when the title of this document changes. More...
 
TitleChange OnTooltipChange
 Called when the tooltip for this document changes. More...
 
DynamicMethod< Nitro.Voidonkeyup
 A method called when any key is released anywhere. Note: this applies only to the main UI document (not world UI's). More...
 
DynamicMethod< Nitro.Voidonresize
 A method called when the document resizes. More...
 
DynamicMethod< Nitro.Voidonkeydown
 A method called when any key is pressed anywhere. Note: this applies only to the main UI document (not world UI's). More...
 
DynamicMethod< Nitro.Voidonmousemove
 A method called when the mouse moves over this document. More...
 
Dictionary< string, DynamicFontActiveFonts
 A set of all fonts available to this renderer, indexed by font name. More...
 

Static Public Attributes

static Css.StyleSheet DefaultStyleSheet
 The default style sheet. Contains styling for e.g. div/span etc. More...
 

Properties

bool AttributesCached [get]
 True if more than one attribute is cached. More...
 
string basepath [get]
 The path that this document is relative to (if any). More...
 
string title [get, set]
 The title of the document. This originates from <title> tags. More...
 
string tooltip [get, set]
 The tooltip of the document. This originates from <.. title="tooltip">. Note that this is set internally. More...
 
object this[string index] [get, set]
 Gets or sets script variable values. More...
 
DocumentElements allElements [get]
 An iteratable set of all elements from this document. Whilst iterating you can actively skip nodes, so it's often useful to cache this first. More...
 
string innerHTML [get, set]
 Gets or sets the innerHTML of this document. More...
 

Events

InputEvent KeyUp
 Called when a key goes up. More...
 
InputEvent KeyDown
 Called when a key goes down. More...
 
InputEvent MouseMove
 Called when the mouse moves. More...
 

Private Attributes

string CurrentTitle
 The title of the document. This originates from <title> tags. More...
 
string CurrentTooltip
 The tooltip of the document. This originates from <.. title="tooltip">. See Document.tooltip. More...
 
NitroDomainManager SecurityDomain
 The nitro securty domain for this document. More...
 

Constructor & Destructor Documentation

PowerUI.Document.Document ( Renderman  renderer)
inline

Creates a new document which will be rendered with the given renderer.

Parameters
rendererThe renderer to use when rendering this document.
PowerUI.Document.Document ( Renderman  renderer,
Window  parentWindow 
)
inline

Creates a new document which will be rendered with the given renderer.

Parameters
rendererThe renderer to use when rendering this document.
parentWindowThe window that will become the parent window. Used in e.g. iframes.
PowerUI.Document.Document ( Renderman  renderer,
Window  parentWindow,
bool  aot 
)
inline

Creates a new document which will be rendered with the given renderer.

Parameters
rendererThe renderer to use when rendering this document.
parentWindowThe window that will become the parent window. Used in e.g. iframes.
aotTrue if this is a Nitro AOT document (used in the Editor only).

Member Function Documentation

void PowerUI.Document.AddCode ( string  code)
inline

Adds the given nitro code to the document. Used by script tags. Note that this will not work at runtime if the code if this document has already been compiled.

Parameters
codeThe nitro code to add to the document.
void PowerUI.Document.AddCode ( string  code,
int  index 
)
inline

Adds the given nitro code to the document. Used by script tags. Note that this will not work at runtime if the code if this document has already been compiled.

Parameters
codeThe nitro code to add to the document.
indexThe index in the code buffer to add the code into.
void PowerUI.Document.AddStyle ( string  css)
inline

Adds the given css style to the document. Used by style tags.

Parameters
cssThe css to add to the document.
void PowerUI.Document.AddStyle ( string  css,
int  index 
)
inline

Adds the given css style to the document. Used by style tags.

Parameters
cssThe css to add to the document.
indexThe index in the style buffer to add the css into.
void PowerUI.Document.clear ( )
inline

Clears the document of all it's content, including scripts and styles.

void PowerUI.Document.ClearCode ( )
inline

Clears all code.

void PowerUI.Document.ClearEvents ( )
inline

Clears all events on this document.

void PowerUI.Document.ClearStyle ( )
inline

Clears all css style definitions from this document.

Element PowerUI.Document.createElement ( string  tag)
inline

Creates a new element in this document. You'll need to parent it to something. E.g. with thisDocument.body.appendChild(...). Alternative to innerHTML and appendInnerHTML.

Parameters
tagThe tag, e.g. <div id='myNewElement' .. >
int PowerUI.Document.GetCodeIndex ( )
inline

Gets a new code index in the CodeBuffer array.

Returns
A new index in the CodeBuffer array.
Element PowerUI.Document.getElementByAttribute ( string  property,
string  value 
)
inline

Gets all elements with the given attribute. May include this element or any of it's kids.

Parameters
propertyThe name of the attribute to find. E.g. "id".
valueOptional. The value that the attribute should be; null for any value.
Returns
A list of all matches.
Element PowerUI.Document.getElementById ( string  id)
inline

Gets the first html element found with the given ID attribute.

Parameters
idThe ID of the element to search for.
Returns
If found, a html element with the given ID; null otherwise.
Element PowerUI.Document.getElementByTagName ( string  tag)
inline

Gets the first child element with the given tag.

Parameters
tagThe html tag to look for.
Returns
The first child with the tag.
List<Element> PowerUI.Document.getElementsByAttribute ( string  property,
string  value 
)
inline

Gets all elements with the given attribute. May include this element or any of it's kids.

Parameters
propertyThe name of the attribute to find. E.g. "id".
valueOptional. The value that the attribute should be; null for any value.
Returns
A list of all matches.
List<Element> PowerUI.Document.getElementsByClassName ( string  className)
inline

Gets all elements with the given class name(s), seperated by spaces. May include this element or any of it's kids.

Parameters
classNameThe name of the classes to find. E.g. "red box".
Returns
A list of all matches.
List<Element> PowerUI.Document.getElementsByTagName ( string  tag)
inline

Gets all child elements with the given tag.

Parameters
tagThe html tag to look for.
Returns
The set of all tags with this tag.
DynamicFont PowerUI.Document.GetFont ( string  fontName)
inline

Gets the font with the given name.

Parameters
fontNameThe name of the font to find.
Returns
A dynamic font if found; null otherwise.
DynamicFont PowerUI.Document.GetOrCreateFont ( string  fontName)
inline

Gets the font with the given name. May load it from the cache or generate a new one.

Parameters
fontNameThe name of the font to find.
Returns
A dynamic font if found; null otherwise.
Css.SelectorStyle PowerUI.Document.getStyleBySelector ( string  selector)
inline

Gets a style definition by css selector from the StyleSheet. If it's not found in the style sheet, the default stylesheet is checked.

Parameters
selectorThe css selector to search for.
Returns
If found, a selector style definition; null otherwise.
int PowerUI.Document.GetStyleIndex ( )
inline

Gets a new style index in the StyleBuffer array.

Returns
A new index in the StyleBuffer array.
void PowerUI.Document.IndexAttribute ( string  attrib)
inline

Request that the given attribute will be indexed.

void PowerUI.Document.NewBody ( )
inline

Called after the innerHTML of the body tag was changed.

object PowerUI.Document.OnWindowOpen ( params object[]  extra)
inline

A shortcut for calling the nitro OnWindowOpen function.

Parameters
extraAdditional parameters to pass into the nitro domain.
Returns
The value that OnWindowOpen returned, if any.
void PowerUI.Document.RemoveCachedElement ( Element  ele)
inline

Removes the given element from any attribute caches. You must check AttributesCached first.

object PowerUI.Document.Run ( string  name,
params object[]  args 
)
inline

Runs a nitro function by name with optional arguments.

Parameters
nameThe name of the function in lowercase.
argsOptional arguments to use when calling the function.
Returns
The value that the called function returned, if any.
bool PowerUI.Document.RunKeyDown ( UIEvent  e)
inline

Runs the keydown events.

Parameters
eThe event which has occured.
bool PowerUI.Document.RunKeyUp ( UIEvent  e)
inline

Runs the keyup events.

Parameters
eThe event which has occured.
object PowerUI.Document.RunLiteral ( string  name,
object[]  args 
)
inline

Runs a nitro function by name with a set of arguments.

Parameters
nameThe name of the function in lowercase.
argsThe set of arguments to use when calling the function.
Returns
The value that the called function returned, if any.
object PowerUI.Document.RunLiteral ( string  name,
Element  element,
object[]  args 
)
inline

Runs a nitro function by name with a set of arguments.

Parameters
nameThe name of the function in lowercase.
elementThe element to use for the 'this' value.
argsThe set of arguments to use when calling the function.
Returns
The value that the called function returned, if any.
object PowerUI.Document.RunLiteral ( string  name,
object[]  args,
bool  optional 
)
inline

Runs a nitro function by name with a set of arguments only if the method exists.

Parameters
nameThe name of the function in lowercase.
argsThe set of arguments to use when calling the function.
optionalTrue if the method call is optional. No exception is thrown if not found.
Returns
The value that the called function returned, if any.
object PowerUI.Document.RunLiteral ( string  name,
Element  element,
object[]  args,
bool  optional 
)
inline

Runs a nitro function by name with a set of arguments only if the method exists.

Parameters
nameThe name of the function in lowercase.
elementThe element to use for the 'this' value.
argsThe set of arguments to use when calling the function.
optionalTrue if the method call is optional. No exception is thrown if not found.
Returns
The value that the called function returned, if any.
bool PowerUI.Document.RunMouseMove ( UIEvent  e)
inline

Called when the mouse moves over this document.

Parameters
eThe mouse event containing the position.
object PowerUI.Document.RunOptionally ( string  name,
Element  element,
params object[]  args 
)
inline

Runs a nitro function by name with a set of arguments only if the method exists.

Parameters
nameThe name of the function in lowercase.
elementThe element to use for the 'this' value.
optionalTrue if the method call is optional. No exception is thrown if not found.
argsThe set of arguments to use when calling the function.
Returns
The value that the called function returned, if any.
object PowerUI.Document.RunOptionally ( string  name,
params object[]  args 
)
inline

Runs a nitro function by name with a set of arguments only if the method exists.

Parameters
nameThe name of the function in lowercase.
optionalTrue if the method call is optional. No exception is thrown if not found.
argsThe set of arguments to use when calling the function.
Returns
The value that the called function returned, if any.
void PowerUI.Document.StartAttributeIndex ( string  attrib)
inline

Starts indexing the given attribute right now.

bool PowerUI.Document.TryCompile ( )
inline

Attempts to compile the code then run OnWindowLoaded. It's only successful if there are no nulls in the code buffer.

Returns
Returns false if we're still waiting on code to download.
bool PowerUI.Document.TryStyle ( )
inline

Attempts to apply any added css. It's only successful if there are no nulls in the style buffer.

Returns
Returns false if we're still waiting on css to download.
void PowerUI.Document.write ( string  text)
inline

Writes the given html to the end of the document.

Parameters
textThe html to write.

Member Data Documentation

Dictionary<string,DynamicFont> PowerUI.Document.ActiveFonts

A set of all fonts available to this renderer, indexed by font name.

bool PowerUI.Document.AotDocument

True if this is a Nitro AOT compilation document.

Dictionary<string,AttributeLookup> PowerUI.Document.AttributeIndex

An attribute index, used to dramatically speed up frequently used unique attributes (like id).

Element PowerUI.Document.body

The body element of the document. It's contained within the html element. Set the innerHTML of this.

string [] PowerUI.Document.CodeBuffer

All code in script tags is buffered and compiled in one go. This is the buffer.

UICode PowerUI.Document.CodeInstance

An instance of the compiled code on this page. May also be null of there is no script on the page.

string PowerUI.Document.CurrentTitle
private

The title of the document. This originates from <title> tags.

string PowerUI.Document.CurrentTooltip
private

The tooltip of the document. This originates from <.. title="tooltip">. See Document.tooltip.

Css.StyleSheet PowerUI.Document.DefaultStyleSheet
static

The default style sheet. Contains styling for e.g. div/span etc.

Element PowerUI.Document.DropdownBox

A global dropdown box for showing dropdown content. Note that this is only available on the top document. See PowerUI.Window.top.

bool PowerUI.Document.FinishedParsing

True if we're done parsing and setting the innerHTML of the body tag. Used to guage when the code should be compiled.

Element PowerUI.Document.html

The HTML element of the document. This is the outermost tag of the document.

FilePath PowerUI.Document.location

The current location (i.e. base URL) of this document. Originates from the src attribute of iframes.

DynamicMethod<Nitro.Void> PowerUI.Document.onkeydown

A method called when any key is pressed anywhere. Note: this applies only to the main UI document (not world UI's).

DynamicMethod<Nitro.Void> PowerUI.Document.onkeyup

A method called when any key is released anywhere. Note: this applies only to the main UI document (not world UI's).

DynamicMethod<Nitro.Void> PowerUI.Document.onmousemove

A method called when the mouse moves over this document.

DynamicMethod<Nitro.Void> PowerUI.Document.onresize

A method called when the document resizes.

OnSizeChange PowerUI.Document.OnResized

Called when the document resizes.

TitleChange PowerUI.Document.OnTitleChange

Called when the title of this document changes.

TitleChange PowerUI.Document.OnTooltipChange

Called when the tooltip for this document changes.

Renderman PowerUI.Document.Renderer

The renderer which will render this document.

string PowerUI.Document.ScriptLocation

Only used by Nitro AOT. The location of the html file for error reporting.

NitroDomainManager PowerUI.Document.SecurityDomain
private

The nitro securty domain for this document.

Css.StyleSheet PowerUI.Document.Style

The css stylesheet for this document. All style tags place their content into this stylesheet.

string [] PowerUI.Document.StyleBuffer

Some styles are loaded externally. Them and any styles after them are buffered to be loaded in order.

Window PowerUI.Document.window

The window that this document belongs to.

Property Documentation

DocumentElements PowerUI.Document.allElements
get

An iteratable set of all elements from this document. Whilst iterating you can actively skip nodes, so it's often useful to cache this first.

bool PowerUI.Document.AttributesCached
get

True if more than one attribute is cached.

string PowerUI.Document.basepath
get

The path that this document is relative to (if any).

string PowerUI.Document.innerHTML
getset

Gets or sets the innerHTML of this document.

object PowerUI.Document.this[string index]
getset

Gets or sets script variable values.

Parameters
indexThe name of the variable.
Returns
The variable value.
string PowerUI.Document.title
getset

The title of the document. This originates from <title> tags.

string PowerUI.Document.tooltip
getset

The tooltip of the document. This originates from <.. title="tooltip">. Note that this is set internally.

Event Documentation

InputEvent PowerUI.Document.KeyDown

Called when a key goes down.

InputEvent PowerUI.Document.KeyUp

Called when a key goes up.

InputEvent PowerUI.Document.MouseMove

Called when the mouse moves.