Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / util / TextMetrics.js
index e0c5967..f0e3bc5 100644 (file)
@@ -1,17 +1,28 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+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.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
- * @class Ext.util.TextMetrics
- * <p>
  * Provides precise pixel measurements for blocks of text so that you can determine exactly how high and
  * wide, in pixels, a given block of text will be. Note that when measuring text, it should be plain text and
- * should not contain any HTML, otherwise it may not be measured correctly.</p> 
- * <p>The measurement works by copying the relevant CSS styles that can affect the font related display, 
+ * should not contain any HTML, otherwise it may not be measured correctly.
+ *
+ * The measurement works by copying the relevant CSS styles that can affect the font related display, 
  * then checking the size of an element that is auto-sized. Note that if the text is multi-lined, you must 
- * provide a <b>fixed width</b> when doing the measurement.</p>
- * 
- * <p>
+ * provide a **fixed width** when doing the measurement.
+ *
  * If multiple measurements are being done on the same element, you create a new instance to initialize 
  * to avoid the overhead of copying the styles to the element repeatedly.
- * </p>
  */
 Ext.define('Ext.util.TextMetrics', {
     statics: {
@@ -23,7 +34,7 @@ Ext.define('Ext.util.TextMetrics', {
          * @param {String} text The text to measure
          * @param {Number} fixedWidth (optional) If the text will be multiline, you have to set a fixed width
          * in order to accurately measure the text height
-         * @return {Object} An object containing the text's size {width: (width), height: (height)}
+         * @return {Object} An object containing the text's size `{width: (width), height: (height)}`
          */
         measure: function(el, text, fixedWidth){
             var me = this,
@@ -48,9 +59,9 @@ Ext.define('Ext.util.TextMetrics', {
     },
     
     /**
-     * @constructor
-     * @param {Mixed} bindTo The element to bind to.
-     * @param {Number} fixedWidth A fixed width to apply to the measuring element.
+     * Creates new TextMetrics.
+     * @param {String/HTMLElement/Ext.Element} bindTo The element or its ID to bind to.
+     * @param {Number} fixedWidth (optional) A fixed width to apply to the measuring element.
      */
     constructor: function(bindTo, fixedWidth){
         var measure = this.measure = Ext.getBody().createChild({
@@ -68,10 +79,9 @@ Ext.define('Ext.util.TextMetrics', {
     },
     
     /**
-     * <p><b>Only available on the instance returned from {@link #createInstance}, <u>not</u> on the singleton.</b></p>
      * Returns the size of the specified text based on the internal element's style and width properties
      * @param {String} text The text to measure
-     * @return {Object} An object containing the text's size {width: (width), height: (height)}
+     * @return {Object} An object containing the text's size `{width: (width), height: (height)}`
      */
     getSize: function(text){
         var measure = this.measure,
@@ -85,7 +95,7 @@ Ext.define('Ext.util.TextMetrics', {
     
     /**
      * Binds this TextMetrics instance to a new element
-     * @param {Mixed} el The element
+     * @param {String/HTMLElement/Ext.Element} el The element or its ID.
      */
     bind: function(el){
         var me = this;
@@ -134,17 +144,18 @@ Ext.define('Ext.util.TextMetrics', {
          delete me.measure;
      }
 }, function(){
-    Ext.core.Element.addMethods({
+    Ext.Element.addMethods({
         /**
          * Returns the width in pixels of the passed text, or the width of the text in this Element.
          * @param {String} text The text to measure. Defaults to the innerHTML of the element.
-         * @param {Number} min (Optional) The minumum value to return.
-         * @param {Number} max (Optional) The maximum value to return.
+         * @param {Number} min (optional) The minumum value to return.
+         * @param {Number} max (optional) The maximum value to return.
          * @return {Number} The text width in pixels.
-         * @member Ext.core.Element getTextWidth
+         * @member Ext.Element
          */
         getTextWidth : function(text, min, max){
             return Ext.Number.constrain(Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width, min || 0, max || 1000000);
         }
     });
 });
+