4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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> * @class Ext.container.ButtonGroup
20 * @extends Ext.panel.Panel
21 * <p>Provides a container for arranging a group of related Buttons in a tabular manner.</p>
23 * {@img Ext.container.ButtonGroup/Ext.container.ButtonGroup.png Ext.container.ButtonGroup component}
24 * <pre><code>
25 Ext.create('Ext.panel.Panel', {
26 title: 'Panel with ButtonGroup',
29 renderTo: document.body,
30 html: 'HTML Panel Content',
50 menu: [{text: 'Menu Item 1'}]
52 xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
54 text: 'Copy', iconCls: 'add16'
56 text: 'Format', iconCls: 'add16'
60 * </code></pre>
62 Ext.define('Ext.container.ButtonGroup', {
63 extend: 'Ext.panel.Panel',
64 alias: 'widget.buttongroup',
65 alternateClassName: 'Ext.ButtonGroup',
67 <span id='Ext-container-ButtonGroup-cfg-columns'> /**
68 </span> * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the
69 * {@link #layout configured layout manager}. See {@link Ext.layout.container.Table#columns}.
72 <span id='Ext-container-ButtonGroup-cfg-baseCls'> /**
73 </span> * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.panel.Panel#baseCls}.
75 baseCls: Ext.baseCSSPrefix + 'btn-group',
77 <span id='Ext-container-ButtonGroup-cfg-layout'> /**
78 </span> * @cfg {Object} layout Defaults to <tt>'table'</tt>. See {@link Ext.container.Container#layout}.
84 defaultType: 'button',
86 <span id='Ext-container-ButtonGroup-cfg-frame'> /**
87 </span> * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.panel.Panel#frame}.
93 internalDefaults: {removeMode: 'container', hideParent: true},
95 initComponent : function(){
96 // Copy the component's columns config to the layout if specified
100 me.noTitleCls = me.baseCls + '-notitle';
102 me.layout = Ext.apply({}, {columns: cols}, me.layout);
106 me.addCls(me.noTitleCls);
108 me.callParent(arguments);
111 afterLayout: function() {
114 me.callParent(arguments);
116 // Pugly hack for a pugly browser:
117 // If not an explicitly set width, then size the width to match the inner table
118 if (me.layout.table && (Ext.isIEQuirks || Ext.isIE6) && !me.width) {
119 var t = me.getTargetEl();
120 t.setWidth(me.layout.table.offsetWidth + t.getPadding('lr'));
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);
173 <span id='Ext-container-ButtonGroup-cfg-tools'> /**
174 </span> * @cfg {Array} tools @hide
176 <span id='Ext-container-ButtonGroup-cfg-collapsible'> /**
177 </span> * @cfg {Boolean} collapsible @hide
179 <span id='Ext-container-ButtonGroup-cfg-collapseMode'> /**
180 </span> * @cfg {Boolean} collapseMode @hide
182 <span id='Ext-container-ButtonGroup-cfg-animCollapse'> /**
183 </span> * @cfg {Boolean} animCollapse @hide
185 <span id='Ext-container-ButtonGroup-cfg-closable'> /**
186 </span> * @cfg {Boolean} closable @hide