Class Index | File Index

Classes


Class View

base gui object !CONSTRUCTOR PARAMETERS ARE PROVIDED IN A OBJECT LITERAL!
Defined in: gamejs-gui.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
View(parent, size, position, surface, visible)
View
Field Summary
Field Attributes Field Name and Description
 
array of this views children views
 
parent view of this view
 
view position relative to parent, [x, y]
 
view size, [width, length]
 
surface this view is rendered on
Method Summary
Method Attributes Method Name and Description
 
addChild(child)
add child to this view
 
blitChild(child)
blit child's surface on this view's surface
 
center(child)
Center a child view within this view.
 
Despatch event to this view.
 
detaches view from it's parent, effectively destroying it
 
draw()
if needed, paints this view, draws children and coposites them on this views surface
 
returns GUI object at the base of this views branch
 
get view position within it's parent element
 
get position & size rect
 
get view size
 
hide()
If this view is visible, hide it.
 
 
get hover state
 
get visible state
 
move(new)
Move view relative to its parent.
 
moveRelative(delta)
Move view relative to its position.
 
on(event, callback, scope)
register a callback for an event.
 
paint this view on it's surface.
 
Redraw this view and its children.
 
removeChild(child)
detaches a child from this view
 
resize(new)
Resize this view.
 
show()
If this view is hidden, make it visible
 
update(miliseconds)
update view.
Class Detail
View(parent, size, position, surface, visible)
View
Parameters:
{View} parent
parent element
{Array} size
array containing width & height of the element, eg. [width, height]
{Array} position
position of the view relative to parent, eg. [x, y]. OPTIONAL, default [0, 0]
{gamejs.Surface} surface
surface to render this view on, OPTIONAL
{Bool} visible
is this view visible? default true
Field Detail
{Array} children
array of this views children views

{View} parent
parent view of this view

{Array} position
view position relative to parent, [x, y]

{Array} size
view size, [width, length]

{gamejs.Surface} surface
surface this view is rendered on
Method Detail
addChild(child)
add child to this view
Parameters:
{View} child
view to add as a child of this view

blitChild(child)
blit child's surface on this view's surface
Parameters:
{View} child
child view to blit

center(child)
Center a child view within this view. Must be direct child
Parameters:
{View} child
child view

despatchEvent(event)
Despatch event to this view. Event is despatched to children if applicable, then handled by this view.
Parameters:
{Event} event
event to despatch

destroy()
detaches view from it's parent, effectively destroying it

{Bool} draw()
if needed, paints this view, draws children and coposites them on this views surface
Returns:
{Bool} has this view been repainted

{GUI} getGUI()
returns GUI object at the base of this views branch
Returns:
{GUI} GUI object at the base if this views branch

{Array} getPosition()
get view position within it's parent element
Returns:
{Array} view position within it's parent element, [x, y]

getRect()
get position & size rect
Returns:
gamejs.Rect instance. Position is relative to parent

{Array} getSize()
get view size
Returns:
{Array} view size, [width, height]

hide()
If this view is visible, hide it. This also blurs and mouse-outs the view, if applicable

isFocused()

{Bool} isHovered()
get hover state
Returns:
{Bool} is mouse hovering on this element?

{Bool} isVisible()
get visible state
Returns:
{Bool} is this view visible?

move(new)
Move view relative to its parent. Generates EVT_MOVE event
Parameters:
{Array} new
position relative to parent element, eg. [x, y]

moveRelative(delta)
Move view relative to its position. Generates EVT_MOVE event
Parameters:
{Array} delta
coordinates relative to current position ,eg. [delta x, delta y]

on(event, callback, scope)
register a callback for an event. When event is triggered, callback is called with event object as argument
Parameters:
{Event ID} event
event ID of the event to be registered on, eg gamejs-gui.EVT_BLUR, gamejs-gui.EVT_KEY_DOWN, etc.
{Function} callback
function to call when event is triggered
{Object} scope
- this object for the callback

paint()
paint this view on it's surface. does not repaint/blit children! override this to implement custom drawing of the element itself. by default, only clears the surface

refresh()
Redraw this view and its children.

removeChild(child)
detaches a child from this view
Parameters:
{View|Number} child
View or or child View id.

resize(new)
Resize this view. Generates EVT_RESIZE event
Parameters:
{Array} new
size, eg. [width, height]

show()
If this view is hidden, make it visible

update(miliseconds)
update view. does nothing by default
Parameters:
{Number} miliseconds
since last update

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Aug 15 2011 16:17:32 GMT+0300 (EEST)