3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * Component layout for {@link Ext.view.BoundList}. Handles constraining the height to the configured maxHeight.
17 * @class Ext.layout.component.BoundList
18 * @extends Ext.layout.component.Component
21 Ext.define('Ext.layout.component.BoundList', {
22 extend: 'Ext.layout.component.Component',
23 alias: 'layout.boundlist',
27 beforeLayout: function() {
28 return this.callParent(arguments) || this.owner.refreshed > 0;
31 onLayout : function(width, height) {
34 floating = owner.floating,
37 isNumber = Ext.isNumber,
38 minWidth, maxWidth, minHeight, maxHeight,
39 naturalWidth, naturalHeight, constrainedWidth, constrainedHeight, undef;
42 // Position offscreen so the natural width is not affected by the viewport's right edge
43 el.setXY([-9999,-9999]);
46 // Calculate initial layout
47 me.setTargetSize(width, height);
49 // Handle min/maxWidth for auto-width
50 if (!isNumber(width)) {
51 minWidth = owner.minWidth;
52 maxWidth = owner.maxWidth;
53 if (isNumber(minWidth) || isNumber(maxWidth)) {
54 naturalWidth = el.getWidth();
55 if (naturalWidth < minWidth) {
56 constrainedWidth = minWidth;
58 else if (naturalWidth > maxWidth) {
59 constrainedWidth = maxWidth;
61 if (constrainedWidth) {
62 me.setTargetSize(constrainedWidth);
66 // Handle min/maxHeight for auto-height
67 if (!isNumber(height)) {
68 minHeight = owner.minHeight;
69 maxHeight = owner.maxHeight;
70 if (isNumber(minHeight) || isNumber(maxHeight)) {
71 naturalHeight = el.getHeight();
72 if (naturalHeight < minHeight) {
73 constrainedHeight = minHeight;
75 else if (naturalHeight > maxHeight) {
76 constrainedHeight = maxHeight;
78 if (constrainedHeight) {
79 me.setTargetSize(undef, constrainedHeight);
90 afterLayout: function() {
92 toolbar = me.owner.pagingToolbar;
95 toolbar.doComponentLayout();
99 setTargetSize : function(width, height) {
106 if (Ext.isNumber(height)) {
107 listHeight = height - owner.el.getFrameWidth('tb');
108 toolbar = owner.pagingToolbar;
110 listHeight -= toolbar.getHeight();
113 me.setElementSize(owner.listEl, null, listHeight);
115 me.callParent(arguments);