Class Index | File Index

Classes


Class Painter

The paint tool application object.
Defined in: index.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
 
Holds all the removable functionality from the paint application.
 
Holds the buffer canvas and context references.
<private>  
Holds references to important DOM elements.
<private> <inner>  
Holds the keyboard event listener object.
 
Holds the current layer ID, canvas and context references.
<private>  
Holds the last recorded mouse coordinates and the button state (if it's down or not).
 
The instance of the active tool object.
Method Summary
Method Attributes Method Name and Description
 
actionAdd(id, func, overwrite)
Add a new action to the paint tool.
 
Remove an action from the paint tool.
<private> <inner>  
The Canvas event handler.
<private> <inner>  
The global keyboard events handler.
<private> <inner>  
The event handler for any changes made to the tool selector.
<private> <inner>  
init()
Initialize the paint application.
 
This method draws the buffer canvas on top of the current image layer, after which the buffer is cleared.
 
Activate a drawing tool by ID.
Class Detail
Painter()
Field Detail
{Object} actions
Holds all the removable functionality from the paint application.
See:
Painter#actionAdd Add a new action.
Painter#actionRemove Remove an action.

{Object} buffer
Holds the buffer canvas and context references.

<private> {Object} elems
Holds references to important DOM elements.

<private> <inner> {lib.dom.KeyboardEventListener} kbListener_
Holds the keyboard event listener object.
See:
lib.dom.KeyboardEventListener The class dealing with the cross-browser differences in the DOM keyboard events.

{Object} layer
Holds the current layer ID, canvas and context references.

<private> {Object} mouse
Holds the last recorded mouse coordinates and the button state (if it's down or not).

{Object} tool
The instance of the active tool object.
See:
PainterConfig.tool_default holds the ID of the tool which is activated when the application loads.
Method Detail
{Boolean} actionAdd(id, func, overwrite)
Add a new action to the paint tool.
Parameters:
{String} id
The ID of the new action.
{Function} func
The constructor function of the new action object.
{Boolean} overwrite Optional, Default: false
Tells to overwrite or not an existing action, with the same ID.
Returns:
{Boolean} True if the action was successfully added, or false if not.
See:
Painter#actionRemove allows you to remove actions.
Painter#actions Holds the action objects.

{Boolean} actionRemove(id)
Remove an action from the paint tool.

If the action object being destructed has the actionRemove() method, then it will be invoked, allowing any custom action removal code to run.

Parameters:
{String} id
The ID of the action object you want to remove.
Returns:
{Boolean} True if the action was removed, or false if it does not exist or some error occurred.
See:
Painter#actionAdd allows you to add new actions.
Painter#actions Holds the action objects.

<private> <inner> ev_canvas(ev)
The Canvas event handler.

This method determines the mouse position relative to the canvas element, after which it invokes the method of the currently active tool with the same name as the current event type. For example, for the mousedown event the tool.mousedown() method is invoked.

The mouse coordinates are added to the ev DOM Event object: ev.x_ and ev.y_.

Parameters:
{Event} ev
The DOM Event object.
Returns:
The result returned by the event handler of the current tool. If no event handler was executed, false is returned.

<private> <inner> ev_keyhandler(ev)
The global keyboard events handler. This makes all the keyboard shortcuts work in the web application.

This method determines the key the user pressed, based on the ev DOM Event object, taking into consideration any browser differences. Two new properties are added to the ev object:

In PainterConfig.keys one can setup the keyboard shortcuts. If the keyboard combination is found in that list, then the associated tool is activated.

Parameters:
{Event} ev
The DOM Event object.
See:
PainterConfig.keys The keyboard shortcuts configuration.
lib.dom.KeyboardEventListener The class dealing with the cross-browser differences in the DOM keyboard events.

<private> <inner> ev_tool_change()
The event handler for any changes made to the tool selector.
See:
Painter#toolActivate The method which does the actual drawing tool activation.

<private> <inner> init()
Initialize the paint application.

layerUpdate()
This method draws the buffer canvas on top of the current image layer, after which the buffer is cleared. This function is called each time when the user completes a drawing operation.

{Boolean} toolActivate(id)
Activate a drawing tool by ID.

The id provided must be available in the global PaintTools object.

Parameters:
{String} id
The ID of the drawing tool to be activated.
Returns:
{Boolean} True if the tool has been activated, or false if not.
See:
PaintTools The object holding all the drawing tools.

Documentation generated by JsDoc Toolkit 2.1.0 on Wed Apr 22 2009 15:41:21 GMT+0300 (EEST)