// Copyright 2008, 2009 Hannes Hochreiner
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
// Add event listener for initialisation.
/** Initialisation function.
*
* This function looks for the objects of the appropriate sub-type and hands them to another function that will add the required methods.
*/
function jessyInk_core_mouseHandler_zoomControl_init()
{
{
if (elems[counter].getAttributeNS("https://launchpad.net/jessyink", "subtype") == "jessyInk_core_mouseHandler_zoomControl")
}
}
/** Function to initialise an object.
*
* @param obj Object to be initialised.
*/
{
// Last dragging position.
// Flag to indicate whether dragging is active currently.
obj.dragging_active = false;
// Flag to indicate whether dragging is working currently.
obj.dragging_working = false;
// Flag to indicate whether the user clicked.
/** Function supplying a custom mouse handler.
*
* @returns A dictionary containing the new mouse handler functions.
*/
obj.getMouseHandler = function ()
{
var handlerDictio = new Object();
handlerDictio[SLIDE_MODE] = new Object();
return handlerDictio;
}
/** Event handler for mouse clicks.
*
* @param e Event object.
*/
obj.mouseclick = function (e)
{
processingEffect = true;
effectArray = new Array();
effectArray[0] = new Object();
if (elem == null)
else
effectArray[0]["options"]["matrixNew"] = obj.pointMatrixToTransformation(obj.rectToMatrix(elem)).mult((new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.getScreenCTM()).inv().mult((new matrixSVG()).fromSVGMatrix(elem.parentNode.getScreenCTM())).inv());
transCounter = 0;
lastFrameTime = null;
effect(1);
return false;
}
/** Function to search for the element the user clicked on.
*
* This function searches for the element with the highest z-order, which encloses the point the user clicked on
* and which view box fits entierly into the currently visible part of the slide.
*
* @param elem Element to start the search from.
* @param pnt Point where the user clicked.
* @returns The element the user clicked on or null, if no element could be found.
*/
{
{
{
var childPointList = obj.projectRect(children[counter].getBBox(), children[counter].getScreenCTM());
viewBbox.x = 0.0;
viewBbox.y = 0.0;
if (obj.pointsWithinRect([pnt], childPointList) && obj.pointsWithinRect(childPointList, screenPointList))
if (child != null)
return child;
}
}
return null;
}
/** Function to project a rectangle using the projection matrix supplied.
*
* @param rect The rectangle to project.
* @param projectionMatrix The projection matrix.
* @returns A list of the four corners of the projected rectangle starting from the upper left corner and going counter-clockwise.
*/
{
}
/** Function to determine whether all the points supplied in a list are within a rectangle.
*
* @param pnts List of points to check.
* @param pointList List of points representing the four corners of the rectangle.
* @return True, if all points are within the rectangle; false, otherwise.
*/
{
var matrixOrig = (new matrixSVG()).fromElements(pntUL.x, pntLL.x, pntUR.x, pntUL.y, pntLL.y, pntUR.y, 1, 1, 1);
{
var subPnts = new Array();
{
else
{
tmpPnt.x = 0.0;
tmpPnt.y = 0.0;
}
}
var matrixPnt = (new matrixSVG).fromElements(subPnts[0].x, subPnts[1].x, subPnts[2].x, subPnts[0].y, subPnts[1].y, subPnts[2].y, 1, 1, 1);
{
{
if ((pntCounter == 0) && !((matrixTrans.e11 > 0.01) && (matrixTrans.e11 < 0.99) && (matrixTrans.e21 > 0.01) && (matrixTrans.e21 < 0.99)))
return false;
else if ((pntCounter == 1) && !((matrixTrans.e12 > 0.01) && (matrixTrans.e12 < 0.99) && (matrixTrans.e22 > 0.01) && (matrixTrans.e22 < 0.99)))
return false;
else if ((pntCounter == 2) && !((matrixTrans.e13 > 0.01) && (matrixTrans.e13 < 0.99) && (matrixTrans.e23 > 0.01) && (matrixTrans.e23 < 0.99)))
return false;
}
}
}
return true;
}
/** Event handler for mouse movements.
*
* @param e Event object.
*/
{
return false;
obj.dragging_working = true;
{
}
else
{
var matrix = (new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.transform.baseVal.consolidate().matrix);
}
obj.dragging_last = p;
obj.dragging_working = false;
return false;
}
/** Event handler for mouse down.
*
* @param e Event object.
*/
{
if (obj.dragging_active)
return false;
var value = 0;
if (e.button)
else if (e.which)
if (value == 1)
{
obj.dragging_active = true;
}
return false;
}
/** Event handler for mouse up.
*
* @param e Event object.
*/
{
obj.dragging_active = false;
return obj.mouseclick(e);
else
return false;
}
/** Function to get the coordinates of a point corrected for the offset of the viewport.
*
* @param e Point.
* @returns Coordinates of the point corrected for the offset of the viewport.
*/
{
return svgPoint;
}
/** Event handler for scrolling.
*
* @param e Event object.
*/
obj.mousewheel = function(e)
{
{
}
else
{
var matrix = (new matrixSVG()).fromSVGMatrix(slides[activeSlide].viewGroup.transform.baseVal.consolidate().matrix);
}
if (e.wheelDelta)
{ // IE Opera
}
else if (e.detail)
{ // MOZ
}
return false;
}
/** Function to project a point to screen coordinates.
*
* @param Point.
* @returns The point projected to screen coordinates.
*/
{
return pnt;
}
/** Function to convert a rectangle into a point matrix.
*
* The function figures out a rectangle that encloses the rectangle given and has the same width/height ratio as the viewport of the presentation.
*
* @param rect Rectangle.
* @return The upper left, upper right and lower right corner of the rectangle in a point matrix.
*/
{
rectXcorr = 0;
rectYcorr = 0;
{
}
else
{
}
{
}
else
{
}
newVectors = (new matrixSVG()).fromElements(rectXcorr, rectXcorr + rectWidth, rectXcorr + rectWidth, rectYcorr, rectYcorr, rectYcorr + rectHeight, 0, 0, 0);
}
/** Function to return a transformation matrix from a point matrix.
*
* @param mPoints The point matrix.
* @returns The transformation matrix.
*/
{
}
}