3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 <div id="cls-Ext.layout.ColumnLayout"></div>/**
16 * @class Ext.layout.ColumnLayout
17 * @extends Ext.layout.ContainerLayout
18 * <p>This is the layout style of choice for creating structural layouts in a multi-column format where the width of
19 * each column can be specified as a percentage or fixed width, but the height is allowed to vary based on the content.
20 * This class is intended to be extended or created via the layout:'column' {@link Ext.Container#layout} config,
21 * and should generally not need to be created directly via the new keyword.</p>
22 * <p>ColumnLayout does not have any direct config options (other than inherited ones), but it does support a
23 * specific config property of <b><tt>columnWidth</tt></b> that can be included in the config of any panel added to it. The
24 * layout will use the columnWidth (if present) or width of each panel during layout to determine how to size each panel.
25 * If width or columnWidth is not specified for a given panel, its width will default to the panel's width (or auto).</p>
26 * <p>The width property is always evaluated as pixels, and must be a number greater than or equal to 1.
27 * The columnWidth property is always evaluated as a percentage, and must be a decimal value greater than 0 and
28 * less than 1 (e.g., .25).</p>
29 * <p>The basic rules for specifying column widths are pretty simple. The logic makes two passes through the
30 * set of contained panels. During the first layout pass, all panels that either have a fixed width or none
31 * specified (auto) are skipped, but their widths are subtracted from the overall container width. During the second
32 * pass, all panels with columnWidths are assigned pixel widths in proportion to their percentages based on
33 * the total <b>remaining</b> container width. In other words, percentage width panels are designed to fill the space
34 * left over by all the fixed-width and/or auto-width panels. Because of this, while you can specify any number of columns
35 * with different percentages, the columnWidths must always add up to 1 (or 100%) when added together, otherwise your
36 * layout may not render as expected. Example usage:</p>
38 // All columns are percentages -- they must add up to 1
39 var p = new Ext.Panel({
40 title: 'Column Layout - Percentage Only',
54 // Mix of width and columnWidth -- all columnWidth values must add up
55 // to 1. The first column will take up exactly 120px, and the last two
56 // columns will fill the remaining container width.
57 var p = new Ext.Panel({
58 title: 'Column Layout - Mixed',
73 Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
85 targetCls: 'x-column-layout-ct',
87 isValidParent : function(c, target){
88 return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
91 getLayoutTargetSize : function() {
92 var target = this.container.getLayoutTarget(), ret;
94 ret = target.getViewSize();
96 // IE in strict mode will return a width of 0 on the 1st pass of getViewSize.
97 // Use getStyleSize to verify the 0 width, the adjustment pass will then work properly
99 if (Ext.isIE && Ext.isStrict && ret.width == 0){
100 ret = target.getStyleSize();
103 ret.width -= target.getPadding('lr');
104 ret.height -= target.getPadding('tb');
109 renderAll : function(ct, target) {
111 // the innerCt prevents wrapping and shuffling while
112 // the container is resizing
113 this.innerCt = target.createChild({cls:'x-column-inner'});
114 this.innerCt.createChild({cls:'x-clear'});
116 Ext.layout.ColumnLayout.superclass.renderAll.call(this, ct, this.innerCt);
120 onLayout : function(ct, target){
121 var cs = ct.items.items,
128 this.renderAll(ct, target);
130 var size = this.getLayoutTargetSize();
132 if(size.width < 1 && size.height < 1){ // display none?
136 var w = size.width - this.scrollOffset,
140 this.innerCt.setWidth(w);
142 // some columns can be percentages while others are fixed
143 // so we need to make 2 passes
145 for(i = 0; i < len; i++){
147 m = c.getPositionEl().getMargins('lr');
150 pw -= (c.getWidth() + m);
154 pw = pw < 0 ? 0 : pw;
156 for(i = 0; i < len; i++){
160 c.setSize(Math.floor(c.columnWidth * pw) - m);
164 // Browsers differ as to when they account for scrollbars. We need to re-measure to see if the scrollbar
165 // spaces were accounted for properly. If not, re-layout.
167 if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
168 var ts = this.getLayoutTargetSize();
169 if (ts.width != size.width){
170 this.adjustmentPass = true;
171 this.onLayout(ct, target);
175 delete this.adjustmentPass;
178 <div id="prop-Ext.layout.ColumnLayout-activeItem"></div>/**
179 * @property activeItem
184 Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;