metaProperty属性的使用
By
admin
at 2017-12-26 • 0人收藏 • 1550人看过
//先导入
import util.metaProperty;
// 画笔
pen = class {
ctor (...) {
this = ..win.graphics.object();
this.init = function (style = 0x0/*_PS_SOLID*/, width = 1, color = 0) {
this.destroy();
if (type(style) != type.number)
error("(1) style 参数错误", 2);
if (type(width) != type.number)
error("(2) width 参数错误", 2);
if (type(color) != type.number)
error("(3) color 参数错误", 2);
this.handle = ::CreatePen(style, width, color);
// 记录属性
this.nStyle = style;
this.nWidth = width;
this.nColor = color;
if (this.canvasHandle)
::SelectObject(this.canvasHandle, this.handle);
}
this.init(...);
}
@_metaProperty;
}
pen._metaProperty = ..util.metaProperty(
style = {
_get = function () {
return owner.nStyle;
}
_set = function (v) {
owner.init(v, owner.width, owner.color);
}
}
width = {
_get = function () {
return owner.nWidth;
}
_set = function (v) {
owner.init(owner.style, v, owner.color);
}
}
color = {
_get = function () {
return owner.nColor;
}
_set = function (v) {
owner.init(owner.style, owner.width, v);
}
}
);登录后方可回帖