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 * Provides a container for arranging a group of related Buttons in a tabular manner.
19 * Ext.create('Ext.panel.Panel', {
20 * title: 'Panel with ButtonGroup',
23 * renderTo: document.body,
25 * html: 'HTML Panel Content',
27 * xtype: 'buttongroup',
38 * xtype:'splitbutton',
39 * text: 'Menu Button',
44 * arrowAlign:'bottom',
45 * menu: [{ text: 'Menu Item 1' }]
47 * xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
49 * text: 'Copy', iconCls: 'add16'
51 * text: 'Format', iconCls: 'add16'
57 Ext.define('Ext.container.ButtonGroup', {
58 extend: 'Ext.panel.Panel',
59 alias: 'widget.buttongroup',
60 alternateClassName: 'Ext.ButtonGroup',
63 * @cfg {Number} columns The `columns` configuration property passed to the
64 * {@link #layout configured layout manager}. See {@link Ext.layout.container.Table#columns}.
68 * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.panel.Panel#baseCls}.
70 baseCls: Ext.baseCSSPrefix + 'btn-group',
73 * @cfg {Object} layout Defaults to <tt>'table'</tt>. See {@link Ext.container.Container#layout}.
79 defaultType: 'button',
82 * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.panel.Panel#frame}.
88 internalDefaults: {removeMode: 'container', hideParent: true},
90 initComponent : function(){
91 // Copy the component's columns config to the layout if specified
95 me.noTitleCls = me.baseCls + '-notitle';
97 me.layout = Ext.apply({}, {columns: cols}, me.layout);
101 me.addCls(me.noTitleCls);
103 me.callParent(arguments);
106 afterLayout: function() {
109 me.callParent(arguments);
111 // Pugly hack for a pugly browser:
112 // If not an explicitly set width, then size the width to match the inner table
113 if (me.layout.table && (Ext.isIEQuirks || Ext.isIE6) && !me.width) {
114 var t = me.getTargetEl();
115 t.setWidth(me.layout.table.offsetWidth + t.getPadding('lr'));
118 // IE7 needs a forced repaint to make the top framing div expand to full width
124 afterRender: function() {
127 //we need to add an addition item in here so the ButtonGroup title is centered
129 // Header text cannot flex, but must be natural size if it's being centered
130 delete me.header.items.items[0].flex;
132 // For Centering, surround the text with two flex:1 spacers.
133 me.suspendLayout = true;
134 me.header.insert(1, {
139 me.header.insert(0, {
144 me.suspendLayout = false;
147 me.callParent(arguments);
151 onBeforeAdd: function(component) {
152 if (component.is('button')) {
153 component.ui = component.ui + '-toolbar';
155 this.callParent(arguments);
159 applyDefaults: function(c) {
160 if (!Ext.isString(c)) {
161 c = this.callParent(arguments);
162 var d = this.internalDefaults;
164 Ext.applyIf(c.initialConfig, d);
174 * @cfg {Array} tools @hide
177 * @cfg {Boolean} collapsible @hide
180 * @cfg {Boolean} collapseMode @hide
183 * @cfg {Boolean} animCollapse @hide
186 * @cfg {Boolean} closable @hide