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");
28 /** false to disable window resize monitoring @type Boolean */
29 this.monitorWindowResize = true;
34 * Fires when a layout is performed.
35 * @param {Roo.LayoutManager} this
39 * @event regionresized
40 * Fires when the user resizes a region.
41 * @param {Roo.LayoutRegion} region The resized region
42 * @param {Number} newSize The new size (width for east/west, height for north/south)
44 "regionresized" : true,
46 * @event regioncollapsed
47 * Fires when a region is collapsed.
48 * @param {Roo.LayoutRegion} region The collapsed region
50 "regioncollapsed" : true,
52 * @event regionexpanded
53 * Fires when a region is expanded.
54 * @param {Roo.LayoutRegion} region The expanded region
56 "regionexpanded" : true
58 this.updating = false;
59 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
62 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
64 * Returns true if this layout is currently being updated
67 isUpdating : function(){
72 * Suspend the LayoutManager from doing auto-layouts while
73 * making multiple add or remove calls
75 beginUpdate : function(){
80 * Restore auto-layouts and optionally disable the manager from performing a layout
81 * @param {Boolean} noLayout true to disable a layout update
83 endUpdate : function(noLayout){
84 this.updating = false;
94 onRegionResized : function(region, newSize){
95 this.fireEvent("regionresized", region, newSize);
99 onRegionCollapsed : function(region){
100 this.fireEvent("regioncollapsed", region);
103 onRegionExpanded : function(region){
104 this.fireEvent("regionexpanded", region);
108 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
109 * performs box-model adjustments.
110 * @return {Object} The size as an object {width: (the width), height: (the height)}
112 getViewSize : function(){
114 if(this.el.dom != document.body){
115 size = this.el.getSize();
117 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
119 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
120 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
125 * Returns the Element this layout is bound to.
126 * @return {Roo.Element}
133 * Returns the specified region.
134 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
135 * @return {Roo.LayoutRegion}
137 getRegion : function(target){
138 return this.regions[target.toLowerCase()];
141 onWindowResize : function(){
142 if(this.monitorWindowResize){