2 * Portions of this file are based on pieces of Yahoo User Interface Library
3 * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4 * YUI licensed under the BSD License:
5 * http://developer.yahoo.net/yui/license.txt
6 * <script type="text/javascript">
10 Roo.lib.Region = function(t, r, b, l) {
20 Roo.lib.Region.prototype = {
21 contains : function(region) {
22 return ( region.left >= this.left &&
23 region.right <= this.right &&
24 region.top >= this.top &&
25 region.bottom <= this.bottom );
29 getArea : function() {
30 return ( (this.bottom - this.top) * (this.right - this.left) );
33 intersect : function(region) {
34 var t = Math.max(this.top, region.top);
35 var r = Math.min(this.right, region.right);
36 var b = Math.min(this.bottom, region.bottom);
37 var l = Math.max(this.left, region.left);
39 if (b >= t && r >= l) {
40 return new Roo.lib.Region(t, r, b, l);
45 union : function(region) {
46 var t = Math.min(this.top, region.top);
47 var r = Math.max(this.right, region.right);
48 var b = Math.max(this.bottom, region.bottom);
49 var l = Math.min(this.left, region.left);
51 return new Roo.lib.Region(t, r, b, l);
54 adjust : function(t, l, b, r) {
63 Roo.lib.Region.getRegion = function(el) {
64 var p = Roo.lib.Dom.getXY(el);
67 var r = p[0] + el.offsetWidth;
68 var b = p[1] + el.offsetHeight;
71 return new Roo.lib.Region(t, r, b, l);