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