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