RosettaCodeData/Task/Animation/Icon/animation-1.icon

45 lines
979 B
Plaintext

import gui
$include "guih.icn"
class WindowApp : Dialog (label, direction)
method rotate_left (msg)
return msg[2:0] || msg[1]
end
method rotate_right (msg)
return msg[-1:0] || msg[1:-1]
end
method reverse_direction ()
direction := 1-direction
end
# this method gets called by the ticker, and updates the label
method tick ()
static msg := "Hello World! "
if direction = 0
then msg := rotate_left (msg)
else msg := rotate_right (msg)
label.set_label(msg)
end
method component_setup ()
direction := 1 # start off rotating to the right
label := Label("label=Hello World! ", "pos=0,0")
# respond to a mouse click on the label
label.connect (self, "reverse_direction", MOUSE_RELEASE_EVENT)
add (label)
connect (self, "dispose", CLOSE_BUTTON_EVENT)
# tick every 100ms
self.set_ticker (100)
end
end
# create and show the window
procedure main ()
w := WindowApp ()
w.show_modal ()
end