PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/script_binding/lua/demo_progressbar.lua

http://ftk.googlecode.com/
Lua | 62 lines | 45 code | 17 blank | 0 comment | 2 complexity | 9fb77d2f14b2b6d74e68cc24f2f04dc6 MD5 | raw file
 1app_win=nil
 2
 3function OnQuit(button)
 4	Ftk.Quit()
 5
 6	return RET_OK
 7end
 8
 9function OnTimer(data)
10	percent=0
11
12	for i=1,3 do
13		progress_bar=app_win:Lookup(i);
14		percent = progress_bar:GetPercent()
15		progress_bar:SetPercent(percent + 10)
16	end
17
18	print("percent:" .. percent)
19	if percent >= 100 then
20		return RET_REMOVE
21	end
22
23	return RET_OK;
24end
25
26function AppInit()
27	win=FtkAppWindow.Create()
28	app_win=win
29	win:SetText("Demo progressbar")
30	win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
31
32	width=win:Width()
33	height=win:Height()
34
35	progress_bar=FtkProgressBar.Create(win, 10, height/6, width-20, 20)
36	progress_bar:SetId(1)
37	progress_bar:SetPercent(20)
38	
39	progress_bar=FtkProgressBar.Create(win, 10, height/3, width-20, 20)
40	progress_bar:SetId(2)
41	progress_bar:SetPercent(20)
42	
43	progress_bar=FtkProgressBar.Create(win, 10, height/2, width-20, 20)
44	progress_bar:SetId(3)
45	progress_bar:SetPercent(20)
46
47	button=FtkButton.Create(win, width/4, 3*height/4, width/2, 60)
48	button:SetText("Quit")
49	button:SetClickedListener("OnQuit")
50
51	timer=FtkSourceTimer.Create(1000, "OnTimer")
52	Ftk.DefaultMainLoop():AddSource(timer)
53
54	win:ShowAll(1)
55
56	return 1
57end
58
59Ftk.Init(1, {"progressbar"})
60AppInit()
61Ftk.Run()
62