diff options
author | Derrell Lipman <derrell@samba.org> | 2007-01-03 20:17:37 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:36:09 -0500 |
commit | 626bb8efb0c825f332c937ffaaadc9b402079539 (patch) | |
tree | 1c95f69d157b24f64edff470143f5f55a09cfca6 /webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic | |
parent | eeddcf8cc8eb655d7c40f1fd5f7fd422529f4f98 (diff) | |
download | samba-626bb8efb0c825f332c937ffaaadc9b402079539.tar.gz samba-626bb8efb0c825f332c937ffaaadc9b402079539.tar.bz2 samba-626bb8efb0c825f332c937ffaaadc9b402079539.zip |
r20517: re-add cleaned-up webapps
(This used to be commit 5a3d6ad0b7cf0ecf8b57b4088b19f7d4291c990b)
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic')
7 files changed, 1840 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Atom.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Atom.js new file mode 100644 index 0000000000..5a1c0ae97f --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Atom.js @@ -0,0 +1,397 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_basic) +#optional(qx.ui.embed.Flash) + +************************************************************************ */ + +/*! + A multi-prupose widget used by many more complex widgets. + + The intended purpose of qx.ui.basic.Atom is to easily align the common icon-text combination in different ways. + This is useful for all types of buttons, menuentires, tooltips, ... +*/ +qx.OO.defineClass("qx.ui.basic.Atom", qx.ui.layout.BoxLayout, +function(vLabel, vIcon, vIconWidth, vIconHeight, vFlash) +{ + qx.ui.layout.BoxLayout.call(this); + + if (this.getOrientation() == null) { + this.setOrientation("horizontal"); + } + + // Prohibit selection + this.setSelectable(false); + + // Disable flex support + this.getLayoutImpl().setEnableFlexSupport(false); + + // Apply constructor arguments + if (qx.util.Validation.isValidString(vLabel)) { + this.setLabel(vLabel); + } else { + this.setLabel(""); + } + + // Simple flash wrapper + if (qx.OO.isAvailable("qx.ui.embed.Flash") && qx.util.Validation.isValidString(vFlash) && qx.util.Validation.isValidNumber(vIconWidth) && qx.util.Validation.isValidNumber(vIconHeight) && qx.ui.embed.Flash.getPlayerVersion().getMajor() > 0) + { + this._flashMode = true; + + this.setIcon(vFlash); + + // flash needs explicit dimensions! + this.setIconWidth(vIconWidth); + this.setIconHeight(vIconHeight); + } + else if (qx.util.Validation.isValidString(vIcon)) + { + this.setIcon(vIcon); + + if (qx.util.Validation.isValidNumber(vIconWidth)) { + this.setIconWidth(vIconWidth); + } + + if (qx.util.Validation.isValidNumber(vIconHeight)) { + this.setIconHeight(vIconHeight); + } + } +}); + +qx.ui.basic.Atom.SHOW_LABEL = "label"; +qx.ui.basic.Atom.SHOW_ICON = "icon"; +qx.ui.basic.Atom.SHOW_BOTH = "both"; + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +/*! + The label/caption/text of the qx.ui.basic.Atom instance +*/ +qx.OO.addProperty({ name : "label", type : "string" }); + +/*! + Any URI String supported by qx.ui.basic.Image to display a icon +*/ +qx.OO.addProperty({ name : "icon", type : "string" }); + +/** + * Any URI String supported by qx.ui.basic.Image to display a disabled icon. + * <p> + * If not set the normal icon is shown transparently. + */ +qx.OO.addProperty({ name : "disabledIcon", type : "string" }); + +/*! + Configure the visibility of the sub elements/widgets. + Possible values: both, text, icon, none +*/ +qx.OO.addProperty({ name : "show", type : "string", defaultValue : "both", possibleValues : [ "both", "label", "icon", "none", null ] }); + +/*! + The position of the icon in relation to the text. + Only useful/needed if text and icon is configured and 'show' is configured as 'both' (default) +*/ +qx.OO.addProperty({ name : "iconPosition", type : "string", defaultValue : "left", possibleValues : [ "top", "right", "bottom", "left" ] }); + +/*! + The width of the icon. + If configured, this makes qx.ui.basic.Atom a little bit faster as it does not need to wait until the image loading is finished. +*/ +qx.OO.addProperty({ name : "iconWidth", type : "number" }); + +/*! + The height of the icon + If configured, this makes qx.ui.basic.Atom a little bit faster as it does not need to wait until the image loading is finished. +*/ +qx.OO.addProperty({ name : "iconHeight", type : "number" }); + +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "atom" }); + + + + + +/* +--------------------------------------------------------------------------- + SUB WIDGETS +--------------------------------------------------------------------------- +*/ + +qx.Proto._flashMode = false; + +qx.Proto._labelObject = null; +qx.Proto._iconObject = null; + +qx.Proto._createLabel = function() +{ + var l = this._labelObject = new qx.ui.basic.Label(this.getLabel()); + + l.setAnonymous(true); + l.setEnabled(this.getEnabled()); + l.setSelectable(false); + + this.addAt(l, this._iconObject ? 1 : 0); +} + +qx.Proto._createIcon = function() +{ + if (this._flashMode && qx.OO.isAvailable("qx.ui.embed.Flash")) + { + var i = this._iconObject = new qx.ui.embed.Flash(this.getIcon()); + } + else + { + var i = this._iconObject = new qx.ui.basic.Image(); + } + + i.setAnonymous(true); + + this._updateIcon(); + + this.addAt(i, 0); +} + +qx.Proto._updateIcon = function() { + // NOTE: We have to check whether the properties "icon" and "disabledIcon" + // exist, because some child classes remove them. + if (this._iconObject && this.getIcon && this.getDisabledIcon) { + var disabledIcon = this.getDisabledIcon(); + if (disabledIcon) { + if (this.getEnabled()) { + this._iconObject.setSource(this.getIcon()); + } else { + this._iconObject.setSource(disabledIcon); + } + this._iconObject.setEnabled(true); + } else { + this._iconObject.setSource(this.getIcon()); + this._iconObject.setEnabled(this.getEnabled()); + } + } +} + +qx.Proto.getLabelObject = function() { + return this._labelObject; +} + +qx.Proto.getIconObject = function() { + return this._iconObject; +} + + + + + + +/* +--------------------------------------------------------------------------- + MODIFIERS +--------------------------------------------------------------------------- +*/ + +qx.Proto._modifyEnabled = function(propValue, propOldValue, propData) +{ + this._updateIcon(); + + if (this._labelObject) { + this._labelObject.setEnabled(propValue); + } + + return qx.ui.layout.BoxLayout.prototype._modifyEnabled.call(this, propValue, propOldValue, propData); +} + +qx.Proto._modifyIconPosition = function(propValue, propOldValue, propData) +{ + switch(propValue) + { + case "top": + case "bottom": + this.setOrientation("vertical"); + this.setReverseChildrenOrder(propValue == "bottom"); + break; + + default: + this.setOrientation("horizontal"); + this.setReverseChildrenOrder(propValue == "right"); + break; + } + + return true; +} + +qx.Proto._modifyShow = function(propValue, propOldValue, propData) +{ + this._handleIcon(); + this._handleLabel(); + + return true; +} + +qx.Proto._modifyLabel = function(propValue, propOldValue, propData) +{ + if (this._labelObject) { + this._labelObject.setHtml(propValue); + } + + this._handleLabel(); + + return true; +} + +qx.Proto._modifyIcon = function(propValue, propOldValue, propData) +{ + this._updateIcon(); + this._handleIcon(); + + return true; +} + +qx.Proto._modifyDisabledIcon = function(propValue, propOldValue, propData) +{ + this._updateIcon(); + this._handleIcon(); + + return true; +} + +qx.Proto._modifyIconWidth = function(propValue, propOldValue, propData) +{ + this._iconObject.setWidth(propValue); + return true; +} + +qx.Proto._modifyIconHeight = function(propValue, propOldValue, propData) +{ + this._iconObject.setHeight(propValue); + return true; +} + + + + + + +/* +--------------------------------------------------------------------------- + HANDLER +--------------------------------------------------------------------------- +*/ + +qx.Proto._iconIsVisible = false; +qx.Proto._labelIsVisible = false; + +qx.Proto._handleLabel = function() +{ + switch(this.getShow()) + { + case qx.ui.basic.Atom.SHOW_LABEL: + case qx.ui.basic.Atom.SHOW_BOTH: + this._labelIsVisible = qx.util.Validation.isValidString(this.getLabel()); + break; + + default: + this._labelIsVisible = false; + } + + if (this._labelIsVisible) + { + this._labelObject ? this._labelObject.setDisplay(true) : this._createLabel(); + } + else if (this._labelObject) + { + this._labelObject.setDisplay(false); + } +} + +qx.Proto._handleIcon = function() +{ + switch(this.getShow()) + { + case qx.ui.basic.Atom.SHOW_ICON: + case qx.ui.basic.Atom.SHOW_BOTH: + this._iconIsVisible = qx.util.Validation.isValidString(this.getIcon()); + break; + + default: + this._iconIsVisible = false; + } + + if (this._iconIsVisible) + { + this._iconObject ? this._iconObject.setDisplay(true) : this._createIcon(); + } + else if (this._iconObject) + { + this._iconObject.setDisplay(false); + } +} + + + + + + +/* +--------------------------------------------------------------------------- + CLONE +--------------------------------------------------------------------------- +*/ + +// Omit recursive cloning +qx.Proto._cloneRecursive = qx.util.Return.returnTrue; + + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return true; + } + + if (this._iconObject) + { + this._iconObject.dispose(); + this._iconObject = null; + } + + if (this._labelObject) + { + this._labelObject.dispose(); + this._labelObject = null; + } + + return qx.ui.layout.BoxLayout.prototype.dispose.call(this); +}
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/HorizontalSpacer.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/HorizontalSpacer.js new file mode 100644 index 0000000000..9db8f12064 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/HorizontalSpacer.js @@ -0,0 +1,31 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_basic) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.basic.HorizontalSpacer", qx.ui.basic.Terminator, +function() +{ + qx.ui.basic.Terminator.call(this); + + this.setWidth("1*"); +}); diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Image.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Image.js new file mode 100644 index 0000000000..0cc25a9d5c --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Image.js @@ -0,0 +1,611 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_basic) +#resource(core:static/image) + +************************************************************************ */ + +/** + * This widget is for all images in qooxdoo projects. + * + * @event error {qx.event.type.Event} + */ +qx.OO.defineClass("qx.ui.basic.Image", qx.ui.basic.Terminator, +function(vSource, vWidth, vHeight) +{ + qx.ui.basic.Terminator.call(this); + + // Reset Alt and Title + this.setHtmlProperty("alt", ""); + this.setHtmlProperty("title", ""); + + // Apply constructor arguments + this.setSource(qx.util.Validation.isValid(vSource) ? vSource : "static/image/blank.gif"); + + // Dimensions + this.setWidth(qx.util.Validation.isValid(vWidth) ? vWidth : "auto"); + this.setHeight(qx.util.Validation.isValid(vHeight) ? vHeight : "auto"); + + // Prohibit selection + this.setSelectable(false); +}); + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +/*! + The source uri of the image. +*/ +qx.OO.addProperty({ name : "source", type : "string" }); + +/*! + The assigned preloader instance of the image. +*/ +qx.OO.addProperty({ name : "preloader", type : "object" }); + +/*! + The loading status. + + True if the image is loaded correctly. False if no image is loaded + or the one that should be loaded is currently loading or not available. +*/ +qx.OO.addProperty({ name : "loaded", type : "boolean", defaultValue : false }); + +/*! + Should the image be maxified in it's own container? +*/ +qx.OO.addProperty({ name : "resizeToInner", type : "boolean", defaultValue : false }); + +/*! + Appearance of the widget +*/ +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "image" }); + + + + + +/* +--------------------------------------------------------------------------- + EVENT MAPPERS +--------------------------------------------------------------------------- +*/ + +qx.Proto._onload = function() { + this.setLoaded(true); +} + +qx.Proto._onerror = function() +{ + this.debug("Could not load: " + this.getSource()); + + this.setLoaded(false); + + if (this.hasEventListeners("error")) { + this.dispatchEvent(new qx.event.type.Event("error"), true); + } +} + + + + + +/* +--------------------------------------------------------------------------- + DISPLAYBLE HANDLING +--------------------------------------------------------------------------- +*/ + +qx.Proto._beforeAppear = function() +{ + var vSource = this.getSource(); + + if (qx.util.Validation.isValidString(vSource)) { + qx.manager.object.ImageManager.getInstance()._sources[vSource]++; + } + + return qx.ui.basic.Terminator.prototype._beforeAppear.call(this); +} + +qx.Proto._beforeDisappear = function() +{ + var vSource = this.getSource(); + + if (qx.util.Validation.isValidString(vSource)) + { + if (qx.manager.object.ImageManager.getInstance()._sources[vSource] <= 1) + { + delete qx.manager.object.ImageManager.getInstance()._sources[vSource]; + } + else + { + qx.manager.object.ImageManager.getInstance()._sources[vSource]--; + } + } + + return qx.ui.basic.Terminator.prototype._beforeDisappear.call(this); +} + + + + + +/* +--------------------------------------------------------------------------- + MODIFIERS +--------------------------------------------------------------------------- +*/ + +qx.Proto._modifySource = function(propValue, propOldValue, propData) +{ + if (propValue && typeof qx.manager.object.ImageManager.getInstance()._sources[propValue] === "undefined") { + qx.manager.object.ImageManager.getInstance()._sources[propValue] = 0; + } + + if (propOldValue) + { + if (qx.manager.object.ImageManager.getInstance()._sources[propOldValue] <= 1) + { + delete qx.manager.object.ImageManager.getInstance()._sources[propOldValue]; + } + else + { + qx.manager.object.ImageManager.getInstance()._sources[propOldValue]--; + } + } + + if (this.isCreated()) + { + if (propValue) + { + this.setPreloader(qx.manager.object.ImagePreloaderManager.getInstance().create(qx.manager.object.AliasManager.getInstance().resolvePath(propValue))); + } + else if (propOldValue) + { + this._resetContent(); + this.setPreloader(null); + } + } + + return true; +} + +qx.Proto._modifyPreloader = function(propValue, propOldValue, propData) +{ + if (propOldValue) + { + // remove event connection + propOldValue.removeEventListener("load", this._onload, this); + propOldValue.removeEventListener("error", this._onerror, this); + } + + if (propValue) + { + // Register to image manager + qx.manager.object.ImageManager.getInstance().add(this); + + // Omit here, otherwise the later setLoaded(true) + // will not be executed (prevent recursion) + + // Changed: Use forceLoaded instead of setLoaded => should be faster + this.forceLoaded(false); + + if (propValue.isErroneous()) + { + this._onerror(); + } + else if (propValue.isLoaded()) + { + this.setLoaded(true); + } + else + { + propValue.addEventListener("load", this._onload, this); + propValue.addEventListener("error", this._onerror, this); + } + } + else + { + // Remove from image manager + qx.manager.object.ImageManager.getInstance().remove(this); + + this.setLoaded(false); + } + + return true; +} + +qx.Proto._modifyLoaded = function(propValue, propOldValue, propData) +{ + if (propValue && this.isCreated()) + { + this._applyContent(); + } + else if (!propValue) + { + this._invalidatePreferredInnerWidth(); + this._invalidatePreferredInnerHeight(); + } + + return true; +} + +qx.Proto._modifyElement = function(propValue, propOldValue, propData) +{ + if (propValue) + { + if (!this._image) + { + try + { + // Create Image-Node + // Webkit has problems with "new Image". Maybe related to "new Function" with + // is also not working correctly. + if (qx.sys.Client.getInstance().isWebkit()) + { + this._image = document.createElement("img"); + } + else + { + this._image = new Image; + } + + // Possible alternative for MSHTML for PNG images + // But it seems not to be faster + // this._image = document.createElement("div"); + + // this costs much performance, move setup to blank gif to error handling + // is this SSL save? + // this._image.src = qx.manager.object.AliasManager.getInstance().resolvePath("static/image/blank.gif"); + + this._image.style.border = "0 none"; + this._image.style.verticalAlign = "top"; + } + catch(ex) + { + this.error("Failed while creating image #1", ex); + } + + if (!qx.sys.Client.getInstance().isMshtml()) { + this._applyEnabled(); + } + } + + propValue.appendChild(this._image); + } + + // call widget implmentation + qx.ui.basic.Terminator.prototype._modifyElement.call(this, propValue, propOldValue, propData); + + if (propValue) + { + try + { + // initialisize preloader + var vSource = this.getSource(); + if (qx.util.Validation.isValidString(vSource)) { + this.setPreloader(qx.manager.object.ImagePreloaderManager.getInstance().create(qx.manager.object.AliasManager.getInstance().resolvePath(vSource))); + } + } + catch(ex) + { + this.error("Failed while creating image #2", ex); + } + } + + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + CLIENT OPTIMIZED MODIFIERS +--------------------------------------------------------------------------- +*/ + +qx.Proto._postApply = function() +{ + if (!this.getLoaded()) { + this._updateContent(qx.manager.object.AliasManager.getInstance().resolvePath("static/image/blank.gif")); + return; + } + + this._postApplyDimensions(); + this._updateContent(); +} + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.Proto._modifyEnabled = function(propValue, propOldValue, propData) + { + if (this._image) { + this._applyEnabled(); + } + + return qx.ui.basic.Terminator.prototype._modifyEnabled.call(this, propValue, propOldValue, propData); + } + + qx.Proto._updateContent = function(vSource) + { + var i = this._image; + var pl = this.getPreloader(); + + if (pl.getIsPng() && this.getEnabled()) + { + i.src = qx.manager.object.AliasManager.getInstance().resolvePath("static/image/blank.gif"); + i.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + (vSource || pl.getSource()) + "',sizingMethod='scale')"; + } + else + { + i.src = vSource || pl.getSource(); + i.style.filter = this.getEnabled() ? "" : "Gray() Alpha(Opacity=30)"; + } + } + + qx.Proto._resetContent = function() + { + var i = this._image; + + i.src = qx.manager.object.AliasManager.getInstance().resolvePath("static/image/blank.gif"); + i.style.filter = ""; + } + + qx.Proto._applyEnabled = qx.Proto._postApply; +} +else +{ + qx.Proto._updateContent = function(vSource) { + this._image.src = vSource || this.getPreloader().getSource(); + } + + qx.Proto._resetContent = function() { + this._image.src = qx.manager.object.AliasManager.getInstance().resolvePath("static/image/blank.gif"); + } + + qx.Proto._applyEnabled = function() + { + if (this._image) + { + var o = this.getEnabled() ? "" : 0.3; + var s = this._image.style; + + s.opacity = s.KhtmlOpacity = s.MozOpacity = o; + } + } + + qx.Proto._modifyEnabled = function(propValue, propOldValue, propData) + { + if (this._image) { + this._applyEnabled(); + } + + return qx.ui.basic.Terminator.prototype._modifyEnabled.call(this, propValue, propOldValue, propData); + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + PREFERRED DIMENSIONS: INNER +--------------------------------------------------------------------------- +*/ + +qx.Proto._computePreferredInnerWidth = function() +{ + if (this.getLoaded()) + { + return this.getPreloader().getWidth(); + } + else if (qx.util.Validation.isValidString(this.getSource())) + { + var vPreloader = qx.manager.object.ImagePreloaderManager.getInstance().get(qx.manager.object.AliasManager.getInstance().resolvePath(this.getSource())); + + if (vPreloader && vPreloader.isLoaded()) { + return vPreloader.getWidth(); + } + } + + return 0; +} + +qx.Proto._computePreferredInnerHeight = function() +{ + if (this.getLoaded()) + { + return this.getPreloader().getHeight(); + } + else if (qx.util.Validation.isValidString(this.getSource())) + { + var vPreloader = qx.manager.object.ImagePreloaderManager.getInstance().get(qx.manager.object.AliasManager.getInstance().resolvePath(this.getSource())); + + if (vPreloader && vPreloader.isLoaded()) { + return vPreloader.getHeight(); + } + } + + return 0; +} + + + + + + + +/* +--------------------------------------------------------------------------- + APPLY +--------------------------------------------------------------------------- +*/ + +qx.Proto._applyContent = function() +{ + qx.ui.basic.Terminator.prototype._applyContent.call(this); + + // Images load asyncron, so we need to force flushing here + // to get an up-to-date view when an image is loaded. + qx.ui.core.Widget.flushGlobalQueues(); +} + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.Proto._postApplyDimensions = function() + { + try + { + var vImageStyle = this._image.style; + + if (this.getResizeToInner()) + { + vImageStyle.pixelWidth = this.getInnerWidth(); + vImageStyle.pixelHeight = this.getInnerHeight(); + } + else + { + vImageStyle.pixelWidth = this.getPreferredInnerWidth(); + vImageStyle.pixelHeight = this.getPreferredInnerHeight(); + } + } + catch(ex) + { + this.error("postApplyDimensions failed", ex); + } + } +} +else +{ + qx.Proto._postApplyDimensions = function() + { + try + { + var vImageNode = this._image; + + if (this.getResizeToInner()) + { + vImageNode.width = this.getInnerWidth(); + vImageNode.height = this.getInnerHeight(); + } + else + { + vImageNode.width = this.getPreferredInnerWidth(); + vImageNode.height = this.getPreferredInnerHeight(); + } + } + catch(ex) + { + this.error("postApplyDimensions failed", ex); + } + } +} + + + + +/* +--------------------------------------------------------------------------- + CHANGES IN DIMENSIONS +--------------------------------------------------------------------------- +*/ + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.Proto._changeInnerWidth = function(vNew, vOld) + { + if (this.getResizeToInner()) { + this._image.style.pixelWidth = vNew; + } + } + + qx.Proto._changeInnerHeight = function(vNew, vOld) + { + if (this.getResizeToInner()) { + this._image.style.pixelHeight = vNew; + } + } +} +else +{ + qx.Proto._changeInnerWidth = function(vNew, vOld) + { + if (this.getResizeToInner()) { + this._image.width = vNew; + } + } + + qx.Proto._changeInnerHeight = function(vNew, vOld) + { + if (this.getResizeToInner()) { + this._image.height = vNew; + } + } +} + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return true; + } + + var vPreloader = this.getPreloader(); + if (vPreloader) + { + // remove event connection + vPreloader.removeEventListener("load", this._onload, this); + vPreloader.removeEventListener("error", this._onerror, this); + + this.forcePreloader(null); + } + + if (this._image) + { + // Remove leaking filter attribute before leaving page + this._image.style.filter = ""; + this._image = null; + } + + qx.manager.object.ImageManager.getInstance().remove(this); + + return qx.ui.basic.Terminator.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Inline.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Inline.js new file mode 100644 index 0000000000..f6c59cf486 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Inline.js @@ -0,0 +1,37 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_basic) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.basic.Inline", qx.ui.layout.CanvasLayout, +function(vId) +{ + qx.ui.layout.CanvasLayout.call(this); + + this.setStyleProperty("position", "relative"); + + if (qx.util.Validation.isValidString(vId)) { + this.setInlineNodeId(vId); + } +}); + +qx.OO.addProperty({ name : "inlineNodeId", type : "string" }); diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Label.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Label.js new file mode 100644 index 0000000000..a284649d98 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Label.js @@ -0,0 +1,546 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_basic) +#require(qx.renderer.font.FontCache) +#after(qx.renderer.font.FontObject) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.basic.Label", qx.ui.basic.Terminator, +function(vHtml, vMnemonic) +{ + qx.ui.basic.Terminator.call(this); + + // Apply constructor arguments + if (qx.util.Validation.isValidString(vHtml)) { + this.setHtml(vHtml); + } + + if (qx.util.Validation.isValidString(vMnemonic)) { + this.setMnemonic(vMnemonic); + } + + // Prohibit stretching through layout handler + this.setAllowStretchX(false); + this.setAllowStretchY(false); + + // Auto Sized + this.auto(); +}); + +qx.Class._measureNodes = {}; + + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "label" }); + +/*! + Any text string which can contain HTML, too +*/ +qx.OO.addProperty({ name : "html", type : "string" }); + +/*! + The alignment of the text. +*/ +qx.OO.addProperty({ name : "textAlign", type : "string", defaultValue : "left", possibleValues : [ "left", "center", "right", "justify" ] }); + +/*! + The styles which should be copied +*/ +qx.OO.addProperty({ name : "fontPropertiesProfile", type : "string", defaultValue : "default", possibleValues : [ "none", "default", "extended", "multiline", "extendedmultiline", "all" ] }); + +/*! + A single character which will be underlined inside the text. +*/ +qx.OO.addProperty({ name : "mnemonic", type : "string" }); + +/*! + The font property describes how to paint the font on the widget. +*/ +qx.OO.addProperty({ name : "font", type : "object", instance : "qx.renderer.font.Font", convert : qx.renderer.font.FontCache, allowMultipleArguments : true }); + +/*! + Wrap the text? +*/ +qx.OO.addProperty({ name : "wrap", type : "boolean", defaultValue : true }); + + + + + + + + + +/* ************************************************************************ + Class data, properties and methods +************************************************************************ */ + +/* +--------------------------------------------------------------------------- + DATA +--------------------------------------------------------------------------- +*/ + +qx.ui.basic.Label.SYMBOL_ELLIPSIS = String.fromCharCode(8230); +qx.ui.basic.Label.SUPPORT_NATIVE_ELLIPSIS = qx.sys.Client.getInstance().isMshtml(); + +// these are the properties what will be copied to the measuring frame. +qx.ui.basic.Label._fontProperties = +{ + "none" : [], + + "default" : ["fontFamily", "fontSize", "fontStyle", "fontWeight", "textDecoration"], + "extended" : ["fontFamily", "fontSize", "fontStyle", "fontWeight", "letterSpacing", "textDecoration", "textTransform", "whiteSpace", "wordSpacing"], + + "multiline" : ["fontFamily", "fontSize", "fontStyle", "fontWeight", "textDecoration", "lineHeight", "wordWrap"], + "extendedmultiline" : ["fontFamily", "fontSize", "fontStyle", "fontWeight", "letterSpacing", "textDecoration", "textTransform", "whiteSpace", "wordSpacing", "lineHeight", "wordBreak", "wordWrap", "quotes"], + + "all" : ["fontFamily", "fontSize", "fontStyle", "fontVariant", "fontWeight", "letterSpacing", "lineBreak", "lineHeight", "quotes", "textDecoration", "textIndent", "textShadow", "textTransform", "textUnderlinePosition", "whiteSpace", "wordBreak", "wordSpacing", "wordWrap"] +} + +qx.ui.basic.Label.htmlToText = function(s) { + return String(s).replace(/\s+|<([^>])+>|&|<|>|"| |&#[0-9]+;|&#x[0-9a-fA-F];]/gi, qx.ui.basic.Label._htmlToText); +} + +qx.ui.basic.Label._htmlToText = function(s) +{ + switch(s) + { + case "&": + return "&"; + + case "<": + return "<"; + + case ">": + return ">"; + + case """: + return '"'; + + case " ": + return String.fromCharCode(160); + + default: + if (s.substring(0, 3) == "&#x") { + return String.fromCharCode(parseInt("0x" + s.substring(3, s.length - 1))); + } + else if (s.substring(0, 2) == "&#") { + return String.fromCharCode(s.substring(2, s.length - 1)); + } + else if (/\s+/.test(s)) { + return " "; + } + else if (/^<BR/gi.test(s)) { + return "\n"; + } + + return ""; + } +} + +qx.ui.basic.Label.textToHtml = function(s) { + return String(s).replace(/&|<|>|\n|\u00A0/g, qx.ui.basic.Label._textToHtml); +} + +qx.ui.basic.Label._textToHtml = function(s) +{ + switch(s) + { + case "&": + return "&"; + + case "<": + return "<"; + + case ">": + return ">"; + + case "\n": + return "<br/>"; + + default: + return " "; + } +} + +qx.ui.basic.Label.createMeasureNode = function(vId) +{ + var vNode = qx.ui.basic.Label._measureNodes[vId]; + + if (!vNode) + { + vNode = document.createElement("div"); + var vStyle = vNode.style; + + vStyle.width = vStyle.height = "auto"; + vStyle.visibility = "hidden"; + vStyle.position = "absolute"; + vStyle.zIndex = "-1"; + + document.body.appendChild(vNode); + + qx.ui.basic.Label._measureNodes[vId] = vNode; + } + + return vNode; +} + + + + + + + + +/* ************************************************************************ + Instance data, properties and methods +************************************************************************ */ + +/* +--------------------------------------------------------------------------- + MODIFIER +--------------------------------------------------------------------------- +*/ + +qx.Proto._htmlMode = false; +qx.Proto._hasMnemonic = false; +qx.Proto._mnemonicHtml = ""; +qx.Proto._mnemonicTest = null; + +qx.Proto._modifyHtml = function(propValue, propOldValue, propData) +{ + this._htmlMode = qx.util.Validation.isValidString(propValue) && propValue.match(/<.*>/) ? true : false; + + if (this._isCreated) { + this._applyContent(); + } + + return true; +} + +qx.Proto._modifyTextAlign = function(propValue, propOldValue, propData) +{ + this.setStyleProperty("textAlign", propValue); + return true; +} + +qx.Proto._modifyMnemonic = function(propValue, propOldValue, propData) +{ + this._hasMnemonic = qx.util.Validation.isValidString(propValue) && propValue.length == 1; + + this._mnemonicHtml = this._hasMnemonic ? "(<span style=\"text-decoration:underline\">" + propValue + "</span>)" : ""; + this._mnemonicTest = this._hasMnemonic ? new RegExp("^(((<([^>]|" + propValue + ")+>)|(&([^;]|" + propValue + ")+;)|[^&" + propValue + "])*)(" + propValue + ")", "i") : null; + + return true; +} + +qx.Proto._modifyFont = function(propValue, propOldValue, propData) +{ + this._invalidatePreferredInnerDimensions(); + + if (propValue) { + propValue._applyWidget(this); + } else if (propOldValue) { + propOldValue._resetWidget(this); + } + + return true; +} + +qx.Proto._modifyWrap = function(propValue, propOldValue, propData) +{ + this.setStyleProperty("whiteSpace", propValue ? "normal" : "nowrap"); + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + HELPER FOR PREFERRED DIMENSION +--------------------------------------------------------------------------- +*/ + +qx.Proto._computeObjectNeededDimensions = function() +{ + // copy styles + var vNode = this._copyStyles(); + + // prepare html + var vHtml = this.getHtml(); + + // test for mnemonic and fix content + if (this._hasMnemonic && !this._mnemonicTest.test(vHtml)) { + vHtml += this._mnemonicHtml; + } + + // apply html + vNode.innerHTML = vHtml; + + // store values + this._cachedPreferredInnerWidth = vNode.scrollWidth; + this._cachedPreferredInnerHeight = vNode.scrollHeight; +} + +qx.Proto._copyStyles = function() +{ + var vProps = this.getFontPropertiesProfile(); + var vNode = qx.ui.basic.Label.createMeasureNode(vProps); + var vUseProperties=qx.ui.basic.Label._fontProperties[vProps]; + var vUsePropertiesLength=vUseProperties.length-1; + var vProperty=vUseProperties[vUsePropertiesLength--]; + + var vStyle = vNode.style; + var vTemp; + + if (!vProperty) { + return vNode; + } + + do { + vStyle[vProperty] = qx.util.Validation.isValid(vTemp = this.getStyleProperty([vProperty])) ? vTemp : ""; + } while(vProperty=vUseProperties[vUsePropertiesLength--]); + + return vNode; +} + + + + + + +/* +--------------------------------------------------------------------------- + PREFERRED DIMENSIONS +--------------------------------------------------------------------------- +*/ + +qx.Proto._computePreferredInnerWidth = function() +{ + this._computeObjectNeededDimensions(); + return this._cachedPreferredInnerWidth; +} + +qx.Proto._computePreferredInnerHeight = function() +{ + this._computeObjectNeededDimensions(); + return this._cachedPreferredInnerHeight; +} + + + + + + +/* +--------------------------------------------------------------------------- + LAYOUT APPLY +--------------------------------------------------------------------------- +*/ + +qx.Proto._postApply = function() +{ + var vHtml = this.getHtml(); + var vElement = this._getTargetNode(); + var vMnemonicMode = 0; + + if (qx.util.Validation.isInvalidString(vHtml)) { + vElement.innerHTML = ""; + return; + } + + if (this._hasMnemonic) { + vMnemonicMode = this._mnemonicTest.test(vHtml) ? 1 : 2; + } + + // works only with text, don't use when wrap is enabled + if (!this._htmlMode && !this.getWrap()) + { + switch(this._computedWidthType) + { + case qx.ui.core.Widget.TYPE_PIXEL: + case qx.ui.core.Widget.TYPE_PERCENT: + + //carstenl: enabled truncation code for flex sizing, too. Appears to work except for the + // truncation code (gecko version), which I have disabled (see below). + case qx.ui.core.Widget.TYPE_FLEX: + var vNeeded = this.getPreferredInnerWidth(); + var vInner = this.getInnerWidth(); + + if (vInner < vNeeded) + { + vElement.style.overflow = "hidden"; + + if (qx.ui.basic.Label.SUPPORT_NATIVE_ELLIPSIS) + { + vElement.style.textOverflow = "ellipsis"; + vHtml += this._mnemonicHtml; + } + else + { + var vMeasureNode = this._copyStyles(); + + var vSplitString = vHtml.split(" "); + var vSplitLength = vSplitString.length; + + var vWordIterator = 0; + var vCharaterIterator = 0; + + var vPost = qx.ui.basic.Label.SYMBOL_ELLIPSIS; + + var vUseInnerText = true; + if (vMnemonicMode == 2) + { + var vPost = this._mnemonicHtml + vPost; + vUseInnerText = false; + } + + // Measure Words (if more than one) + if (vSplitLength > 1) + { + var vSplitTemp = []; + + for (vWordIterator=0; vWordIterator<vSplitLength; vWordIterator++) + { + vSplitTemp.push(vSplitString[vWordIterator]); + + var vLabelText = vSplitTemp.join(" ") + vPost; + if (vUseInnerText) { + qx.dom.Element.setTextContent(vMeasureNode, vLabelText); + } else { + vMeasureNode.innerHTML = vLabelText; + } + + if ((vMeasureNode.scrollWidth > vInner) + /* carstenl: The following code (truncate the text to fit in the available + * space, append ellipsis to indicate truncation) did not reliably + * work in my tests. Problem was that sometimes the measurer returned + * insanely high values for short texts, like "I..." requiring 738 px. + * + * I don't have time to examine this code in detail. Since all of my + * tests used flex width and the truncation code never was intended + * for this, I am disabling truncation if flex is active. + */ + && (this._computedWidthType != qx.ui.core.Widget.TYPE_FLEX)){ + break; + } + } + + // Remove last word which does not fit + vSplitTemp.pop(); + + // Building new temportary array + vSplitTemp = [ vSplitTemp.join(" ") ]; + + // Extracting remaining string + vCharaterString = vHtml.replace(vSplitTemp[0], ""); + } + else + { + var vSplitTemp = []; + vCharaterString = vHtml; + } + + var vCharaterLength = vCharaterString.length; + + // Measure Chars + for (var vCharaterIterator=0; vCharaterIterator<vCharaterLength; vCharaterIterator++) + { + vSplitTemp.push(vCharaterString.charAt(vCharaterIterator)); + + var vLabelText = vSplitTemp.join("") + vPost; + if (vUseInnerText) { + qx.dom.Element.setTextContent(vMeasureNode, vLabelText); + } else { + vMeasureNode.innerHTML = vLabelText; + } + + if (vMeasureNode.scrollWidth > vInner) { + break; + } + } + + // Remove last char which does not fit + vSplitTemp.pop(); + + // Add mnemonic and ellipsis symbol + vSplitTemp.push(vPost); + + // Building Final HTML String + vHtml = vSplitTemp.join(""); + } + + break; + } + else + { + vHtml += this._mnemonicHtml; + } + + // no break here + + default: + vElement.style.overflow = ""; + + if (qx.ui.basic.Label.SUPPORT_NATIVE_ELLIPSIS) { + vElement.style.textOverflow = ""; + } + } + } + + if (vMnemonicMode == 1) + { + // re-test: needed to make ellipsis handling correct + this._mnemonicTest.test(vHtml); + vHtml = RegExp.$1 + "<span style=\"text-decoration:underline\">" + RegExp.$7 + "</span>" + RegExp.rightContext; + } + + return this._postApplyHtml(vElement, vHtml, vMnemonicMode); +} + + +qx.Proto._postApplyHtml = function(vElement, vHtml, vMnemonicMode) +{ + if (this._htmlMode || vMnemonicMode > 0) + { + vElement.innerHTML = vHtml; + } + else + { + try { + qx.dom.Element.setTextContent(vElement, vHtml); + } catch(ex) { + vElement.innerHTML = vHtml; + } + } +}
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Terminator.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Terminator.js new file mode 100644 index 0000000000..2b77bb883c --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/Terminator.js @@ -0,0 +1,187 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_core) + +************************************************************************ */ + +/*! + This widget is the last widget of the current child chain. +*/ +qx.OO.defineClass("qx.ui.basic.Terminator", qx.ui.core.Widget, +function() { + qx.ui.core.Widget.call(this); +}); + + + + + + +/* +--------------------------------------------------------------------------- + APPLY PADDING +--------------------------------------------------------------------------- +*/ + +qx.Proto._applyPaddingX = function(vParent, vChanges, vStyle) +{ + if (vChanges.paddingLeft) { + this._applyRuntimePaddingLeft(this.getPaddingLeft()); + } + + if (vChanges.paddingRight) { + this._applyRuntimePaddingRight(this.getPaddingRight()); + } +} + +qx.Proto._applyPaddingY = function(vParent, vChanges, vStyle) +{ + if (vChanges.paddingTop) { + this._applyRuntimePaddingTop(this.getPaddingTop()); + } + + if (vChanges.paddingBottom) { + this._applyRuntimePaddingBottom(this.getPaddingBottom()); + } +} + + + + + + +/* +--------------------------------------------------------------------------- + APPLY CONTENT +--------------------------------------------------------------------------- +*/ + +qx.Proto._applyContent = function() +{ + // Small optimization: Only add innerPreferred jobs + // if we don't have a static width + if (this._computedWidthTypePixel) { + this._cachedPreferredInnerWidth = null; + } else { + this._invalidatePreferredInnerWidth(); + } + + // Small optimization: Only add innerPreferred jobs + // if we don't have a static height + if (this._computedHeightTypePixel) { + this._cachedPreferredInnerHeight = null; + } else { + this._invalidatePreferredInnerHeight(); + } + + // add load job + if (this._initialLayoutDone) { + this.addToJobQueue("load"); + } +} + +qx.Proto._layoutPost = function(vChanges) { + if (vChanges.initial || vChanges.load || vChanges.width || vChanges.height) { + this._postApply(); + } +} + +qx.Proto._postApply = qx.util.Return.returnTrue; + + + + + + + +/* +--------------------------------------------------------------------------- + BOX DIMENSION HELPERS +--------------------------------------------------------------------------- +*/ + +qx.Proto._computeBoxWidthFallback = qx.Proto.getPreferredBoxWidth; +qx.Proto._computeBoxHeightFallback = qx.Proto.getPreferredBoxHeight; + +qx.Proto._computePreferredInnerWidth = qx.util.Return.returnZero; +qx.Proto._computePreferredInnerHeight = qx.util.Return.returnZero; + + + + + + + +/* +--------------------------------------------------------------------------- + METHODS TO GIVE THE LAYOUTERS INFORMATIONS +--------------------------------------------------------------------------- +*/ + +qx.Proto._isWidthEssential = function() +{ + if (!this._computedLeftTypeNull && !this._computedRightTypeNull) { + return true; + } + + if (!this._computedWidthTypeNull && !this._computedWidthTypeAuto) { + return true; + } + + if (!this._computedMinWidthTypeNull && !this._computedMinWidthTypeAuto) { + return true; + } + + if (!this._computedMaxWidthTypeNull && !this._computedMaxWidthTypeAuto) { + return true; + } + + if (this._borderElement) { + return true; + } + + return false; +} + +qx.Proto._isHeightEssential = function() +{ + if (!this._computedTopTypeNull && !this._computedBottomTypeNull) { + return true; + } + + if (!this._computedHeightTypeNull && !this._computedHeightTypeAuto) { + return true; + } + + if (!this._computedMinHeightTypeNull && !this._computedMinHeightTypeAuto) { + return true; + } + + if (!this._computedMaxHeightTypeNull && !this._computedMaxHeightTypeAuto) { + return true; + } + + if (this._borderElement) { + return true; + } + + return false; +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/VerticalSpacer.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/VerticalSpacer.js new file mode 100644 index 0000000000..6887c9d3fd --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/ui/basic/VerticalSpacer.js @@ -0,0 +1,31 @@ +/* ************************************************************************ + + qooxdoo - the new era of web development + + http://qooxdoo.org + + Copyright: + 2004-2006 by 1&1 Internet AG, Germany, http://www.1and1.org + + License: + LGPL 2.1: http://www.gnu.org/licenses/lgpl.html + + Authors: + * Sebastian Werner (wpbasti) + * Andreas Ecker (ecker) + +************************************************************************ */ + +/* ************************************************************************ + +#module(ui_basic) + +************************************************************************ */ + +qx.OO.defineClass("qx.ui.basic.VerticalSpacer", qx.ui.basic.Terminator, +function() +{ + qx.ui.basic.Terminator.call(this); + + this.setHeight("1*"); +}); |