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);
25 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
26 document.body.scroll = "no";
27 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
28 this.el.position('relative');
33 this.el.addClass("x-layout-container");
35 /** false to disable window resize monitoring @type Boolean */
36 this.monitorWindowResize = true;
41 * Fires when a layout is performed.
42 * @param {Roo.LayoutManager} this
46 * @event regionresized
47 * Fires when the user resizes a region.
48 * @param {Roo.LayoutRegion} region The resized region
49 * @param {Number} newSize The new size (width for east/west, height for north/south)
51 "regionresized" : true,
53 * @event regioncollapsed
54 * Fires when a region is collapsed.
55 * @param {Roo.LayoutRegion} region The collapsed region
57 "regioncollapsed" : true,
59 * @event regionexpanded
60 * Fires when a region is expanded.
61 * @param {Roo.LayoutRegion} region The expanded region
63 "regionexpanded" : true
65 this.updating = false;
66 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
69 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
71 * Returns true if this layout is currently being updated
74 isUpdating : function(){
79 * Suspend the LayoutManager from doing auto-layouts while
80 * making multiple add or remove calls
82 beginUpdate : function(){
87 * Restore auto-layouts and optionally disable the manager from performing a layout
88 * @param {Boolean} noLayout true to disable a layout update
90 endUpdate : function(noLayout){
91 this.updating = false;
101 onRegionResized : function(region, newSize){
102 this.fireEvent("regionresized", region, newSize);
106 onRegionCollapsed : function(region){
107 this.fireEvent("regioncollapsed", region);
110 onRegionExpanded : function(region){
111 this.fireEvent("regionexpanded", region);
115 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
116 * performs box-model adjustments.
117 * @return {Object} The size as an object {width: (the width), height: (the height)}
119 getViewSize : function(){
121 if(this.el.dom != document.body){
122 size = this.el.getSize();
124 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
126 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
127 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
132 * Returns the Element this layout is bound to.
133 * @return {Roo.Element}
140 * Returns the specified region.
141 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
142 * @return {Roo.LayoutRegion}
144 getRegion : function(target){
145 return this.regions[target.toLowerCase()];
148 onWindowResize : function(){
149 if(this.monitorWindowResize){