commit extjs-2.2.1
[extjs.git] / source / widgets / layout / AbsoluteLayout.js
1 /*\r
2  * Ext JS Library 2.2.1\r
3  * Copyright(c) 2006-2009, Ext JS, LLC.\r
4  * licensing@extjs.com\r
5  * \r
6  * http://extjs.com/license\r
7  */\r
8 \r
9 /**\r
10  * @class Ext.layout.AbsoluteLayout\r
11  * @extends Ext.layout.AnchorLayout\r
12  * <p>Inherits the anchoring of {@link Ext.layout.AnchorLayout} and adds the ability for x/y positioning using the\r
13  * standard x and y component config options.</p>\r
14  */\r
15 Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {\r
16     /**\r
17      * @cfg {String} extraCls\r
18      * An optional extra CSS class that will be added to the container (defaults to 'x-abs-layout-item').  This can be useful for\r
19      * adding customized styles to the container or any of its children using standard CSS rules.\r
20      */\r
21     extraCls: 'x-abs-layout-item',\r
22     isForm: false,\r
23     // private\r
24     setContainer : function(ct){\r
25         Ext.layout.AbsoluteLayout.superclass.setContainer.call(this, ct);\r
26         if(ct.isXType('form')){\r
27             this.isForm = true;\r
28         }\r
29     },\r
30 \r
31     onLayout : function(ct, target){\r
32         if(this.isForm){ ct.body.position(); } else { target.position(); }\r
33         Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);\r
34     },\r
35 \r
36     // private\r
37     getAnchorViewSize : function(ct, target){\r
38         return this.isForm ? ct.body.getStyleSize() : Ext.layout.AbsoluteLayout.superclass.getAnchorViewSize.call(this, ct, target);\r
39     },\r
40 \r
41     // private\r
42     isValidParent : function(c, target){\r
43         return this.isForm ? true : Ext.layout.AbsoluteLayout.superclass.isValidParent.call(this, c, target);\r
44     },\r
45 \r
46     // private\r
47     adjustWidthAnchor : function(value, comp){\r
48         return value ? value - comp.getPosition(true)[0] : value;\r
49     },\r
50 \r
51     // private\r
52     adjustHeightAnchor : function(value, comp){\r
53         return  value ? value - comp.getPosition(true)[1] : value;\r
54     }\r
55     /**\r
56      * @property activeItem\r
57      * @hide\r
58      */\r
59 });\r
60 Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;