[Qooxdoo-commit] qooxdoo/source/script/gui QxNativeWindow.js,1.1.2.14,1.1.2.15
Brought to you by:
ecker,
martinwittemann
|
From: Sebastian W. <wp...@us...> - 2006-01-23 17:02:35
|
Update of /cvsroot/qooxdoo/qooxdoo/source/script/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18865/source/script/gui Modified Files: Tag: renderer QxNativeWindow.js Log Message: Cleaned up 'virtual' mode from QxNativeWindow Index: QxNativeWindow.js =================================================================== RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/gui/Attic/QxNativeWindow.js,v retrieving revision 1.1.2.14 retrieving revision 1.1.2.15 diff -u -d -r1.1.2.14 -r1.1.2.15 --- QxNativeWindow.js 23 Jan 2006 15:17:13 -0000 1.1.2.14 +++ QxNativeWindow.js 23 Jan 2006 17:02:20 -0000 1.1.2.15 @@ -30,24 +30,14 @@ ************************************************************************ */ -function QxNativeWindow(vCaption, vSource, vName) +function QxNativeWindow(vSource, vName) { QxTarget.call(this); - this._timer = new QxTimer(100); - this._timer.addEventListener(QxConst.EVENT_TYPE_INTERVAL, this._ontimer, this); - - var o = this; - this.__onload = function(e) { return o._onload(e); }; - if (QxUtil.isValidString(vSource)) { this.setSource(vSource); }; - if (QxUtil.isValidString(vCaption)) { - this.setCaption(vCaption); - }; - if (QxUtil.isValidString(vName)) { this.setName(vName); }; @@ -68,12 +58,12 @@ /*! The left screen coordinate of the window. */ -QxNativeWindow.addProperty({ name : "left", type : QxConst.TYPEOF_NUMBER, defaultValue : 100 }); +QxNativeWindow.addProperty({ name : "left", type : QxConst.TYPEOF_NUMBER, defaultValue : 100, impl : "position" }); /*! The top screen coordinate of the window. */ -QxNativeWindow.addProperty({ name : "top", type : QxConst.TYPEOF_NUMBER, defaultValue : 200 }); +QxNativeWindow.addProperty({ name : "top", type : QxConst.TYPEOF_NUMBER, defaultValue : 200, impl : "position" }); /*! Should be window be modal @@ -81,11 +71,6 @@ QxNativeWindow.addProperty({ name : "modal", type : QxConst.TYPEOF_BOOLEAN, defaultValue : false }); /*! - The text of the caption -*/ -QxNativeWindow.addProperty({ name : "caption", type : QxConst.TYPEOF_STRING }); - -/*! The source url */ QxNativeWindow.addProperty({ name : "source", type : QxConst.TYPEOF_STRING }); @@ -121,27 +106,19 @@ QxNativeWindow.addProperty({ name : "showToolbar", type : QxConst.TYPEOF_BOOLEAN, defaultValue : false }); /*! - Should the caption be shown -*/ -QxNativeWindow.addProperty({ name : "showCaption", type : QxConst.TYPEOF_BOOLEAN, defaultValue : true }); - -/*! If the window is resizeable */ QxNativeWindow.addProperty({ name : "resizeable", type : QxConst.TYPEOF_BOOLEAN, defaultValue : true }); /*! - If the window is moveable -*/ -QxNativeWindow.addProperty({ name : "moveable", type : QxConst.TYPEOF_BOOLEAN, defaultValue : true }); - -/*! If the window is able to scroll and has visible scrollbars if needed */ QxNativeWindow.addProperty({ name : "allowScrollbars", type : QxConst.TYPEOF_BOOLEAN, defaultValue : false }); + + /* --------------------------------------------------------------------------- GROUPS @@ -153,113 +130,35 @@ -proto._defaultURI = "about:blank"; - -/* ---------------------------------------------------------------------------- - SUB WIDGET GETTER ---------------------------------------------------------------------------- -*/ - -proto.getPane = function() { - return this._pane; -}; - - - /* --------------------------------------------------------------------------- - MODIFIY ADDER LOGIC ---------------------------------------------------------------------------- -*/ - -proto.addToWindow = proto.add; - -proto.addToPane = function() { - this._pane.add.apply(this._pane, arguments); -}; - -// Overwrite default -proto.add = proto.addToPane; - - - - -/* ---------------------------------------------------------------------------- - COORDINATES + MODIFIERS --------------------------------------------------------------------------- */ -proto._modifyLeft = function(propValue, propOldValue, propName) { - return this._applyPosition(); -}; - -proto._modifyTop = function(propValue, propOldValue, propName) { - return this._applyPosition(); -}; - -proto._applyPosition = function() +proto._modifyPosition = function(propValue, propOldValue, propName) { - if (this._window && !this.isClosed()) { + if (!this.isClosed()) { this._window.moveTo(this.getLeft(), this.getTop()); }; return true; }; - - -/* ---------------------------------------------------------------------------- - CAPTION ---------------------------------------------------------------------------- -*/ - -proto._modifyCaption = function(propValue, propOldValue, propName) { - return this._applyCaption(); -}; - -proto._modifyShowCaption = function(propValue, propOldValue, propName) { - return this._applyCaption(); -}; - -proto._applyCaption = function() +proto._modifyName = function(propValue, propOldValue, propName) { - if (this._window && this._clientWindowInstance) - { - var v = ""; - - if (this.getShowCaption()) - { - var vc = this.getCaption(); - if (QxUtil.isValidString(vc)) { - v = vc; - }; - }; - - this._clientWindowInstance.getClientDocument().getDocumentElement().title = v; + if (!this.isClosed()) { + this._window.name = propValue; }; return true; }; - - - - - -/* ---------------------------------------------------------------------------- - SOURCE ---------------------------------------------------------------------------- -*/ - proto._modifySource = function(propValue, propOldValue, propName) { - if(this._window && this.isClosed() == false) { - this._window.location.replace(QxUtil.isValidString(propValue) ? propValue : ("javascript:/" + "/")); + if(!this.isClosed()) { + this._window.location.replace(QxUtil.isValidString(propValue) ? propValue : ("javascript://")); }; return true; @@ -268,6 +167,7 @@ + /* --------------------------------------------------------------------------- NAME @@ -276,7 +176,7 @@ proto.getName = function() { - if (this._window && !this.isClosed()) + if (!this.isClosed()) { try { @@ -303,14 +203,6 @@ }; -proto._modifyName = function(propValue, propOldValue, propName) -{ - if (this._window) { - this._window.name = propValue; - }; - - return true; -}; @@ -321,16 +213,8 @@ --------------------------------------------------------------------------- */ -proto._chromeCaptionSize = 24; - proto._isOpened = false; -proto._isLoaded = false; - -proto.isLoaded = function() { - return this._isLoaded; -}; - proto.isClosed = function() { var vClosed = true; @@ -348,14 +232,24 @@ proto.close = function() { - if (this._window) { + if (!this.isClosed()) { this._window.close(); }; }; -proto.getReady = function() { - return this._readyState == 5; -}; + + + + + + + + +/* +--------------------------------------------------------------------------- + OPEN METHOD +--------------------------------------------------------------------------- +*/ proto.open = function() { @@ -447,11 +341,11 @@ ------------------------------------------------------------------------------ */ - if ( QxUtil.isInvalidString(this.getName()) ) { + if (QxUtil.isInvalidString(this.getName())) { this.setName("w" + this.toHashCode()); }; - this._window = window.open(this._defaultURI, this.getName(), conf); + this._window = window.open(this.getSource(), this.getName(), conf); if (!this._window) { @@ -462,8 +356,6 @@ window.application.getClientWindow().getClientDocument().release(this); }; }; - - this._timer.restart(); }; @@ -477,15 +369,15 @@ */ proto.centerToScreen = function() { - return this._centerHelper((screen.width - this.getWidth()) / 2, (screen.height - this.getHeight() - this._chromeCaptionSize) / 2); + return this._centerHelper((screen.width - this.getWidth()) / 2, (screen.height - this.getHeight()) / 2); }; proto.centerToScreenArea = function() { - return this._centerHelper((screen.availWidth - this.getWidth()) / 2, (screen.availHeight - this.getHeight() - this._chromeCaptionSize) / 2); + return this._centerHelper((screen.availWidth - this.getWidth()) / 2, (screen.availHeight - this.getHeight()) / 2); }; proto.centerToOpener = function() { - return this._centerHelper(((QxDom.getWindowInnerWidth(window) - this.getWidth()) / 2) + QxDom.getComputedScreenBoxLeft(window.document.body), ((QxDom.getWindowInnerHeight(window) - this.getHeight() - this._chromeCaptionSize) / 2) + QxDom.getComputedScreenBoxTop(window.document.body)); + return this._centerHelper(((QxDom.getWindowInnerWidth(window) - this.getWidth()) / 2) + QxDom.getComputedScreenBoxLeft(window.document.body), ((QxDom.getWindowInnerHeight(window) - this.getHeight()) / 2) + QxDom.getComputedScreenBoxTop(window.document.body)); }; proto._centerHelper = function(l, t) @@ -499,7 +391,7 @@ this.setTop(t); // focus window if opened - if (this._window && !this.isClosed()) { + if (!this.isClosed()) { this.focus(); }; }; @@ -508,6 +400,7 @@ + /* --------------------------------------------------------------------------- FOCUS HANDLING @@ -516,17 +409,14 @@ proto.focus = function() { - if (this._window) { - try { - this._window.focus(); - } catch(ex) { - }; + if (!this.isClosed()) { + this._window.focus(); }; }; proto.blur = function() { - if (this._window) { + if (!this.isClosed()) { this._window.blur(); }; }; @@ -534,263 +424,6 @@ -/* ---------------------------------------------------------------------------- - TIMER ---------------------------------------------------------------------------- -*/ - -proto._ontimer = function(e) -{ - try - { - if (QxUtil.isValidNumber(this._readyState) && this._isOpened && (!this._window || (this._window && this.isClosed() != false))) - { - if (this.getModal()) { - window.application.getClientWindow().getClientDocument().release(this); - }; - - this._timer.stop(); - - if (this._clientWindowInstance) - { - this._clientWindowInstance.dispose(); - this._clientWindowInstance = null; - }; - - this._isOpened = false; - this._isLoaded = false; - this._readyState = null; - return; - }; - - if (!this._window || this._timerRun) { - return; - }; - - if (this._window) { - this._isOpened = true; - }; - } - catch(ex) - { - this.debug("QxNativeWindow: _ontimer: Error in window pre check handler: " + ex); - return; - }; - - this._timerRun = true; - - try - { - switch(this._readyState) - { - case 0: - this._isLoaded = false; - - var d = this._window.document; - if (d) - { - try { - this._window._QxNativeWindow = this; - } catch(ex) {}; - - if (QxUtil.isValidString(this.getSource())) - { - try - { - // in mshtml it seems not to work, even not for onreadystatechange - // (workaround see case 5 below) - QxDom.addEventListener(this._window, "load", this.__onload); - } - catch(ex) { - }; - - this._window.location.replace(this.getSource()); - this._timer.setInterval(500); - this._readyState = 5; - } - else - { - this._readyState = 1; - }; - - if (!this.getResizeable() && !QxClient.isMshtml()) - { - var w = this.getWidth(); - var h = this.getHeight(); - var win = this._window; - - this._window.addEventListener("resize", function(e) { win.resizeTo(w, h); }, false); - }; - }; - - break; - - case 1: - // Find stylesheet - var ls = document.getElementsByTagName("head")[0].getElementsByTagName("link"); - - for (var i=0, l=ls.length; i<l; i++) - { - if (ls[i].getAttribute("href").indexOf("qooxdoo.css") != -1) - { - var s = ls[i].getAttribute("href"); - break; - }; - }; - - // Building new document - var d = this._window.document; - - d.open("text/html", true); - - d.write('<?xml version="1.0" encoding="iso-8859-1"?>'); - - // Some magick for our optimizer - d.write('<!DOCTYPE html PUBLIC "-/' + '/W3C/' + '/DTD XHTML 1.1/' + '/EN" "http:/' + '/www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'); - d.write('<html xmlns="http:/' + '/www.w3.org/1999/xhtml" xml:lang="en">'); - - d.write('<head>'); - d.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />'); - d.write('<meta http-equiv="MsThemeCompatible" content="yes" />'); - d.write('<meta http-equiv="ImageToolBar" content="no" />'); - d.write('<meta http-equiv="Pragma" content="no-cache" />'); - d.write('<meta http-equiv="Expires" content="-1" />'); - d.write('<meta http-equiv="Cache-Control" content="no-cache" />'); - d.write('<meta name="MSSmartTagsPreventParsing" content="yes" />'); - - if (this.getShowCaption()) { - d.write('<title>' + this.getCaption() + '</title>'); - }; - - if (QxUtil.isValidString(s)) { - d.write('<link type="text/css" rel="StyleSheet" href="' + s + '"/>'); - }; - - d.write('</head><body></body></html>'); - - d.close(); - - this._readyState++; - - break; - - case 2: - var d = this._window.document; - if (d && d.body) - { - this._clientWindowInstance = new QxClientWindow(this._window); - this._pane = this._clientWindowInstance.getClientDocument(); - - this._readyState++; - }; - - break; - - case 3: - try{ - if (this.hasEventListeners("ready")) { - this.dispatchEvent(new QxEvent("ready")); - }; - } - catch(ex) - { - this.debug("Error in ready implementation: " + ex); - this._timer.stop(); - }; - - this._readyState++; - - break; - - case 4: - this.focus(); - this._readyState++; - - this._onload(); - - if (this._clientWindowInstance) { - QxWidget.flushGlobalQueues(); - }; - - this._timer.setInterval(500); - this._timer.restart(); - break; - - case 5: - // workaround for mshtml (see case 0 below) - try { - if (this._window.document.readyState == "complete") { - this._onload(); - }; - } catch(ex) {}; - - if (!this.getMoveable()) { - try{ - this._window.moveTo(this.getLeft(), this.getTop()); - } catch(ex) {}; - }; - - if (!this.getResizeable() && (this.getWidth() == "auto" || this.getHeight() == "auto")) - { - var w, h; - - if (this.getWidth() == "auto") { - w = this._clientWindowInstance.getClientDocument().getPreferredBoxWidth(); - }; - - if (this.getHeight() == "auto") { - h = this._clientWindowInstance.getClientDocument().getPreferredBoxHeight(); - }; - - if (QxUtil.isValidNumber(w) || QxUtil.isValidNumber(h)) - { - if (QxClient.isMshtml()) - { - try { - this._window.resizeTo(QxUtil.isValidNumber(w) ? w : this.getWidth(), QxUtil.isValidNumber(h) ? h + this._chromeCaptionSize : this.getHeight()); - } catch(ex) {}; - } - else - { - if (QxUtil.isValidNumber(w)) { - this._window.innerWidth = w; - }; - - if (QxUtil.isValidNumber(h)) { - // https://bugzilla.mozilla.org/show_bug.cgi?id=176320 - // Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 - if( this._window.innerHeight != 150 && h != 150) { - this._window.innerHeight = h; - }; - }; - }; - }; - }; - - break; - }; - } - catch(ex) - { - this.debug("QxNativeWindow: _ontimer: Error in window ready state handler: " + ex); - return; - }; - - delete this._timerRun; -}; - -proto._onload = function() -{ - if (!this._isLoaded) - { - this._isLoaded = true; - this.focus(); - this.dispatchEvent(new QxEvent("load")); - }; -}; - - /* @@ -805,49 +438,11 @@ return; }; - if (this._timer) - { - this._timer.removeEventListener("interval", this._ontimer, this); - this._timer.dispose(); - - this._timer = null; - }; - - if (this._clientWindowInstance) - { - this._clientWindowInstance.dispose(); - this._clientWindowInstance = null; - }; - - if (this._pane) - { - this._pane.dispose(); - this._pane = null; - }; - if (this._window) { - if (!this.isClosed()) - { - QxDom.removeEventListener(this._window, "load", this.__onload); - }; - this.close(); - - try - { - if (this._window._QxNativeWindow) - { - this._window._QxNativeWindow.dispose(); - this._window._QxNativeWindow = null; - }; - } - catch(ex) {}; - this._window = null; }; - this._readyState = null; - return QxTarget.prototype.dispose.call(this); }; |