Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / layout / container / HBox.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 horizontally across a Container. This layout optionally divides available horizontal
17  * space between child items containing a numeric `flex` configuration.
18  *
19  * This layout may also be used to set the heights of child items by configuring it with the {@link #align} option.
20  *
21  *     @example
22  *     Ext.create('Ext.Panel', {
23  *         width: 500,
24  *         height: 300,
25  *         title: "HBoxLayout Panel",
26  *         layout: {
27  *             type: 'hbox',
28  *             align: 'stretch'
29  *         },
30  *         renderTo: document.body,
31  *         items: [{
32  *             xtype: 'panel',
33  *             title: 'Inner Panel One',
34  *             flex: 2
35  *         },{
36  *             xtype: 'panel',
37  *             title: 'Inner Panel Two',
38  *             flex: 1
39  *         },{
40  *             xtype: 'panel',
41  *             title: 'Inner Panel Three',
42  *             flex: 1
43  *         }]
44  *     });
45  */
46 Ext.define('Ext.layout.container.HBox', {
47
48     /* Begin Definitions */
49
50     alias: ['layout.hbox'],
51     extend: 'Ext.layout.container.Box',
52     alternateClassName: 'Ext.layout.HBoxLayout',
53
54     /* End Definitions */
55
56     /**
57      * @cfg {String} align
58      * Controls how the child items of the container are aligned. Acceptable configuration values for this property are:
59      *
60      * - **top** : **Default** child items are aligned vertically at the **top** of the container
61      * - **middle** : child items are aligned vertically in the **middle** of the container
62      * - **stretch** : child items are stretched vertically to fill the height of the container
63      * - **stretchmax** : child items are stretched vertically to the height of the largest item.
64      */
65     align: 'top', // top, middle, stretch, strechmax
66
67     //@private
68     alignCenteringString: 'middle',
69
70     type : 'hbox',
71
72     direction: 'horizontal',
73
74     // When creating an argument list to setSize, use this order
75     parallelSizeIndex: 0,
76     perpendicularSizeIndex: 1,
77
78     parallelPrefix: 'width',
79     parallelPrefixCap: 'Width',
80     parallelLT: 'l',
81     parallelRB: 'r',
82     parallelBefore: 'left',
83     parallelBeforeCap: 'Left',
84     parallelAfter: 'right',
85     parallelPosition: 'x',
86
87     perpendicularPrefix: 'height',
88     perpendicularPrefixCap: 'Height',
89     perpendicularLT: 't',
90     perpendicularRB: 'b',
91     perpendicularLeftTop: 'top',
92     perpendicularRightBottom: 'bottom',
93     perpendicularPosition: 'y',
94     configureItem: function(item) {
95         if (item.flex) {
96             item.layoutManagedWidth = 1;
97         } else {
98             item.layoutManagedWidth = 2;
99         }
100
101         if (this.align === 'stretch' || this.align === 'stretchmax') {
102             item.layoutManagedHeight = 1;
103         } else {
104             item.layoutManagedHeight = 2;
105         }
106         this.callParent(arguments);
107     }
108 });