PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/script_binding/lua/demo_scrollbar.lua

http://ftk.googlecode.com/
Lua | 68 lines | 49 code | 18 blank | 1 comment | 0 complexity | 30d98305fa85d2dd2f505843c68b7d4c MD5 | raw file
 1function OnQuit(button)
 2	print("OnQuit: " .. button:GetText())
 3	Ftk.Quit()
 4
 5	return RET_OK
 6end
 7
 8function OnScroll(scrollbar)
 9	print("current value: " .. scrollbar:GetValue())
10	return RET_OK
11end
12
13function AppInit()
14	win=FtkAppWindow.Create()
15	win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
16	win:SetText("Demo scrollbar")
17
18	width=win:Width()
19	height=win:Height()
20
21	scroll_bar=FtkScrollBar.Create(win, width/8, 5, 0, height/2)
22	scroll_bar:SetParam(0, 120, 120)
23	scroll_bar:SetListener("OnScroll")
24	
25	scroll_bar=FtkScrollBar.Create(win, width/4, 5, 0, height/2)
26	scroll_bar:SetParam(40, 120, 60)
27	scroll_bar:SetListener("OnScroll")
28	
29	scroll_bar=FtkScrollBar.Create(win, 3*width/8, 5, 0, height/2)
30	scroll_bar:SetParam(110, 120, 30)
31	scroll_bar:SetListener("OnScroll")
32	
33	scroll_bar=FtkScrollBar.Create(win, width/2, 5, 0, height/2)
34	scroll_bar:SetParam(120, 120, 20)
35	scroll_bar:SetListener("OnScroll")
36	
37	-- h
38
39	scroll_bar=FtkScrollBar.Create(win, 5, height/2 + 10, width - 10, 0)
40	scroll_bar:SetParam(0, 120, 120)
41	scroll_bar:SetListener("OnScroll")
42	
43	scroll_bar=FtkScrollBar.Create(win, 5, height/2 + 30, width - 10, 0)
44	scroll_bar:SetParam(40, 120, 60)
45	scroll_bar:SetListener("OnScroll")
46	
47	scroll_bar=FtkScrollBar.Create(win, 5, height/2 + 50, width - 10, 0)
48	scroll_bar:SetParam(110, 120, 30)
49	scroll_bar:SetListener("OnScroll")
50	
51	scroll_bar=FtkScrollBar.Create(win, 5, height/2 + 80, width - 10, 0)
52	scroll_bar:SetParam(120, 120, 20)
53	scroll_bar:SetListener("OnScroll")
54
55	button=FtkButton.Create(win, 2*width/3, height/4, width/3-5, 50)
56	button:SetText("Quit")
57	button:SetClickedListener("OnQuit")
58
59	win:SetFocus(button)
60	win:ShowAll(1)
61
62	return 1
63end
64
65Ftk.Init(1, {"scroll_bar"})
66AppInit()
67Ftk.Run()
68