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 * @class Ext.container.ButtonGroup
17 * @extends Ext.panel.Panel
18 * <p>Provides a container for arranging a group of related Buttons in a tabular manner.</p>
20 * {@img Ext.container.ButtonGroup/Ext.container.ButtonGroup.png Ext.container.ButtonGroup component}
22 Ext.create('Ext.panel.Panel', {
23 title: 'Panel with ButtonGroup',
26 renderTo: document.body,
27 html: 'HTML Panel Content',
47 menu: [{text: 'Menu Item 1'}]
49 xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
51 text: 'Copy', iconCls: 'add16'
53 text: 'Format', iconCls: 'add16'
59 Ext.define('Ext.container.ButtonGroup', {
60 extend: 'Ext.panel.Panel',
61 alias: 'widget.buttongroup',
62 alternateClassName: 'Ext.ButtonGroup',
65 * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the
66 * {@link #layout configured layout manager}. See {@link Ext.layout.container.Table#columns}.
70 * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.panel.Panel#baseCls}.
72 baseCls: Ext.baseCSSPrefix + 'btn-group',
75 * @cfg {Object} layout Defaults to <tt>'table'</tt>. See {@link Ext.container.Container#layout}.
81 defaultType: 'button',
84 * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.panel.Panel#frame}.
90 internalDefaults: {removeMode: 'container', hideParent: true},
92 initComponent : function(){
93 // Copy the component's columns config to the layout if specified
97 me.noTitleCls = me.baseCls + '-notitle';
99 me.layout = Ext.apply({}, {columns: cols}, me.layout);
103 me.addCls(me.noTitleCls);
105 me.callParent(arguments);
108 afterLayout: function() {
111 me.callParent(arguments);
113 // Pugly hack for a pugly browser:
114 // If not an explicitly set width, then size the width to match the inner table
115 if (me.layout.table && (Ext.isIEQuirks || Ext.isIE6) && !me.width) {
116 var t = me.getTargetEl();
117 t.setWidth(me.layout.table.offsetWidth + t.getPadding('lr'));
121 afterRender: function() {
124 //we need to add an addition item in here so the ButtonGroup title is centered
126 // Header text cannot flex, but must be natural size if it's being centered
127 delete me.header.items.items[0].flex;
129 // For Centering, surround the text with two flex:1 spacers.
130 me.suspendLayout = true;
131 me.header.insert(1, {
136 me.header.insert(0, {
141 me.suspendLayout = false;
144 me.callParent(arguments);
148 onBeforeAdd: function(component) {
149 if (component.is('button')) {
150 component.ui = component.ui + '-toolbar';
152 this.callParent(arguments);
156 applyDefaults: function(c) {
157 if (!Ext.isString(c)) {
158 c = this.callParent(arguments);
159 var d = this.internalDefaults;
161 Ext.applyIf(c.initialConfig, d);
171 * @cfg {Array} tools @hide
174 * @cfg {Boolean} collapsible @hide
177 * @cfg {Boolean} collapseMode @hide
180 * @cfg {Boolean} animCollapse @hide
183 * @cfg {Boolean} closable @hide