}
@Override
public void draw(PU_Rect drawArea)
{
PU_Rect realRect = new PU_Rect(getRect().x + drawArea.x, getRect().y + drawArea.y, getRect().width, getRect().height);
PU_Rect inRect = drawArea.intersection(realRect);
if(mBackgroundColor != null)
{
PUWeb.engine().setColor(mBackgroundColor.getColor().r, mBackgroundColor.getColor().g, mBackgroundColor.getColor().b, mBackgroundColor.getColor().a);
PUWeb.engine().renderFillRect(inRect.x, inRect.y, inRect.width, inRect.height);
}
if(mBorderColor != null)
{
PUWeb.engine().setColor(mBorderColor.getColor().r, mBorderColor.getColor().g, mBorderColor.getColor().b, mBorderColor.getColor().a);
PUWeb.engine().renderRect(inRect.x, inRect.y, inRect.width, inRect.height);
}
if(mImage.getImage() != null)
{
mImage.getImage().drawRectInRect(getRect(), drawArea);
}
PU_Font font = getFont();
int caretX = 0;
int textX = getRect().x + font.getStringWidth(" ");
int textY = getRect().y + ((getRect().height/2)-(font.getLineHeight()/2));
if(!mText.equals(""))
{
String drawText = "";
if(mPassword)
{
for(int i = 0; i < mText.length(); i++)
{
drawText += "*";
}
}
else
{
drawText = mText;
}
font.setColor(getFontColor().r, getFontColor().g, getFontColor().b);
font.drawTextInRect(drawText, drawArea.x + textX, drawArea.y + textY, inRect);
caretX = font.getStringWidth(drawText);
}
//draw caret
if(mCaret && !mReadOnly && hasFocus())
{
caretX += textX;
if(inRect.contains(drawArea.x+caretX, drawArea.y+textY))
{
PUWeb.engine().setColor(getFontColor().r, getFontColor().g, getFontColor().b, 255);
PUWeb.engine().renderLine(drawArea.x+caretX, drawArea.y+textY, drawArea.x+caretX, drawArea.y+textY+font.getLineHeight());
}
}