metaProperty属性的使用

By admin at 2017-12-26 • 0人收藏 • 1455人看过
//先导入
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);
		}
	}
);


登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...