Class Ext.util.TextMetrics
Package: | Ext.util |
Class: | TextMetrics |
Extends: | Object |
Defined In: | TextMetrics.js |
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.
This class is a singleton and cannot be created directly.
属性
-
方法
-
事件
公共属性
此类没有公共属性。
公共方法
|
bind(String/HTMLElement el ) : void |
TextMetrics |
Binds this TextMetrics instance to an element from which to copy existing CSS styles
that can affect the size of the ... |
|
createInstance(String/HTMLElement el , [Number fixedWidth ]) : Ext.util.TextMetrics.Instance |
TextMetrics |
Return a unique TextMetrics instance that can be bound directly to an element and reused. This reduces
the overhead ... |
|
getHeight(String text ) : Number |
TextMetrics |
Returns the measured height of the specified text. For multiline text, be sure to call
setFixedWidth if necessary. |
|
getSize(String text ) : Object |
TextMetrics |
Returns the size of the specified text based on the internal element's style and width properties |
|
getWidth(String text ) : Number |
TextMetrics |
Returns the measured width of the specified text |
|
measure(String/HTMLElement el , String text , [Number fixedWidth ]) : Object |
TextMetrics |
Measures the size of the specified text |
|
setFixedWidth(Number width ) : void |
TextMetrics |
Sets a fixed width on the internal measurement element. If the text will be multiline, you have
to set a fixed width... |
公共事件
此类没有公共事件。
方法详情
bind
public function bind(String/HTMLElement el
)
Binds this TextMetrics instance to an element from which to copy existing CSS styles
that can affect the size of the rendered text
This method is defined by TextMetrics.
createInstance
public function createInstance(String/HTMLElement el
, [Number fixedWidth
])
Return a unique TextMetrics instance that can be bound directly to an element and reused. This reduces
the overhead of multiple calls to initialize the style properties on each measurement.
参数:
el
: String/HTMLElementThe element, dom node or id that the instance will be bound to
fixedWidth
: Number(可选) If the text will be multiline, you have to set a fixed width in order to accurately measure the text height
返回:
This method is defined by TextMetrics.
getHeight
public function getHeight(String text
)
Returns the measured height of the specified text. For multiline text, be sure to call
setFixedWidth if necessary.
参数:
text
: StringThe text to measure
返回:
This method is defined by TextMetrics.
getSize
public function getSize(String text
)
Returns the size of the specified text based on the internal element's style and width properties
参数:
text
: StringThe text to measure
返回:
This method is defined by TextMetrics.
getWidth
public function getWidth(String text
)
Returns the measured width of the specified text
参数:
text
: StringThe text to measure
返回:
This method is defined by TextMetrics.
measure
public function measure(String/HTMLElement el
, String text
, [Number fixedWidth
])
Measures the size of the specified text
参数:
el
: String/HTMLElementThe element, dom node or id from which to copy existing CSS styles that can affect the size of the rendered text
text
: StringThe text to measure
fixedWidth
: Number(可选) If the text will be multiline, you have to set a fixed width in order to accurately measure the text height
返回:
This method is defined by TextMetrics.
setFixedWidth
public function setFixedWidth(Number width
)
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.
This method is defined by TextMetrics.