/* ************************************************************************ 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