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){
20 Roo.LayoutManager.superclass.constructor.call(this);
22 this.el = Roo.get(container);
26 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
27 document.body.scroll = "no";
28 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
29 this.el.position('relative');
32 this.el.addClass("x-layout-container");
34 /** false to disable window resize monitoring @type Boolean */
35 this.monitorWindowResize = true;
40 * Fires when a layout is performed.
41 * @param {Roo.LayoutManager} this
45 * @event regionresized
46 * Fires when the user resizes a region.
47 * @param {Roo.LayoutRegion} region The resized region
48 * @param {Number} newSize The new size (width for east/west, height for north/south)
50 "regionresized" : true,
52 * @event regioncollapsed
53 * Fires when a region is collapsed.
54 * @param {Roo.LayoutRegion} region The collapsed region
56 "regioncollapsed" : true,
58 * @event regionexpanded
59 * Fires when a region is expanded.
60 * @param {Roo.LayoutRegion} region The expanded region
62 "regionexpanded" : true
64 this.updating = false;
65 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
68 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
70 * Returns true if this layout is currently being updated
73 isUpdating : function(){
78 * Suspend the LayoutManager from doing auto-layouts while
79 * making multiple add or remove calls
81 beginUpdate : function(){
86 * Restore auto-layouts and optionally disable the manager from performing a layout
87 * @param {Boolean} noLayout true to disable a layout update
89 endUpdate : function(noLayout){
90 this.updating = false;
100 onRegionResized : function(region, newSize){
101 this.fireEvent("regionresized", region, newSize);
105 onRegionCollapsed : function(region){
106 this.fireEvent("regioncollapsed", region);
109 onRegionExpanded : function(region){
110 this.fireEvent("regionexpanded", region);
114 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
115 * performs box-model adjustments.
116 * @return {Object} The size as an object {width: (the width), height: (the height)}
118 getViewSize : function(){
120 if(this.el.dom != document.body){
121 size = this.el.getSize();
123 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
125 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
126 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
131 * Returns the Element this layout is bound to.
132 * @return {Roo.Element}
139 * Returns the specified region.
140 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
141 * @return {Roo.LayoutRegion}
143 getRegion : function(target){
144 return this.regions[target.toLowerCase()];
147 onWindowResize : function(){
148 if(this.monitorWindowResize){