Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / TextItem.html
index 9205e15..09e5561 100644 (file)
@@ -1,58 +1,60 @@
-<html>
-<head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
-  <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
-<div id="cls-Ext.menu.TextItem"></div>/**
- * @class Ext.menu.TextItem
- * @extends Ext.menu.BaseItem
- * Adds a static text string to a menu, usually used as either a heading or group separator.
+<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-toolbar.TextItem-method-constructor'><span id='Ext-toolbar.TextItem'>/**
+</span></span> * @class Ext.toolbar.TextItem
+ * @extends Ext.toolbar.Item
+ *
+ * A simple class that renders text directly into a toolbar.
+ *
+ * ## Example usage
+ *
+ * {@img Ext.toolbar.TextItem/Ext.toolbar.TextItem.png TextItem component}
+ *
+ *      Ext.create('Ext.panel.Panel', {
+ *          title: 'Panel with TextItem',
+ *          width: 300,
+ *          height: 200,
+ *          tbar: [
+ *              {xtype: 'tbtext', text: 'Sample TextItem'}
+ *          ],
+ *          renderTo: Ext.getBody()
+ *      });
+ *
  * @constructor
  * Creates a new TextItem
- * @param {Object/String} config If config is a string, it is used as the text to display, otherwise it
- * is applied as a config object (and should contain a <tt>text</tt> property).
- * @xtype menutextitem
+ * @param {Object} text A text string, or a config object containing a &lt;tt&gt;text&lt;/tt&gt; property
+ * @xtype tbtext
  */
-Ext.menu.TextItem = Ext.extend(Ext.menu.BaseItem, {
-    <div id="cfg-Ext.menu.TextItem-text"></div>/**
-     * @cfg {String} text The text to display for this item (defaults to '')
-     */
-    <div id="cfg-Ext.menu.TextItem-hideOnClick"></div>/**
-     * @cfg {Boolean} hideOnClick True to hide the containing menu after this item is clicked (defaults to false)
-     */
-    hideOnClick : false,
-    <div id="cfg-Ext.menu.TextItem-itemCls"></div>/**
-     * @cfg {String} itemCls The default CSS class to use for text items (defaults to "x-menu-text")
+Ext.define('Ext.toolbar.TextItem', {
+    extend: 'Ext.toolbar.Item',
+    requires: ['Ext.XTemplate'],
+    alias: 'widget.tbtext',
+    alternateClassName: 'Ext.Toolbar.TextItem',
+    
+<span id='Ext-toolbar.TextItem-cfg-text'>    /**
+</span>     * @cfg {String} text The text to be used as innerHTML (html tags are accepted)
      */
-    itemCls : "x-menu-text",
+    text: '',
     
-    constructor : function(config) {
-        if (typeof config == 'string') {
-            config = {
-                text: config
-            };
-        }
-        Ext.menu.TextItem.superclass.constructor.call(this, config);
+    renderTpl: '{text}',
+    //
+    baseCls: Ext.baseCSSPrefix + 'toolbar-text',
+    
+    onRender : function() {
+        Ext.apply(this.renderData, {
+            text: this.text
+        });
+        this.callParent(arguments);
     },
 
-    // private
-    onRender : function() {
-        var s = document.createElement("span");
-        s.className = this.itemCls;
-        s.innerHTML = this.text;
-        this.el = s;
-        Ext.menu.TextItem.superclass.onRender.apply(this, arguments);
+<span id='Ext-toolbar.TextItem-method-setText'>    /**
+</span>     * Updates this item's text, setting the text to be used as innerHTML.
+     * @param {String} t The text to display (html accepted).
+     */
+    setText : function(t) {
+        if (this.rendered) {
+            this.el.update(t);
+            this.ownerCt.doLayout(); // In case an empty text item (centered at zero height) receives new text.
+        } else {
+            this.text = t;
+        }
     }
-});
-Ext.reg('menutextitem', Ext.menu.TextItem);</pre>    
-</body>
-</html>
\ No newline at end of file
+});</pre></pre></body></html>
\ No newline at end of file