component provides Button(AdaptEvents) requires io.Output out, data.IntUtil iu, Font, os.SystemInfo sysInfo {
Font labelFont
Button:Button(char myLabel[])
{
text = myLabel
labelFont = new Font(sysInfo.getSystemFont(false), 15)
}
void AdaptEvents:active()
{
labelFont = new Font(sysInfo.getSystemFont(false), 15)
postRepaint()
}
void Button:setPosition(int x, int y)
{
xPosition = x
yPosition = y
}
void Button:paint(Canvas c)
{
c.rect(new Rect2D(xPosition+1, yPosition+1, 40, 20, new Color(150, 140, 140, 255)))
c.rect(new Rect2D(xPosition, yPosition, 40, 20, new Color(220, 188, 157, 255)))
c.text(new Point2D(xPosition+3, yPosition+1, new Color(0, 0, 0, 255)), labelFont, text)
}
void Button:click(int x, int y, int button)
{
if (button == MouseButtons.BUTTON_LEFT)
{
emitevent click()
}
}
void Button:postRepaint()
{
emitevent repaint()
}
void Button:setFocus()
{
emitevent requestFocus()
}
void Button:setDisabled(bool d)
{
disabled = d
postRepaint()
}
void Button:setText(char t[])
{
text = t
}
char[] Button:getText()
{
return text
}
Rect Button:getBounds()
{
return new Rect(xPosition, yPosition, 40, 20)
}
WH Button:getPreferredSize()
{
return new WH(40, 20)
}
Point Button:getPosition()
{
return new Point(xPosition, yPosition)
}
bool Button:equals(Object o)
{
Button bq = o
return text == bq.getText()
}
}