public void Create(RichTextField owner, HtmlElement element)
{
_owner = owner;
_element = element;
string type = element.GetString("type");
if (type != null)
{
type = type.ToLower();
}
_hidden = type == "hidden";
if (!_hidden)
{
int width = element.GetInt("width", 0);
int height = element.GetInt("height", 0);
int borderSize = element.GetInt("border", defaultBorderSize);
Color borderColor = element.GetColor("border-color", defaultBorderColor);
Color backgroundColor = element.GetColor("background-color", defaultBackgroundColor);
if (width == 0)
{
width = element.space;
if (width > _owner.width / 2 || width < 100)
{
width = (int)_owner.width / 2;
}
}
if (height == 0)
{
height = element.format.size + 10;
}
textInput.textFormat = element.format;
textInput.displayAsPassword = type == "password";
textInput.maxLength = element.GetInt("maxlength", int.MaxValue);
textInput.border = borderSize;
textInput.borderColor = borderColor;
textInput.backgroundColor = backgroundColor;
textInput.SetSize(width, height);
}
textInput.text = element.GetString("value");
}