Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / docs / source / ColumnLayout.html
index 1a6992d..13308f5 100644 (file)
@@ -1,17 +1,12 @@
-<html>
-<head>
-  <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.layout.ColumnLayout"></div>/**\r
+<html>\r
+<head>\r
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js"><div id="cls-Ext.layout.ColumnLayout"></div>/**\r
  * @class Ext.layout.ColumnLayout\r
  * @extends Ext.layout.ContainerLayout\r
  * <p>This is the layout style of choice for creating structural layouts in a multi-column format where the width of\r
@@ -40,7 +35,7 @@ var p = new Ext.Panel({
     layout:'column',\r
     items: [{\r
         title: 'Column 1',\r
-        columnWidth: .25 \r
+        columnWidth: .25\r
     },{\r
         title: 'Column 2',\r
         columnWidth: .6\r
@@ -72,49 +67,66 @@ var p = new Ext.Panel({
 Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {\r
     // private\r
     monitorResize:true,\r
-    \r
+\r
+    type: 'column',\r
+\r
     extraCls: 'x-column',\r
 \r
     scrollOffset : 0,\r
 \r
     // private\r
+\r
+    targetCls: 'x-column-layout-ct',\r
+\r
     isValidParent : function(c, target){\r
-        return (c.getPositionEl ? c.getPositionEl() : c.getEl()).dom.parentNode == this.innerCt.dom;\r
+        return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;\r
     },\r
 \r
-    // private\r
-    onLayout : function(ct, target){\r
-        var cs = ct.items.items, len = cs.length, c, i;\r
+    getLayoutTargetSize : function() {\r
+        var target = this.container.getLayoutTarget(), ret;\r
+        if (target) {\r
+            ret = target.getViewSize();\r
+            ret.width -= target.getPadding('lr');\r
+            ret.height -= target.getPadding('tb');\r
+        }\r
+        return ret;\r
+    },\r
 \r
+    renderAll : function(ct, target) {\r
         if(!this.innerCt){\r
-            target.addClass('x-column-layout-ct');\r
-\r
             // the innerCt prevents wrapping and shuffling while\r
             // the container is resizing\r
             this.innerCt = target.createChild({cls:'x-column-inner'});\r
             this.innerCt.createChild({cls:'x-clear'});\r
         }\r
-        this.renderAll(ct, this.innerCt);\r
+        Ext.layout.ColumnLayout.superclass.renderAll.call(this, ct, this.innerCt);\r
+    },\r
 \r
-        var size = Ext.isIE && target.dom != Ext.getBody().dom ? target.getStyleSize() : target.getViewSize();\r
+    // private\r
+    onLayout : function(ct, target){\r
+        var cs = ct.items.items, len = cs.length, c, i;\r
+\r
+        this.renderAll(ct, target);\r
+\r
+        var size = this.getLayoutTargetSize();\r
 \r
         if(size.width < 1 && size.height < 1){ // display none?\r
             return;\r
         }\r
 \r
-        var w = size.width - target.getPadding('lr') - this.scrollOffset,\r
-            h = size.height - target.getPadding('tb'),\r
+        var w = size.width - this.scrollOffset,\r
+            h = size.height,\r
             pw = w;\r
 \r
         this.innerCt.setWidth(w);\r
-        \r
+\r
         // some columns can be percentages while others are fixed\r
         // so we need to make 2 passes\r
 \r
         for(i = 0; i < len; i++){\r
             c = cs[i];\r
             if(!c.columnWidth){\r
-                pw -= (c.getSize().width + c.getEl().getMargins('lr'));\r
+                pw -= (c.getWidth() + c.getPositionEl().getMargins('lr'));\r
             }\r
         }\r
 \r
@@ -123,17 +135,30 @@ Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
         for(i = 0; i < len; i++){\r
             c = cs[i];\r
             if(c.columnWidth){\r
-                c.setSize(Math.floor(c.columnWidth*pw) - c.getEl().getMargins('lr'));\r
+                c.setSize(Math.floor(c.columnWidth * pw) - c.getPositionEl().getMargins('lr'));\r
             }\r
         }\r
+\r
+        // Browsers differ as to when they account for scrollbars.  We need to re-measure to see if the scrollbar\r
+        // spaces were accounted for properly.  If not, re-layout.\r
+        if (Ext.isIE) {\r
+            if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {\r
+                var ts = this.getLayoutTargetSize();\r
+                if (ts.width != size.width){\r
+                    this.adjustmentPass = true;\r
+                    this.onLayout(ct, target);\r
+                }\r
+            }\r
+        }\r
+        delete this.adjustmentPass;\r
     }\r
-    \r
+\r
     <div id="prop-Ext.layout.ColumnLayout-activeItem"></div>/**\r
      * @property activeItem\r
      * @hide\r
      */\r
 });\r
 \r
-Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;</pre>
-</body>
+Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;</pre>    \r
+</body>\r
 </html>
\ No newline at end of file