3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.BasicLayoutRegion
11
* @extends Ext.util.Observable
12
* This class represents a lightweight region in a layout manager. This region does not move dom nodes
13
* and does not have a titlebar, tabs or any other features. All it does is size and position
14
* panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
16
Ext.BasicLayoutRegion = function(mgr, config, pos, skipConfig){
22
* Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
23
* @param {Ext.LayoutRegion} this
24
* @param {Ext.ContentPanel} panel The panel
25
* @param {Object} e The cancel event object
27
"beforeremove" : true,
30
* Fires when the layout for this region is changed.
31
* @param {Ext.LayoutRegion} this
35
* @event visibilitychange
36
* Fires when this region is shown or hidden
37
* @param {Ext.LayoutRegion} this
38
* @param {Boolean} visibility true or false
40
"visibilitychange" : true,
43
* Fires when a panel is added.
44
* @param {Ext.LayoutRegion} this
45
* @param {Ext.ContentPanel} panel The panel
50
* Fires when a panel is removed.
51
* @param {Ext.LayoutRegion} this
52
* @param {Ext.ContentPanel} panel The panel
54
"panelremoved" : true,
57
* Fires when this region is collapsed.
58
* @param {Ext.LayoutRegion} this
63
* Fires when this region is expanded.
64
* @param {Ext.LayoutRegion} this
69
* Fires when this region is slid into view.
70
* @param {Ext.LayoutRegion} this
75
* Fires when this region slides out of view.
76
* @param {Ext.LayoutRegion} this
80
* @event panelactivated
81
* Fires when a panel is activated.
82
* @param {Ext.LayoutRegion} this
83
* @param {Ext.ContentPanel} panel The activated panel
85
"panelactivated" : true,
88
* Fires when the user resizes this region.
89
* @param {Ext.LayoutRegion} this
90
* @param {Number} newSize The new size (width for east/west, height for north/south)
94
/** A collection of panels in this region. @type Ext.util.MixedCollection */
95
this.panels = new Ext.util.MixedCollection();
96
this.panels.getKey = this.getPanelId.createDelegate(this);
98
this.activePanel = null;
99
if(skipConfig !== true){
100
this.applyConfig(config);
104
Ext.extend(Ext.BasicLayoutRegion, Ext.util.Observable, {
105
getPanelId : function(p){
109
applyConfig : function(config){
110
this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
111
this.config = config;
115
* Resizes the region to the specified size. For vertical regions (west, east) this adjusts
116
* the width, for horizontal (north, south) the height.
117
* @param {Number} newSize The new width or height
119
resizeTo : function(newSize){
120
var el = this.el ? this.el :
121
(this.activePanel ? this.activePanel.getEl() : null);
123
switch(this.position){
126
el.setWidth(newSize);
127
this.fireEvent("resized", this, newSize);
131
el.setHeight(newSize);
132
this.fireEvent("resized", this, newSize);
139
return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
142
getMargins : function(){
146
updateBox : function(box){
148
var el = this.activePanel.getEl();
149
el.dom.style.left = box.x + "px";
150
el.dom.style.top = box.y + "px";
151
this.activePanel.setSize(box.width, box.height);
155
* Returns the container element for this region.
156
* @return {Ext.Element}
159
return this.activePanel;
163
* Returns true if this region is currently visible.
166
isVisible : function(){
167
return this.activePanel ? true : false;
170
setActivePanel : function(panel){
171
panel = this.getPanel(panel);
172
if(this.activePanel && this.activePanel != panel){
173
this.activePanel.setActiveState(false);
174
this.activePanel.getEl().setLeftTop(-10000,-10000);
176
this.activePanel = panel;
177
panel.setActiveState(true);
179
panel.setSize(this.box.width, this.box.height);
181
this.fireEvent("panelactivated", this, panel);
182
this.fireEvent("invalidated");
186
* Show the specified panel.
187
* @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
188
* @return {Ext.ContentPanel} The shown panel or null
190
showPanel : function(panel){
191
if(panel = this.getPanel(panel)){
192
this.setActivePanel(panel);
198
* Get the active panel for this region.
199
* @return {Ext.ContentPanel} The active panel or null
201
getActivePanel : function(){
202
return this.activePanel;
206
* Add the passed ContentPanel(s)
207
* @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
208
* @return {Ext.ContentPanel} The panel added (if only one was added)
210
add : function(panel){
211
if(arguments.length > 1){
212
for(var i = 0, len = arguments.length; i < len; i++) {
213
this.add(arguments[i]);
217
if(this.hasPanel(panel)){
218
this.showPanel(panel);
221
var el = panel.getEl();
222
if(el.dom.parentNode != this.mgr.el.dom){
223
this.mgr.el.dom.appendChild(el.dom);
226
panel.setRegion(this);
228
this.panels.add(panel);
229
el.setStyle("position", "absolute");
230
if(!panel.background){
231
this.setActivePanel(panel);
232
if(this.config.initialSize && this.panels.getCount()==1){
233
this.resizeTo(this.config.initialSize);
236
this.fireEvent("paneladded", this, panel);
241
* Returns true if the panel is in this region.
242
* @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
245
hasPanel : function(panel){
246
if(typeof panel == "object"){ // must be panel obj
247
panel = panel.getId();
249
return this.getPanel(panel) ? true : false;
253
* Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
254
* @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
255
* @param {Boolean} preservePanel Overrides the config preservePanel option
256
* @return {Ext.ContentPanel} The panel that was removed
258
remove : function(panel, preservePanel){
259
panel = this.getPanel(panel);
264
this.fireEvent("beforeremove", this, panel, e);
265
if(e.cancel === true){
268
var panelId = panel.getId();
269
this.panels.removeKey(panelId);
274
* Returns the panel specified or null if it's not in this region.
275
* @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
276
* @return {Ext.ContentPanel}
278
getPanel : function(id){
279
if(typeof id == "object"){ // must be panel obj
282
return this.panels.get(id);
286
* Returns this regions position (north/south/east/west/center).
289
getPosition: function(){
290
return this.position;
b'\\ No newline at end of file'