Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / Body.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-layout-component-Body'>/**
19 </span> * Component layout for components which maintain an inner body element which must be resized to synchronize with the
20  * Component size.
21  * @class Ext.layout.component.Body
22  * @extends Ext.layout.component.Component
23  * @private
24  */
25
26 Ext.define('Ext.layout.component.Body', {
27
28     /* Begin Definitions */
29
30     alias: ['layout.body'],
31
32     extend: 'Ext.layout.component.Component',
33
34     uses: ['Ext.layout.container.Container'],
35
36     /* End Definitions */
37
38     type: 'body',
39     
40     onLayout: function(width, height) {
41         var me = this,
42             owner = me.owner;
43
44         // Size the Component's encapsulating element according to the dimensions
45         me.setTargetSize(width, height);
46
47         // Size the Component's body element according to the content box of the encapsulating element
48         me.setBodySize.apply(me, arguments);
49
50         // We need to bind to the owner whenever we do not have a user set height or width.
51         if (owner &amp;&amp; owner.layout &amp;&amp; owner.layout.isLayout) {
52             if (!Ext.isNumber(owner.height) || !Ext.isNumber(owner.width)) {
53                 owner.layout.bindToOwnerCtComponent = true;
54             }
55             else {
56                 owner.layout.bindToOwnerCtComponent = false;
57             }
58         }
59         
60         me.callParent(arguments);
61     },
62
63 <span id='Ext-layout-component-Body-method-setBodySize'>    /**
64 </span>     * @private
65      * &lt;p&gt;Sizes the Component's body element to fit exactly within the content box of the Component's encapsulating element.&lt;p&gt;
66      */
67     setBodySize: function(width, height) {
68         var me = this,
69             owner = me.owner,
70             frameSize = owner.frameSize,
71             isNumber = Ext.isNumber;
72
73         if (isNumber(width)) {
74             width -= owner.el.getFrameWidth('lr') - frameSize.left - frameSize.right;
75         }
76         if (isNumber(height)) {
77             height -= owner.el.getFrameWidth('tb') - frameSize.top - frameSize.bottom;
78         }
79
80         me.setElementSize(owner.body, width, height);
81     }
82 });</pre>
83 </body>
84 </html>