Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / FitLayout.html
1 <html>\r
2 <head>\r
3   <title>The source code</title>\r
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
6 </head>\r
7 <body  onload="prettyPrint();">\r
8     <pre class="prettyprint lang-js"><div id="cls-Ext.layout.FitLayout"></div>/**\r
9  * @class Ext.layout.FitLayout\r
10  * @extends Ext.layout.ContainerLayout\r
11  * <p>This is a base class for layouts that contain <b>a single item</b> that automatically expands to fill the layout's\r
12  * container.  This class is intended to be extended or created via the <tt>layout:'fit'</tt> {@link Ext.Container#layout}\r
13  * config, and should generally not need to be created directly via the new keyword.</p>\r
14  * <p>FitLayout does not have any direct config options (other than inherited ones).  To fit a panel to a container\r
15  * using FitLayout, simply set layout:'fit' on the container and add a single panel to it.  If the container has\r
16  * multiple panels, only the first one will be displayed.  Example usage:</p>\r
17  * <pre><code>\r
18 var p = new Ext.Panel({\r
19     title: 'Fit Layout',\r
20     layout:'fit',\r
21     items: {\r
22         title: 'Inner Panel',\r
23         html: '&lt;p&gt;This is the inner panel content&lt;/p&gt;',\r
24         border: false\r
25     }\r
26 });\r
27 </code></pre>\r
28  */\r
29 Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {\r
30     // private\r
31     monitorResize:true,\r
32 \r
33     // private\r
34     onLayout : function(ct, target){\r
35         Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);\r
36         if(!this.container.collapsed){\r
37             var sz = (Ext.isIE6 && Ext.isStrict && target.dom == document.body) ? target.getViewSize() : target.getStyleSize();\r
38             this.setItemSize(this.activeItem || ct.items.itemAt(0), sz);\r
39         }\r
40     },\r
41 \r
42     // private\r
43     setItemSize : function(item, size){\r
44         if(item && size.height > 0){ // display none?\r
45             item.setSize(size);\r
46         }\r
47     }\r
48 });\r
49 Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;</pre>    \r
50 </body>\r
51 </html>