Class Index | File Index

Classes


Class pwlib.tools.insertimg

The "Insert image" tool.
Defined in: insertimg.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
<private> <inner>  
Holds the DOM image element.
<private> <inner>  
Tells if the image element loaded or not.
<private> <inner>  
Holds the image aspect ratio, used by the resize method.
<private> <inner>  
Tells if the drawing canvas needs to be updated or not.
<private> <inner>  
Holds the previous tool ID.
<private> <inner>  
Tells if the Shift key is down or not.
<private> <inner>  
The interval ID used for invoking the drawing operation every few milliseconds.
<private> <inner>  
x0
Holds the starting point on the x axis of the image, for the current drawing operation.
<private> <inner>  
y0
Holds the starting point on the y axis of the image, for the current drawing operation.
Method Summary
Method Attributes Method Name and Description
 
The tool activation event handler.
 
The tool deactivation event handler.
 
draw()
Perform the drawing operation.
<private> <inner>  
The load event handler for the image element.
 
keydown(ev)
The keydown event handler allows users to press the Escape key to cancel the drawing operation and return to the previous tool.
 
The mousedown event handler.
 
The mousemove event handler.
 
mouseup(ev)
The mouseup event handler.
 
The tool preactivation code.
Class Detail
pwlib.tools.insertimg(app)
Parameters:
{PaintWeb} app
Reference to the main paint application object.
Field Detail
<private> <inner> {Element} imageElement
Holds the DOM image element.

<private> <inner> {Boolean} imageLoaded
Tells if the image element loaded or not.

<private> <inner> {Number} imageRatio
Holds the image aspect ratio, used by the resize method.

<private> <inner> {Boolean} needsRedraw
Tells if the drawing canvas needs to be updated or not.
Default Value:
false

<private> <inner> {String} prevTool
Holds the previous tool ID.

<private> <inner> {Boolean} shiftKey
Tells if the Shift key is down or not. This is used by the drawing function.
Default Value:
false

<private> <inner> timer
The interval ID used for invoking the drawing operation every few milliseconds.
See:
PaintWeb.config.toolDrawDelay

<private> <inner> {Number} x0
Holds the starting point on the x axis of the image, for the current drawing operation.

<private> <inner> {Number} y0
Holds the starting point on the y axis of the image, for the current drawing operation.
Method Detail
activate()
The tool activation event handler. This function is called once the previous tool has been deactivated.

deactivate()
The tool deactivation event handler.

draw()
Perform the drawing operation. When the mouse button is not down, the user is allowed to pick where he/she wants to insert the image element, inside the canvas. Once the mousedown event is fired, this method allows the user to resize the image inside the canvas.
See:
PaintWeb.config.toolDrawDelay

<private> <inner> ev_imageLoaded()
The load event handler for the image element. This method makes sure the image dimensions are synchronized with the zoom level, and draws the image on the canvas.

{Boolean} keydown(ev)
The keydown event handler allows users to press the Escape key to cancel the drawing operation and return to the previous tool.
Parameters:
{Event} ev
The DOM Event object.
Returns:
{Boolean} True if the key was recognized, or false if not.

mousedown(ev)
The mousedown event handler. This method stores the current mouse location and the image aspect ratio for later reuse by the draw() method.
Parameters:
{Event} ev
The DOM Event object.

mousemove(ev)
The mousemove event handler.
Parameters:
{Event} ev
The DOM Event object.

mouseup(ev)
The mouseup event handler. This method completes the drawing operation by inserting the image in the layer canvas, and by activating the previous tool.
Parameters:
{Event} ev
The DOM Event object.

{Boolean} preActivate()
The tool preactivation code. This function asks the user to provide an URL to the image which is desired to be inserted into the canvas.
Returns:
{Boolean} True if the URL provided is correct. False is returned if the URL is not provided or if it's incorrect. When false is returned the tool activation is cancelled.

Documentation generated by JsDoc Toolkit 2.3.0 on Sat Jun 26 2010 21:57:03 GMT+0300 (EEST)