X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/layout/container/Fit.js diff --git a/src/layout/container/Fit.js b/src/layout/container/Fit.js new file mode 100644 index 00000000..166e4db0 --- /dev/null +++ b/src/layout/container/Fit.js @@ -0,0 +1,64 @@ +/** + * @class Ext.layout.container.Fit + * @extends Ext.layout.container.AbstractFit + *

This is a base class for layouts that contain a single item that automatically expands to fill the layout's + * container. This class is intended to be extended or created via the layout:'fit' {@link Ext.container.Container#layout} + * config, and should generally not need to be created directly via the new keyword.

+ *

FitLayout does not have any direct config options (other than inherited ones). To fit a panel to a container + * using FitLayout, simply set layout:'fit' on the container and add a single panel to it. If the container has + * multiple panels, only the first one will be displayed. + * {@img Ext.layout.container.Fit/Ext.layout.container.Fit.png Ext.layout.container.Fit container layout} + * Example usage:

+ *

+    Ext.create('Ext.panel.Panel', {
+        title: 'Fit Layout',
+        width: 300,
+        height: 150,
+        layout:'fit',
+        items: {
+            title: 'Inner Panel',
+            html: '

This is the inner panel content

', + bodyPadding: 20, + border: false + }, + renderTo: Ext.getBody() + }); +
+ */ +Ext.define('Ext.layout.container.Fit', { + + /* Begin Definitions */ + + extend: 'Ext.layout.container.AbstractFit', + alias: 'layout.fit', + alternateClassName: 'Ext.layout.FitLayout', + + /* End Definitions */ + + // @private + onLayout : function() { + var me = this; + me.callParent(); + + if (me.owner.items.length) { + me.setItemBox(me.owner.items.get(0), me.getLayoutTargetSize()); + } + }, + + getTargetBox : function() { + return this.getLayoutTargetSize(); + }, + + setItemBox : function(item, box) { + var me = this; + if (item && box.height > 0) { + if (me.isManaged('width') === true) { + box.width = undefined; + } + if (me.isManaged('height') === true) { + box.height = undefined; + } + me.setItemSize(item, box.width, box.height); + } + } +}); \ No newline at end of file