diff options
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer')
23 files changed, 6955 insertions, 0 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/Border.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/Border.js new file mode 100644 index 0000000000..37bee9153c --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/Border.js @@ -0,0 +1,1184 @@ +/* ************************************************************************ + + 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) +#require(qx.sys.Client) +#load(qx.renderer.border.BorderObject) + +************************************************************************ */ + +/*! + Border implementation for qx.ui.core.Widget instances. +*/ +qx.OO.defineClass("qx.renderer.border.Border", qx.core.Object, +function(vWidth, vStyle, vColor) +{ + qx.core.Object.call(this); + + this._themedEdges = {}; + this._initCache(); + + if (qx.util.Validation.isValidNumber(vWidth)) + { + this.setWidth(vWidth); + + if (qx.util.Validation.isValidString(vStyle)) { + this.setStyle(vStyle); + } + + if (qx.util.Validation.isValid(vColor)) { + this.setColor(vColor); + } + } +}); + + +qx.Class.enhancedCrossBrowserMode = true; + +qx.Proto._needsCompilationTop = true; +qx.Proto._needsCompilationRight = true; +qx.Proto._needsCompilationBottom = true; +qx.Proto._needsCompilationLeft = true; + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "topWidth", type : "number", defaultValue : 0, impl : "borderTopProperty" }); +qx.OO.addProperty({ name : "rightWidth", type : "number", defaultValue : 0, impl : "borderRightProperty" }); +qx.OO.addProperty({ name : "bottomWidth", type : "number", defaultValue : 0, impl : "borderBottomProperty" }); +qx.OO.addProperty({ name : "leftWidth", type : "number", defaultValue : 0, impl : "borderLeftProperty" }); + +qx.OO.addProperty({ name : "topStyle", type : "string", defaultValue : "none", impl : "borderTopProperty" }); +qx.OO.addProperty({ name : "rightStyle", type : "string", defaultValue : "none", impl : "borderRightProperty" }); +qx.OO.addProperty({ name : "bottomStyle", type : "string", defaultValue : "none", impl : "borderBottomProperty" }); +qx.OO.addProperty({ name : "leftStyle", type : "string", defaultValue : "none", impl : "borderLeftProperty" }); + +qx.OO.addProperty({ name : "topColor", impl : "borderTopProperty", type : "object", instance : "qx.renderer.color.Color", convert : qx.renderer.color.ColorCache }); +qx.OO.addProperty({ name : "rightColor", impl : "borderRightProperty", type : "object", instance : "qx.renderer.color.Color", convert : qx.renderer.color.ColorCache }); +qx.OO.addProperty({ name : "bottomColor", impl : "borderBottomProperty", type : "object", instance : "qx.renderer.color.Color", convert : qx.renderer.color.ColorCache }); +qx.OO.addProperty({ name : "leftColor", impl : "borderLeftProperty", type : "object", instance : "qx.renderer.color.Color", convert : qx.renderer.color.ColorCache }); + + + + +/* +--------------------------------------------------------------------------- + UTILITY +--------------------------------------------------------------------------- +*/ + +qx.renderer.border.Border.fromString = function(vDefString) +{ + var vBorder = new qx.renderer.border.Border; + var vAllParts = vDefString.split(/\s+/); + var vPart, vTemp; + + for (var i=0; i<vAllParts.length; i++) + { + switch(vPart = vAllParts[i]) + { + case "groove": + case "ridge": + case "inset": + case "outset": + case "solid": + case "dotted": + case "dashed": + case "double": + case "none": + vBorder.setStyle(vPart); + break; + + default: + vTemp = parseFloat(vPart); + + if(vTemp == vPart || qx.lang.String.contains(vPart, "px")) + { + vBorder.setWidth(vTemp); + } + else + { + vPart = vPart.toLowerCase(); + vBorder.setColor(new qx.renderer.color.Color(vPart)); + } + + break; + } + } + + return vBorder; +} + + + + + +/* +--------------------------------------------------------------------------- + COMPATIBILITY TO qx.renderer.border.BorderOBJECT +--------------------------------------------------------------------------- +*/ + +qx.Proto.addListenerWidget = qx.util.Return.returnTrue; +qx.Proto.removeListenerWidget = qx.util.Return.returnTrue; + +qx.Proto._sync = qx.util.Return.returnTrue; + + + + + +/* +--------------------------------------------------------------------------- + COMBINED SETTERS +--------------------------------------------------------------------------- +*/ + +qx.Proto.setWidth = function(vWidth) +{ + this.setTopWidth(vWidth); + this.setRightWidth(vWidth); + this.setBottomWidth(vWidth); + this.setLeftWidth(vWidth); + + return true; +} + +qx.Proto.setStyle = function(vStyle) +{ + this.setTopStyle(vStyle); + this.setRightStyle(vStyle); + this.setBottomStyle(vStyle); + this.setLeftStyle(vStyle); + + return true; +} + +qx.Proto.setColor = function(vColor) +{ + this.setTopColor(vColor); + this.setRightColor(vColor); + this.setBottomColor(vColor); + this.setLeftColor(vColor); + + return true; +} + + + + +qx.Proto.setTop = function(vWidth, vStyle, vColor) +{ + this.setTopWidth(vWidth); + this.setTopStyle(vStyle); + this.setTopColor(vColor); + + return true; +} + +qx.Proto.setRight = function(vWidth, vStyle, vColor) +{ + this.setRightWidth(vWidth); + this.setRightStyle(vStyle); + this.setRightColor(vColor); + + return true; +} + +qx.Proto.setBottom = function(vWidth, vStyle, vColor) +{ + this.setBottomWidth(vWidth); + this.setBottomStyle(vStyle); + this.setBottomColor(vColor); + + return true; +} + +qx.Proto.setLeft = function(vWidth, vStyle, vColor) +{ + this.setLeftWidth(vWidth); + this.setLeftStyle(vStyle); + this.setLeftColor(vColor); + + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + INITIALISATION OF CACHE +--------------------------------------------------------------------------- +*/ + + +if (qx.sys.Client.getInstance().isGecko()) +{ + qx.Proto._initCache = function() + { + this._defsX = + { + borderLeft : "", + borderRight : "", + + MozBorderLeftColors : "", + MozBorderRightColors : "" + } + + this._defsY = + { + borderTop : "", + borderBottom : "", + + MozBorderTopColors : "", + MozBorderBottomColors : "" + } + } +} +else +{ + qx.Proto._initCache = function() + { + this._defsX = + { + borderLeft : "", + borderRight : "" + } + + this._defsY = + { + borderTop : "", + borderBottom : "" + } + + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + this._enhancedDefsX = + { + borderLeft : "", + borderRight : "" + } + + this._enhancedDefsY = + { + borderTop : "", + borderBottom : "" + } + } + } +} + + +/* +--------------------------------------------------------------------------- + BORDER MODIFIER AND SYNCER +--------------------------------------------------------------------------- +*/ + +if (qx.sys.Client.getInstance().isGecko() || qx.renderer.border.Border.enhancedCrossBrowserMode) +{ + qx.Proto._addToThemed3DColors = function(vProp) + { + var needRegistering = qx.lang.Object.isEmpty(this._themedEdges); + + this._themedEdges[vProp] = true; + + if (needRegistering) + { + (new qx.renderer.color.ColorObject("ThreeDDarkShadow")).add(this); + (new qx.renderer.color.ColorObject("ThreeDShadow")).add(this); + (new qx.renderer.color.ColorObject("ThreeDLightShadow")).add(this); + (new qx.renderer.color.ColorObject("ThreeDHighlight")).add(this); + } + } + + qx.Proto._removeFromThemed3DColors = function(vProp) + { + delete this._themedEdges[vProp]; + + if (qx.lang.Object.isEmpty(this._themedEdges)) + { + (new qx.renderer.color.ColorObject("ThreeDDarkShadow")).remove(this); + (new qx.renderer.color.ColorObject("ThreeDShadow")).remove(this); + (new qx.renderer.color.ColorObject("ThreeDLightShadow")).remove(this); + (new qx.renderer.color.ColorObject("ThreeDHighlight")).remove(this); + } + } +} +else +{ + qx.Proto._addToThemed3DColors = function(vProp) + { + var needRegistering = qx.lang.Object.isEmpty(this._themedEdges); + + this._themedEdges[vProp] = true; + + if (needRegistering) + { + (new qx.renderer.color.ColorObject("ThreeDLightShadow")).add(this); + } + } + + qx.Proto._removeFromThemed3DColors = function(vProp) + { + delete this._themedEdges[vProp]; + + if (qx.lang.Object.isEmpty(this._themedEdges)) + { + (new qx.renderer.color.ColorObject("ThreeDLightShadow")).remove(this); + } + } +} + + + + + +qx.renderer.border.Border.data = +{ + 1 : + { + outset : + { + top : [ "threedhighlight" ], + right : [ "threedshadow" ], + bottom : [ "threedshadow" ], + left : [ "threedhighlight" ] + }, + + inset : + { + top : [ "threedshadow" ], + right : [ "threedhighlight" ], + bottom : [ "threedhighlight" ], + left : [ "threedshadow" ] + } + }, + + 2 : + { + outset : + { + top : [ "threedlightshadow", "threedhighlight" ], + right : [ "threeddarkshadow", "threedshadow" ], + bottom : [ "threeddarkshadow", "threedshadow" ], + left : [ "threedlightshadow", "threedhighlight" ] + }, + + inset : + { + top : [ "threedshadow", "threeddarkshadow" ], + right : [ "threedhighlight", "threedlightshadow" ], + bottom : [ "threedhighlight", "threedlightshadow" ], + left : [ "threedshadow", "threeddarkshadow" ] + }, + + ridge : + { + top : [ "threedhighlight", "threedshadow" ], + right : [ "threedshadow", "threedhighlight" ], + bottom : [ "threedshadow", "threedhighlight" ], + left : [ "threedhighlight", "threedshadow" ] + }, + + groove : + { + top : [ "threedshadow", "threedhighlight" ], + right : [ "threedhighlight", "threedshadow" ], + bottom : [ "threedhighlight", "threedshadow" ], + left : [ "threedshadow", "threedhighlight" ] + } + } +} + + + + + +qx.Proto._generateDefString = function(vWidth, vStyle, vColor) +{ + if (typeof vWidth !== "number" || vWidth < 0) { + return ""; + } + + var vArr = [ vWidth + "px" ]; + + if (qx.util.Validation.isValidString(vStyle)) { + vArr.push(vStyle); + } + + if (qx.util.Validation.isValidObject(vColor) && vColor instanceof qx.renderer.color.Color) { + vColor = vColor.getStyle(); + } + + if (qx.util.Validation.isValidString(vColor)) { + vArr.push(vColor); + } + + return vArr.join(" "); +} + + + + +// TODO: Add more smartness ;) +// Only update the border edges which depends on this color object +qx.Proto._updateColors = function(vColorObject, vNewValue) +{ + this._needsCompilationTop = true; + this._needsCompilationRight = true; + this._needsCompilationBottom = true; + this._needsCompilationLeft = true; + + this._sync("top"); + this._sync("right"); + this._sync("bottom"); + this._sync("left"); +} + + + + + + + +qx.Proto._handleColorRegistration = function(propValue, propOldValue, propData) +{ + if (qx.lang.String.contains(propData.name, "Style")) + { + switch(propValue) + { + case "outset": + case "inset": + case "groove": + case "ridge": + this._addToThemed3DColors(propData.name); + break; + + default: + this._removeFromThemed3DColors(propData.name); + } + } + + if (qx.lang.String.contains(propData.name, "Color")) + { + if (propOldValue instanceof qx.renderer.color.ColorObject) + { + // detect if there are no other deps anymore + switch(propOldValue) + { + case this.getTopColor(): + case this.getRightColor(): + case this.getBottomColor(): + case this.getLeftColor(): + break; + + default: + propOldValue.remove(this); + } + } + + if (propValue instanceof qx.renderer.color.ColorObject) + { + // simply add, internal storage is a hash key so + // this is not a problem also if this is already + // registered there. + propValue.add(this); + } + } +} + + + + + + + + +qx.Proto._modifyBorderTopProperty = function(propValue, propOldValue, propData) +{ + this._handleColorRegistration(propValue, propOldValue, propData); + + this._needsCompilationTop = true; + this._useEnhancedCrossBrowserMode = null; + + this._sync("top"); + + return true; +} + +qx.Proto._modifyBorderRightProperty = function(propValue, propOldValue, propData) +{ + this._handleColorRegistration(propValue, propOldValue, propData); + + this._needsCompilationRight = true; + this._useEnhancedCrossBrowserMode = null; + + this._sync("right"); + + return true; +} + +qx.Proto._modifyBorderBottomProperty = function(propValue, propOldValue, propData) +{ + this._handleColorRegistration(propValue, propOldValue, propData); + + this._needsCompilationBottom = true; + this._useEnhancedCrossBrowserMode = null; + + this._sync("bottom"); + + return true; +} + +qx.Proto._modifyBorderLeftProperty = function(propValue, propOldValue, propData) +{ + this._handleColorRegistration(propValue, propOldValue, propData); + + this._needsCompilationLeft = true; + this._useEnhancedCrossBrowserMode = null; + + this._sync("left"); + + return true; +} + + + + + + + + + +qx.Proto.getUseEnhancedCrossBrowserMode = function() +{ + if (this._useEnhancedCrossBrowserMode == null) { + this._useEnhancedCrossBrowserMode = this._evalUseEnhancedCrossBrowserMode(); + } + + return this._useEnhancedCrossBrowserMode; +} + +qx.Proto._evalUseEnhancedCrossBrowserMode = function() +{ + if (this.getTopWidth() == 2) { + switch(this.getTopStyle()) { + case "outset": case "inset": case "groove": case "ridge": return true; + } + } + + if (this.getRightWidth() == 2) { + switch(this.getRightStyle()) { + case "outset": case "inset": case "groove": case "ridge": return true; + } + } + + if (this.getBottomWidth() == 2) { + switch(this.getBottomStyle()) { + case "outset": case "inset": case "groove": case "ridge": return true; + } + } + + if (this.getLeftWidth() == 2) { + switch(this.getLeftStyle()) { + case "outset": case "inset": case "groove": case "ridge": return true; + } + } + + return false; +} + + + + + + +/* +--------------------------------------------------------------------------- + BORDER APPLY IMPLEMENTATION +--------------------------------------------------------------------------- +*/ + +qx.Proto._applyWidget = function(o) +{ + this._applyWidgetX(o); + this._applyWidgetY(o); +} + +qx.Proto._resetWidget = function(o) +{ + this._resetWidgetX(o); + this._resetWidgetY(o); +} + +qx.Proto._resetWidgetX = function(o) { + return qx.renderer.border.Border._resetBorderX(o); +} + +qx.Proto._resetWidgetY = function(o) { + return qx.renderer.border.Border._resetBorderY(o); +} + +qx.Proto._applyWidgetXCommon = function(vObject) +{ + if (this._needsCompilationLeft) { + this._compileLeft(); + } + + if (this._needsCompilationRight) { + this._compileRight(); + } + + for (var i in this._defsX) { + vObject._style[i] = this._defsX[i]; + } + + if (!qx.sys.Client.getInstance().isGecko() && qx.renderer.border.Border.enhancedCrossBrowserMode) + { + if (this.getUseEnhancedCrossBrowserMode()) { + vObject._createElementForEnhancedBorder(); + } + + if (vObject._borderStyle) + { + for (var i in this._enhancedDefsX) { + vObject._borderStyle[i] = this._enhancedDefsX[i]; + } + } + } +} + +qx.Proto._applyWidgetYCommon = function(vObject) +{ + if (this._needsCompilationTop) { + this._compileTop(); + } + + if (this._needsCompilationBottom) { + this._compileBottom(); + } + + for (var i in this._defsY) { + vObject._style[i] = this._defsY[i]; + } + + if (!qx.sys.Client.getInstance().isGecko() && qx.renderer.border.Border.enhancedCrossBrowserMode) + { + if (this.getUseEnhancedCrossBrowserMode()) { + vObject._createElementForEnhancedBorder(); + } + + if (vObject._borderStyle) + { + for (var i in this._enhancedDefsY) { + vObject._borderStyle[i] = this._enhancedDefsY[i]; + } + } + } +} + +if (qx.sys.Client.getInstance().isGecko()) +{ + qx.Proto._applyWidgetX = qx.Proto._applyWidgetXCommon; + qx.Proto._applyWidgetY = qx.Proto._applyWidgetYCommon; + + qx.Proto._generateMozColorDefString = function(vWidth, vStyle, vEdge) + { + try + { + try { + var a = qx.renderer.border.Border.data[vWidth][vStyle][vEdge]; + } catch(ex) {} + + if (typeof a === "object") + { + for (var i=0, s=[], l=a.length; i<l; i++) { + s.push((new qx.renderer.color.ColorObject(a[i]).getStyle())); + } + + return s.join(" "); + } + } + catch(ex) { + this.error("Failed to generate Mozilla Color Definition Strings", ex); + } + + return ""; + } + + qx.Proto._compileTop = function() + { + var w=this.getTopWidth(), s=this.getTopStyle(), d=this._defsY; + + d.borderTop = this._generateDefString(w, s, this.getTopColor()); + d.MozBorderTopColors = this._generateMozColorDefString(w, s, "top"); + + this._needsCompilationTop = false; + } + + qx.Proto._compileRight = function() + { + var w=this.getRightWidth(), s=this.getRightStyle(), d=this._defsX; + + d.borderRight = this._generateDefString(w, s, this.getRightColor()); + d.MozBorderRightColors = this._generateMozColorDefString(w, s, "right"); + + this._needsCompilationRight = false; + } + + qx.Proto._compileBottom = function() + { + var w=this.getBottomWidth(), s=this.getBottomStyle(), d=this._defsY; + + d.borderBottom = this._generateDefString(w, s, this.getBottomColor()); + d.MozBorderBottomColors = this._generateMozColorDefString(w, s, "bottom"); + + this._needsCompilationBottom = false; + } + + qx.Proto._compileLeft = function() + { + var w=this.getLeftWidth(), s=this.getLeftStyle(), d=this._defsX; + + d.borderLeft = this._generateDefString(w, s, this.getLeftColor()); + d.MozBorderLeftColors = this._generateMozColorDefString(w, s, "left"); + + this._needsCompilationLeft = false; + } + + qx.renderer.border.Border._resetBorderX = function(o) + { + var s = o._style; + s.borderLeft = s.borderRight = s.MozBorderLeftColors = s.MozBorderRightColors = ""; + } + + qx.renderer.border.Border._resetBorderY = function(o) + { + var s = o._style; + s.borderTop = s.borderBottom = s.MozBorderTopColors = s.MozBorderBottomColors = ""; + } +} +else +{ + qx.Proto._applyWidgetX = function(vObject) + { + this._applyWidgetXCommon(vObject); + + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + if (this.getUseEnhancedCrossBrowserMode()) { + vObject._createElementForEnhancedBorder(); + } + + if (vObject._borderStyle) + { + for (var i in this._enhancedDefsX) { + vObject._borderStyle[i] = this._enhancedDefsX[i]; + } + } + } + } + + qx.Proto._applyWidgetY = function(vObject) + { + this._applyWidgetYCommon(vObject); + + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + if (this.getUseEnhancedCrossBrowserMode()) { + vObject._createElementForEnhancedBorder(); + } + + if (vObject._borderStyle) + { + for (var i in this._enhancedDefsY) { + vObject._borderStyle[i] = this._enhancedDefsY[i]; + } + } + } + } + + qx.Proto._compileTop = function() + { + var vTopWidth = this.getTopWidth(); + var vTopStyle = this.getTopStyle(); + var vTopColor = this.getTopColor(); + + switch(vTopWidth) + { + case 1: + switch(vTopStyle) + { + case "outset": + case "inset": + vTopColor = (new qx.renderer.color.ColorObject(qx.renderer.border.Border.data[vTopWidth][vTopStyle]["top"][0])); + vTopStyle = "solid"; + } + + break; + + case 2: + switch(vTopStyle) + { + case "outset": + case "inset": + case "groove": + case "ridge": + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + try + { + var c = qx.renderer.border.Border.data[vTopWidth][vTopStyle]["top"]; + + if (typeof c === "object") + { + vTopStyle = "solid"; + vTopWidth = 1; + vTopColor = (new qx.renderer.color.ColorObject(c[1])); + + this._enhancedDefsY.borderTop = this._generateDefString(vTopWidth, vTopStyle, vTopColor); + + vTopColor = (new qx.renderer.color.ColorObject(c[0])); + } + } + catch(ex) + { + this.error("Failed to compile top border", ex); + this.warn("Details: Width=" + vTopWidth + ", Style=" + vTopStyle); + } + } + else + { + vTopColor = (new qx.renderer.color.ColorObject("threedlightshadow")); + } + } + + break; + } + + this._defsY.borderTop = this._generateDefString(vTopWidth, vTopStyle, vTopColor); + this._needsCompilationTop = false; + } + + qx.Proto._compileRight = function() + { + var vRightWidth = this.getRightWidth(); + var vRightStyle = this.getRightStyle(); + var vRightColor = this.getRightColor(); + + switch(vRightWidth) + { + case 1: + switch(vRightStyle) + { + case "outset": + case "inset": + vRightColor = (new qx.renderer.color.ColorObject(qx.renderer.border.Border.data[vRightWidth][vRightStyle]["right"][0])); + vRightStyle = "solid"; + } + + break; + + case 2: + switch(vRightStyle) + { + case "outset": + case "inset": + case "groove": + case "ridge": + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + try + { + var c = qx.renderer.border.Border.data[vRightWidth][vRightStyle]["right"]; + + if (typeof c === "object") + { + vRightStyle = "solid"; + vRightWidth = 1; + vRightColor = (new qx.renderer.color.ColorObject(c[1])); + + this._enhancedDefsX.borderRight = this._generateDefString(vRightWidth, vRightStyle, vRightColor); + + vRightColor = (new qx.renderer.color.ColorObject(c[0])); + } + } + catch(ex) + { + this.error("Failed to compile right border", ex); + this.warn("Details: Width=" + vRightWidth + ", Style=" + vRightStyle); + } + } + else + { + vRightColor = (new qx.renderer.color.ColorObject("threedlightshadow")); + } + } + + break; + } + + this._defsX.borderRight = this._generateDefString(vRightWidth, vRightStyle, vRightColor); + this._needsCompilationRight = false; + } + + qx.Proto._compileBottom = function() + { + var vBottomWidth = this.getBottomWidth(); + var vBottomStyle = this.getBottomStyle(); + var vBottomColor = this.getBottomColor(); + + switch(vBottomWidth) + { + case 1: + switch(vBottomStyle) + { + case "outset": + case "inset": + vBottomColor = (new qx.renderer.color.ColorObject(qx.renderer.border.Border.data[vBottomWidth][vBottomStyle]["bottom"][0])); + vBottomStyle = "solid"; + } + + break; + + case 2: + switch(vBottomStyle) + { + case "outset": + case "inset": + case "groove": + case "ridge": + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + try + { + var c = qx.renderer.border.Border.data[vBottomWidth][vBottomStyle]["bottom"]; + + if (typeof c === "object") + { + vBottomStyle = "solid"; + vBottomWidth = 1; + vBottomColor = (new qx.renderer.color.ColorObject(c[1])); + + this._enhancedDefsY.borderBottom = this._generateDefString(vBottomWidth, vBottomStyle, vBottomColor); + + vBottomColor = (new qx.renderer.color.ColorObject(c[0])); + } + } + catch(ex) { + this.error("Failed to compile bottom border", ex); + this.warn("Details: Width=" + vBottomWidth + ", Style=" + vBottomStyle); + } + } + else + { + vBottomColor = (new qx.renderer.color.ColorObject("threedlightshadow")); + } + } + + break; + } + + this._defsY.borderBottom = this._generateDefString(vBottomWidth, vBottomStyle, vBottomColor); + this._needsCompilationBottom = false; + } + + qx.Proto._compileLeft = function() + { + var vLeftWidth = this.getLeftWidth(); + var vLeftStyle = this.getLeftStyle(); + var vLeftColor = this.getLeftColor(); + + switch(vLeftWidth) + { + case 1: + switch(vLeftStyle) + { + case "outset": + case "inset": + vLeftColor = (new qx.renderer.color.ColorObject(qx.renderer.border.Border.data[vLeftWidth][vLeftStyle]["left"][0])); + vLeftStyle = "solid"; + } + + break; + + case 2: + switch(vLeftStyle) + { + case "outset": + case "inset": + case "groove": + case "ridge": + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + try + { + var c = qx.renderer.border.Border.data[vLeftWidth][vLeftStyle]["left"]; + + if (typeof c === "object") + { + vLeftStyle = "solid"; + vLeftWidth = 1; + vLeftColor = (new qx.renderer.color.ColorObject(c[1])); + + this._enhancedDefsX.borderLeft = this._generateDefString(vLeftWidth, vLeftStyle, vLeftColor); + + vLeftColor = (new qx.renderer.color.ColorObject(c[0])); + } + } + catch(ex) { + this.error("Failed to compile left border", ex); + this.warn("Details: Width=" + vLeftWidth + ", Style=" + vLeftStyle); + } + } + else + { + vLeftColor = (new qx.renderer.color.ColorObject("threedlightshadow")); + } + } + + break; + } + + this._defsX.borderLeft = this._generateDefString(vLeftWidth, vLeftStyle, vLeftColor); + this._needsCompilationLeft = false; + } + + qx.renderer.border.Border._resetBorderX = function(o) + { + var s = o._style; + s.borderLeft = s.borderRight = "0px none"; + + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + s = o._borderStyle; + if (s) { + s.borderLeft = s.borderRight = "0px none"; + } + } + } + + qx.renderer.border.Border._resetBorderY = function(o) + { + var s = o._style; + s.borderTop = s.borderBottom = "0px none"; + + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + s = o._borderStyle; + if (s) { + s.borderTop = s.borderBottom = "0px none"; + } + } + } +} + + + + + + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + if (typeof this._defsX === "object") { + for (var i in this._defsX) { + delete this._defsX[i]; + } + } + + delete this._defsX; + + if (typeof this._defsY === "object") { + for (var i in this._defsY) { + delete this._defsY[i]; + } + } + + delete this._defsY; + + if (qx.renderer.border.Border.enhancedCrossBrowserMode) + { + if (typeof this._enhancedDefsX === "object") { + for (var i in this._enhancedDefsX) { + delete this._enhancedDefsX[i]; + } + } + + delete this._enhancedDefsX; + + if (typeof this._enhancedDefsY === "object") { + for (var i in this._enhancedDefsY) { + delete this._enhancedDefsY[i]; + } + } + + delete this._enhancedDefsY; + } + + delete this._themedEdges; + + return qx.core.Object.prototype.dispose.call(this); +} + + + + + + + + +/* +--------------------------------------------------------------------------- + PRESETS +--------------------------------------------------------------------------- +*/ + +/* +qx.Class.presets = +{ + black : new qx.Class(1, "solid", "black"), + white : new qx.Class(1, "solid", "white"), + none : new qx.Class(0, "none") +} +*/ diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderCache.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderCache.js new file mode 100644 index 0000000000..cb94559b23 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderCache.js @@ -0,0 +1,62 @@ +/* ************************************************************************ + + 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) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.border.BorderCache"); + +qx.renderer.border.BorderCache = function(propValue, propData) +{ + if (qx.util.Validation.isValidArray(propValue) && propValue.length > 1) + { + propString = ""; + + for (var i=0, l=propValue.length, p; i<l; i++) + { + p = propValue[i]; + + propString += p; + + if (typeof p === "number") { + propString += "px"; + } + + if (i<(l-1)) { + propString += " "; + } + } + + propValue = propString; + } + else if (qx.util.Validation.isInvalidString(propValue)) + { + return propValue; + } + + if (qx.renderer.border.BorderCache._data[propValue]) { + return qx.renderer.border.BorderCache._data[propValue]; + } + + return qx.renderer.border.BorderCache._data[propValue] = qx.renderer.border.BorderObject.fromString(propValue); +} + +qx.renderer.border.BorderCache._data = {}; diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderObject.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderObject.js new file mode 100644 index 0000000000..e8e1dc0fcc --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderObject.js @@ -0,0 +1,149 @@ +/* ************************************************************************ + + 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) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.border.BorderObject", qx.renderer.border.Border, +function(vWidth, vStyle, vColor) +{ + this._dependentObjects = {}; + + qx.renderer.border.Border.call(this, vWidth, vStyle, vColor); +}); + + + +/* +--------------------------------------------------------------------------- + UTILITY +--------------------------------------------------------------------------- +*/ + +qx.renderer.border.BorderObject.fromString = function(vDefString) +{ + var vBorder = new qx.renderer.border.BorderObject; + var vAllParts = vDefString.split(/\s+/); + var vPart, vTemp; + + for (var i=0; i<vAllParts.length; i++) + { + vPart = vAllParts[i]; + + switch(vPart) + { + case "groove": + case "ridge": + case "inset": + case "outset": + case "solid": + case "dotted": + case "dashed": + case "double": + case "none": + vBorder.setStyle(vPart); + break; + + default: + vTemp = parseFloat(vPart); + + if(vTemp == vPart || qx.lang.String.contains(vPart, "px")) + { + vBorder.setWidth(vTemp); + } + else + { + vPart = vPart.toLowerCase(); + vBorder.setColor(qx.renderer.color.Color.themedNames[vPart] ? new qx.renderer.color.ColorObject(vPart) : new qx.renderer.color.Color(vPart)); + } + + break; + } + } + + return vBorder; +} + + + + + + +/* +--------------------------------------------------------------------------- + WIDGET CONNECTION +--------------------------------------------------------------------------- +*/ + +qx.Proto.addListenerWidget = function(o) { + this._dependentObjects[o.toHashCode()] = o; +} + +qx.Proto.removeListenerWidget = function(o) { + delete this._dependentObjects[o.toHashCode()]; +} + +qx.Proto._sync = function(vEdge) +{ + var vAll = this._dependentObjects; + var vCurrent; + + for (vKey in vAll) + { + vCurrent = vAll[vKey]; + + if (vCurrent.isCreated()) { + vCurrent._updateBorder(vEdge); + } + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + if (typeof this._dependentObjects === "object") + { + var vAll = this._dependentObjects; + for (vKey in vAll) { + delete vAll[vKey]; + } + + vAll = null; + delete this._dependentObjects; + } + + return qx.renderer.border.Border.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderPresets.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderPresets.js new file mode 100644 index 0000000000..9a0f8630c9 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/border/BorderPresets.js @@ -0,0 +1,71 @@ +/* ************************************************************************ + + 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) + +************************************************************************ */ + +/*! + Some common used border styles. +*/ +qx.OO.defineClass("qx.renderer.border.BorderPresets", qx.core.Object, function() +{ + qx.core.Object.call(this); + + this.black = new qx.renderer.border.Border(1, "solid", "black"); + this.white = new qx.renderer.border.Border(1, "solid", "white"); + this.none = new qx.renderer.border.Border(0, "none"); + + this.inset = new qx.renderer.border.BorderObject(2, "inset"); + this.outset = new qx.renderer.border.BorderObject(2, "outset"); + this.groove = new qx.renderer.border.BorderObject(2, "groove"); + this.ridge = new qx.renderer.border.BorderObject(2, "ridge"); + this.thinInset = new qx.renderer.border.BorderObject(1, "inset"); + this.thinOutset = new qx.renderer.border.BorderObject(1, "outset"); + + this.verticalDivider = new qx.renderer.border.BorderObject(1, "inset"); + this.verticalDivider.setLeftWidth(0); + this.verticalDivider.setRightWidth(0); + + this.horizontalDivider = new qx.renderer.border.BorderObject(1, "inset"); + this.horizontalDivider.setTopWidth(0); + this.horizontalDivider.setBottomWidth(0); + + this.shadow = new qx.renderer.border.BorderObject(1, "solid", "threedshadow"); + this.lightShadow = new qx.renderer.border.BorderObject(1, "solid", "threedlightshadow"); + this.info = new qx.renderer.border.BorderObject(1, "solid", "infotext"); +}); + + + + + + + +/* +--------------------------------------------------------------------------- + DEFER SINGLETON INSTANCE +--------------------------------------------------------------------------- +*/ + +/** + * Singleton Instance Getter + */ +qx.Class.getInstance = qx.util.Return.returnInstance; diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/Color.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/Color.js new file mode 100644 index 0000000000..868ac6f496 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/Color.js @@ -0,0 +1,542 @@ +/* ************************************************************************ + + 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) +#require(qx.util.Return) +#load(qx.renderer.color.ColorObject) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.color.Color", qx.core.Object, +function(vValue) +{ + if (qx.util.Validation.isValid(vValue)) { + this.setValue(vValue); + } + + qx.core.Object.call(this); +}); + + + + + +/* ************************************************************************ + Class data, properties and methods +************************************************************************ */ + +/* +--------------------------------------------------------------------------- + CORE METHODS +--------------------------------------------------------------------------- +*/ + +qx.renderer.color.Color.rgb2style = function(r, g, b) { + return "rgb(" + r + "," + g + "," + b + ")"; +} + + + + + +/* +--------------------------------------------------------------------------- + CORE DATA +--------------------------------------------------------------------------- +*/ + +qx.renderer.color.Color.m_hex = [ "0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f" ]; +qx.renderer.color.Color.m_rgb = { 0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15 } + +qx.renderer.color.Color.r_hex3 = /^#([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})$/; +qx.renderer.color.Color.r_hex6 = /^#([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})([0-9a-f]{1})$/; +qx.renderer.color.Color.r_cssrgb = /^rgb\(\s*([0-9]{1,3}\.{0,1}[0-9]*)\s*,\s*([0-9]{1,3}\.{0,1}[0-9]*)\s*,\s*([0-9]{1,3}\.{0,1}[0-9]*)\s*\)$/; + +qx.renderer.color.Color.r_rgb = /^[0-9]{1,3},[0-9]{1,3},[0-9]{1,3}$/; +qx.renderer.color.Color.r_number = /^[0-9]{1,3}\.{0,1}[0-9]*$/; +qx.renderer.color.Color.r_percent = /^[0-9]{1,3}\.{0,1}[0-9]*%$/; + +qx.renderer.color.Color.htmlNames = +{ + maroon : [ 128,0,0 ], + red : [ 255,0,0 ], + orange : [ 255,165,0 ], + yellow : [ 255,255,0 ], + olive : [ 128,128,0 ], + purple : [ 128,0,128 ], + fuchsia : [ 255,0,255 ], + white : [ 255,255,255 ], + lime : [ 0,255,0 ], + green : [ 0,128,0 ], + navy : [ 0,0,128 ], + blue : [ 0,0,255 ], + aqua : [ 0,255,255 ], + teal : [ 0,128,128 ], + black : [ 0,0,0 ], + silver : [ 192,192,192 ], + gray : [ 128,128,128 ], + transparent : [-1,-1,-1] +} + +// TODO: Add some IE related colors (IE 4.x) +// http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/colors/colors.asp +/* +qx.renderer.color.Color.cssNames = +{ + +} +*/ + +/* + ActiveBorder: Active window border. + ActiveCaption: Active window caption. + + AppWorkspace: Background color of multiple document interface. + Background: Desktop background. + + ButtonFace: Face color for three-dimensional display elements. + ButtonHighlight: Highlight color for three-dimensional display elements (for edges facing away from the light source). + ButtonShadow: Shadow color for three-dimensional display elements. + ButtonText: Text on push buttons. + + CaptionText: Text in caption, size box, and scrollbar arrow box. + GrayText: Grayed (disabled) text. + + Highlight: Item(s) selected in a control. + HighlightText: Text of item(s) selected in a control. + + InactiveBorder: Inactive window border. + InactiveCaption: Inactive window caption. + InactiveCaptionText: Color of text in an inactive caption. + + InfoBackground: Background color for tooltip controls. + InfoText: Text color for tooltip controls. + + Menu: Menu background. + MenuText: Text in menus. + + Scrollbar: Scroll bar gray area. + + ThreeDDarkShadow: Dark shadow for three-dimensional display elements. + ThreeDFace: Face color for three-dimensional display elements. + ThreeDHighlight: Highlight color for three-dimensional display elements. + ThreeDLightShadow: Light color for three-dimensional display elements (for edges facing the light source). + ThreeDShadow: Dark shadow for three-dimensional display elements. + + Window: Window background. + WindowFrame: Window frame. + WindowText: Text in windows. +*/ + +qx.renderer.color.Color.themedNames = +{ + activeborder : 1, + activecaption : 1, + appworkspace : 1, + background : 1, + buttonface : 1, + buttonhighlight : 1, + buttonshadow : 1, + buttontext : 1, + captiontext : 1, + graytext : 1, + highlight : 1, + highlighttext : 1, + inactiveborder : 1, + inactivecaption : 1, + inactivecaptiontext : 1, + infobackground : 1, + infotext : 1, + menu : 1, + menutext : 1, + scrollbar : 1, + threeddarkshadow : 1, + threedface : 1, + threedhighlight : 1, + threedlightshadow : 1, + threedshadow : 1, + window : 1, + windowframe : 1, + windowtext : 1 +} + + + + + + + +/* ************************************************************************ + Instance data, properties and methods +************************************************************************ */ + +/* +--------------------------------------------------------------------------- + UTILITY +--------------------------------------------------------------------------- +*/ + +qx.renderer.color.Color.fromString = function(vDefString) { + return new qx.renderer.color.Color(vDefString); +} + +qx.renderer.color.Color.fromRandom = function() { + return new qx.renderer.color.Color([Math.round(255*Math.random()), Math.round(255*Math.random()), Math.round(255*Math.random())]); +} + + + + + + +/* +--------------------------------------------------------------------------- + DATA +--------------------------------------------------------------------------- +*/ + +qx.Proto._value = null; +qx.Proto._style = null; + +qx.Proto._isRgbColor = false; +qx.Proto._isHtmlColor = false; +qx.Proto._isThemedColor = false; + +qx.Proto._red = null; +qx.Proto._green = null; +qx.Proto._blue = null; + +qx.Proto._hex = null; + + + + + +/* +--------------------------------------------------------------------------- + COMPATIBILITY METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto.add = qx.util.Return.returnTrue; +qx.Proto.remove = qx.util.Return.returnTrue; + + + + + + +/* +--------------------------------------------------------------------------- + PUBLIC METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto.isRgbColor = function() { + return this._isRgbColor; +} + +qx.Proto.isHtmlColor = function() { + return this._isHtmlColor; +} + +qx.Proto.isThemedColor = function() { + return this._isThemedColor; +} + + + + +qx.Proto.setValue = function(vValue) +{ + this._normalize(vValue); + + if (this._isThemedColor) { + throw new Error("Please use qx.renderer.color.ColorObject for themed colors!"); + } +} + +qx.Proto.getValue = function() { + return this._value || ""; +} + + + + +qx.Proto.getStyle = function() +{ + if (this._style == null) { + this._evalStyle(); + } + + return this._style; +} + +qx.Proto._evalStyle = function() +{ + if (this._isRgbColor) + { + this._style = qx.renderer.color.Color.rgb2style(this._red, this._green, this._blue); + } + else if (this._isThemedColor) + { + this._applyThemedValue(); + } + else if (this._isHtmlColor) + { + this._style = this._value; + } + else if (qx.util.Validation.isValid(this._value)) + { + throw new Error("_evalStyle could not handle non-rgb colors :" + this.getValue() + "!"); + } +} + + + + +qx.Proto.getHex = function() +{ + if (this._hex == null) { + this._evalHex(); + } + + return this._hex; +} + +qx.Proto._evalHex = function() +{ + if (this._isRgbColor) + { + var a = ["#"]; + + var r = this.getRed(); + a.push(qx.renderer.color.Color.m_hex[Math.floor(r/16)]); + a.push(qx.renderer.color.Color.m_hex[Math.floor(r%16)]); + + var g = this.getGreen(); + a.push(qx.renderer.color.Color.m_hex[Math.floor(g/16)]); + a.push(qx.renderer.color.Color.m_hex[Math.floor(g%16)]); + + var b = this.getBlue(); + a.push(qx.renderer.color.Color.m_hex[Math.floor(b/16)]); + a.push(qx.renderer.color.Color.m_hex[Math.floor(b%16)]); + + this._hex = a.join(""); + } + else + { + // TODO + } +} + + + + +qx.Proto.getRed = function() +{ + if (this._red == null) { + this._evalRgb(); + } + + return this._red; +} + +qx.Proto.getGreen = function() +{ + if (this._green == null) { + this._evalRgb(); + } + + return this._green; +} + +qx.Proto.getBlue = function() +{ + if (this._blue == null) { + this._evalRgb(); + } + + return this._blue; +} + + + + +qx.Proto._evalRgb = function() +{ + if (this._isThemedColor) + { + this._applyThemedValue(); + } + else if (this._isHtmlColor) + { + var a = qx.renderer.color.Color.htmlNames[this._value]; + + this._red = a[0]; + this._green = a[1]; + this._blue = a[2]; + } + else + { + throw new Error("_evalRgb needs implementation!"); + } +} + + + + + +/* +--------------------------------------------------------------------------- + PRIVATE METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto._normalize = function(vInValue) +{ + this._isThemedColor = this._isRgbColor = this._isHtmlColor = false; + this._hex = null; + + var invalid = new Error("Invalid color: " + vInValue); + + switch(typeof vInValue) + { + case "string": + vInValue = vInValue.toLowerCase(); + + if (qx.renderer.color.Color.htmlNames[vInValue]) + { + this._isHtmlColor = true; + } + else if (qx.renderer.color.Color.themedNames[vInValue]) + { + this._isThemedColor = true; + } + else if (qx.renderer.color.Color.r_cssrgb.test(vInValue)) + { + this._red = parseInt(RegExp.$1); + this._green = parseInt(RegExp.$2); + this._blue = parseInt(RegExp.$3); + + this._isRgbColor = true; + } + else if (qx.renderer.color.Color.r_hex3.test(vInValue)) + { + this._hex = vInValue; + + this._red = (qx.renderer.color.Color.m_rgb[RegExp.$1] * 16) + qx.renderer.color.Color.m_rgb[RegExp.$1]; + this._green = (qx.renderer.color.Color.m_rgb[RegExp.$2] * 16) + qx.renderer.color.Color.m_rgb[RegExp.$2]; + this._blue = (qx.renderer.color.Color.m_rgb[RegExp.$3] * 16) + qx.renderer.color.Color.m_rgb[RegExp.$3]; + + this._isRgbColor = true; + } + else if (qx.renderer.color.Color.r_hex6.test(vInValue)) + { + this._hex = vInValue; + + this._red = (qx.renderer.color.Color.m_rgb[RegExp.$1] * 16) + qx.renderer.color.Color.m_rgb[RegExp.$2]; + this._green = (qx.renderer.color.Color.m_rgb[RegExp.$3] * 16) + qx.renderer.color.Color.m_rgb[RegExp.$4]; + this._blue = (qx.renderer.color.Color.m_rgb[RegExp.$5] * 16) + qx.renderer.color.Color.m_rgb[RegExp.$6]; + + this._isRgbColor = true; + } + else + { + throw invalid; + } + + break; + + case "number": + if (vInValue >= 0 && vInValue <= 255) + { + this._red = this._green = this._blue = vInValue; + this._isRgbColor = true; + } + else + { + throw invalid; + } + + break; + + case "object": + if (qx.util.Validation.isValidArray(vInValue) && vInValue.length == 3) + { + this._red = vInValue[0]; + this._green = vInValue[1]; + this._blue = vInValue[2]; + + this._isRgbColor = true; + break; + } + + default: + throw invalid; + } + + if (!this._isRgbColor) + { + this._red = this._green = this._blue = null; + this._style = this._isHtmlColor ? vInValue : null; + } + else + { + this._style = null; + + if (!(this._red >= 0 && this._red <= 255 && this._green >= 0 && this._green <= 255 && this._blue >= 0 && this._blue <= 255)) { + throw invalid; + } + } + + return this._value = vInValue; +} + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return true; + } + + delete this._value; + delete this._style; + + delete this._red; + delete this._green; + delete this._blue; + + delete this._isRgbColor; + delete this._isHtmlColor; + delete this._isThemedColor; + + return qx.core.Object.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/ColorCache.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/ColorCache.js new file mode 100644 index 0000000000..add29d1190 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/ColorCache.js @@ -0,0 +1,83 @@ +/* ************************************************************************ + + 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) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.color.ColorCache"); + +qx.renderer.color.ColorCache = function(propValue) +{ + var propKey; + var propKeyAsStyle = false; + + switch(typeof propValue) + { + case "string": + if (propValue != "") { + propValue = propKey = propValue.toLowerCase(); + break; + } + + return propValue; + + case "number": + if (propValue >= 0 && propValue <= 255) + { + propKey = propValue.toString(); + break; + } + + return propValue; + + case "object": + if (propValue == null || propValue instanceof qx.renderer.color.Color) { + return propValue; + } + + // Try to detect array of RGB values + if (typeof propValue.join === "function" && propValue.length == 3) + { + propKey = "rgb(" + propValue.join(",") + ")"; + propKeyAsStyle = true; + break; + } + + default: + return propValue; + } + + if (qx.renderer.color.ColorCache._data[propKey]) { + return qx.renderer.color.ColorCache._data[propKey]; + } + + // this.debug("Create new color instance: " + propKey); + + var vColorObject = qx.renderer.color.ColorCache._data[propKey] = qx.renderer.color.Color.themedNames[propValue] ? new qx.renderer.color.ColorObject(propValue) : new qx.renderer.color.Color(propValue); + + if (propKeyAsStyle) { + vColorObject._style = propKey; + } + + return vColorObject; +} + +qx.renderer.color.ColorCache._data = {}; diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/ColorObject.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/ColorObject.js new file mode 100644 index 0000000000..57b65668a6 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/color/ColorObject.js @@ -0,0 +1,154 @@ +/* ************************************************************************ + + 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) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.color.ColorObject", qx.renderer.color.Color, +function(vValue) +{ + // this.debug("Value: " + vValue); + this.setValue(vValue); + + if(qx.manager.object.ColorManager.getInstance().has(this._value)) { + return qx.manager.object.ColorManager.getInstance().get(this._value); + } + + qx.core.Object.call(this); + + // Register this color object to manager instance + qx.manager.object.ColorManager.getInstance().add(this); + + // Here will all objects with a dependency to this + // color stored. + this._dependentObjects = {}; +}); + + + + +/* +--------------------------------------------------------------------------- + UTILITY +--------------------------------------------------------------------------- +*/ + +qx.renderer.color.ColorObject.fromString = function(vDefString) { + return new qx.renderer.color.ColorObject(vDefString); +} + + + + +/* +--------------------------------------------------------------------------- + PUBLIC METHODS +--------------------------------------------------------------------------- +*/ + +/*! + Set a new value from selected theme (only for Operating System Colors) +*/ +qx.Proto._updateTheme = function(vTheme) +{ + if (!this._isThemedColor) { + throw new Error("Could not redefine themed value of non os colors!"); + } + + this._applyThemedValue(); + this._syncObjects(); +} + +qx.Proto._applyThemedValue = function() +{ + var vTheme = qx.manager.object.ColorManager.getInstance().getColorTheme(); + var vRgb = vTheme.getValueByName(this._value); + + if (vRgb) + { + this._red = vRgb[0]; + this._green = vRgb[1]; + this._blue = vRgb[2]; + } + + this._style = vTheme.getStyleByName(this._value); + this._hex = null; +} + +qx.Proto._syncObjects = function() +{ + for (var i in this._dependentObjects) { + this._dependentObjects[i]._updateColors(this, this._style); + } +} + +qx.Proto.setValue = function(vValue) +{ + this._normalize(vValue); + this._syncObjects(); +} + + + + + +/* +--------------------------------------------------------------------------- + OBJECT MANAGMENT +--------------------------------------------------------------------------- +*/ + +qx.Proto.add = function(vObject) { + this._dependentObjects[vObject.toHashCode()] = vObject; +} + +qx.Proto.remove = function(vObject) { + delete this._dependentObjects[vObject.toHashCode()]; +} + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return true; + } + + if (this._dependentObjects) + { + for (var i in this._dependentObjects) { + delete this._dependentObjects[i]; + } + + delete this._dependentObjects; + } + + return qx.renderer.color.Color.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/Font.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/Font.js new file mode 100644 index 0000000000..ceac713d8f --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/Font.js @@ -0,0 +1,218 @@ +/* ************************************************************************ + + 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) +#load(qx.renderer.font.FontObject) + +************************************************************************ */ + +/*! + Font implementation for qx.ui.core.Widget instances. +*/ + +qx.OO.defineClass("qx.renderer.font.Font", qx.core.Object, +function(vSize, vName) +{ + qx.core.Object.call(this); + + this._defs = {}; + + if (qx.util.Validation.isValidNumber(vSize)) { + this.setSize(vSize); + } + + if (qx.util.Validation.isValidString(vName)) { + this.setName(vName); + } +}); + + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "size", type : "number", impl : "style" }); +qx.OO.addProperty({ name : "name", type : "string", impl : "style" }); +qx.OO.addProperty({ name : "bold", type : "boolean", defaultValue : false, impl : "style" }); +qx.OO.addProperty({ name : "italic", type : "boolean", defaultValue : false, impl : "style" }); +qx.OO.addProperty({ name : "underline", type : "boolean", defaultValue : false, impl : "style" }); +qx.OO.addProperty({ name : "strikeout", type : "boolean", defaultValue : false, impl : "style" }); + + + + + +/* +--------------------------------------------------------------------------- + MODIFIER +--------------------------------------------------------------------------- +*/ + +qx.Proto._modifyStyle = function(propValue, propOldValue, propData) +{ + this._needsCompilation = true; + return true; +} + + + + +/* +--------------------------------------------------------------------------- + UTILITY +--------------------------------------------------------------------------- +*/ + +qx.renderer.font.Font.fromString = function(s) +{ + var vFont = new qx.renderer.font.Font; + var vAllParts = s.split(/\s+/); + var vName = []; + var vPart; + + for (var i = 0; i < vAllParts.length; i++) + { + switch(vPart = vAllParts[i]) + { + case "bold": + vFont.setBold(true); + break; + + case "italic": + vFont.setItalic(true); + break; + + case "underline": + vFont.setUnderline(true); + break; + + case "strikeout": + vFont.setStrikeout(true); + break; + + default: + var vTemp = parseFloat(vPart); + + if(vTemp == vPart || qx.lang.String.contains(vPart, "px")) + { + vFont.setSize(vTemp); + } + else + { + vName.push(vPart); + } + + break; + } + } + + if(vName.length > 0) { + vFont.setName(vName.join(" ")); + } + + return vFont; +} + + + + +/* +--------------------------------------------------------------------------- + UTILITY +--------------------------------------------------------------------------- +*/ + +qx.Proto._needsCompilation = true; + +qx.Proto._compile = function() +{ + var vName = this.getName(); + var vSize = this.getSize(); + var vBold = this.getBold(); + var vItalic = this.getItalic(); + var vUnderline = this.getUnderline(); + var vStrikeout = this.getStrikeout(); + var vDecoration = ""; + + if (this.getUnderline()) { + vDecoration = "underline"; + } + + if (this.getStrikeout()) { + vDecoration += " " + "strikeout"; + } + + this._defs.fontFamily = qx.util.Validation.isValidString(vName) ? vName : ""; + this._defs.fontSize = qx.util.Validation.isValidNumber(vSize) ? vSize + "px" : ""; + this._defs.fontWeight = this.getBold() ? "bold" : "normal"; + this._defs.fontStyle = this.getItalic() ? "italic" : "normal"; + this._defs.textDecoration = qx.util.Validation.isValidString(vDecoration) ? vDecoration : ""; + + this._needsCompilation = false; +} + +qx.Proto._applyWidget = function(vWidget) +{ + if (this._needsCompilation) { + this._compile(); + } + + vWidget.setStyleProperty("fontFamily", this._defs.fontFamily); + vWidget.setStyleProperty("fontSize", this._defs.fontSize); + vWidget.setStyleProperty("fontWeight", this._defs.fontWeight); + vWidget.setStyleProperty("fontStyle", this._defs.fontStyle); + vWidget.setStyleProperty("textDecoration", this._defs.textDecoration); +} + +qx.Proto._resetWidget = function(vWidget) +{ + vWidget.removeStyleProperty("fontFamily"); + vWidget.removeStyleProperty("fontSize"); + vWidget.removeStyleProperty("fontWeight"); + vWidget.removeStyleProperty("fontStyle"); + vWidget.removeStyleProperty("textDecoration"); +} + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return true; + } + + delete this._defs; + + return qx.core.Object.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/FontCache.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/FontCache.js new file mode 100644 index 0000000000..03b1ee769e --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/FontCache.js @@ -0,0 +1,70 @@ +/* ************************************************************************ + + 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.renderer.font.FontCache"); + +qx.renderer.font.FontCache = function(propValue, propData) +{ + var propKey; + var propKeyAsStyle = false; + + switch(typeof propValue) + { + case "string": + if (propValue != "") + { + propValue = propKey = propValue.toLowerCase(); + break; + } + + return propValue; + + case "number": + propKey = propValue.toString(); + break; + + case "object": + if (propValue == null || propValue instanceof qx.renderer.font.Font) { + return propValue; + } + + // Try to detect array of RGB values + if (typeof propValue.join === "function") + { + propKey = propValue.join(" ").toLowerCase(); + break; + } + + default: + return propValue; + } + + if (qx.renderer.font.FontCache._data[propKey]) { + return qx.renderer.font.FontCache._data[propKey]; + } + + return qx.renderer.font.FontCache._data[propKey] = qx.renderer.font.Font.fromString(propKey); +} + +qx.renderer.font.FontCache._data = {}; diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/FontObject.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/FontObject.js new file mode 100644 index 0000000000..674b1f9215 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/font/FontObject.js @@ -0,0 +1,93 @@ +/* ************************************************************************ + + 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.renderer.font.FontObject", qx.renderer.font.Font, +function(vSize, vName) +{ + this._dependentObjects = {}; + + qx.renderer.font.Font.call(this, vSize, vName); +}); + + + + +/* +--------------------------------------------------------------------------- + WIDGET CONNECTION +--------------------------------------------------------------------------- +*/ + +qx.Proto.addListenerWidget = function(o) { + this._dependentObjects[o.toHashCode()] = o; +} + +qx.Proto.removeListenerWidget = function(o) { + delete this._dependentObjects[o.toHashCode()]; +} + +qx.Proto._sync = function(vEdge) +{ + var vAll = this._dependentObjects; + var vCurrent; + + for (vKey in vAll) + { + vCurrent = vAll[vKey]; + + if (vCurrent.isCreated()) { + vCurrent._updateFont(vEdge); + } + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + if (typeof this._dependentObjects === "object") + { + for (vKey in this._dependentObjects) { + delete this._dependentObjects[vKey]; + } + + delete this._dependentObjects; + } + + return qx.renderer.font.Font.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/CanvasLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/CanvasLayoutImpl.js new file mode 100644 index 0000000000..dec4297676 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/CanvasLayoutImpl.js @@ -0,0 +1,297 @@ +/* ************************************************************************ + + 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) +#module(ui_layout) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.CanvasLayoutImpl", qx.renderer.layout.LayoutImpl, +function(vWidget) { + qx.renderer.layout.LayoutImpl.call(this, vWidget); +}); + + + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + + Inherits from qx.renderer.layout.LayoutImpl: + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [11] DISPOSER +*/ + + + +/* +--------------------------------------------------------------------------- + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the box width of the given child +*/ +qx.Proto.computeChildBoxWidth = function(vChild) +{ + var vValue = null; + + if (vChild._computedLeftTypeNull || vChild._computedRightTypeNull) + { + vValue = vChild.getWidthValue(); + } + else if (vChild._hasParent) + { + vValue = this.getWidget().getInnerWidth() - vChild.getLeftValue() - vChild.getRightValue(); + } + + return vValue || vChild._computeBoxWidthFallback(); +} + +/*! + Compute and return the box height of the given child +*/ +qx.Proto.computeChildBoxHeight = function(vChild) +{ + var vValue = null; + + if (vChild._computedTopTypeNull || vChild._computedBottomTypeNull) + { + vValue = vChild.getHeightValue(); + } + else if (vChild._hasParent) + { + vValue = this.getWidget().getInnerHeight() - vChild.getTopValue() - vChild.getBottomValue(); + } + + return vValue || vChild._computeBoxHeightFallback(); +} + + + + + +/* +--------------------------------------------------------------------------- + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the needed width of the given child +*/ +qx.Proto.computeChildNeededWidth = function(vChild) +{ + var vLeft = vChild._computedLeftTypePercent ? null : vChild.getLeftValue(); + var vRight = vChild._computedRightTypePercent ? null : vChild.getRightValue(); + var vMinBox = vChild._computedMinWidthTypePercent ? null : vChild.getMinWidthValue(); + var vMaxBox = vChild._computedMaxWidthTypePercent ? null : vChild.getMaxWidthValue(); + + if (vLeft != null && vRight != null) + { + var vBox = vChild.getPreferredBoxWidth() || 0; + } + else + { + var vBox = (vChild._computedWidthTypePercent ? null : vChild.getWidthValue()) || vChild.getPreferredBoxWidth() || 0; + } + + return qx.lang.Number.limit(vBox, vMinBox, vMaxBox) + vLeft + vRight + vChild.getMarginLeft() + vChild.getMarginRight(); +} + +/*! + Compute and return the needed height of the given child +*/ +qx.Proto.computeChildNeededHeight = function(vChild) +{ + var vTop = vChild._computedTopTypePercent ? null : vChild.getTopValue(); + var vBottom = vChild._computedBottomTypePercent ? null : vChild.getBottomValue(); + var vMinBox = vChild._computedMinHeightTypePercent ? null : vChild.getMinHeightValue(); + var vMaxBox = vChild._computedMaxHeightTypePercent ? null : vChild.getMaxHeightValue(); + + if (vTop != null && vBottom != null) + { + var vBox = vChild.getPreferredBoxHeight() || 0; + } + else + { + var vBox = (vChild._computedHeightTypePercent ? null : vChild.getHeightValue()) || vChild.getPreferredBoxHeight() || 0; + } + + return qx.lang.Number.limit(vBox, vMinBox, vMaxBox) + vTop + vBottom + vChild.getMarginTop() + vChild.getMarginBottom(); +} + + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) +{ + // this makes sure that both functions get executed before return + var vUpdatePercent = vChild._recomputePercentX(); + var vUpdateRange = vChild._recomputeRangeX(); + + return vUpdatePercent || vUpdateRange; +} + +/*! + Actions that should be done if the inner height of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) +{ + // this makes sure that both functions get executed before return + var vUpdatePercent = vChild._recomputePercentY(); + var vUpdateRange = vChild._recomputeRangeY(); + + return vUpdatePercent || vUpdateRange; +} + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +/*! + This is called from qx.ui.core.Widget and it's task is to apply the layout + (excluding border and padding) to the child. +*/ +qx.Proto.layoutChild = function(vChild, vJobs) +{ + this.layoutChild_sizeX_essentialWrapper(vChild, vJobs); + this.layoutChild_sizeY_essentialWrapper(vChild, vJobs); + + this.layoutChild_sizeLimitX(vChild, vJobs); + this.layoutChild_sizeLimitY(vChild, vJobs); + + this.layoutChild_locationX(vChild, vJobs); + this.layoutChild_locationY(vChild, vJobs); + + this.layoutChild_marginX(vChild, vJobs); + this.layoutChild_marginY(vChild, vJobs); +} + +if (qx.sys.Client.getInstance().isMshtml() || qx.sys.Client.getInstance().isOpera()) +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width || vJobs.minWidth || vJobs.maxWidth || vJobs.left || vJobs.right) + { + if (vChild._computedMinWidthTypeNull && vChild._computedWidthTypeNull && vChild._computedMaxWidthTypeNull && !(!vChild._computedLeftTypeNull && !vChild._computedRightTypeNull)) + { + vChild._resetRuntimeWidth(); + } + else + { + vChild._applyRuntimeWidth(vChild.getBoxWidth()); + } + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height || vJobs.minHeight || vJobs.maxHeight || vJobs.top || vJobs.bottom) + { + if (vChild._computedMinHeightTypeNull && vChild._computedHeightTypeNull && vChild._computedMaxHeightTypeNull && !(!vChild._computedTopTypeNull && !vChild._computedBottomTypeNull)) + { + vChild._resetRuntimeHeight(); + } + else + { + vChild._applyRuntimeHeight(vChild.getBoxHeight()); + } + } + } +} +else +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width) { + vChild._computedWidthTypeNull ? vChild._resetRuntimeWidth() : vChild._applyRuntimeWidth(vChild.getWidthValue()); + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height) { + vChild._computedHeightTypeNull ? vChild._resetRuntimeHeight() : vChild._applyRuntimeHeight(vChild.getHeightValue()); + } + } +} + +qx.Proto.layoutChild_locationX = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + if (vJobs.initial || vJobs.left || vJobs.parentPaddingLeft) { + vChild._computedLeftTypeNull ? vChild._computedRightTypeNull && vWidget.getPaddingLeft() > 0 ? vChild._applyRuntimeLeft(vWidget.getPaddingLeft()) : vChild._resetRuntimeLeft() : vChild._applyRuntimeLeft(vChild.getLeftValue() + vWidget.getPaddingLeft()); + } + + if (vJobs.initial || vJobs.right || vJobs.parentPaddingRight) { + vChild._computedRightTypeNull ? vChild._computedLeftTypeNull && vWidget.getPaddingRight() > 0 ? vChild._applyRuntimeRight(vWidget.getPaddingRight()) : vChild._resetRuntimeRight() : vChild._applyRuntimeRight(vChild.getRightValue() + vWidget.getPaddingRight()); + } +} + +qx.Proto.layoutChild_locationY = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + if (vJobs.initial || vJobs.top || vJobs.parentPaddingTop) { + vChild._computedTopTypeNull ? vChild._computedBottomTypeNull && vWidget.getPaddingTop() > 0 ? vChild._applyRuntimeTop(vWidget.getPaddingTop()) : vChild._resetRuntimeTop() : vChild._applyRuntimeTop(vChild.getTopValue() + vWidget.getPaddingTop()); + } + + if (vJobs.initial || vJobs.bottom || vJobs.parentPaddingBottom) { + vChild._computedBottomTypeNull ? vChild._computedTopTypeNull && vWidget.getPaddingBottom() > 0 ? vChild._applyRuntimeBottom(vWidget.getPaddingBottom()) : vChild._resetRuntimeBottom() : vChild._applyRuntimeBottom(vChild.getBottomValue() + vWidget.getPaddingBottom()); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/DockLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/DockLayoutImpl.js new file mode 100644 index 0000000000..c948fca9b6 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/DockLayoutImpl.js @@ -0,0 +1,488 @@ +/* ************************************************************************ + + 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_layout) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.DockLayoutImpl", qx.renderer.layout.LayoutImpl, +function(vWidget) { + qx.renderer.layout.LayoutImpl.call(this, vWidget); +}); + + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + + Inherits from qx.renderer.layout.LayoutImpl: + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [11] DISPOSER +*/ + + + + +/* +--------------------------------------------------------------------------- + [00] ADDITIONAL GLOBAL DATA AND METHODS +--------------------------------------------------------------------------- +*/ + +qx.renderer.layout.DockLayoutImpl.METHOD_LOCATION = "layoutChild_location_"; + +qx.renderer.layout.DockLayoutImpl._childRanking = { + vertical : function(c) { return c.getVerticalAlign() ? 1e6 : c.getHorizontalAlign() ? 2e6 : 3e6; }, + horizontal : function(c) { return c.getHorizontalAlign() ? 1e6 : c.getVerticalAlign() ? 2e6 : 3e6; }, + ordered : function(c) { return c.getHorizontalAlign() || c.getVerticalAlign() ? 1e6 : 2e6; } +} + +qx.renderer.layout.DockLayoutImpl._childCheck = +{ + common : function(vChild) { + if (!(vChild._computedLeftTypeNull && vChild._computedRightTypeNull && vChild._computedTopTypeNull && vChild._computedBottomTypeNull)) { + throw new Error("qx.renderer.layout.DockLayoutImpl: It is not allowed to define any location values for children: " + vChild + "!"); + } + }, + + horizontal : function(vChild) + { + if (!(vChild._computedMinHeightTypeNull && vChild._computedHeightTypeNull && vChild._computedMaxHeightTypeNull)) { + throw new Error("qx.renderer.layout.DockLayoutImpl: It is not allowed to define any vertical dimension for 'horizontal' placed children: " + vChild + "!"); + } + }, + + vertical : function(vChild) + { + if (!(vChild._computedMinWidthTypeNull && vChild._computedWidthTypeNull && vChild._computedMaxWidthTypeNull)) { + throw new Error("qx.renderer.layout.DockLayoutImpl: It is not allowed to define any horizontal dimension for 'vertical' placed children: " + vChild + "!"); + } + }, + + "default" : function(vChild) + { + qx.renderer.layout.DockLayoutImpl._childCheck.horizontal(vChild); + qx.renderer.layout.DockLayoutImpl._childCheck.vertical(vChild); + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the box width of the given child +*/ +qx.Proto.computeChildBoxWidth = function(vChild) +{ + if (this.getChildAlignMode(vChild) == "horizontal") { + return vChild.getWidthValue() || vChild._computeBoxWidthFallback(); + } + + return this.getWidget().getInnerWidth() - this._lastLeft - this._lastRight; +} + +/*! + Compute and return the box height of the given child +*/ +qx.Proto.computeChildBoxHeight = function(vChild) +{ + if (this.getChildAlignMode(vChild) == "vertical") { + return vChild.getHeightValue() || vChild._computeBoxHeightFallback(); + } + + return this.getWidget().getInnerHeight() - this._lastTop - this._lastBottom; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) +{ + vChild._recomputePercentX(); + vChild.addToLayoutChanges("location"); + + // inform the caller if there were any notable changes occured + return true; +} + +/*! + Actions that should be done if the inner height of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) +{ + vChild._recomputePercentY(); + vChild.addToLayoutChanges("location"); + + // inform the caller if there were any notable changes occured + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Invalidate and recompute things because of job in queue (before the rest of job handling will be executed). +*/ +qx.Proto.updateSelfOnJobQueueFlush = qx.util.Return.returnFalse; + + + + + + + +/* +--------------------------------------------------------------------------- + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Updates children on special jobs +*/ +qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue) +{ + if (vQueue.mode || vQueue.addChild || vQueue.removeChild) { + this.getWidget()._addChildrenToLayoutQueue("location"); + } +} + + + + + + + + + +/* +--------------------------------------------------------------------------- + [09] FLUSH LAYOUT QUEUES OF CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + This method have full control of the order in which the + registered (or also non-registered) children should be + layouted on the horizontal axis. +*/ +qx.Proto.flushChildrenQueue = function(vChildrenQueue) +{ + var vWidget=this.getWidget(), vChildren=vWidget.getVisibleChildren(), vChildrenLength=vChildren.length, vMode=vWidget.getMode(); + + // reset layout + this._lastLeft = this._lastRight = this._lastTop = this._lastBottom = 0; + + // sorting children + var vRankImpl = qx.renderer.layout.DockLayoutImpl._childRanking[vMode]; + var vOrderedChildren = qx.lang.Array.copy(vChildren).sort(function(c1, c2) { + return (vRankImpl(c1) + vChildren.indexOf(c1)) - (vRankImpl(c2) + vChildren.indexOf(c2)); + }); + + // flushing children + for (var i=0; i<vChildrenLength; i++) { + vWidget._layoutChild(vOrderedChildren[i]); + } +} + +qx.Proto.getChildAlign = function(vChild) { + return vChild.getVerticalAlign() || vChild.getHorizontalAlign() || "default"; +} + +qx.Proto.getChildAlignMode = function(vChild) { + return vChild.getVerticalAlign() ? "vertical" : vChild.getHorizontalAlign() ? "horizontal" : "default"; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +/*! + This is called from qx.ui.core.Widget and it's task is to apply the layout + (excluding border and padding) to the child. +*/ +qx.Proto.layoutChild = function(vChild, vJobs) +{ + qx.renderer.layout.DockLayoutImpl._childCheck.common(vChild); + qx.renderer.layout.DockLayoutImpl._childCheck[this.getChildAlignMode(vChild)](vChild); + + this.layoutChild_sizeX_essentialWrapper(vChild, vJobs); + this.layoutChild_sizeY_essentialWrapper(vChild, vJobs); + + this.layoutChild_sizeLimitX(vChild, vJobs); + this.layoutChild_sizeLimitY(vChild, vJobs); + + this[qx.renderer.layout.DockLayoutImpl.METHOD_LOCATION + this.getChildAlign(vChild)](vChild, vJobs); +} + +qx.Proto.layoutChild_location_top = function(vChild, vJobs) +{ + vChild._applyRuntimeTop(this._lastTop); + vChild._applyRuntimeLeft(this._lastLeft); + + this.layoutChild_location_horizontal(vChild); + + this._lastTop += vChild.getBoxHeight(); +} + +qx.Proto.layoutChild_location_left = function(vChild, vJobs) +{ + vChild._applyRuntimeLeft(this._lastLeft); + vChild._applyRuntimeTop(this._lastTop); + + this.layoutChild_location_vertical(vChild); + + this._lastLeft += vChild.getBoxWidth(); +} + + + + + + + +if (qx.sys.Client.getInstance().isMshtml() || qx.sys.Client.getInstance().isOpera()) +{ + qx.Proto._applyComputedWidth = function(vChild) + { + // direct recompute (need to be done, while layouting as the + // _last* variable changes during layout process) + vChild._recomputeBoxWidth(); + + // wrong: simple invalidates are enough here + // correct: needs recompute to inform children (to update centering for example) + vChild._recomputeOuterWidth(); + vChild._recomputeInnerWidth(); + + // apply calculated width + vChild._applyRuntimeWidth(vChild.getBoxWidth()); + } + + qx.Proto._applyComputedHeight = function(vChild) + { + // direct recompute (need to be done, while layouting as the + // _last* variable changes during layout process) + vChild._recomputeBoxHeight(); + + // wrong: simple invalidates are enough here + // correct: needs recompute to inform children (to update centering for example) + vChild._recomputeOuterHeight(); + vChild._recomputeInnerHeight(); + + // apply calculated height + vChild._applyRuntimeHeight(vChild.getBoxHeight()); + } + + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + // We need to respect all dimension properties on the horizontal axis in internet explorer to set the 'width' style + if (vJobs.initial || vJobs.width || vJobs.minWidth || vJobs.maxWidth) { + vChild._computedWidthTypeNull && vChild._computedMinWidthTypeNull && vChild._computedMaxWidthTypeNull ? vChild._resetRuntimeWidth() : vChild._applyRuntimeWidth(vChild.getBoxWidth()); + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + // We need to respect all dimension properties on the vertical axis in internet explorer to set the 'height' style + if (vJobs.initial || vJobs.height || vJobs.minHeight || vJobs.maxHeight) { + vChild._computedHeightTypeNull && vChild._computedMinHeightTypeNull && vChild._computedMaxHeightTypeNull ? vChild._resetRuntimeHeight() : vChild._applyRuntimeHeight(vChild.getBoxHeight()); + } + } + + qx.Proto.layoutChild_location_horizontal = function(vChild) { + this._applyComputedWidth(vChild); + } + + qx.Proto.layoutChild_location_vertical = function(vChild) { + this._applyComputedHeight(vChild); + } + + qx.Proto.layoutChild_location_right = function(vChild, vJobs) + { + vChild._applyRuntimeLeft(this.getWidget().getInnerWidth() - this._lastRight - vChild.getBoxWidth()); + vChild._applyRuntimeTop(this._lastTop); + + this.layoutChild_location_vertical(vChild); + + this._lastRight += vChild.getBoxWidth(); + } + + qx.Proto.layoutChild_location_bottom = function(vChild, vJobs) + { + vChild._applyRuntimeTop(this.getWidget().getInnerHeight() - this._lastBottom - vChild.getBoxHeight()); + vChild._applyRuntimeLeft(this._lastLeft); + + this.layoutChild_location_horizontal(vChild); + + this._lastBottom += vChild.getBoxHeight(); + } + + qx.Proto.layoutChild_location_default = function(vChild, vJobs) + { + var vWidget = this.getWidget(); + + vChild._resetRuntimeRight(); + vChild._resetRuntimeBottom(); + + vChild._applyRuntimeTop(this._lastTop); + vChild._applyRuntimeLeft(this._lastLeft); + + this._applyComputedWidth(vChild); + this._applyComputedHeight(vChild); + } +} +else +{ + qx.Proto._applyComputedWidth = function(vChild) + { + // direct recompute (need to be done, while layouting as the + // _last* variable changes during layout process) + vChild._recomputeBoxWidth(); + + // wrong: simple invalidates are enough here + // correct: needs recompute to inform children (to update centering for example) + vChild._recomputeOuterWidth(); + vChild._recomputeInnerWidth(); + } + + qx.Proto._applyComputedHeight = function(vChild) + { + // direct recompute (need to be done, while layouting as the + // _last* variable changes during layout process) + vChild._recomputeBoxHeight(); + + // wrong: simple invalidates are enough here + // correct: needs recompute to inform children (to update centering for example) + vChild._recomputeOuterHeight(); + vChild._recomputeInnerHeight(); + } + + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width) { + vChild._computedWidthTypeNull ? vChild._resetRuntimeWidth() : vChild._applyRuntimeWidth(vChild.getWidthValue()); + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height) { + vChild._computedHeightTypeNull ? vChild._resetRuntimeHeight() : vChild._applyRuntimeHeight(vChild.getHeightValue()); + } + } + + qx.Proto.layoutChild_location_horizontal = function(vChild) + { + this._applyComputedWidth(vChild); + vChild._applyRuntimeRight(this._lastRight); + } + + qx.Proto.layoutChild_location_vertical = function(vChild) + { + this._applyComputedHeight(vChild); + vChild._applyRuntimeBottom(this._lastBottom); + } + + qx.Proto.layoutChild_location_right = function(vChild, vJobs) + { + vChild._applyRuntimeRight(this._lastRight); + vChild._applyRuntimeTop(this._lastTop); + + this.layoutChild_location_vertical(vChild); + + this._lastRight += vChild.getBoxWidth(); + } + + qx.Proto.layoutChild_location_bottom = function(vChild, vJobs) + { + vChild._applyRuntimeBottom(this._lastBottom); + vChild._applyRuntimeLeft(this._lastLeft); + + this.layoutChild_location_horizontal(vChild); + + this._lastBottom += vChild.getBoxHeight(); + } + + qx.Proto.layoutChild_location_default = function(vChild, vJobs) + { + vChild._resetRuntimeWidth(); + vChild._resetRuntimeHeight(); + + vChild._applyRuntimeTop(this._lastTop); + vChild._applyRuntimeRight(this._lastRight); + vChild._applyRuntimeBottom(this._lastBottom); + vChild._applyRuntimeLeft(this._lastLeft); + + this._applyComputedWidth(vChild); + this._applyComputedHeight(vChild); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/FlowLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/FlowLayoutImpl.js new file mode 100644 index 0000000000..cd11e3dd86 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/FlowLayoutImpl.js @@ -0,0 +1,426 @@ +/* ************************************************************************ + + 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_layout) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.FlowLayoutImpl", qx.renderer.layout.LayoutImpl, +function(vWidget) { + qx.renderer.layout.LayoutImpl.call(this, vWidget); +}); + +qx.renderer.layout.FlowLayoutImpl.STR_FIRST = "getFirstVisibleChild"; +qx.renderer.layout.FlowLayoutImpl.STR_LAST = "getLastVisibleChild"; +qx.renderer.layout.FlowLayoutImpl.STR_NEXT = "getNextSibling"; +qx.renderer.layout.FlowLayoutImpl.STR_PREVIOUS = "getPreviousSibling"; + + +/*! + Global Structure: + + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + Inherits from qx.renderer.layout.LayoutImpl: + + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [11] DISPOSER +*/ + + + + + + +/* +--------------------------------------------------------------------------- + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the width needed by all children of this widget +*/ +qx.Proto.computeChildrenNeededWidth = function() +{ + var w = this.getWidget(); + return qx.renderer.layout.LayoutImpl.prototype.computeChildrenNeededWidth_sum.call(this) + ((w.getVisibleChildrenLength()-1) * w.getHorizontalSpacing()); +} + +/*! + Calculate the layout to get the needed height of the children +*/ +qx.Proto.computeChildrenNeededHeight = function() +{ + var vWidget = this.getWidget(); + + var vInnerWidth = vWidget.getInnerWidth(); + + var vHorizontalSpacing = vWidget.getHorizontalSpacing(); + var vVerticalSpacing = vWidget.getVerticalSpacing(); + var vReversed = vWidget.getReverseChildrenOrder(); + + var vRowWidth = 0; + var vRowHeight = 0; + + var vRowHeightSum = 0; + + for (var i=0, ch=vWidget.getVisibleChildren(), chl=ch.length, chc; i<chl; i++) + { + chc = vReversed ? ch[chl-1-i] : ch[i]; + + vRowWidth += chc.getNeededWidth(); + + if (vRowWidth > vInnerWidth) + { + vRowHeightSum += vRowHeight + vVerticalSpacing; + vRowWidth = chc.getNeededWidth(); + vRowHeight = chc.getNeededHeight(); + } + else + { + vRowHeight = Math.max(vRowHeight, chc.getNeededHeight()); + } + + vRowWidth += vHorizontalSpacing; + } + + return vRowHeightSum + vRowHeight; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS +--------------------------------------------------------------------------- +*/ + +/*! + Things to do and layout when any of the childs changes it's outer width. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild) +{ + // If a child only change it's width also recompute the height + // as the layout flows around here + //this.getWidget()._recomputeNeededHeightHelper(); + this.getWidget()._invalidatePreferredInnerHeight(); +} + + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) +{ + vChild._recomputePercentX(); + vChild.addToLayoutChanges("location"); + + return true; +} + +/*! + Actions that should be done if the inner height of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) +{ + vChild._recomputePercentY(); + vChild.addToLayoutChanges("location"); + + return true; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Updates children on special jobs +*/ +qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue) +{ + if (vQueue.horizontalSpacing || vQueue.verticalSpacing || vQueue.reverseChildrenOrder || vQueue.horizontalChildrenAlign || vQueue.verticalChildrenAlign) { + this.getWidget()._addChildrenToLayoutQueue("location"); + } +} + + + + + + +/* +--------------------------------------------------------------------------- + [08] CHILDREN ADD/REMOVE/MOVE HANDLING +--------------------------------------------------------------------------- +*/ + +/*! + This method combines calls of methods which should be done if a widget should be removed from the current layout. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateChildrenOnRemoveChild = function(vChild, vIndex) +{ + var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i=-1; + + if (w.getReverseChildrenOrder()) + { + while((chc=ch[++i]) && i<vIndex) { + chc.addToLayoutChanges("location"); + } + } + else + { + i+=vIndex; + while(chc=ch[++i]) { + chc.addToLayoutChanges("location"); + } + } +} + +/*! + This method combines calls of methods which should be done if a child should be moved + inside the same parent to a new positions. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateChildrenOnMoveChild = function(vChild, vIndex, vOldIndex) +{ + for (var i=Math.min(vIndex, vOldIndex), ch=this.getWidget().getVisibleChildren(), l=ch.length; i<l; i++) { + ch[i].addToLayoutChanges("location"); + } +} + + + + + + +/* +--------------------------------------------------------------------------- + [09] FLUSH LAYOUT QUEUES OF CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + This method have full control of the order in which the + registered (or also non-registered) children should be + layouted on the horizontal axis. +*/ + +qx.Proto.flushChildrenQueue = function(vChildrenQueue) +{ + var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, chh; + + if (w.getReverseChildrenOrder()) + { + // layout all childs from the first child + // with an own layout request to the end + var i=chl, changed=false; + while(chc=ch[--i]) + { + chh = chc.toHashCode(); + + if (changed || vChildrenQueue[chh]) + { + w._layoutChild(chc); + changed = true; + } + } + } + else + { + // layout all childs from the first child + // with an own layout request to the end + var i=-1, changed=false; + while(chc=ch[++i]) + { + chh = chc.toHashCode(); + + if (changed || vChildrenQueue[chh]) + { + w._layoutChild(chc); + changed = true; + } + } + } +} + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +qx.Proto.layoutChild = function(vChild, vJobs) +{ + this.layoutChild_sizeX_essentialWrapper(vChild, vJobs); + this.layoutChild_sizeY_essentialWrapper(vChild, vJobs); + + this.layoutChild_sizeLimitX(vChild, vJobs); + this.layoutChild_sizeLimitY(vChild, vJobs); + + this.layoutChild_marginX(vChild, vJobs); + this.layoutChild_marginY(vChild, vJobs); + + this.layoutChild_location(vChild, vJobs); +} + +if (qx.sys.Client.getInstance().isMshtml() || qx.sys.Client.getInstance().isOpera()) +{ + /*! + We need to respect all dimension properties on the horizontal axis in + internet explorer to set the 'width' style + */ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width || vJobs.minWidth || vJobs.maxWidth) { + vChild._computedWidthTypeNull && vChild._computedMinWidthTypeNull && vChild._computedMaxWidthTypeNull ? vChild._resetRuntimeWidth() : vChild._applyRuntimeWidth(vChild.getBoxWidth()); + } + } + + /*! + We need to respect all dimension properties on the vertical axis in + internet explorer to set the 'height' style + */ + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height || vJobs.minHeight || vJobs.maxHeight) { + vChild._computedHeightTypeNull && vChild._computedMinHeightTypeNull && vChild._computedMaxHeightTypeNull ? vChild._resetRuntimeHeight() : vChild._applyRuntimeHeight(vChild.getBoxHeight()); + } + } +} +else +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width) { + vChild._computedWidthTypeNull ? vChild._resetRuntimeWidth() : vChild._applyRuntimeWidth(vChild.getWidthValue()); + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height) { + vChild._computedHeightTypeNull ? vChild._resetRuntimeHeight() : vChild._applyRuntimeHeight(vChild.getHeightValue()); + } + } +} + +qx.Proto.layoutChild_location = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + var vReverse = vWidget.getReverseChildrenOrder(); + + var vMethodBegin = vReverse ? qx.renderer.layout.FlowLayoutImpl.STR_LAST : qx.renderer.layout.FlowLayoutImpl.STR_FIRST; + var vMethodContinue = vReverse ? qx.renderer.layout.FlowLayoutImpl.STR_NEXT : qx.renderer.layout.FlowLayoutImpl.STR_PREVIOUS; + + if (vChild == vWidget[vMethodBegin]()) + { + vChild._cachedLocationHorizontal = vChild._cachedLocationVertical = vChild._cachedRow = 0; + } + else + { + var vTempChild = vChild[vMethodContinue](); + + // stupidly update cache value (check them later) + vChild._cachedLocationHorizontal = vTempChild._cachedLocationHorizontal + vTempChild.getOuterWidth() + vWidget.getHorizontalSpacing(); + vChild._cachedLocationVertical = vTempChild._cachedLocationVertical; + vChild._cachedRow = vTempChild._cachedRow; + + // check now + if ((vChild._cachedLocationHorizontal + vChild.getOuterWidth()) > vWidget.getInnerWidth()) + { + // evaluate width of previous row + vRowMax = vTempChild.getOuterHeight(); + while((vTempChild = vTempChild[vMethodContinue]()) && vTempChild._cachedRow == vChild._cachedRow) { + vRowMax = Math.max(vRowMax, vTempChild.getOuterHeight()); + } + + // switch to new row + vChild._cachedLocationHorizontal = 0; + vChild._cachedLocationVertical += vWidget.getVerticalSpacing() + vRowMax; + vChild._cachedRow++; + } + } + + // add margins and parent padding + if (vWidget.getHorizontalChildrenAlign() == "right") + { + vChild._resetRuntimeLeft(); + vChild._applyRuntimeRight(vWidget.getPaddingRight() + vChild._cachedLocationHorizontal); + } + else + { + vChild._resetRuntimeRight(); + vChild._applyRuntimeLeft(vWidget.getPaddingLeft() + vChild._cachedLocationHorizontal); + } + + if (vWidget.getVerticalChildrenAlign() == "bottom") + { + vChild._resetRuntimeTop(); + vChild._applyRuntimeBottom(vWidget.getPaddingBottom() + vChild._cachedLocationVertical); + } + else + { + vChild._resetRuntimeBottom(); + vChild._applyRuntimeTop(vWidget.getPaddingTop() + vChild._cachedLocationVertical); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/GridLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/GridLayoutImpl.js new file mode 100644 index 0000000000..ecb8c899a7 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/GridLayoutImpl.js @@ -0,0 +1,300 @@ +/* ************************************************************************ + + 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_layout) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.GridLayoutImpl", qx.renderer.layout.LayoutImpl, +function(vWidget) { + qx.renderer.layout.LayoutImpl.call(this, vWidget); +}); + + + + +/*! + Global Structure: + + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + Inherits from qx.renderer.layout.LayoutImpl: + + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [11] DISPOSER +*/ + + + +/* +--------------------------------------------------------------------------- + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the box width of the given child. +*/ +qx.Proto.computeChildBoxWidth = function(vChild) +{ + var vWidget = this.getWidget(); + var vColWidth = vWidget.getColumnInnerWidth(vChild._col, vChild._row); + + // extend colwidth to spanned area + if (vWidget.isSpanStart(vChild._col, vChild._row)) + { + var vEntry = vWidget.getSpanEntry(vChild._col, vChild._row); + for (var i=1; i<vEntry.colLength; i++) + { + // right padding from the previous cell + vColWidth += vWidget.getComputedCellPaddingRight(vChild._col + i - 1, vChild._row); + + // left padding from the current cell + vColWidth += vWidget.getComputedCellPaddingLeft(vChild._col + i, vChild._row); + + // spacing between previous and current cell + vColWidth += vWidget.getHorizontalSpacing(); + + // inner width of the current cell plus + vColWidth += vWidget.getColumnInnerWidth(vChild._col + i, vChild._row); + } + } + + return vChild.getAllowStretchX() ? vColWidth : Math.min(vChild.getWidthValue(), vColWidth); +} + +/*! + Compute and return the box height of the given child. +*/ +qx.Proto.computeChildBoxHeight = function(vChild) +{ + var vWidget = this.getWidget(); + var vRowHeight = vWidget.getRowInnerHeight(vChild._col, vChild._row); + + // extend colwidth to spanned area + if (vWidget.isSpanStart(vChild._col, vChild._row)) + { + var vEntry = vWidget.getSpanEntry(vChild._col, vChild._row); + for (var i=1; i<vEntry.rowLength; i++) + { + // right padding from the previous cell + vRowHeight += vWidget.getComputedCellPaddingBottom(vChild._col, vChild._row + i - 1); + + // left padding from the current cell + vRowHeight += vWidget.getComputedCellPaddingTop(vChild._col, vChild._row + i); + + // spacing between previous and current cell + vRowHeight += vWidget.getVerticalSpacing(); + + // inner width of the current cell plus + vRowHeight += vWidget.getRowInnerHeight(vChild._col, vChild._row + i); + } + } + + return vChild.getAllowStretchY() ? vRowHeight : Math.min(vChild.getHeightValue(), vRowHeight); +} + + + + + + + +/* +--------------------------------------------------------------------------- + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the width needed by all children of this widget + which is in a grid layout the width used by all columns. +*/ +qx.Proto.computeChildrenNeededWidth = function() +{ + var vWidget = this.getWidget(); + var vSpacingX = vWidget.getHorizontalSpacing(); + var vSum = -vSpacingX; + + for (var i=0, l=vWidget.getColumnCount(); i<l; i++) { + vSum += vWidget.getColumnBoxWidth(i) + vSpacingX; + } + + return vSum; +} + +/*! + Compute and return the height needed by all children of this widget + which is in a grid layout the height used by all rows. +*/ +qx.Proto.computeChildrenNeededHeight = function() +{ + var vWidget = this.getWidget(); + var vSpacingY = vWidget.getVerticalSpacing(); + var vSum = -vSpacingY; + + for (var i=0, l=vWidget.getRowCount(); i<l; i++) { + vSum += vWidget.getRowBoxHeight(i) + vSpacingY; + } + + return vSum; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) +{ + vChild._recomputePercentX(); + vChild.addToLayoutChanges("locationX"); + + return true; +} + +/*! + Actions that should be done if the inner height of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) +{ + vChild._recomputePercentY(); + vChild.addToLayoutChanges("locationY"); + + return true; +} + + + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +/*! + This is called from qx.ui.core.Widget and it's task is to apply the layout + (excluding border and padding) to the child. +*/ + +qx.Proto.layoutChild = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + this.layoutChild_sizeX(vChild, vJobs); + this.layoutChild_sizeY(vChild, vJobs); + + this.layoutChild_sizeLimitX(vChild, vJobs); + this.layoutChild_sizeLimitY(vChild, vJobs); + + this.layoutChild_marginX(vChild, vJobs); + this.layoutChild_marginY(vChild, vJobs); + + this.layoutChild_locationX(vChild, vJobs); + this.layoutChild_locationY(vChild, vJobs); +} + +qx.Proto.layoutChild_sizeX = function(vChild, vJobs) +{ + vChild._applyRuntimeWidth(vChild.getBoxWidth()); +} + +qx.Proto.layoutChild_sizeY = function(vChild, vJobs) +{ + vChild._applyRuntimeHeight(vChild.getBoxHeight()); +} + +qx.Proto.layoutChild_locationX = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + var vSpacingX = vWidget.getHorizontalSpacing(); + var vLocSumX = vWidget.getPaddingLeft() + vWidget.getComputedCellPaddingLeft(vChild._col, vChild._row); + + for (var i=0; i<vChild._col; i++) { + vLocSumX += vWidget.getColumnBoxWidth(i) + vSpacingX; + } + + switch(vChild.getHorizontalAlign() || vWidget.getColumnHorizontalAlignment(vChild._col) || vWidget.getRowHorizontalAlignment(vChild._row) || vWidget.getHorizontalChildrenAlign()) + { + case "center": + vLocSumX += Math.round((vWidget.getColumnInnerWidth(vChild._col, vChild._row) - vChild.getBoxWidth()) / 2); + break; + + case "right": + vLocSumX += vWidget.getColumnInnerWidth(vChild._col, vChild._row) - vChild.getBoxWidth(); + break; + } + + vChild._applyRuntimeLeft(vLocSumX); +} + +qx.Proto.layoutChild_locationY = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + var vSpacingY = vWidget.getVerticalSpacing(); + var vLocSumY = vWidget.getPaddingTop() + vWidget.getComputedCellPaddingTop(vChild._col, vChild._row); + + for (var i=0; i<vChild._row; i++) { + vLocSumY += vWidget.getRowBoxHeight(i) + vSpacingY; + } + + switch(vChild.getVerticalAlign() || vWidget.getRowVerticalAlignment(vChild._row) || vWidget.getColumnVerticalAlignment(vChild._col) || vWidget.getVerticalChildrenAlign()) + { + case "middle": + vLocSumY += Math.round((vWidget.getRowInnerHeight(vChild._col, vChild._row) - vChild.getBoxHeight()) / 2); + break; + + case "bottom": + vLocSumY += vWidget.getRowInnerHeight(vChild._col, vChild._row) - vChild.getBoxHeight(); + break; + } + + vChild._applyRuntimeTop(vLocSumY); +}
\ No newline at end of file diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/HorizontalBoxLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/HorizontalBoxLayoutImpl.js new file mode 100644 index 0000000000..6276f309bc --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/HorizontalBoxLayoutImpl.js @@ -0,0 +1,863 @@ +/* ************************************************************************ + + 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) +#module(ui_layout) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.HorizontalBoxLayoutImpl", qx.renderer.layout.LayoutImpl, +function(vWidget) { + qx.renderer.layout.LayoutImpl.call(this, vWidget); +}); + +qx.OO.addProperty({ name : "enableFlexSupport", type : "boolean", defaultValue : true }); + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + + Inherits from qx.renderer.layout.LayoutImpl: + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [11] DISPOSER +*/ + + + + +/* +--------------------------------------------------------------------------- + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the box width of the given child. +*/ +qx.Proto.computeChildBoxWidth = function(vChild) { + return vChild.getWidthValue() || vChild._computeBoxWidthFallback(); +} + +/*! + Compute and return the box height of the given child. +*/ +qx.Proto.computeChildBoxHeight = function(vChild) +{ + if (this.getWidget().getStretchChildrenOrthogonalAxis() && vChild._computedHeightTypeNull && vChild.getAllowStretchY()) { + return this.getWidget().getInnerHeight(); + } + + return vChild.getHeightValue() || vChild._computeBoxHeightFallback(); +} + +/*! + Computes the width of all flexible children. +*/ +qx.Proto.computeChildrenFlexWidth = function() +{ + if (this._childrenFlexWidthComputed || !this.getEnableFlexSupport()) { + return; + } + + this._childrenFlexWidthComputed = true; + + // this.debug("computeChildrenFlexWidth"); + + var vWidget = this.getWidget(); + var vChildren = vWidget.getVisibleChildren(); + var vChildrenLength = vChildren.length; + var vCurrentChild; + var vFlexibleChildren = []; + var vAvailWidth = vWidget.getInnerWidth(); + var vUsedWidth = vWidget.getSpacing() * (vChildrenLength-1); + var vIterator; + + + // ************************************************************* + // 1. Compute the sum of all static sized children and finding + // all flexible children. + // ************************************************************* + for (vIterator=0; vIterator<vChildrenLength; vIterator++) + { + vCurrentChild = vChildren[vIterator]; + + if (vCurrentChild._computedWidthTypeFlex) + { + vFlexibleChildren.push(vCurrentChild); + + if (vWidget._computedWidthTypeAuto) { + vUsedWidth += vCurrentChild.getPreferredBoxWidth(); + } + } + else + { + vUsedWidth += vCurrentChild.getOuterWidth(); + } + } + + // this.debug("Width: " + vUsedWidth + "/" + vAvailWidth); + // this.debug("Flexible Count: " + vFlexibleChildren.length); + + + // ************************************************************* + // 2. Compute the sum of all flexible children widths + // ************************************************************* + var vRemainingWidth = vAvailWidth - vUsedWidth; + var vFlexibleChildrenLength = vFlexibleChildren.length; + var vPrioritySum = 0; + + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) { + vPrioritySum += vFlexibleChildren[vIterator]._computedWidthParsed; + } + + + // ************************************************************* + // 3. Calculating the size of each 'part'. + // ************************************************************* + var vPartWidth = vRemainingWidth / vPrioritySum; + + + if (!vWidget.getUseAdvancedFlexAllocation()) + { + // ************************************************************* + // 4a. Computing the flex width value of each flexible child + // and add the width to the usedWidth, so that we can + // fix rounding problems later. + // ************************************************************* + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthParsed * vPartWidth); + vUsedWidth += vCurrentChild._computedWidthFlexValue; + } + } + else + { + // ************************************************************* + // 4b. Calculating the diff. Which means respect the min/max + // width configuration in flex and store the higher/lower + // data in a diff. + // ************************************************************* + + var vAllocationDiff = 0; + var vMinAllocationLoops, vFlexibleChildrenLength, vAdjust, vCurrentAllocationSum, vFactorSum, vComputedFlexibleWidth; + + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + vComputedFlexibleWidth = vCurrentChild._computedWidthFlexValue = vCurrentChild._computedWidthParsed * vPartWidth; + vAllocationDiff += vComputedFlexibleWidth - qx.lang.Number.limit(vComputedFlexibleWidth, vCurrentChild.getMinWidthValue(), vCurrentChild.getMaxWidthValue()); + } + + // Rounding diff + vAllocationDiff = Math.round(vAllocationDiff); + + if (vAllocationDiff == 0) + { + // ************************************************************* + // 5a. If the diff is equal zero we must not do anything more + // and do nearly identical the same like in 4a. which means + // to round the calculated flex value and add it to the + // used width so we can fix rounding problems later. + // ************************************************************* + + // Rounding values and fixing rounding errors + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue); + vUsedWidth += vCurrentChild._computedWidthFlexValue; + } + } + else + { + // ************************************************************* + // 5b. Find maximum loops of each adjustable child to adjust + // the width until the min/max width limits are reached. + // ************************************************************* + + var vUp = vAllocationDiff > 0; + for (vIterator=vFlexibleChildrenLength-1; vIterator>=0; vIterator--) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + if (vUp) + { + vAdjust = (vCurrentChild.getMaxWidthValue() || Infinity) - vCurrentChild._computedWidthFlexValue; + + if (vAdjust > 0) + { + vCurrentChild._allocationLoops = Math.floor(vAdjust / vCurrentChild._computedWidthParsed); + } + else + { + qx.lang.Array.removeAt(vFlexibleChildren, vIterator); + + vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue); + vUsedWidth += Math.round(vCurrentChild._computedWidthFlexValue + vAdjust); + } + } + else + { + vAdjust = qx.util.Validation.isValidNumber(vCurrentChild.getMinWidthValue()) ? vCurrentChild._computedWidthFlexValue - vCurrentChild.getMinWidthValue() : vCurrentChild._computedWidthFlexValue; + + if (vAdjust > 0) + { + vCurrentChild._allocationLoops = Math.floor(vAdjust / vCurrentChild._computedWidthParsed); + } + else + { + qx.lang.Array.removeAt(vFlexibleChildren, vIterator); + + vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue); + vUsedWidth += Math.round(vCurrentChild._computedWidthFlexValue - vAdjust); + } + } + } + + // ************************************************************* + // 6. Try to reallocate the width between flexible children + // so that the requirements through min/max limits + // are satisfied. + // ************************************************************* + while (vAllocationDiff != 0 && vFlexibleChildrenLength > 0) + { + vFlexibleChildrenLength = vFlexibleChildren.length; + vMinAllocationLoops = Infinity; + vFactorSum = 0; + + // Find minimal loop amount + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vMinAllocationLoops = Math.min(vMinAllocationLoops, vFlexibleChildren[vIterator]._allocationLoops); + vFactorSum += vFlexibleChildren[vIterator]._computedWidthParsed; + } + + // Be sure that the adjustment is not bigger/smaller than diff + vCurrentAllocationSum = Math.min(vFactorSum * vMinAllocationLoops, vAllocationDiff); + + // this.debug("Diff: " + vAllocationDiff); + // this.debug("Min Loops: " + vMinAllocationLoops); + // this.debug("Sum: " + vCurrentAllocationSum); + // this.debug("Factor: " + vFactorSum); + + // Reducing diff by current sum + vAllocationDiff -= vCurrentAllocationSum; + + // Adding sizes to children to adjust + for (vIterator=vFlexibleChildrenLength-1; vIterator>=0; vIterator--) + { + vCurrentChild = vFlexibleChildren[vIterator]; + vCurrentChild._computedWidthFlexValue += vCurrentAllocationSum / vFactorSum * vCurrentChild._computedWidthParsed; + + if (vCurrentChild._allocationLoops == vMinAllocationLoops) + { + vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue); + + vUsedWidth += vCurrentChild._computedWidthFlexValue; + delete vCurrentChild._allocationLoops; + qx.lang.Array.removeAt(vFlexibleChildren, vIterator); + } + else + { + if (vAllocationDiff == 0) + { + vCurrentChild._computedWidthFlexValue = Math.round(vCurrentChild._computedWidthFlexValue); + vUsedWidth += vCurrentChild._computedWidthFlexValue; + delete vCurrentChild._allocationLoops; + } + else + { + vCurrentChild._allocationLoops -= vMinAllocationLoops; + } + } + } + } + } + } + + // ************************************************************* + // 7. Fix rounding errors + // ************************************************************* + vCurrentChild._computedWidthFlexValue += vAvailWidth - vUsedWidth; +} + +qx.Proto.invalidateChildrenFlexWidth = function() { + delete this._childrenFlexWidthComputed; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the width needed by all children of this widget +*/ +qx.Proto.computeChildrenNeededWidth = function() +{ + var w = this.getWidget(); + return qx.renderer.layout.LayoutImpl.prototype.computeChildrenNeededWidth_sum.call(this) + ((w.getVisibleChildrenLength()-1) * w.getSpacing()); +} + + + + + + +/* +--------------------------------------------------------------------------- + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS +--------------------------------------------------------------------------- +*/ + +/*! + Things to do and layout when any of the childs changes its outer width. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild) +{ + // if a childrens outer width changes we need to update our accumulated + // width of all childrens (used for center or right alignments) + this.getWidget()._invalidateAccumulatedChildrenOuterWidth(); +} + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) +{ + if (this.getWidget().getHorizontalChildrenAlign() == "center") { + vChild.addToLayoutChanges("locationX"); + } + + // use variables here to be sure to call both methods. + var vUpdatePercent = vChild._recomputePercentX(); + var vUpdateFlex = vChild._recomputeFlexX(); + + // inform the caller if there were any notable changes occured + return vUpdatePercent || vUpdateFlex; +} + +/*! + Actions that should be done if the inner height of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) +{ + // use variables here to be sure to call both methods. + var vUpdatePercent = vChild._recomputePercentY(); + var vUpdateStretch = vChild._recomputeStretchingY(); + + // priority to childs internal alignment + if ((vChild.getVerticalAlign() || this.getWidget().getVerticalChildrenAlign()) == "middle") { + vChild.addToLayoutChanges("locationY"); + } + + // inform the caller if there were any notable changes occured + return vUpdatePercent || vUpdateStretch; +} + + + + + +/* +--------------------------------------------------------------------------- + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Invalidate and recompute things because of job in queue (before the rest of job handling will be executed). +*/ +qx.Proto.updateSelfOnJobQueueFlush = function(vJobQueue) +{ + if (vJobQueue.addChild || vJobQueue.removeChild) { + this.getWidget()._invalidateAccumulatedChildrenOuterWidth(); + } +} + + + + + + +/* +--------------------------------------------------------------------------- + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Updates children on special jobs +*/ +qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue) +{ + var vStretchX=false, vStretchY=false; + var vWidget = this.getWidget(); + + // switching the orientation need updates for stretching on both axis + if (vQueue.orientation) { + vStretchX = vStretchY = true; + } + + // different updates depending from the current orientation (or the new one) + if (vQueue.spacing || vQueue.orientation || vQueue.reverseChildrenOrder || vQueue.horizontalChildrenAlign) { + vWidget._addChildrenToLayoutQueue("locationX"); + } + + if (vQueue.verticalChildrenAlign) { + vWidget._addChildrenToLayoutQueue("locationY"); + } + + if (vQueue.stretchChildrenOrthogonalAxis) { + vStretchY = true; + } + + // if stretching should be reworked reset the previous one and add + // a layout job to update the width respectively height. + if (vStretchX) + { + vWidget._recomputeChildrenStretchingX(); + vWidget._addChildrenToLayoutQueue("width"); + } + + if (vStretchY) + { + vWidget._recomputeChildrenStretchingY(); + vWidget._addChildrenToLayoutQueue("height"); + } + + return true; +} + + + + + +/* +--------------------------------------------------------------------------- + [08] CHILDREN ADD/REMOVE/MOVE HANDLING +--------------------------------------------------------------------------- +*/ + +/*! + This method combines calls of methods which should be done if a widget should be removed from the current layout. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateChildrenOnRemoveChild = function(vChild, vIndex) +{ + var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i=-1; + + // Fix index to be at the first flex child + if (this.getEnableFlexSupport()) + { + for (i=0; i<chl; i++) + { + chc = ch[i]; + if (chc.getHasFlexX()) + { + vIndex = Math.min(vIndex, i); + break; + } + } + + i=-1; + } + + // Handle differently depending on layout mode + switch(w.getLayoutMode()) + { + case "right": + case "left-reversed": + while((chc=ch[++i]) && i<vIndex) { + chc.addToLayoutChanges("locationX"); + } + + break; + + case "center": + case "center-reversed": + while(chc=ch[++i]) { + chc.addToLayoutChanges("locationX"); + } + + break; + + default: + i+=vIndex; + while(chc=ch[++i]) { + chc.addToLayoutChanges("locationX"); + } + } +} + +/*! + This method combines calls of methods which should be done if a child should be moved + inside the same parent to a new positions. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateChildrenOnMoveChild = function(vChild, vIndex, vOldIndex) +{ + var vChildren = this.getWidget().getVisibleChildren(); + + var vStart = Math.min(vIndex, vOldIndex); + var vStop = Math.max(vIndex, vOldIndex)+1; + + for (var i=vStart; i<vStop; i++) { + vChildren[i].addToLayoutChanges("locationX"); + } +} + + + + + +/* +--------------------------------------------------------------------------- + [09] FLUSH LAYOUT QUEUES OF CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + This method have full control of the order in which the + registered (or also non-registered) children should be + layouted on the horizontal axis. +*/ +qx.Proto.flushChildrenQueue = function(vChildrenQueue) +{ + var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i; + + // This block is needed for flex handling and + // will inform flex children if there was any + // change to the other content + if (this.getEnableFlexSupport()) + { + this.invalidateChildrenFlexWidth(); + + for (i=0; i<chl; i++) + { + chc = ch[i]; + if (chc.getHasFlexX()) + { + chc._computedWidthValue = null; + + if (chc._recomputeBoxWidth()) + { + chc._recomputeOuterWidth(); + chc._recomputeInnerWidth(); + } + + vChildrenQueue[chc.toHashCode()] = chc; + chc._layoutChanges.width = true; + } + } + } + + switch(w.getLayoutMode()) + { + case "right": + case "left-reversed": + // find the last child which has a layout request + for (var i=chl-1; i>=0 && !vChildrenQueue[ch[i].toHashCode()]; i--) {} + + // layout all children before this last child + for (var j=0; j<=i; j++) { + w._layoutChild(chc=ch[j]); + } + + break; + + case "center": + case "center-reversed": + // re-layout all children + i = -1; + while(chc=ch[++i]) { + w._layoutChild(chc); + } + + break; + + default: + // layout all childs from the first child + // with an own layout request to the end + i = -1; + var changed=false; + while(chc=ch[++i]) + { + if (changed || vChildrenQueue[chc.toHashCode()]) + { + w._layoutChild(chc); + changed = true; + } + } + } +} + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +/*! + This is called from qx.ui.core.Widget and it's task is to apply the layout + (excluding border and padding) to the child. +*/ +qx.Proto.layoutChild = function(vChild, vJobs) +{ + this.layoutChild_sizeX(vChild, vJobs); + this.layoutChild_sizeY(vChild, vJobs); + + this.layoutChild_sizeLimitX(vChild, vJobs); + this.layoutChild_sizeLimitY(vChild, vJobs); + + this.layoutChild_locationX(vChild, vJobs); + this.layoutChild_locationY(vChild, vJobs); + + this.layoutChild_marginX(vChild, vJobs); + this.layoutChild_marginY(vChild, vJobs); +} + +if (qx.sys.Client.getInstance().isMshtml() || qx.sys.Client.getInstance().isOpera() || qx.sys.Client.getInstance().isWebkit() ) +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width || vJobs.minWidth || vJobs.maxWidth) + { + if (vChild._isWidthEssential() && (!vChild._computedWidthTypeNull || !vChild._computedMinWidthTypeNull || !vChild._computedMaxWidthTypeNull)) + { + vChild._applyRuntimeWidth(vChild.getBoxWidth()); + } + else + { + vChild._resetRuntimeWidth(); + } + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height || vJobs.minHeight || vJobs.maxHeight) + { + if ((vChild._isHeightEssential() && (!vChild._computedHeightTypeNull || !vChild._computedMinHeightTypeNull || !vChild._computedMaxHeightTypeNull)) || (vChild.getAllowStretchY() && this.getWidget().getStretchChildrenOrthogonalAxis())) + { + vChild._applyRuntimeHeight(vChild.getBoxHeight()); + } + else + { + vChild._resetRuntimeHeight(); + } + } + } +} +else +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width) + { + if (vChild._isWidthEssential() && !vChild._computedWidthTypeNull) + { + vChild._applyRuntimeWidth(vChild.getWidthValue()); + } + else + { + vChild._resetRuntimeWidth(); + } + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height) + { + if (vChild._isHeightEssential() && !vChild._computedHeightTypeNull) + { + vChild._applyRuntimeHeight(vChild.getHeightValue()); + } + else + { + vChild._resetRuntimeHeight(); + } + } + } +} + +qx.Proto.layoutChild_locationX = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + // handle first child + if (vWidget.getFirstVisibleChild() == vChild) + { + switch(vWidget.getLayoutMode()) + { + case "right": + case "left-reversed": + var vPos = vWidget.getPaddingRight() + vWidget.getAccumulatedChildrenOuterWidth() - vChild.getOuterWidth(); + break; + + case "center": + case "center-reversed": + var vPos = vWidget.getPaddingLeft() + Math.round((vWidget.getInnerWidth() - vWidget.getAccumulatedChildrenOuterWidth()) / 2); + break; + + default: + var vPos = vWidget.getPaddingLeft(); + } + } + + // handle any following child + else + { + var vPrev = vChild.getPreviousVisibleSibling(); + + switch(vWidget.getLayoutMode()) + { + case "right": + case "left-reversed": + var vPos = vPrev._cachedLocationHorizontal - vChild.getOuterWidth() - vWidget.getSpacing(); + break; + + default: + var vPos = vPrev._cachedLocationHorizontal + vPrev.getOuterWidth() + vWidget.getSpacing(); + } + } + + // store for next sibling + vChild._cachedLocationHorizontal = vPos; + + // apply styles + switch(vWidget.getLayoutMode()) + { + case "right": + case "right-reversed": + case "center-reversed": + // add relative positions (like 'position:relative' in css) + vPos += !vChild._computedRightTypeNull ? vChild.getRightValue() : !vChild._computedLeftTypeNull ? -(vChild.getLeftValue()) : 0; + + vChild._resetRuntimeLeft(); + vChild._applyRuntimeRight(vPos); + break; + + default: + // add relative positions (like 'position:relative' in css) + vPos += !vChild._computedLeftTypeNull ? vChild.getLeftValue() : !vChild._computedRightTypeNull ? -(vChild.getRightValue()) : 0; + + vChild._resetRuntimeRight(); + vChild._applyRuntimeLeft(vPos); + } +} + +qx.Proto.layoutChild_locationY = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + // special stretching support + if (qx.sys.Client.getInstance().isGecko() && vChild.getAllowStretchY() && vWidget.getStretchChildrenOrthogonalAxis() && vChild._computedHeightTypeNull) + { + vChild._applyRuntimeTop(vWidget.getPaddingTop() || 0); + vChild._applyRuntimeBottom(vWidget.getPaddingBottom() || 0); + + return; + } + + // priority to childs internal alignment + var vAlign = vChild.getVerticalAlign() || vWidget.getVerticalChildrenAlign(); + + // handle middle alignment + var vPos = vAlign == "middle" ? Math.round((vWidget.getInnerHeight() - vChild.getOuterHeight()) / 2) : 0; + + // the bottom alignment use the real 'bottom' styleproperty to + // use the best available method in modern browsers + if (vAlign == "bottom") + { + // add parent padding + vPos += vWidget.getPaddingBottom(); + + // relative positions (like 'position:relative' in css) + if (!vChild._computedBottomTypeNull) { + vPos += vChild.getBottomValue(); + } + else if (!vChild._computedTopTypeNull) { + vPos -= vChild.getTopValue(); + } + + // apply styles + vChild._resetRuntimeTop(); + vChild._applyRuntimeBottom(vPos); + } + else + { + // add parent padding + vPos += vWidget.getPaddingTop(); + + // relative positions (like 'position:relative' in css) + if (!vChild._computedTopTypeNull) { + vPos += vChild.getTopValue(); + } + else if (!vChild._computedBottomTypeNull) { + vPos -= vChild.getBottomValue(); + } + + // apply styles + vChild._resetRuntimeBottom(); + vChild._applyRuntimeTop(vPos); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/LayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/LayoutImpl.js new file mode 100644 index 0000000000..5855d7d420 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/LayoutImpl.js @@ -0,0 +1,442 @@ +/* ************************************************************************ + + 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) +#module(ui_layout) +#require(qx.sys.Client) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.LayoutImpl", qx.core.Object, +function(vWidget) +{ + qx.core.Object.call(this); + + this._widget = vWidget; +}); + + + + +/*! + Returns the associated widget +*/ +qx.Proto.getWidget = function() { + return this._widget; +} + + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER +*/ + + +/* +--------------------------------------------------------------------------- + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the box width of the given child +*/ +qx.Proto.computeChildBoxWidth = function(vChild) { + return vChild.getWidthValue() || vChild._computeBoxWidthFallback(); +} + +/*! + Compute and return the box height of the given child +*/ +qx.Proto.computeChildBoxHeight = function(vChild) { + return vChild.getHeightValue() || vChild._computeBoxHeightFallback(); +} + + + + + +/* +--------------------------------------------------------------------------- + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the needed width of the given child +*/ +qx.Proto.computeChildNeededWidth = function(vChild) +{ + // omit ultra long lines, these two variables only needed once + // here, but this enhance the readability of the code :) + var vMinBox = vChild._computedMinWidthTypePercent ? null : vChild.getMinWidthValue(); + var vMaxBox = vChild._computedMaxWidthTypePercent ? null : vChild.getMaxWidthValue(); + + var vBox = (vChild._computedWidthTypePercent || vChild._computedWidthTypeFlex ? null : vChild.getWidthValue()) || vChild.getPreferredBoxWidth() || 0; + + return qx.lang.Number.limit(vBox, vMinBox, vMaxBox) + vChild.getMarginLeft() + vChild.getMarginRight(); +} + +/*! + Compute and return the needed height of the given child +*/ +qx.Proto.computeChildNeededHeight = function(vChild) +{ + // omit ultra long lines, these two variables only needed once + // here, but this enhance the readability of the code :) + var vMinBox = vChild._computedMinHeightTypePercent ? null : vChild.getMinHeightValue(); + var vMaxBox = vChild._computedMaxHeightTypePercent ? null : vChild.getMaxHeightValue(); + + var vBox = (vChild._computedHeightTypePercent || vChild._computedHeightTypeFlex ? null : vChild.getHeightValue()) || vChild.getPreferredBoxHeight() || 0; + + return qx.lang.Number.limit(vBox, vMinBox, vMaxBox) + vChild.getMarginTop() + vChild.getMarginBottom(); +} + + + + +/* +--------------------------------------------------------------------------- + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Calculate the maximum needed width of all children +*/ +qx.Proto.computeChildrenNeededWidth_max = function() +{ + for (var i=0, ch=this.getWidget().getVisibleChildren(), chl=ch.length, maxv=0; i<chl; i++) { + maxv = Math.max(maxv, ch[i].getNeededWidth()); + } + + return maxv; +} + +/*! + Calculate the maximum needed height of all children +*/ +qx.Proto.computeChildrenNeededHeight_max = function() +{ + for (var i=0, ch=this.getWidget().getVisibleChildren(), chl=ch.length, maxv=0; i<chl; i++) { + maxv = Math.max(maxv, ch[i].getNeededHeight()); + } + + return maxv; +} + +qx.Proto.computeChildrenNeededWidth_sum = function() +{ + for (var i=0, ch=this.getWidget().getVisibleChildren(), chl=ch.length, sumv=0; i<chl; i++) { + sumv += ch[i].getNeededWidth(); + } + + return sumv; +} + +qx.Proto.computeChildrenNeededHeight_sum = function() +{ + for (var i=0, ch=this.getWidget().getVisibleChildren(), chl=ch.length, sumv=0; i<chl; i++) { + sumv += ch[i].getNeededHeight(); + } + + return sumv; +} + +/*! + Compute and return the width needed by all children of this widget +*/ +qx.Proto.computeChildrenNeededWidth = qx.Proto.computeChildrenNeededWidth_max; + +/*! + Compute and return the height needed by all children of this widget +*/ +qx.Proto.computeChildrenNeededHeight = qx.Proto.computeChildrenNeededHeight_max; + + + + +/* +--------------------------------------------------------------------------- + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS +--------------------------------------------------------------------------- +*/ + +/*! + Things to do and layout when any of the childs changes its outer width. + Needed by layouts where the children depend on each other, like flow or box layouts. +*/ +qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild) {} + +/*! + Things to do and layout when any of the childs changes its outer height. + Needed by layouts where the children depend on each other, like flow or box layouts. +*/ +qx.Proto.updateSelfOnChildOuterHeightChange = function(vChild) {} + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the layout widget has changed. + Normally this includes updates to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) {} + +/*! + Actions that should be done if the inner height of the layout widget has changed. + Normally this includes updates to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) {} + + + + + +/* +--------------------------------------------------------------------------- + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Invalidate and recompute cached data according to job queue. + This is executed at the beginning of the job queue handling. +*/ +qx.Proto.updateSelfOnJobQueueFlush = function(vJobQueue) {} + + + + + + +/* +--------------------------------------------------------------------------- + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Updates children on job queue flush. + This is executed at the end of the job queue handling. +*/ +qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue) {} + + + + + + +/* +--------------------------------------------------------------------------- + [08] CHILDREN ADD/REMOVE/MOVE HANDLING +--------------------------------------------------------------------------- +*/ + +/*! + Add child to current layout. Rarely needed by some layout implementations. +*/ +qx.Proto.updateChildrenOnAddChild = function(vChild, vIndex) {} + +/*! + Remove child from current layout. + Needed by layouts where the children depend on each other, like flow or box layouts. +*/ +qx.Proto.updateChildrenOnRemoveChild = function(vChild, vIndex) {} + +/*! + Move child within its parent to a new position. + Needed by layouts where the children depend on each other, like flow or box layouts. +*/ +qx.Proto.updateChildrenOnMoveChild = function(vChild, vIndex, vOldIndex) {} + + + + + + + +/* +--------------------------------------------------------------------------- + [09] FLUSH LAYOUT QUEUES OF CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Has full control of the order in which the registered + (or non-registered) children should be layouted. +*/ +qx.Proto.flushChildrenQueue = function(vChildrenQueue) +{ + var vWidget = this.getWidget(); + + for (var vHashCode in vChildrenQueue) { + vWidget._layoutChild(vChildrenQueue[vHashCode]); + } +} + + + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Called from qx.ui.core.Widget. Its task is to apply the layout + (excluding border and padding) to the child. +*/ +qx.Proto.layoutChild = function(vChild, vJobs) {} + +if (qx.sys.Client.getInstance().isMshtml()) +{ + qx.Proto.layoutChild_sizeLimitX = qx.util.Return.returnTrue; + qx.Proto.layoutChild_sizeLimitY = qx.util.Return.returnTrue; +} +else +{ + /*! + Apply min-/max-width/height to the child. Direct usage of stylesheet properties. + This is only possible in modern capable clients (i.e. excluding all current + versions of Internet Explorer) + */ + qx.Proto.layoutChild_sizeLimitX = function(vChild, vJobs) + { + if (vJobs.minWidth) { + vChild._computedMinWidthTypeNull ? vChild._resetRuntimeMinWidth() : vChild._applyRuntimeMinWidth(vChild.getMinWidthValue()); + } + else if (vJobs.initial && !vChild._computedMinWidthTypeNull) { + vChild._applyRuntimeMinWidth(vChild.getMinWidthValue()); + } + + if (vJobs.maxWidth) { + vChild._computedMaxWidthTypeNull ? vChild._resetRuntimeMaxWidth() : vChild._applyRuntimeMaxWidth(vChild.getMaxWidthValue()); + } + else if (vJobs.initial && !vChild._computedMaxWidthTypeNull) { + vChild._applyRuntimeMaxWidth(vChild.getMaxWidthValue()); + } + } + + qx.Proto.layoutChild_sizeLimitY = function(vChild, vJobs) + { + if (vJobs.minHeight) { + vChild._computedMinHeightTypeNull ? vChild._resetRuntimeMinHeight() : vChild._applyRuntimeMinHeight(vChild.getMinHeightValue()); + } + else if (vJobs.initial && !vChild._computedMinHeightTypeNull) { + vChild._applyRuntimeMinHeight(vChild.getMinHeightValue()); + } + + if (vJobs.maxHeight) { + vChild._computedMaxHeightTypeNull ? vChild._resetRuntimeMaxHeight() : vChild._applyRuntimeMaxHeight(vChild.getMaxHeightValue()); + } + else if (vJobs.initial && !vChild._computedMaxHeightTypeNull) { + vChild._applyRuntimeMaxHeight(vChild.getMaxHeightValue()); + } + } +} + +/*! + Apply the margin values as pure stylesheet equivalent. +*/ +qx.Proto.layoutChild_marginX = function(vChild, vJobs) +{ + if (vJobs.marginLeft || vJobs.initial) + { + var vValueLeft = vChild.getMarginLeft(); + vValueLeft != null ? vChild._applyRuntimeMarginLeft(vValueLeft) : vChild._resetRuntimeMarginLeft(); + } + + if (vJobs.marginRight || vJobs.initial) + { + var vValueRight = vChild.getMarginRight(); + vValueRight != null ? vChild._applyRuntimeMarginRight(vValueRight) : vChild._resetRuntimeMarginRight(); + } +} + +qx.Proto.layoutChild_marginY = function(vChild, vJobs) +{ + if (vJobs.marginTop || vJobs.initial) + { + var vValueTop = vChild.getMarginTop(); + vValueTop != null ? vChild._applyRuntimeMarginTop(vValueTop) : vChild._resetRuntimeMarginTop(); + } + + if (vJobs.marginBottom || vJobs.initial) + { + var vValueBottom = vChild.getMarginBottom(); + vValueBottom != null ? vChild._applyRuntimeMarginBottom(vValueBottom) : vChild._resetRuntimeMarginBottom(); + } +} + +qx.Proto.layoutChild_sizeX_essentialWrapper = function(vChild, vJobs) { + return vChild._isWidthEssential() ? this.layoutChild_sizeX(vChild, vJobs) : vChild._resetRuntimeWidth(); +} + +qx.Proto.layoutChild_sizeY_essentialWrapper = function(vChild, vJobs) { + return vChild._isHeightEssential() ? this.layoutChild_sizeY(vChild, vJobs) : vChild._resetRuntimeHeight(); +} + + + + + + +/* +--------------------------------------------------------------------------- + [11] DISPOSER +--------------------------------------------------------------------------- +*/ + +/*! + Dispose the layout implmentation and release the associated widget. +*/ +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return true; + } + + this._widget = null; + + qx.core.Object.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuButtonLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuButtonLayoutImpl.js new file mode 100644 index 0000000000..c62b60e18e --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuButtonLayoutImpl.js @@ -0,0 +1,183 @@ +/* ************************************************************************ + + 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_menu) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.MenuButtonLayoutImpl", qx.renderer.layout.HorizontalBoxLayoutImpl, +function(vWidget) +{ + qx.renderer.layout.HorizontalBoxLayoutImpl.call(this, vWidget); + + // We don't need flex support, should make things a bit faster, + // as this omits some additional loops in qx.renderer.layout.HorizontalBoxLayoutImpl. + this.setEnableFlexSupport(false); +}); + + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + + Inherits from qx.renderer.layout.HorizontalBoxLayoutImpl: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [11] DISPOSER +*/ + + + + + +/* +--------------------------------------------------------------------------- + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the width needed by all children of this widget +*/ +qx.Proto.computeChildrenNeededWidth = function() +{ + // Caching the widget reference + var vWidget = this.getWidget(); + + // Ignore the verticalBoxLayout inside qx.ui.menu.Menu + var vMenu = vWidget.getParent().getParent(); + + // Let the menu do the real hard things + return vMenu.getMenuButtonNeededWidth(); +} + + + + + + + +/* +--------------------------------------------------------------------------- + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS +--------------------------------------------------------------------------- +*/ + +/*! + Things to do and layout when any of the childs changes its outer width. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateSelfOnChildOuterWidthChange = function(vChild) +{ + // Caching the widget reference + var vWidget = this.getWidget(); + + // Ignore the verticalBoxLayout inside qx.ui.menu.Menu + var vMenu = vWidget.getParent().getParent(); + + // Send out invalidate signals + switch(vChild) + { + case vWidget._iconObject: + vMenu._invalidateMaxIconWidth(); + break; + + case vWidget._labelObject: + vMenu._invalidateMaxLabelWidth(); + break; + + case vWidget._shortcutObject: + vMenu._invalidateMaxShortcutWidth(); + break; + + case vWidget._arrowObject: + vMenu._invalidateMaxArrowWidth(); + break; + } + + // Call superclass implementation + return qx.renderer.layout.HorizontalBoxLayoutImpl.prototype.updateSelfOnChildOuterWidthChange.call(this, vChild); +} + + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +qx.Proto.layoutChild_locationX = function(vChild, vJobs) +{ + // Caching the widget reference + var vWidget = this.getWidget(); + + // Ignore the verticalBoxLayout inside qx.ui.menu.Menu + var vMenu = vWidget.getParent().getParent(); + + // Left position of the child + var vPos = null; + + // Ask the menu instance for the correct location + switch(vChild) + { + case vWidget._iconObject: + vPos = vMenu.getIconPosition(); + break; + + case vWidget._labelObject: + vPos = vMenu.getLabelPosition(); + break; + + case vWidget._shortcutObject: + vPos = vMenu.getShortcutPosition(); + break; + + case vWidget._arrowObject: + vPos = vMenu.getArrowPosition(); + break; + } + + if (vPos != null) + { + vPos += vWidget.getPaddingLeft(); + vChild._applyRuntimeLeft(vPos); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuLayoutImpl.js new file mode 100644 index 0000000000..abb747cc81 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/MenuLayoutImpl.js @@ -0,0 +1,100 @@ +/* ************************************************************************ + + 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_menu) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.MenuLayoutImpl", qx.renderer.layout.VerticalBoxLayoutImpl, +function(vWidget) +{ + qx.renderer.layout.VerticalBoxLayoutImpl.call(this, vWidget); + + // We don't need flex support, should make things a bit faster, + // as this omits some additional loops in qx.renderer.layout.HorizontalBoxLayoutImpl. + this.setEnableFlexSupport(false); +}); + + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + + Inherits from qx.renderer.layout.VerticalBoxLayoutImpl: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER +*/ + + + + +/* +--------------------------------------------------------------------------- + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Updates children on special jobs +*/ +qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue) +{ + var vWidget = this.getWidget(); + var ch, chc; + + if (vQueue.preferredInnerWidth) + { + var ch = vWidget.getChildren(), chl = ch.length, chc; + var sch, schl; + + for (var i=0; i<chl; i++) + { + chc = ch[i]; + sch = chc.getChildren(); + schl = sch.length; + + for (var j=0; j<schl; j++) { + sch[j].addToLayoutChanges("locationX"); + } + } + } + + // Call superclass implementation + return qx.renderer.layout.VerticalBoxLayoutImpl.prototype.updateChildrenOnJobQueueFlush.call(this, vQueue); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/VerticalBoxLayoutImpl.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/VerticalBoxLayoutImpl.js new file mode 100644 index 0000000000..deaac7f9d7 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout/VerticalBoxLayoutImpl.js @@ -0,0 +1,866 @@ +/* ************************************************************************ + + 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) +#module(ui_layout) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.layout.VerticalBoxLayoutImpl", qx.renderer.layout.LayoutImpl, +function(vWidget) { + qx.renderer.layout.LayoutImpl.call(this, vWidget); +}); + +qx.OO.addProperty({ name : "enableFlexSupport", type : "boolean", defaultValue : true }); + + + +/*! + Global Structure: + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH + [08] CHILDREN ADD/REMOVE/MOVE HANDLING + [09] FLUSH LAYOUT QUEUES OF CHILDREN + [10] LAYOUT CHILD + [11] DISPOSER + + + Inherits from qx.renderer.layout.LayoutImpl: + [02] COMPUTE NEEDED DIMENSIONS FOR AN INDIVIDUAL CHILD + [11] DISPOSER +*/ + + + +/* +--------------------------------------------------------------------------- + [01] COMPUTE BOX DIMENSIONS FOR AN INDIVIDUAL CHILD +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the box width of the given child. +*/ +qx.Proto.computeChildBoxWidth = function(vChild) +{ + if (this.getWidget().getStretchChildrenOrthogonalAxis() && vChild._computedWidthTypeNull && vChild.getAllowStretchX()) { + return this.getWidget().getInnerWidth(); + } + + return vChild.getWidthValue() || vChild._computeBoxWidthFallback(); +} + +/*! + Compute and return the box height of the given child. +*/ +qx.Proto.computeChildBoxHeight = function(vChild) { + return vChild.getHeightValue() || vChild._computeBoxHeightFallback(); +} + +/*! + Computes the height of all flexible children. +*/ +qx.Proto.computeChildrenFlexHeight = function() +{ + if (this._childrenFlexHeightComputed || !this.getEnableFlexSupport()) { + return; + } + + this._childrenFlexHeightComputed = true; + + // this.debug("computeChildrenFlexHeight"); + + var vWidget = this.getWidget(); + var vChildren = vWidget.getVisibleChildren(); + var vChildrenLength = vChildren.length; + var vCurrentChild; + var vFlexibleChildren = []; + var vAvailHeight = vWidget.getInnerHeight(); + var vUsedHeight = vWidget.getSpacing() * (vChildrenLength-1); + var vIterator; + + + // ************************************************************* + // 1. Compute the sum of all static sized children and finding + // all flexible children. + // ************************************************************* + for (vIterator=0; vIterator<vChildrenLength; vIterator++) + { + vCurrentChild = vChildren[vIterator]; + + if (vCurrentChild._computedHeightTypeFlex) + { + vFlexibleChildren.push(vCurrentChild); + + if (vWidget._computedHeightTypeAuto) { + vUsedHeight += vCurrentChild.getPreferredBoxHeight(); + } + } + else + { + vUsedHeight += vCurrentChild.getOuterHeight(); + } + } + + // this.debug("Height: " + vUsedHeight + "/" + vAvailHeight); + // this.debug("Flexible Count: " + vFlexibleChildren.length); + + + // ************************************************************* + // 2. Compute the sum of all flexible children heights + // ************************************************************* + var vRemainingHeight = vAvailHeight - vUsedHeight; + var vFlexibleChildrenLength = vFlexibleChildren.length; + var vPrioritySum = 0; + + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) { + vPrioritySum += vFlexibleChildren[vIterator]._computedHeightParsed; + } + + + // ************************************************************* + // 3. Calculating the size of each 'part'. + // ************************************************************* + var vPartHeight = vRemainingHeight / vPrioritySum; + + + if (!vWidget.getUseAdvancedFlexAllocation()) + { + // ************************************************************* + // 4a. Computing the flex height value of each flexible child + // and add the height to the usedHeight, so that we can + // fix rounding problems later. + // ************************************************************* + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + vCurrentChild._computedHeightFlexValue = Math.round(vCurrentChild._computedHeightParsed * vPartHeight); + vUsedHeight += vCurrentChild._computedHeightFlexValue; + } + } + else + { + // ************************************************************* + // 4b. Calculating the diff. Which means respect the min/max + // height configuration in flex and store the higher/lower + // data in a diff. + // ************************************************************* + + var vAllocationDiff = 0; + var vMinAllocationLoops, vFlexibleChildrenLength, vAdjust, vCurrentAllocationSum, vFactorSum, vComputedFlexibleHeight; + + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + vComputedFlexibleHeight = vCurrentChild._computedHeightFlexValue = vCurrentChild._computedHeightParsed * vPartHeight; + vAllocationDiff += vComputedFlexibleHeight - qx.lang.Number.limit(vComputedFlexibleHeight, vCurrentChild.getMinHeightValue(), vCurrentChild.getMaxHeightValue()); + } + + // Rounding diff + vAllocationDiff = Math.round(vAllocationDiff); + + if (vAllocationDiff == 0) + { + // ************************************************************* + // 5a. If the diff is equal zero we must not do anything more + // and do nearly identical the same like in 4a. which means + // to round the calculated flex value and add it to the + // used height so we can fix rounding problems later. + // ************************************************************* + + // Rounding values and fixing rounding errors + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + vCurrentChild._computedHeightFlexValue = Math.round(vCurrentChild._computedHeightFlexValue); + vUsedHeight += vCurrentChild._computedHeightFlexValue; + } + } + else + { + // ************************************************************* + // 5b. Find maximum loops of each adjustable child to adjust + // the height until the min/max height limits are reached. + // ************************************************************* + + var vUp = vAllocationDiff > 0; + for (vIterator=vFlexibleChildrenLength-1; vIterator>=0; vIterator--) + { + vCurrentChild = vFlexibleChildren[vIterator]; + + if (vUp) + { + vAdjust = (vCurrentChild.getMaxHeightValue() || Infinity) - vCurrentChild._computedHeightFlexValue; + + if (vAdjust > 0) + { + vCurrentChild._allocationLoops = Math.floor(vAdjust / vCurrentChild._computedHeightParsed); + } + else + { + qx.lang.Array.removeAt(vFlexibleChildren, vIterator); + + vCurrentChild._computedHeightFlexValue = Math.round(vCurrentChild._computedHeightFlexValue); + vUsedHeight += Math.round(vCurrentChild._computedHeightFlexValue + vAdjust); + } + } + else + { + vAdjust = qx.util.Validation.isValidNumber(vCurrentChild.getMinHeightValue()) ? vCurrentChild._computedHeightFlexValue - vCurrentChild.getMinHeightValue() : vCurrentChild._computedHeightFlexValue; + + if (vAdjust > 0) + { + vCurrentChild._allocationLoops = Math.floor(vAdjust / vCurrentChild._computedHeightParsed); + } + else + { + qx.lang.Array.removeAt(vFlexibleChildren, vIterator); + + vCurrentChild._computedHeightFlexValue = Math.round(vCurrentChild._computedHeightFlexValue); + vUsedHeight += Math.round(vCurrentChild._computedHeightFlexValue - vAdjust); + } + } + } + + // ************************************************************* + // 6. Try to reallocate the height between flexible children + // so that the requirements through min/max limits + // are satisfied. + // ************************************************************* + while (vAllocationDiff != 0 && vFlexibleChildrenLength > 0) + { + vFlexibleChildrenLength = vFlexibleChildren.length; + vMinAllocationLoops = Infinity; + vFactorSum = 0; + + // Find minimal loop amount + for (vIterator=0; vIterator<vFlexibleChildrenLength; vIterator++) + { + vMinAllocationLoops = Math.min(vMinAllocationLoops, vFlexibleChildren[vIterator]._allocationLoops); + vFactorSum += vFlexibleChildren[vIterator]._computedHeightParsed; + } + + // Be sure that the adjustment is not bigger/smaller than diff + vCurrentAllocationSum = Math.min(vFactorSum * vMinAllocationLoops, vAllocationDiff); + + // this.debug("Diff: " + vAllocationDiff); + // this.debug("Min Loops: " + vMinAllocationLoops); + // this.debug("Sum: " + vCurrentAllocationSum); + // this.debug("Factor: " + vFactorSum); + + // Reducing diff by current sum + vAllocationDiff -= vCurrentAllocationSum; + + // Adding sizes to children to adjust + for (vIterator=vFlexibleChildrenLength-1; vIterator>=0; vIterator--) + { + vCurrentChild = vFlexibleChildren[vIterator]; + vCurrentChild._computedHeightFlexValue += vCurrentAllocationSum / vFactorSum * vCurrentChild._computedHeightParsed; + + if (vCurrentChild._allocationLoops == vMinAllocationLoops) + { + vCurrentChild._computedHeightFlexValue = Math.round(vCurrentChild._computedHeightFlexValue); + + vUsedHeight += vCurrentChild._computedHeightFlexValue; + delete vCurrentChild._allocationLoops; + qx.lang.Array.removeAt(vFlexibleChildren, vIterator); + } + else + { + if (vAllocationDiff == 0) + { + vCurrentChild._computedHeightFlexValue = Math.round(vCurrentChild._computedHeightFlexValue); + vUsedHeight += vCurrentChild._computedHeightFlexValue; + delete vCurrentChild._allocationLoops; + } + else + { + vCurrentChild._allocationLoops -= vMinAllocationLoops; + } + } + } + } + } + } + + // ************************************************************* + // 7. Fix rounding errors + // ************************************************************* + vCurrentChild._computedHeightFlexValue += vAvailHeight - vUsedHeight; +} + +qx.Proto.invalidateChildrenFlexHeight = function() { + delete this._childrenFlexHeightComputed; +} + + + + + +/* +--------------------------------------------------------------------------- + [03] COMPUTE NEEDED DIMENSIONS FOR ALL CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + Compute and return the height needed by all children of this widget +*/ +qx.Proto.computeChildrenNeededHeight = function() +{ + var w = this.getWidget(); + return qx.renderer.layout.LayoutImpl.prototype.computeChildrenNeededHeight_sum.call(this) + ((w.getVisibleChildrenLength()-1) * w.getSpacing()); +} + + + + + + +/* +--------------------------------------------------------------------------- + [04] UPDATE LAYOUT WHEN A CHILD CHANGES ITS OUTER DIMENSIONS +--------------------------------------------------------------------------- +*/ + +/*! + Things to do and layout when any of the childs changes its outer height. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateSelfOnChildOuterHeightChange = function(vChild) +{ + // if a childrens outer height changes we need to update our accumulated + // height of all childrens (used for middle or bottom alignments) + this.getWidget()._invalidateAccumulatedChildrenOuterHeight(); +} + + + + + +/* +--------------------------------------------------------------------------- + [05] UPDATE CHILD ON INNER DIMENSION CHANGES OF LAYOUT +--------------------------------------------------------------------------- +*/ + +/*! + Actions that should be done if the inner width of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerWidthChange = function(vChild) +{ + // use variables here to be sure to call both methods. + var vUpdatePercent = vChild._recomputePercentX(); + var vUpdateStretch = vChild._recomputeStretchingX(); + + // priority to childs internal alignment + if ((vChild.getHorizontalAlign() || this.getWidget().getHorizontalChildrenAlign()) == "center") { + vChild.addToLayoutChanges("locationX"); + } + + // inform the caller if there were any notable changes occured + return vUpdatePercent || vUpdateStretch; +} + +/*! + Actions that should be done if the inner height of the widget was changed. + Normally this includes update to percent values and ranges. +*/ +qx.Proto.updateChildOnInnerHeightChange = function(vChild) +{ + if (this.getWidget().getVerticalChildrenAlign() == "middle") { + vChild.addToLayoutChanges("locationY"); + } + + // use variables here to be sure to call both methods. + var vUpdatePercent = vChild._recomputePercentY(); + var vUpdateFlex = vChild._recomputeFlexY(); + + // inform the caller if there were any notable changes occured + return vUpdatePercent || vUpdateFlex; +} + + + + + + + +/* +--------------------------------------------------------------------------- + [06] UPDATE LAYOUT ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Invalidate and recompute things because of job in queue (before the rest of job handling will be executed). +*/ +qx.Proto.updateSelfOnJobQueueFlush = function(vJobQueue) +{ + if (vJobQueue.addChild || vJobQueue.removeChild) { + this.getWidget()._invalidateAccumulatedChildrenOuterHeight(); + } +} + + + + + + +/* +--------------------------------------------------------------------------- + [07] UPDATE CHILDREN ON JOB QUEUE FLUSH +--------------------------------------------------------------------------- +*/ + +/*! + Updates children on special jobs +*/ +qx.Proto.updateChildrenOnJobQueueFlush = function(vQueue) +{ + var vStretchX=false, vStretchY=false; + var vWidget = this.getWidget(); + + // switching the orientation need updates for stretching on both axis + if (vQueue.orientation) { + vStretchX = vStretchY = true; + } + + // different updates depending from the current orientation (or the new one) + if (vQueue.spacing || vQueue.orientation || vQueue.reverseChildrenOrder || vQueue.verticalChildrenAlign) { + vWidget._addChildrenToLayoutQueue("locationY"); + } + + if (vQueue.horizontalChildrenAlign) { + vWidget._addChildrenToLayoutQueue("locationX"); + } + + if (vQueue.stretchChildrenOrthogonalAxis) { + vStretchX = true; + } + + // if stretching should be reworked reset the previous one and add + // a layout job to update the width respectively height. + if (vStretchX) + { + vWidget._recomputeChildrenStretchingX(); + vWidget._addChildrenToLayoutQueue("width"); + } + + if (vStretchY) + { + vWidget._recomputeChildrenStretchingY(); + vWidget._addChildrenToLayoutQueue("height"); + } + + return true; +} + + + + + + +/* +--------------------------------------------------------------------------- + [08] CHILDREN ADD/REMOVE/MOVE HANDLING +--------------------------------------------------------------------------- +*/ + +/*! + This method combines calls of methods which should be done if a widget should be removed from the current layout. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateChildrenOnRemoveChild = function(vChild, vIndex) +{ + var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i=-1; + + // Fix index to be at the first flex child + if (this.getEnableFlexSupport()) + { + for (var i=0; i<chl; i++) + { + chc = ch[i]; + if (chc.getHasFlexY()) + { + vIndex = Math.min(vIndex, i); + break; + } + } + + i=-1; + } + + // Handle differently depending on layout mode + switch(w.getLayoutMode()) + { + case "bottom": + case "top-reversed": + while((chc=ch[++i]) && i<vIndex) { + chc.addToLayoutChanges("locationY"); + } + + break; + + case "middle": + case "middle-reversed": + while(chc=ch[++i]) { + chc.addToLayoutChanges("locationY"); + } + + break; + + default: + i+=vIndex; + while(chc=ch[++i]) { + chc.addToLayoutChanges("locationY"); + } + } +} + +/*! + This method combines calls of methods which should be done if a child should be moved + inside the same parent to a new positions. + Needed by layouts where the children depends on each-other, like flow- or box-layouts. +*/ +qx.Proto.updateChildrenOnMoveChild = function(vChild, vIndex, vOldIndex) +{ + var vChildren = this.getWidget().getVisibleChildren(); + + var vStart = Math.min(vIndex, vOldIndex); + var vStop = Math.max(vIndex, vOldIndex)+1; + + for (var i=vStart; i<vStop; i++) { + vChildren[i].addToLayoutChanges("locationY"); + } +} + + + + + +/* +--------------------------------------------------------------------------- + [09] FLUSH LAYOUT QUEUES OF CHILDREN +--------------------------------------------------------------------------- +*/ + +/*! + This method have full control of the order in which the + registered (or also non-registered) children should be + layouted on the horizontal axis. +*/ +qx.Proto.flushChildrenQueue = function(vChildrenQueue) +{ + var w=this.getWidget(), ch=w.getVisibleChildren(), chl=ch.length, chc, i; + + // This block is needed for flex handling and + // will inform flex children if there was any + // change to the other content + if (this.getEnableFlexSupport()) + { + this.invalidateChildrenFlexHeight(); + + for (i=0; i<chl; i++) + { + chc = ch[i]; + if (chc.getHasFlexY()) + { + chc._computedHeightValue = null; + + if (chc._recomputeBoxHeight()) + { + chc._recomputeOuterHeight(); + chc._recomputeInnerHeight(); + } + + vChildrenQueue[chc.toHashCode()] = chc; + chc._layoutChanges.height = true; + } + } + } + + switch(w.getLayoutMode()) + { + case "bottom": + case "top-reversed": + // find the last child which has a layout request + for (var i=chl-1; i>=0 && !vChildrenQueue[ch[i].toHashCode()]; i--) {} + + // layout all children before this last child + for (var j=0; j<=i; j++) { + w._layoutChild(chc=ch[j]); + } + + break; + + case "middle": + case "middle-reversed": + // re-layout all children + i = -1; + while(chc=ch[++i]) { + w._layoutChild(chc); + } + + break; + + default: + // layout all childs from the first child + // with an own layout request to the end + i = -1; + var changed=false; + while(chc=ch[++i]) + { + if (changed || vChildrenQueue[chc.toHashCode()]) + { + w._layoutChild(chc); + changed = true; + } + } + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + [10] LAYOUT CHILD +--------------------------------------------------------------------------- +*/ + +/*! + This is called from qx.ui.core.Widget and it's task is to apply the layout + (excluding border and padding) to the child. +*/ +qx.Proto.layoutChild = function(vChild, vJobs) +{ + this.layoutChild_sizeX(vChild, vJobs); + this.layoutChild_sizeY(vChild, vJobs); + + this.layoutChild_sizeLimitX(vChild, vJobs); + this.layoutChild_sizeLimitY(vChild, vJobs); + + this.layoutChild_locationX(vChild, vJobs); + this.layoutChild_locationY(vChild, vJobs); + + this.layoutChild_marginX(vChild, vJobs); + this.layoutChild_marginY(vChild, vJobs); +} + +if (qx.sys.Client.getInstance().isMshtml() || qx.sys.Client.getInstance().isOpera() || qx.sys.Client.getInstance().isWebkit()) +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width || vJobs.minWidth || vJobs.maxWidth) + { + if ((vChild._isWidthEssential() && (!vChild._computedWidthTypeNull || !vChild._computedMinWidthTypeNull || !vChild._computedMaxWidthTypeNull)) || (vChild.getAllowStretchX() && this.getWidget().getStretchChildrenOrthogonalAxis())) + { + vChild._applyRuntimeWidth(vChild.getBoxWidth()); + } + else + { + vChild._resetRuntimeWidth(); + } + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height || vJobs.minHeight || vJobs.maxHeight) + { + if (vChild._isHeightEssential() && (!vChild._computedHeightTypeNull || !vChild._computedMinHeightTypeNull || !vChild._computedMaxHeightTypeNull)) + { + vChild._applyRuntimeHeight(vChild.getBoxHeight()); + } + else + { + vChild._resetRuntimeHeight(); + } + } + } +} +else +{ + qx.Proto.layoutChild_sizeX = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.width) + { + if (vChild._isWidthEssential() && !vChild._computedWidthTypeNull) + { + vChild._applyRuntimeWidth(vChild.getWidthValue()); + } + else + { + vChild._resetRuntimeWidth(); + } + } + } + + qx.Proto.layoutChild_sizeY = function(vChild, vJobs) + { + if (vJobs.initial || vJobs.height) + { + if (vChild._isHeightEssential() && !vChild._computedHeightTypeNull) + { + vChild._applyRuntimeHeight(vChild.getHeightValue()); + } + else + { + vChild._resetRuntimeHeight(); + } + } + } +} + +qx.Proto.layoutChild_locationY = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + // handle first child + if (vWidget.getFirstVisibleChild() == vChild) + { + switch(vWidget.getLayoutMode()) + { + case "bottom": + case "top-reversed": + var vPos = vWidget.getPaddingBottom() + vWidget.getAccumulatedChildrenOuterHeight() - vChild.getOuterHeight(); + break; + + case "middle": + case "middle-reversed": + var vPos = vWidget.getPaddingTop() + Math.round((vWidget.getInnerHeight() - vWidget.getAccumulatedChildrenOuterHeight()) / 2); + break; + + default: + var vPos = vWidget.getPaddingTop(); + } + } + + // handle any following child + else + { + var vPrev = vChild.getPreviousVisibleSibling(); + + switch(vWidget.getLayoutMode()) + { + case "bottom": + case "top-reversed": + var vPos = vPrev._cachedLocationVertical - vChild.getOuterHeight() - vWidget.getSpacing(); + break; + + default: + var vPos = vPrev._cachedLocationVertical + vPrev.getOuterHeight() + vWidget.getSpacing(); + } + } + + // store for next sibling + vChild._cachedLocationVertical = vPos; + + // apply styles + switch(this.getWidget().getLayoutMode()) + { + case "bottom": + case "bottom-reversed": + case "middle-reversed": + // add relative positions (like 'position:relative' in css) + vPos += !vChild._computedBottomTypeNull ? vChild.getBottomValue() : !vChild._computedTopTypeNull ? -(vChild.getTopValue()) : 0; + + vChild._resetRuntimeTop(); + vChild._applyRuntimeBottom(vPos); + break; + + default: + // add relative positions (like 'position:relative' in css) + vPos += !vChild._computedTopTypeNull ? vChild.getTopValue() : !vChild._computedBottomTypeNull ? -(vChild.getBottomValue()) : 0; + + vChild._resetRuntimeBottom(); + vChild._applyRuntimeTop(vPos); + } +} + +qx.Proto.layoutChild_locationX = function(vChild, vJobs) +{ + var vWidget = this.getWidget(); + + // special stretching support + if (qx.sys.Client.getInstance().isGecko() && vChild.getAllowStretchX() && vWidget.getStretchChildrenOrthogonalAxis() && vChild._computedWidthTypeNull) + { + vChild._applyRuntimeLeft(vWidget.getPaddingLeft() || 0); + vChild._applyRuntimeRight(vWidget.getPaddingRight() || 0); + + return; + } + + // priority to childs internal alignment + var vAlign = vChild.getHorizontalAlign() || vWidget.getHorizontalChildrenAlign(); + + // handle center alignment + var vPos = vAlign == "center" ? Math.round((vWidget.getInnerWidth() - vChild.getOuterWidth()) / 2) : 0; + + // the right alignment use the real 'right' styleproperty to + // use the best available method in modern browsers + if (vAlign == "right") + { + // add parent padding + vPos += vWidget.getPaddingRight(); + + // relative positions (like 'position:relative' in css) + if (!vChild._computedRightTypeNull) { + vPos += vChild.getRightValue(); + } + else if (!vChild._computedLeftTypeNull) { + vPos -= vChild.getLeftValue(); + } + + // apply styles + vChild._resetRuntimeLeft(); + vChild._applyRuntimeRight(vPos); + } + else + { + // add parent padding + vPos += vWidget.getPaddingLeft(); + + // relative positions (like 'position:relative' in css) + if (!vChild._computedLeftTypeNull) { + vPos += vChild.getLeftValue(); + } + else if (!vChild._computedRightTypeNull) { + vPos -= vChild.getRightValue(); + } + + // apply styles + vChild._resetRuntimeRight(); + vChild._applyRuntimeLeft(vPos); + } +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/AppearanceTheme.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/AppearanceTheme.js new file mode 100644 index 0000000000..57cb643fb7 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/AppearanceTheme.js @@ -0,0 +1,164 @@ +/* ************************************************************************ + + 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) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.theme.AppearanceTheme", qx.core.Object, +function(vTitle) +{ + qx.core.Object.call(this); + + this.setTitle(vTitle); +}); + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "title", type : "string", allowNull : false, defaultValue : "" }); + + + + + +/* +--------------------------------------------------------------------------- + DATA +--------------------------------------------------------------------------- +*/ + +qx.Proto._appearances = {}; + + + + + +/* +--------------------------------------------------------------------------- + CORE METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto.registerAppearance = function(vId, vData) { + this._appearances[vId] = vData; +} + +qx.Proto.getAppearance = function(vId) { + return this._appearances[vId]; +} + +qx.Proto.setupAppearance = function(vAppearance) +{ + if (!vAppearance._setupDone) + { + if (vAppearance.setup) { + vAppearance.setup(this); + } + + vAppearance._setupDone = true; + } +} + + + + + + + + +/* +--------------------------------------------------------------------------- + WIDGET METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto.initialFrom = function(vId) +{ + var vAppearance = this.getAppearance(vId); + if (vAppearance) + { + this.setupAppearance(vAppearance); + + try + { + return vAppearance.initial ? vAppearance.initial(this) : {} + } + catch(ex) + { + this.error("Couldn't apply initial appearance", ex); + } + } + else + { + return this.error("Missing appearance: " + vId); + } +} + +qx.Proto.stateFrom = function(vId, vStates) +{ + var vAppearance = this.getAppearance(vId); + if (vAppearance) + { + this.setupAppearance(vAppearance); + + try + { + return vAppearance.state ? vAppearance.state(this, vStates) : {} + } + catch(ex) + { + this.error("Couldn't apply state appearance", ex); + } + } + else + { + return this.error("Missing appearance: " + vId); + } +} + + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + this._appearances = null; + + return qx.core.Object.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/ColorTheme.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/ColorTheme.js new file mode 100644 index 0000000000..2e72dc624a --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/ColorTheme.js @@ -0,0 +1,132 @@ +/* ************************************************************************ + + 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) +#after(qx.manager.object.ColorManager) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.theme.ColorTheme", qx.core.Object, +function(vTitle) +{ + qx.core.Object.call(this); + + this._compiledColors = {}; + this.setTitle(vTitle); +}); + + + + + +/* +--------------------------------------------------------------------------- + PROPERTIES +--------------------------------------------------------------------------- +*/ + +qx.OO.addProperty({ name : "title", type : "string", allowNull : false, defaultValue : "" }); + + + + + +/* +--------------------------------------------------------------------------- + DATA +--------------------------------------------------------------------------- +*/ + +qx.Proto._needsCompilation = true; +qx.Proto._colors = {}; + + + + +/* +--------------------------------------------------------------------------- + PUBLIC METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto.getValueByName = function(vName) { + return this._colors[vName] || ""; +} + +qx.Proto.getStyleByName = function(vName) { + return this._compiledColors[vName] || ""; +} + + + + + + +/* +--------------------------------------------------------------------------- + PRIVATE METHODS +--------------------------------------------------------------------------- +*/ + +qx.Proto.compile = function() +{ + if (!this._needsCompilation) { + return; + } + + for (var vName in qx.renderer.color.Color.themedNames) { + this._compileValue(vName); + } + + this._needsCompilation = false; +} + +qx.Proto._compileValue = function(vName) +{ + var v = this._colors[vName]; + this._compiledColors[vName] = v ? qx.renderer.color.Color.rgb2style.apply(this, this._colors[vName]) : vName; +} + +qx.Proto._register = function() { + return qx.manager.object.ColorManager.getInstance().registerTheme(this); +} + + + + + + +/* +--------------------------------------------------------------------------- + DISPOSER +--------------------------------------------------------------------------- +*/ + +qx.Proto.dispose = function() +{ + if (this.getDisposed()) { + return; + } + + delete this._colors; + delete this._compiledColors; + + qx.core.Object.prototype.dispose.call(this); +} diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/IconTheme.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/IconTheme.js new file mode 100644 index 0000000000..1402ce76c0 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/IconTheme.js @@ -0,0 +1,34 @@ +/* ************************************************************************ + + 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) +#after(qx.manager.object.ImageManager) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.theme.IconTheme", qx.core.Object, +function(vTitle) +{ + qx.core.Object.call(this); + + this.setTitle(vTitle); +}); + +qx.OO.addProperty({ name : "title", type : "string", allowNull : false, defaultValue : "" }); diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/WidgetTheme.js b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/WidgetTheme.js new file mode 100644 index 0000000000..54d318f2f0 --- /dev/null +++ b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/theme/WidgetTheme.js @@ -0,0 +1,34 @@ +/* ************************************************************************ + + 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) +#after(qx.manager.object.ImageManager) + +************************************************************************ */ + +qx.OO.defineClass("qx.renderer.theme.WidgetTheme", qx.core.Object, +function(vTitle) +{ + qx.core.Object.call(this); + + this.setTitle(vTitle); +}); + +qx.OO.addProperty({ name : "title", type : "string", allowNull : false, defaultValue : "" }); |