import("gui")
class SampleDialog
{
inject(System.GUI)
method create_label ()
{
{Attribute.FONT : {"typeface":"Verdana","size":18}}^attr
Label.new("Sample Label", attr)
}
method create_label_image ()
{
image = Image.load_image("c:\\nexus\\samples\\images\\price.jpg")
attr = {Attribute.IMAGE : image}
Label.new("", attr)
}
method button1_action (button)
{
print("Button1 Action")
}
method create_button1 ()
{
button = Button.new("Button1")
image = Image.load_image("c:\\nexus\\samples\\images\\screen.png")
button.set_image(image)
button.set_fgcolor({"red":255, "green":100, "blue":200})
button.set_font({"typeface":"Verdana","bold":true,"size":20})
handler = EventHandler.new(get_method("button1_action"), self)
button.set_event(Event.ACTION, handler)
button
}
method button2_action (button)
{
print("Button2 Action")
}
method create_button2 ()
{
button = Button.new("Button2")
button.set_fgcolor({"red":255, "green":100, "blue":20})
handler = EventHandler.new(get_method("button2_action"), self)
button.set_event(Event.ACTION, handler)
button
}
method create_child ()
{
VBox.new({HBox.new({create_label(), create_button1(), create_button2()}),
Fill.new(),
create_label_image()})
}
public method show ()
{
@dialog.show()
System.GUI.main_loop()
}
method initialize ()
{
field @dialog
attr =
{Attribute.TITLE : "Sample Dialog",
Attribute.SIZE : {"width":300, "height":200},
Attribute.OPACITY : 255}
@dialog = Dialog.new(create_child(), attr)
@dialog.set_bgcolor({"red":255, "green":100, "blue":20})
}
}
method main ()
{
dialog = SampleDialog.new()
dialog.show()
}
main()