RosettaCodeData/Task/Animation/Phix/animation.phix

34 lines
819 B
Text
Raw Permalink Normal View History

2018-08-17 15:15:24 +01:00
--
-- demo\rosetta\Animation.exw
--
include pGUI.e
2016-12-05 23:44:36 +01:00
string hw = "Hello World! "
2018-08-17 15:15:24 +01:00
bool direction = true
Ihandle label
2016-12-05 23:44:36 +01:00
2018-08-17 15:15:24 +01:00
function timer_cb(Ihandle /*ih*/)
hw = iff(direction?hw[$]&hw[1..-2]:hw[2..$]&hw[1])
IupSetAttribute(label,"TITLE",hw)
return IUP_IGNORE
end function
2016-12-05 23:44:36 +01:00
2018-08-17 15:15:24 +01:00
function key_cb(Ihandle /*ih*/, atom c)
if c=K_ESC then return IUP_CLOSE end if
if c=K_UP then direction = not direction end if
return IUP_CONTINUE
2016-12-05 23:44:36 +01:00
end function
2018-08-17 15:15:24 +01:00
procedure main()
IupOpen()
label = IupLabel(hw,"FONT=\"Verdana, 18\"")
Ihandle dlg = IupDialog(label,"TITLE=Animation, DIALOGFRAME=YES, CHILDOFFSET=70x40, SIZE=200x80")
IupSetCallback(dlg, "K_ANY", Icallback("key_cb"))
IupShow(dlg)
Ihandle hTimer = IupTimer(Icallback("timer_cb"), 160)
IupMainLoop()
IupClose()
end procedure
main()