/*
* 创建文本框
* _id:文本框编号
* _text:文本框上的文字
* _x:文本框的x位置
* _y:文本框的y位置
* _width:文本框的宽度
* _height:文本框的高度
*/
function Text(_id,_text,_x,_y,_width,_height)
{
this.id = _id;
this.text = _text;
this.x = typeof(_x)!="undefined"?_x:0;
this.y = typeof(_y)!="undefined"?_y:0;
this.width = typeof(_width)!="undefined"?_width:20;
this.height = typeof(_height)!="undefined"?_height:50;
this.parent = null;
var TT = document.createElement("input");
TT.setAttribute("type","text");
TT.setAttribute("value",_text);
TT.style.width = this.width "px";
TT.style.height = this.height "px";
TT.style.position = "absolute";
TT.style.left = this.x "px";
TT.style.top = this.y "px";
/*
* 添加到父对象
* _parent:父对象名字
*/
this.addToParent = function(_parent)
{
if(typeof(_parent)!="undefined")
{
this.parent = _parent;
}
else
{
this.parent = document.body;
}
this.parent.appendChild(TT);
}
/*
* 设置背景颜色
* _color:要设置的颜色
*/
this.setBackgroundColor = function(_color)
{
if(typeof(_color)=="undefined")return;
TT.style.backgroundColor = _color;
}
/*
* 设置文本框的文字大小
* size:要设置的文字大小
*/
this.setFontSize = function(size)
{
TT.style.fontSize = size "px";
}
/*
* 设置字体颜色
* _color:要设置的颜色
*/
this.setFontColor=function (_color)
{
TT.style.color=_color;
}
/*
* 设置背景图片
* _url:要设置的图片的路径
*/
this.setBackgroundImage = function(_url)
{
TT.style.backgroundImage = "url(" _url ")";
}
/*
* 设置显示内容
* _text:要显示的内容
*/
this.setText = function(__text)
{
this.text = __text;
TT.setAttribute("value",__text);
}
}