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