X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..6746dc89c47ed01b165cc1152533605f97eb8e8d:/docs/source/TextMetrics.html diff --git a/docs/source/TextMetrics.html b/docs/source/TextMetrics.html index 21d9b316..93acaae3 100644 --- a/docs/source/TextMetrics.html +++ b/docs/source/TextMetrics.html @@ -1,29 +1,43 @@ -
+ +/** - * @class Ext.util.TextMetrics - * <p> - * Provides precise pixel measurements for blocks of text so that you can determine exactly how high and + + + + +\ No newline at end of file +The source code + + + + + + +/** + * 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: { shared: null, - /** + /** * Measures the size of the specified text * @param {String/HTMLElement} el The element, dom node or id from which to copy existing CSS styles * that can affect the size of the rendered text * @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, @@ -37,7 +51,7 @@ Ext.define('Ext.util.TextMetrics', { return shared.getSize(text); }, - /** + /** * Destroy the TextMetrics instance created by {@link #measure}. */ destroy: function(){ @@ -47,10 +61,10 @@ Ext.define('Ext.util.TextMetrics', { } }, - /** - * @constructor + /** + * Creates new TextMetrics. * @param {Mixed} bindTo The element to bind to. - * @param {Number} fixedWidth A fixed width to apply to the measuring element. + * @param {Number} fixedWidth (optional) A fixed width to apply to the measuring element. */ constructor: function(bindTo, fixedWidth){ var measure = this.measure = Ext.getBody().createChild({ @@ -67,11 +81,10 @@ 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 + /** + * 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, @@ -83,7 +96,7 @@ Ext.define('Ext.util.TextMetrics', { return size; }, - /** + /** * Binds this TextMetrics instance to a new element * @param {Mixed} el The element */ @@ -96,7 +109,7 @@ Ext.define('Ext.util.TextMetrics', { ); }, - /** + /** * Sets a fixed width on the internal measurement element. If the text will be multiline, you have * to set a fixed width in order to accurately measure the text height. * @param {Number} width The width to set on the element @@ -105,7 +118,7 @@ Ext.define('Ext.util.TextMetrics', { this.measure.setWidth(width); }, - /** + /** * Returns the measured width of the specified text * @param {String} text The text to measure * @return {Number} width The width in pixels @@ -115,7 +128,7 @@ Ext.define('Ext.util.TextMetrics', { return this.getSize(text).width; }, - /** + /** * Returns the measured height of the specified text * @param {String} text The text to measure * @return {Number} height The height in pixels @@ -124,7 +137,7 @@ Ext.define('Ext.util.TextMetrics', { return this.getSize(text).height; }, - /** + /** * Destroy this instance */ destroy: function(){ @@ -135,17 +148,19 @@ Ext.define('Ext.util.TextMetrics', { } }, function(){ Ext.core.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.core.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); } }); }); -