1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-layout.container.Box'>/**
2 </span> * @class Ext.layout.container.Box
3 * @extends Ext.layout.container.Container
4 * <p>Base Class for HBoxLayout and VBoxLayout Classes. Generally it should not need to be used directly.</p>
7 Ext.define('Ext.layout.container.Box', {
9 /* Begin Definitions */
11 alias: ['layout.box'],
12 extend: 'Ext.layout.container.Container',
13 alternateClassName: 'Ext.layout.BoxLayout',
16 'Ext.layout.container.boxOverflow.None',
17 'Ext.layout.container.boxOverflow.Menu',
18 'Ext.layout.container.boxOverflow.Scroller',
20 'Ext.dd.DragDropManager'
25 <span id='Ext-layout.container.Box-cfg-animate'> /**
26 </span> * @cfg {Mixed} animate
27 * <p>If truthy, child Component are <i>animated</i> into position whenever the Container
28 * is layed out. If this option is numeric, it is used as the animation duration in milliseconds.</p>
29 * <p>May be set as a property at any time.</p>
32 <span id='Ext-layout.container.Box-cfg-defaultMargins'> /**
33 </span> * @cfg {Object} defaultMargins
34 * <p>If the individual contained items do not have a <tt>margins</tt>
35 * property specified or margin specified via CSS, the default margins from this property will be
36 * applied to each item.</p>
37 * <br><p>This property may be specified as an object containing margins
38 * to apply in the format:</p><pre><code>
41 right: (right margin),
42 bottom: (bottom margin),
44 }</code></pre>
45 * <p>This property may also be specified as a string containing
46 * space-separated, numeric margin values. The order of the sides associated
47 * with each value matches the way CSS processes margin values:</p>
48 * <div class="mdetail-params"><ul>
49 * <li>If there is only one value, it applies to all sides.</li>
50 * <li>If there are two values, the top and bottom borders are set to the
51 * first value and the right and left are set to the second.</li>
52 * <li>If there are three values, the top is set to the first value, the left
53 * and right are set to the second, and the bottom is set to the third.</li>
54 * <li>If there are four values, they apply to the top, right, bottom, and
55 * left, respectively.</li>
56 * </ul></div>
57 * <p>Defaults to:</p><pre><code>
58 * {top:0, right:0, bottom:0, left:0}
59 * </code></pre>
68 <span id='Ext-layout.container.Box-cfg-padding'> /**
69 </span> * @cfg {String} padding
70 * <p>Sets the padding to be applied to all child items managed by this layout.</p>
71 * <p>This property must be specified as a string containing
72 * space-separated, numeric padding values. The order of the sides associated
73 * with each value matches the way CSS processes padding values:</p>
74 * <div class="mdetail-params"><ul>
75 * <li>If there is only one value, it applies to all sides.</li>
76 * <li>If there are two values, the top and bottom borders are set to the
77 * first value and the right and left are set to the second.</li>
78 * <li>If there are three values, the top is set to the first value, the left
79 * and right are set to the second, and the bottom is set to the third.</li>
80 * <li>If there are four values, they apply to the top, right, bottom, and
81 * left, respectively.</li>
82 * </ul></div>
83 * <p>Defaults to: <code>"0"</code></p>
86 // documented in subclasses
89 <span id='Ext-layout.container.Box-cfg-pack'> /**
90 </span> * @cfg {String} pack
91 * Controls how the child items of the container are packed together. Acceptable configuration values
92 * for this property are:
93 * <div class="mdetail-params"><ul>
94 * <li><b><tt>start</tt></b> : <b>Default</b><div class="sub-desc">child items are packed together at
95 * <b>left</b> side of container</div></li>
96 * <li><b><tt>center</tt></b> : <div class="sub-desc">child items are packed together at
97 * <b>mid-width</b> of container</div></li>
98 * <li><b><tt>end</tt></b> : <div class="sub-desc">child items are packed together at <b>right</b>
99 * side of container</div></li>
100 * </ul></div>
102 <span id='Ext-layout.container.Box-cfg-flex'> /**
103 </span> * @cfg {Number} flex
104 * This configuration option is to be applied to <b>child <tt>items</tt></b> of the container managed
105 * by this layout. Each child item with a <tt>flex</tt> property will be flexed <b>horizontally</b>
106 * according to each item's <b>relative</b> <tt>flex</tt> value compared to the sum of all items with
107 * a <tt>flex</tt> value specified. Any child items that have either a <tt>flex = 0</tt> or
108 * <tt>flex = undefined</tt> will not be 'flexed' (the initial size will not be changed).
113 itemCls: Ext.baseCSSPrefix + 'box-item',
114 targetCls: Ext.baseCSSPrefix + 'box-layout-ct',
115 innerCls: Ext.baseCSSPrefix + 'box-inner',
117 bindToOwnerCtContainer: true,
121 // availableSpaceOffset is used to adjust the availableWidth, typically used
122 // to reserve space for a scrollbar
123 availableSpaceOffset: 0,
125 // whether or not to reserve the availableSpaceOffset in layout calculations
128 <span id='Ext-layout.container.Box-cfg-clearInnerCtOnLayout'> /**
129 </span> * @cfg {Boolean} clearInnerCtOnLayout
131 clearInnerCtOnLayout: false,
133 flexSortFn: function (a, b) {
134 var maxParallelPrefix = 'max' + this.parallelPrefixCap,
135 infiniteValue = Infinity;
136 a = a.component[maxParallelPrefix] || infiniteValue;
137 b = b.component[maxParallelPrefix] || infiniteValue;
138 // IE 6/7 Don't like Infinity - Infinity...
139 if (!isFinite(a) && !isFinite(b)) {
145 // Sort into *descending* order.
146 minSizeSortFn: function(a, b) {
147 return b.available - a.available;
150 constructor: function(config) {
153 me.callParent(arguments);
155 // The sort function needs access to properties in this, so must be bound.
156 me.flexSortFn = Ext.Function.bind(me.flexSortFn, me);
158 me.initOverflowHandler();
161 <span id='Ext-layout.container.Box-method-getChildBox'> /**
163 * Returns the current size and positioning of the passed child item.
164 * @param {Component} child The child Component to calculate the box for
165 * @return {Object} Object containing box measurements for the child. Properties are left,top,width,height.
167 getChildBox: function(child) {
168 child = child.el || this.owner.getComponent(child).el;
170 left: child.getLeft(true),
171 top: child.getTop(true),
172 width: child.getWidth(),
173 height: child.getHeight()
177 <span id='Ext-layout.container.Box-method-calculateChildBox'> /**
179 * Calculates the size and positioning of the passed child item.
180 * @param {Component} child The child Component to calculate the box for
181 * @return {Object} Object containing box measurements for the child. Properties are left,top,width,height.
183 calculateChildBox: function(child) {
185 boxes = me.calculateChildBoxes(me.getVisibleItems(), me.getLayoutTargetSize()).boxes,
189 child = me.owner.getComponent(child);
190 for (; i < ln; i++) {
191 if (boxes[i].component === child) {
197 <span id='Ext-layout.container.Box-method-calculateChildBoxes'> /**
199 * Calculates the size and positioning of each item in the box. This iterates over all of the rendered,
200 * visible items and returns a height, width, top and left for each, as well as a reference to each. Also
201 * returns meta data such as maxSize which are useful when resizing layout wrappers such as this.innerCt.
202 * @param {Array} visibleItems The array of all rendered, visible items to be calculated for
203 * @param {Object} targetSize Object containing target size and height
204 * @return {Object} Object containing box measurements for each child, plus meta data
206 calculateChildBoxes: function(visibleItems, targetSize) {
210 infiniteValue = Infinity,
213 parallelPrefix = me.parallelPrefix,
214 parallelPrefixCap = me.parallelPrefixCap,
215 perpendicularPrefix = me.perpendicularPrefix,
216 perpendicularPrefixCap = me.perpendicularPrefixCap,
217 parallelMinString = 'min' + parallelPrefixCap,
218 perpendicularMinString = 'min' + perpendicularPrefixCap,
219 perpendicularMaxString = 'max' + perpendicularPrefixCap,
221 parallelSize = targetSize[parallelPrefix] - me.scrollOffset,
222 perpendicularSize = targetSize[perpendicularPrefix],
223 padding = me.padding,
224 parallelOffset = padding[me.parallelBefore],
225 paddingParallel = parallelOffset + padding[me.parallelAfter],
226 perpendicularOffset = padding[me.perpendicularLeftTop],
227 paddingPerpendicular = perpendicularOffset + padding[me.perpendicularRightBottom],
228 availPerpendicularSize = mmax(0, perpendicularSize - paddingPerpendicular),
230 isStart = me.pack == 'start',
231 isCenter = me.pack == 'center',
232 isEnd = me.pack == 'end',
234 constrain = Ext.Number.constrain,
235 visibleCount = visibleItems.length,
245 i, child, childParallel, childPerpendicular, childMargins, childSize, minParallel, tmpObj, shortfall,
246 tooNarrow, availableSpace, minSize, item, length, itemIndex, box, oldSize, newSize, reduction, diff,
247 flexedBoxes, remainingSpace, remainingFlex, flexedSize, parallelMargins, calcs, offset,
248 perpendicularMargins, stretchSize;
250 //gather the total flex of all flexed items and the width taken up by fixed width items
251 for (i = 0; i < visibleCount; i++) {
252 child = visibleItems[i];
253 childPerpendicular = child[perpendicularPrefix];
254 me.layoutItem(child);
255 childMargins = child.margins;
256 parallelMargins = childMargins[me.parallelBefore] + childMargins[me.parallelAfter];
258 // Create the box description object for this child item.
261 margins: childMargins
264 // flex and not 'auto' width
266 totalFlex += child.flex;
267 childParallel = undefinedValue;
269 // Not flexed or 'auto' width or undefined width
271 if (!(child[parallelPrefix] && childPerpendicular)) {
272 childSize = child.getSize();
274 childParallel = child[parallelPrefix] || childSize[parallelPrefix];
275 childPerpendicular = childPerpendicular || childSize[perpendicularPrefix];
278 nonFlexSize += parallelMargins + (childParallel || 0);
279 desiredSize += parallelMargins + (child.flex ? child[parallelMinString] || 0 : childParallel);
280 minimumSize += parallelMargins + (child[parallelMinString] || childParallel || 0);
282 // Max height for align - force layout of non-laid out subcontainers without a numeric height
283 if (typeof childPerpendicular != 'number') {
284 // Clear any static sizing and revert to flow so we can get a proper measurement
285 // child['set' + perpendicularPrefixCap](null);
286 childPerpendicular = child['get' + perpendicularPrefixCap]();
289 // Track the maximum perpendicular size for use by the stretch and stretchmax align config values.
290 maxSize = mmax(maxSize, childPerpendicular + childMargins[me.perpendicularLeftTop] + childMargins[me.perpendicularRightBottom]);
292 tmpObj[parallelPrefix] = childParallel || undefinedValue;
293 tmpObj[perpendicularPrefix] = childPerpendicular || undefinedValue;
296 shortfall = desiredSize - parallelSize;
297 tooNarrow = minimumSize > parallelSize;
299 //the space available to the flexed items
300 availableSpace = mmax(0, parallelSize - nonFlexSize - paddingParallel - (me.reserveOffset ? me.availableSpaceOffset : 0));
303 for (i = 0; i < visibleCount; i++) {
305 minSize = visibleItems[i][parallelMinString] || visibleItems[i][parallelPrefix] || box[parallelPrefix];
306 box.dirtySize = box.dirtySize || box[parallelPrefix] != minSize;
307 box[parallelPrefix] = minSize;
311 //all flexed items should be sized to their minimum size, other items should be shrunk down until
312 //the shortfall has been accounted for
313 if (shortfall > 0) {
315 * When we have a shortfall but are not tooNarrow, we need to shrink the width of each non-flexed item.
316 * Flexed items are immediately reduced to their minWidth and anything already at minWidth is ignored.
317 * The remaining items are collected into the minWidths array, which is later used to distribute the shortfall.
319 for (i = 0; i < visibleCount; i++) {
320 item = visibleItems[i];
321 minSize = item[parallelMinString] || 0;
323 //shrink each non-flex tab by an equal amount to make them all fit. Flexed items are all
324 //shrunk to their minSize because they're flexible and should be the first to lose size
327 box.dirtySize = box.dirtySize || box[parallelPrefix] != minSize;
328 box[parallelPrefix] = minSize;
333 available: boxes[i][parallelPrefix] - minSize,
339 //sort by descending amount of width remaining before minWidth is reached
340 Ext.Array.sort(minSizes, me.minSizeSortFn);
343 * Distribute the shortfall (difference between total desired size of all items and actual size available)
344 * between the non-flexed items. We try to distribute the shortfall evenly, but apply it to items with the
345 * smallest difference between their size and minSize first, so that if reducing the size by the average
346 * amount would make that item less than its minSize, we carry the remainder over to the next item.
348 for (i = 0, length = minSizes.length; i < length; i++) {
349 itemIndex = minSizes[i].index;
351 if (itemIndex == undefinedValue) {
354 item = visibleItems[itemIndex];
355 minSize = minSizes[i].minSize;
357 box = boxes[itemIndex];
358 oldSize = box[parallelPrefix];
359 newSize = mmax(minSize, oldSize - math.ceil(shortfall / (length - i)));
360 reduction = oldSize - newSize;
362 box.dirtySize = box.dirtySize || box[parallelPrefix] != newSize;
363 box[parallelPrefix] = newSize;
364 shortfall -= reduction;
368 remainingSpace = availableSpace;
369 remainingFlex = totalFlex;
372 // Create an array containing *just the flexed boxes* for allocation of remainingSpace
373 for (i = 0; i < visibleCount; i++) {
374 child = visibleItems[i];
375 if (isStart && child.flex) {
376 flexedBoxes.push(boxes[Ext.Array.indexOf(visibleItems, child)]);
379 // The flexed boxes need to be sorted in ascending order of maxSize to work properly
380 // so that unallocated space caused by maxWidth being less than flexed width
381 // can be reallocated to subsequent flexed boxes.
382 Ext.Array.sort(flexedBoxes, me.flexSortFn);
384 // Calculate the size of each flexed item, and attempt to set it.
385 for (i = 0; i < flexedBoxes.length; i++) {
386 calcs = flexedBoxes[i];
387 child = calcs.component;
388 childMargins = calcs.margins;
390 flexedSize = math.ceil((child.flex / remainingFlex) * remainingSpace);
392 // Implement maxSize and minSize check
393 flexedSize = Math.max(child['min' + parallelPrefixCap] || 0, math.min(child['max' + parallelPrefixCap] || infiniteValue, flexedSize));
395 // Remaining space has already had all parallel margins subtracted from it, so just subtract consumed size
396 remainingSpace -= flexedSize;
397 remainingFlex -= child.flex;
399 calcs.dirtySize = calcs.dirtySize || calcs[parallelPrefix] != flexedSize;
400 calcs[parallelPrefix] = flexedSize;
406 parallelOffset += availableSpace / 2;
409 parallelOffset += availableSpace;
412 // Fix for left and right docked Components in a dock component layout. This is for docked Headers and docked Toolbars.
413 // Older Microsoft browsers do not size a position:absolute element's width to match its content.
414 // So in this case, in the updateInnerCtSize method we may need to adjust the size of the owning Container's element explicitly based upon
415 // the discovered max width. So here we put a calculatedWidth property in the metadata to facilitate this.
416 if (me.owner.dock && (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) && !me.owner.width && me.direction == 'vertical') {
418 calculatedWidth = maxSize + me.owner.el.getPadding('lr') + me.owner.el.getBorderWidth('lr');
419 if (me.owner.frameSize) {
420 calculatedWidth += me.owner.frameSize.left + me.owner.frameSize.right;
422 // If the owning element is not sized, calculate the available width to center or stretch in based upon maxSize
423 availPerpendicularSize = Math.min(availPerpendicularSize, targetSize.width = maxSize + padding.left + padding.right);
426 //finally, calculate the left and top position of each item
427 for (i = 0; i < visibleCount; i++) {
428 child = visibleItems[i];
431 childMargins = calcs.margins;
433 perpendicularMargins = childMargins[me.perpendicularLeftTop] + childMargins[me.perpendicularRightBottom];
435 // Advance past the "before" margin
436 parallelOffset += childMargins[me.parallelBefore];
438 calcs[me.parallelBefore] = parallelOffset;
439 calcs[me.perpendicularLeftTop] = perpendicularOffset + childMargins[me.perpendicularLeftTop];
441 if (me.align == 'stretch') {
442 stretchSize = constrain(availPerpendicularSize - perpendicularMargins, child[perpendicularMinString] || 0, child[perpendicularMaxString] || infiniteValue);
443 calcs.dirtySize = calcs.dirtySize || calcs[perpendicularPrefix] != stretchSize;
444 calcs[perpendicularPrefix] = stretchSize;
446 else if (me.align == 'stretchmax') {
447 stretchSize = constrain(maxSize - perpendicularMargins, child[perpendicularMinString] || 0, child[perpendicularMaxString] || infiniteValue);
448 calcs.dirtySize = calcs.dirtySize || calcs[perpendicularPrefix] != stretchSize;
449 calcs[perpendicularPrefix] = stretchSize;
451 else if (me.align == me.alignCenteringString) {
452 // When calculating a centered position within the content box of the innerCt, the width of the borders must be subtracted from
453 // the size to yield the space available to center within.
454 // The updateInnerCtSize method explicitly adds the border widths to the set size of the innerCt.
455 diff = mmax(availPerpendicularSize, maxSize) - me.innerCt.getBorderWidth(me.perpendicularLT + me.perpendicularRB) - calcs[perpendicularPrefix];
457 calcs[me.perpendicularLeftTop] = perpendicularOffset + Math.round(diff / 2);
461 // Advance past the box size and the "after" margin
462 parallelOffset += (calcs[parallelPrefix] || 0) + childMargins[me.parallelAfter];
468 calculatedWidth: calculatedWidth,
470 nonFlexSize: nonFlexSize,
471 desiredSize: desiredSize,
472 minimumSize: minimumSize,
473 shortfall: shortfall,
479 <span id='Ext-layout.container.Box-method-initOverflowHandler'> /**
482 initOverflowHandler: function() {
483 var handler = this.overflowHandler;
485 if (typeof handler == 'string') {
491 var handlerType = 'None';
492 if (handler && handler.type != undefined) {
493 handlerType = handler.type;
496 var constructor = Ext.layout.container.boxOverflow[handlerType];
497 if (constructor[this.type]) {
498 constructor = constructor[this.type];
501 this.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.' + handlerType, this, handler);
504 <span id='Ext-layout.container.Box-method-onLayout'> /**
506 * Runs the child box calculations and caches them in childBoxCache. Subclasses can used these cached values
509 onLayout: function() {
511 // Clear the innerCt size so it doesn't influence the child items.
512 if (this.clearInnerCtOnLayout === true && this.adjustmentPass !== true) {
513 this.innerCt.setSize(null, null);
517 targetSize = me.getLayoutTargetSize(),
518 items = me.getVisibleItems(),
519 calcs = me.calculateChildBoxes(items, targetSize),
522 handler, method, results;
524 if (me.autoSize && calcs.meta.desiredSize) {
525 targetSize[me.parallelPrefix] = calcs.meta.desiredSize;
528 //invoke the overflow handler, if one is configured
529 if (meta.shortfall > 0) {
530 handler = me.overflowHandler;
531 method = meta.tooNarrow ? 'handleOverflow': 'clearOverflow';
533 results = handler[method](calcs, targetSize);
536 if (results.targetSize) {
537 targetSize = results.targetSize;
540 if (results.recalculate) {
541 items = me.getVisibleItems(owner);
542 calcs = me.calculateChildBoxes(items, targetSize);
547 me.overflowHandler.clearOverflow();
550 <span id='Ext-layout.container.Box-property-layoutTargetLastSize'> /**
552 * @property layoutTargetLastSize
554 * Private cache of the last measured size of the layout target. This should never be used except by
555 * BoxLayout subclasses during their onLayout run.
557 me.layoutTargetLastSize = targetSize;
559 <span id='Ext-layout.container.Box-property-childBoxCache'> /**
561 * @property childBoxCache
563 * Array of the last calculated height, width, top and left positions of each visible rendered component
564 * within the Box layout.
566 me.childBoxCache = calcs;
568 me.updateInnerCtSize(targetSize, calcs);
569 me.updateChildBoxes(boxes);
570 me.handleTargetOverflow(targetSize);
573 <span id='Ext-layout.container.Box-method-updateChildBoxes'> /**
574 </span> * Resizes and repositions each child component
575 * @param {Array} boxes The box measurements
577 updateChildBoxes: function(boxes) {
580 length = boxes.length,
582 dd = Ext.dd.DDM.getDDById(me.innerCt.id), // Any DD active on this layout's element (The BoxReorderer plugin does this.)
583 oldBox, newBox, changed, comp, boxAnim, animCallback;
585 for (; i < length; i++) {
587 comp = newBox.component;
589 // If a Component is being drag/dropped, skip positioning it.
590 // Accomodate the BoxReorderer plugin: Its current dragEl must not be positioned by the layout
591 if (dd && (dd.getDragEl() === comp.el.dom)) {
597 oldBox = me.getChildBox(comp);
599 // If we are animating, we build up an array of Anim config objects, one for each
600 // child Component which has any changed box properties. Those with unchanged
601 // properties are not animated.
603 // Animate may be a config object containing callback.
604 animCallback = me.animate.callback || me.animate;
606 layoutAnimation: true, // Component Target handler must use set*Calculated*Size
612 // Only set from and to properties when there's a change.
613 // Perform as few Component setter methods as possible.
614 // Temporarily set the property values that we are not animating
615 // so that doComponentLayout does not auto-size them.
616 if (!isNaN(newBox.width) && (newBox.width != oldBox.width)) {
618 // boxAnim.from.width = oldBox.width;
619 boxAnim.to.width = newBox.width;
621 if (!isNaN(newBox.height) && (newBox.height != oldBox.height)) {
623 // boxAnim.from.height = oldBox.height;
624 boxAnim.to.height = newBox.height;
626 if (!isNaN(newBox.left) && (newBox.left != oldBox.left)) {
628 // boxAnim.from.left = oldBox.left;
629 boxAnim.to.left = newBox.left;
631 if (!isNaN(newBox.top) && (newBox.top != oldBox.top)) {
633 // boxAnim.from.top = oldBox.top;
634 boxAnim.to.top = newBox.top;
637 animQueue.push(boxAnim);
640 if (newBox.dirtySize) {
641 if (newBox.width !== oldBox.width || newBox.height !== oldBox.height) {
642 me.setItemSize(comp, newBox.width, newBox.height);
645 // Don't set positions to NaN
646 if (isNaN(newBox.left) || isNaN(newBox.top)) {
649 comp.setPosition(newBox.left, newBox.top);
653 // Kick off any queued animations
654 length = animQueue.length;
657 // A function which cleans up when a Component's animation is done.
658 // The last one to finish calls the callback.
659 var afterAnimate = function(anim) {
660 // When we've animated all changed boxes into position, clear our busy flag and call the callback.
663 me.layoutBusy = false;
664 if (Ext.isFunction(animCallback)) {
670 var beforeAnimate = function() {
671 me.layoutBusy = true;
674 // Start each box animation off
675 for (i = 0, length = animQueue.length; i < length; i++) {
676 boxAnim = animQueue[i];
678 // Clean up the Component after. Clean up the *layout* after the last animation finishes
679 boxAnim.listeners.afteranimate = afterAnimate;
681 // The layout is busy during animation, and may not be called, so set the flag when the first animation begins
683 boxAnim.listeners.beforeanimate = beforeAnimate;
685 if (me.animate.duration) {
686 boxAnim.duration = me.animate.duration;
688 comp = boxAnim.target;
689 delete boxAnim.target;
690 // Stop any currently running animation
691 comp.stopAnimation();
692 comp.animate(boxAnim);
697 <span id='Ext-layout.container.Box-method-updateInnerCtSize'> /**
699 * Called by onRender just before the child components are sized and positioned. This resizes the innerCt
700 * to make sure all child items fit within it. We call this before sizing the children because if our child
701 * items are larger than the previous innerCt size the browser will insert scrollbars and then remove them
702 * again immediately afterwards, giving a performance hit.
703 * Subclasses should provide an implementation.
704 * @param {Object} currentSize The current height and width of the innerCt
705 * @param {Array} calculations The new box calculations of all items to be laid out
707 updateInnerCtSize: function(tSize, calcs) {
711 padding = me.padding,
713 height = tSize.height,
718 if (me.direction == 'horizontal') {
719 innerCtWidth = width;
720 innerCtHeight = meta.maxSize + padding.top + padding.bottom + me.innerCt.getBorderWidth('tb');
722 if (align == 'stretch') {
723 innerCtHeight = height;
725 else if (align == 'middle') {
726 innerCtHeight = mmax(height, innerCtHeight);
729 innerCtHeight = height;
730 innerCtWidth = meta.maxSize + padding.left + padding.right + me.innerCt.getBorderWidth('lr');
732 if (align == 'stretch') {
733 innerCtWidth = width;
735 else if (align == 'center') {
736 innerCtWidth = mmax(width, innerCtWidth);
739 me.getRenderTarget().setSize(innerCtWidth || undefined, innerCtHeight || undefined);
741 // If a calculated width has been found (and this only happens for auto-width vertical docked Components in old Microsoft browsers)
742 // then, if the Component has not assumed the size of its content, set it to do so.
743 if (meta.calculatedWidth && me.owner.el.getWidth() > meta.calculatedWidth) {
744 me.owner.el.setWidth(meta.calculatedWidth);
747 if (me.innerCt.dom.scrollTop) {
748 me.innerCt.dom.scrollTop = 0;
752 <span id='Ext-layout.container.Box-method-handleTargetOverflow'> /**
754 * This should be called after onLayout of any BoxLayout subclass. If the target's overflow is not set to 'hidden',
755 * we need to lay out a second time because the scrollbars may have modified the height and width of the layout
756 * target. Having a Box layout inside such a target is therefore not recommended.
757 * @param {Object} previousTargetSize The size and height of the layout target before we just laid out
758 * @param {Ext.container.Container} container The container
759 * @param {Ext.core.Element} target The target element
760 * @return True if the layout overflowed, and was reflowed in a secondary onLayout call.
762 handleTargetOverflow: function(previousTargetSize) {
763 var target = this.getTarget(),
764 overflow = target.getStyle('overflow'),
767 if (overflow && overflow != 'hidden' && !this.adjustmentPass) {
768 newTargetSize = this.getLayoutTargetSize();
769 if (newTargetSize.width != previousTargetSize.width || newTargetSize.height != previousTargetSize.height) {
770 this.adjustmentPass = true;
776 delete this.adjustmentPass;
780 isValidParent : function(item, target, position) {
781 // Note: Box layouts do not care about order within the innerCt element because it's an absolutely positioning layout
782 // We only care whether the item is a direct child of the innerCt element.
783 var itemEl = item.el ? item.el.dom : Ext.getDom(item);
784 return (itemEl && this.innerCt && itemEl.parentNode === this.innerCt.dom) || false;
787 // Overridden method from AbstractContainer.
788 // Used in the base AbstractLayout.beforeLayout method to render all items into.
789 getRenderTarget: function() {
791 // the innerCt prevents wrapping and shuffling while the container is resizing
792 this.innerCt = this.getTarget().createChild({
796 this.padding = Ext.util.Format.parseBox(this.padding);
802 renderItem: function(item, target) {
803 this.callParent(arguments);
805 itemEl = item.getEl(),
806 style = itemEl.dom.style,
807 margins = item.margins || item.margin;
809 // Parse the item's margin/margins specification
811 if (Ext.isString(margins) || Ext.isNumber(margins)) {
812 margins = Ext.util.Format.parseBox(margins);
814 Ext.applyIf(margins, {top: 0, right: 0, bottom: 0, left: 0});
817 margins = Ext.apply({}, me.defaultMargins);
820 // Add any before/after CSS margins to the configured margins, and zero the CSS margins
821 margins.top += itemEl.getMargin('t');
822 margins.right += itemEl.getMargin('r');
823 margins.bottom += itemEl.getMargin('b');
824 margins.left += itemEl.getMargin('l');
825 style.marginTop = style.marginRight = style.marginBottom = style.marginLeft = '0';
827 // Item must reference calculated margins.
828 item.margins = margins;
831 <span id='Ext-layout.container.Box-method-destroy'> /**
834 destroy: function() {
835 Ext.destroy(this.overflowHandler);
836 this.callParent(arguments);
838 });</pre></pre></body></html>