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");
33 /** false to disable window resize monitoring @type Boolean */
34 this.monitorWindowResize = true;
39 * Fires when a layout is performed.
40 * @param {Roo.LayoutManager} this
44 * @event regionresized
45 * Fires when the user resizes a region.
46 * @param {Roo.LayoutRegion} region The resized region
47 * @param {Number} newSize The new size (width for east/west, height for north/south)
49 "regionresized" : true,
51 * @event regioncollapsed
52 * Fires when a region is collapsed.
53 * @param {Roo.LayoutRegion} region The collapsed region
55 "regioncollapsed" : true,
57 * @event regionexpanded
58 * Fires when a region is expanded.
59 * @param {Roo.LayoutRegion} region The expanded region
61 "regionexpanded" : true
63 this.updating = false;
64 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
67 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
69 * Returns true if this layout is currently being updated
72 isUpdating : function(){
77 * Suspend the LayoutManager from doing auto-layouts while
78 * making multiple add or remove calls
80 beginUpdate : function(){
85 * Restore auto-layouts and optionally disable the manager from performing a layout
86 * @param {Boolean} noLayout true to disable a layout update
88 endUpdate : function(noLayout){
89 this.updating = false;
99 onRegionResized : function(region, newSize){
100 this.fireEvent("regionresized", region, newSize);
104 onRegionCollapsed : function(region){
105 this.fireEvent("regioncollapsed", region);
108 onRegionExpanded : function(region){
109 this.fireEvent("regionexpanded", region);
113 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
114 * performs box-model adjustments.
115 * @return {Object} The size as an object {width: (the width), height: (the height)}
117 getViewSize : function(){
119 if(this.el.dom != document.body){
120 size = this.el.getSize();
122 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
124 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
125 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
130 * Returns the Element this layout is bound to.
131 * @return {Roo.Element}
138 * Returns the specified region.
139 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
140 * @return {Roo.LayoutRegion}
142 getRegion : function(target){
143 return this.regions[target.toLowerCase()];
146 onWindowResize : function(){
147 if(this.monitorWindowResize){