Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / source / util / TextMetrics.js
diff --git a/source/util/TextMetrics.js b/source/util/TextMetrics.js
deleted file mode 100644 (file)
index 9c73a6e..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/**\r
- * @class Ext.util.TextMetrics\r
- * Provides precise pixel measurements for blocks of text so that you can determine exactly how high and\r
- * wide, in pixels, a given block of text will be.\r
- * @singleton\r
- */\r
-Ext.util.TextMetrics = function(){\r
-    var shared;\r
-    return {\r
-        /**\r
-         * Measures the size of the specified text\r
-         * @param {String/HTMLElement} el The element, dom node or id from which to copy existing CSS styles\r
-         * that can affect the size of the rendered text\r
-         * @param {String} text The text to measure\r
-         * @param {Number} fixedWidth (optional) If the text will be multiline, you have to set a fixed width\r
-         * in order to accurately measure the text height\r
-         * @return {Object} An object containing the text's size {width: (width), height: (height)}\r
-         */\r
-        measure : function(el, text, fixedWidth){\r
-            if(!shared){\r
-                shared = Ext.util.TextMetrics.Instance(el, fixedWidth);\r
-            }\r
-            shared.bind(el);\r
-            shared.setFixedWidth(fixedWidth || 'auto');\r
-            return shared.getSize(text);\r
-        },\r
-\r
-        /**\r
-         * Return a unique TextMetrics instance that can be bound directly to an element and reused.  This reduces\r
-         * the overhead of multiple calls to initialize the style properties on each measurement.\r
-         * @param {String/HTMLElement} el The element, dom node or id that the instance will be bound to\r
-         * @param {Number} fixedWidth (optional) If the text will be multiline, you have to set a fixed width\r
-         * in order to accurately measure the text height\r
-         * @return {Ext.util.TextMetrics.Instance} instance The new instance\r
-         */\r
-        createInstance : function(el, fixedWidth){\r
-            return Ext.util.TextMetrics.Instance(el, fixedWidth);\r
-        }\r
-    };\r
-}();\r
-\r
-Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){\r
-    var ml = new Ext.Element(document.createElement('div'));\r
-    document.body.appendChild(ml.dom);\r
-    ml.position('absolute');\r
-    ml.setLeftTop(-1000, -1000);\r
-    ml.hide();\r
-\r
-    if(fixedWidth){\r
-        ml.setWidth(fixedWidth);\r
-    }\r
-\r
-    var instance = {\r
-        /**\r
-         * Returns the size of the specified text based on the internal element's style and width properties\r
-         * @param {String} text The text to measure\r
-         * @return {Object} An object containing the text's size {width: (width), height: (height)}\r
-         */\r
-        getSize : function(text){\r
-            ml.update(text);\r
-            var s = ml.getSize();\r
-            ml.update('');\r
-            return s;\r
-        },\r
-\r
-        /**\r
-         * Binds this TextMetrics instance to an element from which to copy existing CSS styles\r
-         * that can affect the size of the rendered text\r
-         * @param {String/HTMLElement} el The element, dom node or id\r
-         */\r
-        bind : function(el){\r
-            ml.setStyle(\r
-                Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')\r
-            );\r
-        },\r
-\r
-        /**\r
-         * Sets a fixed width on the internal measurement element.  If the text will be multiline, you have\r
-         * to set a fixed width in order to accurately measure the text height.\r
-         * @param {Number} width The width to set on the element\r
-         */\r
-        setFixedWidth : function(width){\r
-            ml.setWidth(width);\r
-        },\r
-\r
-        /**\r
-         * Returns the measured width of the specified text\r
-         * @param {String} text The text to measure\r
-         * @return {Number} width The width in pixels\r
-         */\r
-        getWidth : function(text){\r
-            ml.dom.style.width = 'auto';\r
-            return this.getSize(text).width;\r
-        },\r
-\r
-        /**\r
-         * Returns the measured height of the specified text.  For multiline text, be sure to call\r
-         * {@link #setFixedWidth} if necessary.\r
-         * @param {String} text The text to measure\r
-         * @return {Number} height The height in pixels\r
-         */\r
-        getHeight : function(text){\r
-            return this.getSize(text).height;\r
-        }\r
-    };\r
-\r
-    instance.bind(bindTo);\r
-\r
-    return instance;\r
-};\r
-\r
-// backwards compat\r
-Ext.Element.measureText = Ext.util.TextMetrics.measure;
\ No newline at end of file