4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
13 * @class Roo.LayoutManager
14 * @extends Roo.util.Observable
15 * Base class for layout managers.
17 Roo.LayoutManager = function(container, config){
18 Roo.LayoutManager.superclass.constructor.call(this);
19 this.el = Roo.get(container);
21 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
22 document.body.scroll = "no";
23 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
24 this.el.position('relative');
27 this.el.addClass("x-layout-container");
29 Roo.log('this.el!!!!!!!!');
30 Roo.log(this.el);return
32 /** false to disable window resize monitoring @type Boolean */
33 this.monitorWindowResize = true;
38 * Fires when a layout is performed.
39 * @param {Roo.LayoutManager} this
43 * @event regionresized
44 * Fires when the user resizes a region.
45 * @param {Roo.LayoutRegion} region The resized region
46 * @param {Number} newSize The new size (width for east/west, height for north/south)
48 "regionresized" : true,
50 * @event regioncollapsed
51 * Fires when a region is collapsed.
52 * @param {Roo.LayoutRegion} region The collapsed region
54 "regioncollapsed" : true,
56 * @event regionexpanded
57 * Fires when a region is expanded.
58 * @param {Roo.LayoutRegion} region The expanded region
60 "regionexpanded" : true
62 this.updating = false;
63 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
66 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
68 * Returns true if this layout is currently being updated
71 isUpdating : function(){
76 * Suspend the LayoutManager from doing auto-layouts while
77 * making multiple add or remove calls
79 beginUpdate : function(){
84 * Restore auto-layouts and optionally disable the manager from performing a layout
85 * @param {Boolean} noLayout true to disable a layout update
87 endUpdate : function(noLayout){
88 this.updating = false;
98 onRegionResized : function(region, newSize){
99 this.fireEvent("regionresized", region, newSize);
103 onRegionCollapsed : function(region){
104 this.fireEvent("regioncollapsed", region);
107 onRegionExpanded : function(region){
108 this.fireEvent("regionexpanded", region);
112 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
113 * performs box-model adjustments.
114 * @return {Object} The size as an object {width: (the width), height: (the height)}
116 getViewSize : function(){
118 if(this.el.dom != document.body){
119 size = this.el.getSize();
121 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
123 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
124 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
129 * Returns the Element this layout is bound to.
130 * @return {Roo.Element}
137 * Returns the specified region.
138 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
139 * @return {Roo.LayoutRegion}
141 getRegion : function(target){
142 return this.regions[target.toLowerCase()];
145 onWindowResize : function(){
146 if(this.monitorWindowResize){