X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=blobdiff_plain;f=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fmandelbrot.js;h=7a67687edc3f7a951dad7d89f8396962fe13c8d0;hp=02654971e238b88020bf35a64a7046f7c1132de7;hb=4d8e7dcbb2fdcb51faf6e0c2f3ba4c24c8b9e7b3;hpb=eceff1c913ed3ce42776db2b5b1cf69e44f0b921 diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index 0265497..7a67687 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -52,6 +52,8 @@ function drawImage() { let canvas = document.getElementById("mbrotImage"); let context = canvas.getContext("2d"); + document.getElementById("drawButton").hidden = true; + document.getElementById("statusLabel").value = document.getElementById("mbrotBundle").getString("statusDrawing"); @@ -137,7 +139,7 @@ function drawLine(line, dimensions, canvas, context, iterMax, algorithm) { if (img_y < canvas.height) setTimeout(drawLine, 0, img_y, dimensions, canvas, context, iterMax, algorithm); - else + else if (gStartTime) EndCalc(); } @@ -333,6 +335,27 @@ function drawPoint(context, img_x, img_y, C, iterMax, algorithm) { /***** pure UI functions *****/ +var zoomstart; + +function mouseevent(etype, event) { + let canvas = document.getElementById("mbrotImage"); + switch (etype) { + case 'down': + if (event.button == 0) + // left button - start dragzoom + zoomstart = {x: event.clientX - canvas.offsetLeft, + y: event.clientY - canvas.offsetTop}; + break; + case 'up': + if (event.button == 0) + alert(zoomstart.x + ',' + zoomstart.y + '-' + + (event.clientX - canvas.offsetLeft) + ',' + + (event.clientY - canvas.offsetTop)); + zoomstart = undefined; + break; + } +} + function saveImage() { const bundle = document.getElementById("mbrotBundle"); const nsIFilePicker = Components.interfaces.nsIFilePicker; @@ -458,6 +481,29 @@ function setAlgorithm(algoID) { gPref.setCharPref("mandelbrot.use_algorithm", algoID); } +function addonsManager(aPane) { + var theEM = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow("Extension:Manager"); + if (theEM) { + theEM.focus(); + if (aPane) + theEM.showView(aPane); + return; + } + + const EMURL = "chrome://mozapps/content/extensions/extensions.xul"; + const EMFEATURES = "all,dialog=no"; + if (aPane) + window.openDialog(EMURL, "", EMFEATURES, aPane); + else + window.openDialog(EMURL, "", EMFEATURES); +} + +function errorConsole() { + toOpenWindowByType("global:console", "chrome://global/content/console.xul"); +} + /***** helper functions from external sources *****/ // function below is based on http://developer.mozilla.org/en/docs/Code_snippets:Canvas @@ -493,3 +539,40 @@ function quitApp(aForceQuit) { Components.interfaces.nsIAppStartup.eAttemptQuit; appStartup.quit(quitSeverity); } + +// functions below are from comm-central/suite/common/tasksOverlay.js +function toOpenWindow(aWindow) { + try { + // Try to focus the previously focused window e.g. message compose body + aWindow.document.commandDispatcher.focusedWindow.focus(); + } catch (e) { + // e.g. full-page plugin or non-XUL document; just raise the top window + aWindow.focus(); + } +} + +function toOpenWindowByType(inType, uri, features) { + // don't do several loads in parallel + if (uri in window) + return; + + var topWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator) + .getMostRecentWindow(inType); + if ( topWindow ) + toOpenWindow( topWindow ); + else { + // open the requested window, but block it until it's fully loaded + function newWindowLoaded(event) { + // make sure that this handler is called only once + window.removeEventListener("unload", newWindowLoaded, false); + window[uri].removeEventListener("load", newWindowLoaded, false); + delete window[uri]; + } + // remember the newly loading window until it's fully loaded + // or until the current window passes away + window[uri] = window.openDialog(uri, "", features || "all,dialog=no"); + window[uri].addEventListener("load", newWindowLoaded, false); + window.addEventListener("unload", newWindowLoaded, false); + } +}