Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / ext-base-region.html
diff --git a/docs/source/ext-base-region.html b/docs/source/ext-base-region.html
new file mode 100644 (file)
index 0000000..dd46669
--- /dev/null
@@ -0,0 +1,84 @@
+<html>\r
+<head>\r
+  <title>The source code</title>\r
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body  onload="prettyPrint();">\r
+    <pre class="prettyprint lang-js">  Ext.lib.Region = function(t, r, b, l) {\r
+               var me = this;\r
+        me.top = t;\r
+        me[1] = t;\r
+        me.right = r;\r
+        me.bottom = b;\r
+        me.left = l;\r
+        me[0] = l;\r
+    };\r
+\r
+    Ext.lib.Region.prototype = {\r
+        contains : function(region) {\r
+               var me = this;\r
+            return ( region.left >= me.left &&\r
+                     region.right <= me.right &&\r
+                     region.top >= me.top &&\r
+                     region.bottom <= me.bottom );\r
+\r
+        },\r
+\r
+        getArea : function() {\r
+               var me = this;\r
+            return ( (me.bottom - me.top) * (me.right - me.left) );\r
+        },\r
+\r
+        intersect : function(region) {\r
+            var me = this,\r
+               t = Math.max(me.top, region.top),\r
+               r = Math.min(me.right, region.right),\r
+               b = Math.min(me.bottom, region.bottom),\r
+               l = Math.max(me.left, region.left);\r
+\r
+            if (b >= t && r >= l) {\r
+                return new Ext.lib.Region(t, r, b, l);\r
+            }\r
+        },\r
+        \r
+        union : function(region) {\r
+               var me = this,\r
+               t = Math.min(me.top, region.top),\r
+               r = Math.max(me.right, region.right),\r
+               b = Math.max(me.bottom, region.bottom),\r
+               l = Math.min(me.left, region.left);\r
+\r
+            return new Ext.lib.Region(t, r, b, l);\r
+        },\r
+\r
+        constrainTo : function(r) {\r
+               var me = this;\r
+            me.top = me.top.constrain(r.top, r.bottom);\r
+            me.bottom = me.bottom.constrain(r.top, r.bottom);\r
+            me.left = me.left.constrain(r.left, r.right);\r
+            me.right = me.right.constrain(r.left, r.right);\r
+            return me;\r
+        },\r
+\r
+        adjust : function(t, l, b, r) {\r
+               var me = this;\r
+            me.top += t;\r
+            me.left += l;\r
+            me.right += r;\r
+            me.bottom += b;\r
+            return me;\r
+        }\r
+    };\r
+\r
+    Ext.lib.Region.getRegion = function(el) {\r
+        var p = Ext.lib.Dom.getXY(el),\r
+               t = p[1],\r
+               r = p[0] + el.offsetWidth,\r
+               b = p[1] + el.offsetHeight,\r
+               l = p[0];\r
+\r
+        return new Ext.lib.Region(t, r, b, l);\r
+    };</pre>    \r
+</body>\r
+</html>
\ No newline at end of file