Upgrade to ExtJS 3.2.1 - Released 04/27/2010
[extjs.git] / docs / source / ButtonGroup.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.2.1
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15 <div id="cls-Ext.ButtonGroup"></div>/**
16  * @class Ext.ButtonGroup
17  * @extends Ext.Panel
18  * Container for a group of buttons. Example usage:
19  * <pre><code>
20 var p = new Ext.Panel({
21     title: 'Panel with Button Group',
22     width: 300,
23     height:200,
24     renderTo: document.body,
25     html: 'whatever',
26     tbar: [{
27         xtype: 'buttongroup',
28         {@link #columns}: 3,
29         title: 'Clipboard',
30         items: [{
31             text: 'Paste',
32             scale: 'large',
33             rowspan: 3, iconCls: 'add',
34             iconAlign: 'top',
35             cls: 'x-btn-as-arrow'
36         },{
37             xtype:'splitbutton',
38             text: 'Menu Button',
39             scale: 'large',
40             rowspan: 3,
41             iconCls: 'add',
42             iconAlign: 'top',
43             arrowAlign:'bottom',
44             menu: [{text: 'Menu Item 1'}]
45         },{
46             xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
47         },{
48             text: 'Copy', iconCls: 'add16'
49         },{
50             text: 'Format', iconCls: 'add16'
51         }]
52     }]
53 });
54  * </code></pre>
55  * @constructor
56  * Create a new ButtonGroup.
57  * @param {Object} config The config object
58  * @xtype buttongroup
59  */
60 Ext.ButtonGroup = Ext.extend(Ext.Panel, {
61     <div id="cfg-Ext.ButtonGroup-columns"></div>/**
62      * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the
63      * {@link #layout configured layout manager}. See {@link Ext.layout.TableLayout#columns}.
64      */
65     <div id="cfg-Ext.ButtonGroup-baseCls"></div>/**
66      * @cfg {String} baseCls  Defaults to <tt>'x-btn-group'</tt>.  See {@link Ext.Panel#baseCls}.
67      */
68     baseCls: 'x-btn-group',
69     <div id="cfg-Ext.ButtonGroup-layout"></div>/**
70      * @cfg {String} layout  Defaults to <tt>'table'</tt>.  See {@link Ext.Container#layout}.
71      */
72     layout:'table',
73     defaultType: 'button',
74     <div id="cfg-Ext.ButtonGroup-frame"></div>/**
75      * @cfg {Boolean} frame  Defaults to <tt>true</tt>.  See {@link Ext.Panel#frame}.
76      */
77     frame: true,
78     internalDefaults: {removeMode: 'container', hideParent: true},
79
80     initComponent : function(){
81         this.layoutConfig = this.layoutConfig || {};
82         Ext.applyIf(this.layoutConfig, {
83             columns : this.columns
84         });
85         if(!this.title){
86             this.addClass('x-btn-group-notitle');
87         }
88         this.on('afterlayout', this.onAfterLayout, this);
89         Ext.ButtonGroup.superclass.initComponent.call(this);
90     },
91
92     applyDefaults : function(c){
93         c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);
94         var d = this.internalDefaults;
95         if(c.events){
96             Ext.applyIf(c.initialConfig, d);
97             Ext.apply(c, d);
98         }else{
99             Ext.applyIf(c, d);
100         }
101         return c;
102     },
103
104     onAfterLayout : function(){
105         var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;
106         this.body.setWidth(bodyWidth);
107         this.el.setWidth(bodyWidth + this.getFrameWidth());
108     }
109     <div id="cfg-Ext.ButtonGroup-tools"></div>/**
110      * @cfg {Array} tools  @hide
111      */
112 });
113
114 Ext.reg('buttongroup', Ext.ButtonGroup);
115 </pre>    
116 </body>
117 </html>