diff options
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/source/class/qx/renderer/layout')
9 files changed, 3965 insertions, 0 deletions
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); + } +} |