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>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 Ext.lib.Region = function(t, r, b, l) {
\r
24 Ext.lib.Region.prototype = {
\r
25 contains : function(region) {
\r
27 return ( region.left >= me.left &&
\r
28 region.right <= me.right &&
\r
29 region.top >= me.top &&
\r
30 region.bottom <= me.bottom );
\r
34 getArea : function() {
\r
36 return ( (me.bottom - me.top) * (me.right - me.left) );
\r
39 intersect : function(region) {
\r
41 t = Math.max(me.top, region.top),
\r
42 r = Math.min(me.right, region.right),
\r
43 b = Math.min(me.bottom, region.bottom),
\r
44 l = Math.max(me.left, region.left);
\r
46 if (b >= t && r >= l) {
\r
47 return new Ext.lib.Region(t, r, b, l);
\r
51 union : function(region) {
\r
53 t = Math.min(me.top, region.top),
\r
54 r = Math.max(me.right, region.right),
\r
55 b = Math.max(me.bottom, region.bottom),
\r
56 l = Math.min(me.left, region.left);
\r
58 return new Ext.lib.Region(t, r, b, l);
\r
61 constrainTo : function(r) {
\r
63 me.top = me.top.constrain(r.top, r.bottom);
\r
64 me.bottom = me.bottom.constrain(r.top, r.bottom);
\r
65 me.left = me.left.constrain(r.left, r.right);
\r
66 me.right = me.right.constrain(r.left, r.right);
\r
70 adjust : function(t, l, b, r) {
\r
80 Ext.lib.Region.getRegion = function(el) {
\r
81 var p = Ext.lib.Dom.getXY(el),
\r
83 r = p[0] + el.offsetWidth,
\r
84 b = p[1] + el.offsetHeight,
\r
87 return new Ext.lib.Region(t, r, b, l);
\r