API Docs for: 最后更新日期:2014年8月25日
Google搜索   
Show:

File: lib/ui/LCheckBox-0.1.0.js

/** @language japanese
 * lufylegend.jsの専用のUI、チェックボックス
 * @class UI:LCheckBox
 * @constructor
 * @since 0.1.0
 * @examplelink <p><a href="../../../api/ui/LCheckBox.html" target="_blank">実際のサンプルを見る</a></p>
 * @public
 */
var LCheckBox = (function () {
	function LCheckBox (layer, layerSelect) {
		var s = this, grd;
		LExtends(s, LSprite, []);
		s.type = "LCheckBox";
		if (!layer) {
			grd = LGlobal.canvas.createLinearGradient(0, -20, 0, 40);
			grd.addColorStop(0, "#FFFFFF");
			grd.addColorStop(1, "#CCCCCC");
			layer = new LSprite();
			layer.graphics.drawRoundRect(1, "#CCCCCC", [0, 0, 20, 20, 4], true, grd);
		} else {
			layer = layer.clone();
		}
		if (!layerSelect) {
			grd = LGlobal.canvas.createLinearGradient(0, -20, 0, 20);
			grd.addColorStop(0, "#FFFFFF");
			grd.addColorStop(1, "#008000");
			layerSelect = new LSprite();
			layerSelect.graphics.drawLine(5, grd, [4, 10, 12, 16]);
			layerSelect.graphics.drawLine(5, grd, [10, 16, 16, 4]);
		} else {
			layerSelect = layerSelect.clone();
		}
		s.layer = layer;
		s.layerSelect = layerSelect;
		s.addChild(s.layer);
		s.addChild(s.layerSelect);
		/** @language japanese
		 * ボタンの選択する状態
		 * @property checked
		 * @type Boolean
		 * @since 0.1.0
		 * @public
		 */
		s.layerSelect.visible = s.checked = false;
		s.addEventListener(LMouseEvent.MOUSE_UP, s._onChange);
	}
	LCheckBox.prototype._onChange = function (e) {
		var s = e.clickTarget;
		s.checked = !s.checked;
		s.layerSelect.visible = s.checked;
	};
	/** @language japanese
	 * ボタンの選択状態を設定する。
	 * @method setChecked
	 * @param {String} value ボタンの選択状態。
	 * @since 0.1.0
	 * @public
	 */
	LCheckBox.prototype.setChecked = function (value) {
		var s = this;
		s.checked = value;
		s.layerSelect.visible = s.checked;
	};
	LCheckBox.prototype.clone = function () {
		var s = this, a = new LCheckBox(s.layer.clone(), s.layerSelect.clone());
		a.setChecked(s.checked);
		return a;
	};
	return LCheckBox;
})();