allow string based values for comboboxarray
[roojs1] / Roo / LayoutManager.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12 /**
13  * @class Roo.LayoutManager
14  * @extends Roo.util.Observable
15  * Base class for layout managers.
16  */
17 Roo.LayoutManager = function(container, config){
18     Roo.LayoutManager.superclass.constructor.call(this);
19     this.el = Roo.get(container);
20     // ie scrollbar fix
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');
25     }
26     this.id = this.el.id;
27     this.el.addClass("x-layout-container");
28     /** false to disable window resize monitoring @type Boolean */
29     this.monitorWindowResize = true;
30     this.regions = {};
31     this.addEvents({
32         /**
33          * @event layout
34          * Fires when a layout is performed. 
35          * @param {Roo.LayoutManager} this
36          */
37         "layout" : true,
38         /**
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)
43          */
44         "regionresized" : true,
45         /**
46          * @event regioncollapsed
47          * Fires when a region is collapsed. 
48          * @param {Roo.LayoutRegion} region The collapsed region
49          */
50         "regioncollapsed" : true,
51         /**
52          * @event regionexpanded
53          * Fires when a region is expanded.  
54          * @param {Roo.LayoutRegion} region The expanded region
55          */
56         "regionexpanded" : true
57     });
58     this.updating = false;
59     Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
60 };
61
62 Roo.extend(Roo.LayoutManager, Roo.util.Observable, {
63     /**
64      * Returns true if this layout is currently being updated
65      * @return {Boolean}
66      */
67     isUpdating : function(){
68         return this.updating; 
69     },
70     
71     /**
72      * Suspend the LayoutManager from doing auto-layouts while
73      * making multiple add or remove calls
74      */
75     beginUpdate : function(){
76         this.updating = true;    
77     },
78     
79     /**
80      * Restore auto-layouts and optionally disable the manager from performing a layout
81      * @param {Boolean} noLayout true to disable a layout update 
82      */
83     endUpdate : function(noLayout){
84         this.updating = false;
85         if(!noLayout){
86             this.layout();
87         }    
88     },
89     
90     layout: function(){
91         
92     },
93     
94     onRegionResized : function(region, newSize){
95         this.fireEvent("regionresized", region, newSize);
96         this.layout();
97     },
98     
99     onRegionCollapsed : function(region){
100         this.fireEvent("regioncollapsed", region);
101     },
102     
103     onRegionExpanded : function(region){
104         this.fireEvent("regionexpanded", region);
105     },
106         
107     /**
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)}
111      */
112     getViewSize : function(){
113         var size;
114         if(this.el.dom != document.body){
115             size = this.el.getSize();
116         }else{
117             size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
118         }
119         size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
120         size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
121         return size;
122     },
123     
124     /**
125      * Returns the Element this layout is bound to.
126      * @return {Roo.Element}
127      */
128     getEl : function(){
129         return this.el;
130     },
131     
132     /**
133      * Returns the specified region.
134      * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
135      * @return {Roo.LayoutRegion}
136      */
137     getRegion : function(target){
138         return this.regions[target.toLowerCase()];
139     },
140     
141     onWindowResize : function(){
142         if(this.monitorWindowResize){
143             this.layout();
144         }
145     }
146 });