3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
8 * @class Ext.layout.FitLayout
9 * @extends Ext.layout.ContainerLayout
10 * <p>This is a base class for layouts that contain <b>a single item</b> that automatically expands to fill the layout's
11 * container. This class is intended to be extended or created via the <tt>layout:'fit'</tt> {@link Ext.Container#layout}
12 * config, and should generally not need to be created directly via the new keyword.</p>
13 * <p>FitLayout does not have any direct config options (other than inherited ones). To fit a panel to a container
14 * using FitLayout, simply set layout:'fit' on the container and add a single panel to it. If the container has
15 * multiple panels, only the first one will be displayed. Example usage:</p>
17 var p = new Ext.Panel({
22 html: '<p>This is the inner panel content</p>',
28 Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {
34 getLayoutTargetSize : function() {
35 var target = this.container.getLayoutTarget();
39 // Style Sized (scrollbars not included)
40 return target.getStyleSize();
44 onLayout : function(ct, target){
45 Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
47 this.setItemSize(this.activeItem || ct.items.itemAt(0), this.getLayoutTargetSize());
52 setItemSize : function(item, size){
53 if(item && size.height > 0){ // display none?
58 Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;