4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-container-ButtonGroup'>/**
19 </span> * Provides a container for arranging a group of related Buttons in a tabular manner.
22 * Ext.create('Ext.panel.Panel', {
23 * title: 'Panel with ButtonGroup',
26 * renderTo: document.body,
28 * html: 'HTML Panel Content',
30 * xtype: 'buttongroup',
41 * xtype:'splitbutton',
42 * text: 'Menu Button',
47 * arrowAlign:'bottom',
48 * menu: [{ text: 'Menu Item 1' }]
50 * xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
52 * text: 'Copy', iconCls: 'add16'
54 * text: 'Format', iconCls: 'add16'
60 Ext.define('Ext.container.ButtonGroup', {
61 extend: 'Ext.panel.Panel',
62 alias: 'widget.buttongroup',
63 alternateClassName: 'Ext.ButtonGroup',
65 <span id='Ext-container-ButtonGroup-cfg-columns'> /**
66 </span> * @cfg {Number} columns The `columns` configuration property passed to the
67 * {@link #layout configured layout manager}. See {@link Ext.layout.container.Table#columns}.
70 <span id='Ext-container-ButtonGroup-cfg-baseCls'> /**
71 </span> * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.panel.Panel#baseCls}.
73 baseCls: Ext.baseCSSPrefix + 'btn-group',
75 <span id='Ext-container-ButtonGroup-cfg-layout'> /**
76 </span> * @cfg {Object} layout Defaults to <tt>'table'</tt>. See {@link Ext.container.Container#layout}.
82 defaultType: 'button',
84 <span id='Ext-container-ButtonGroup-cfg-frame'> /**
85 </span> * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.panel.Panel#frame}.
91 internalDefaults: {removeMode: 'container', hideParent: true},
93 initComponent : function(){
94 // Copy the component's columns config to the layout if specified
98 me.noTitleCls = me.baseCls + '-notitle';
100 me.layout = Ext.apply({}, {columns: cols}, me.layout);
104 me.addCls(me.noTitleCls);
106 me.callParent(arguments);
109 afterLayout: function() {
112 me.callParent(arguments);
114 // Pugly hack for a pugly browser:
115 // If not an explicitly set width, then size the width to match the inner table
116 if (me.layout.table && (Ext.isIEQuirks || Ext.isIE6) && !me.width) {
117 var t = me.getTargetEl();
118 t.setWidth(me.layout.table.offsetWidth + t.getPadding('lr'));
122 afterRender: function() {
125 //we need to add an addition item in here so the ButtonGroup title is centered
127 // Header text cannot flex, but must be natural size if it's being centered
128 delete me.header.items.items[0].flex;
130 // For Centering, surround the text with two flex:1 spacers.
131 me.suspendLayout = true;
132 me.header.insert(1, {
137 me.header.insert(0, {
142 me.suspendLayout = false;
145 me.callParent(arguments);
149 onBeforeAdd: function(component) {
150 if (component.is('button')) {
151 component.ui = component.ui + '-toolbar';
153 this.callParent(arguments);
157 applyDefaults: function(c) {
158 if (!Ext.isString(c)) {
159 c = this.callParent(arguments);
160 var d = this.internalDefaults;
162 Ext.applyIf(c.initialConfig, d);
171 <span id='Ext-container-ButtonGroup-cfg-tools'> /**
172 </span> * @cfg {Array} tools @hide
174 <span id='Ext-container-ButtonGroup-cfg-collapsible'> /**
175 </span> * @cfg {Boolean} collapsible @hide
177 <span id='Ext-container-ButtonGroup-cfg-collapseMode'> /**
178 </span> * @cfg {Boolean} collapseMode @hide
180 <span id='Ext-container-ButtonGroup-cfg-animCollapse'> /**
181 </span> * @cfg {Boolean} animCollapse @hide
183 <span id='Ext-container-ButtonGroup-cfg-closable'> /**
184 </span> * @cfg {Boolean} closable @hide