ht.ui.drawable.NinePatchImageDrawable(image, colorTint)

new NinePatchImageDrawable(image, colorTint)

NinePatchImageDrawable 类从 ht.ui.drawable.Drawable 继承,重写了 draw 方法来绘制九宫格图片,
九宫格图片格式遵循 Android 标准

Parameters:
Name Type Attributes Description
image string
colorTint string <optional>

Extends

Methods

addPropertyChangeListener(listener, scope, ahead) → {void}

增加属性事件变化监听函数

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

ahead boolean <optional>

是否将当前监听器插入到监听器列表开头

Returns:
void
Inherited From:

draw(x, y, width, height, data, view, dom) → {void}

绘制内容

Parameters:
Name Type Attributes Description
x number

绘制范围的 x 坐标

y number

绘制范围的 y 坐标

width number

绘制范围的宽度

height number

绘制范围的高度

data ht.Data <optional>

绘制相关的 Data 对象,如绘制树组件中节点的 icon 时,可以用此参数判断出当前在绘制哪个节点

view ht.ui.View

当前在绘制的组件

dom HTMLElement <optional>

当前在绘制的 dom 对象,绝大多数组件无需考虑这个参数(因为只有一个绘制 canvas),特殊的是右键菜单,每个子菜单都是一个单独的 canvas,这种情况下才有这个参数

Returns:
void
Inherited From:
Example
// 下面这段代码绘制了一个矩形
function MyDrawable() {
	MyDrawable.superClass.constructor.call(this);
}
ht.Default.def(MyDrawable, ht.ui.drawable.Drawable, {
	draw: function(x, y, width, height, data, view, dom) {
		var g = view.getRootContext(dom);
		g.beginPath();
		g.rect(x, y, width, height);
		g.fillStyle = 'red';
		g.fill();
	}
});

firePropertyChange(property, oldValue, newValue, compareFunc) → {boolean}

派发属性变化事件

Parameters:
Name Type Attributes Description
property string

属性名

oldValue any

属性变化之前的值

newValue any

属性变化之后的值

compareFunc Object <optional>

比较函数,用于比较新值和旧值是否一致,如果一致则不会派发事件

Returns:
boolean -

事件是否派发成功

Inherited From:

fp(property, oldValue, newValue, compareFunc) → {boolean}

派发属性变化事件,firePropertyChange 的缩写

Parameters:
Name Type Attributes Description
property string

属性名

oldValue any

属性变化之前的值

newValue any

属性变化之后的值

compareFunc Object <optional>

比较函数,用于比较新值和旧值是否一致,如果一致则不会派发事件

Returns:
boolean -

事件是否派发成功

Inherited From:

getColorTint() → {string}

获取图片染色

Returns:
string -

图片染色

getImage() → {string}

获取要绘制的九宫格图片

Returns:
string -

要绘制的九宫格图片,可能是注册的图片名或图片路径

getSerializableProperties() → {object}

获取可序列化的属性

Returns:
object -

属性 map

Inherited From:

mp(listener, scope, ahead) → {void}

增加属性事件变化监听函数,addPropertyChangeListener 的缩写

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

ahead boolean <optional>

是否将当前监听器插入到监听器列表开头

Returns:
void
Inherited From:

removePropertyChangeListener(listener, scope) → {void}

删除属性事件变化监听器

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

Returns:
void
Inherited From:

setColorTint(color) → {void}

设置图片染色

Parameters:
Name Type Description
color string

颜色值

Returns:
void

setImage(image) → {void}

设置要绘制的九宫格图片

Parameters:
Name Type Description
image string

要绘制的九宫格图片,可以是注册的图片名或图片路径

Returns:
void

ump(listener, scope) → {void}

删除属性事件变化监听器,removePropertyChangeListener 的缩写

Parameters:
Name Type Attributes Description
listener Object

监听器函数

scope object <optional>

函数域

Returns:
void
Inherited From: