Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / layout / container / VBox.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
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.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * A layout that arranges items vertically down a Container. This layout optionally divides available vertical space
17  * between child items containing a numeric `flex` configuration.
18  *
19  * This layout may also be used to set the widths of child items by configuring it with the {@link #align} option.
20  *
21  *     @example
22  *     Ext.create('Ext.Panel', {
23  *         width: 500,
24  *         height: 400,
25  *         title: "VBoxLayout Panel",
26  *         layout: {
27  *             type: 'vbox',
28  *             align: 'center'
29  *         },
30  *         renderTo: document.body,
31  *         items: [{
32  *             xtype: 'panel',
33  *             title: 'Inner Panel One',
34  *             width: 250,
35  *             flex: 2
36  *         },
37  *         {
38  *             xtype: 'panel',
39  *             title: 'Inner Panel Two',
40  *             width: 250,
41  *             flex: 4
42  *         },
43  *         {
44  *             xtype: 'panel',
45  *             title: 'Inner Panel Three',
46  *             width: '50%',
47  *             flex: 4
48  *         }]
49  *     });
50  */
51 Ext.define('Ext.layout.container.VBox', {
52
53     /* Begin Definitions */
54
55     alias: ['layout.vbox'],
56     extend: 'Ext.layout.container.Box',
57     alternateClassName: 'Ext.layout.VBoxLayout',
58
59     /* End Definitions */
60
61     /**
62      * @cfg {String} align
63      * Controls how the child items of the container are aligned. Acceptable configuration values for this property are:
64      *
65      * - **left** : **Default** child items are aligned horizontally at the **left** side of the container
66      * - **center** : child items are aligned horizontally at the **mid-width** of the container
67      * - **stretch** : child items are stretched horizontally to fill the width of the container
68      * - **stretchmax** : child items are stretched horizontally to the size of the largest item.
69      */
70     align : 'left', // left, center, stretch, strechmax
71
72     //@private
73     alignCenteringString: 'center',
74
75     type: 'vbox',
76
77     direction: 'vertical',
78
79     // When creating an argument list to setSize, use this order
80     parallelSizeIndex: 1,
81     perpendicularSizeIndex: 0,
82
83     parallelPrefix: 'height',
84     parallelPrefixCap: 'Height',
85     parallelLT: 't',
86     parallelRB: 'b',
87     parallelBefore: 'top',
88     parallelBeforeCap: 'Top',
89     parallelAfter: 'bottom',
90     parallelPosition: 'y',
91
92     perpendicularPrefix: 'width',
93     perpendicularPrefixCap: 'Width',
94     perpendicularLT: 'l',
95     perpendicularRB: 'r',
96     perpendicularLeftTop: 'left',
97     perpendicularRightBottom: 'right',
98     perpendicularPosition: 'x',
99     configureItem: function(item) {
100         if (item.flex) {
101             item.layoutManagedHeight = 1;
102         } else {
103             item.layoutManagedHeight = 2;
104         }
105
106         if (this.align === 'stretch' || this.align === 'stretchmax') {
107             item.layoutManagedWidth = 1;
108         } else {
109             item.layoutManagedWidth = 2;
110         }
111         this.callParent(arguments);
112     }
113 });