3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Ext.lib.Region = function(t, r, b, l) {
17 Ext.lib.Region.prototype = {
18 contains : function(region) {
20 return ( region.left >= me.left &&
21 region.right <= me.right &&
22 region.top >= me.top &&
23 region.bottom <= me.bottom );
27 getArea : function() {
29 return ( (me.bottom - me.top) * (me.right - me.left) );
32 intersect : function(region) {
34 t = Math.max(me.top, region.top),
35 r = Math.min(me.right, region.right),
36 b = Math.min(me.bottom, region.bottom),
37 l = Math.max(me.left, region.left);
39 if (b >= t && r >= l) {
40 return new Ext.lib.Region(t, r, b, l);
44 union : function(region) {
46 t = Math.min(me.top, region.top),
47 r = Math.max(me.right, region.right),
48 b = Math.max(me.bottom, region.bottom),
49 l = Math.min(me.left, region.left);
51 return new Ext.lib.Region(t, r, b, l);
54 constrainTo : function(r) {
56 me.top = me.top.constrain(r.top, r.bottom);
57 me.bottom = me.bottom.constrain(r.top, r.bottom);
58 me.left = me.left.constrain(r.left, r.right);
59 me.right = me.right.constrain(r.left, r.right);
63 adjust : function(t, l, b, r) {
73 Ext.lib.Region.getRegion = function(el) {
74 var p = Ext.lib.Dom.getXY(el),
76 r = p[0] + el.offsetWidth,
77 b = p[1] + el.offsetHeight,
80 return new Ext.lib.Region(t, r, b, l);