PageRenderTime 303ms CodeModel.GetById 141ms app.highlight 3ms RepoModel.GetById 158ms app.codeStats 0ms

/script_binding/lua/demo_combo_box.lua

http://ftk.googlecode.com/
Lua | 59 lines | 46 code | 13 blank | 0 comment | 2 complexity | 8b14403732a74b4dfddcc429e0ca0aa6 MD5 | raw file
 1function OnQuit(button)
 2	for i=1, 4 do
 3		combo_box=button:Toplevel():Lookup(i)
 4		print(tostring(i) .. ":" .. combo_box:GetText())
 5	end
 6	Ftk.Quit()
 7
 8	return RET_OK
 9end
10
11function ComboBoxInit(combo_box, n)
12	for i=1,n do
13		combo_box:Append(nil, i .. " seconds");
14	end
15end
16
17function AppInit()
18	win=FtkAppWindow.Create()
19	win:SetText("Demo combobox")
20	win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
21
22	width=win:Width()
23	height=win:Height()
24
25	width = width/2 - 10;
26	combo_box=FtkComboBox.Create(win, 0, height/4, width, 50)
27	combo_box:SetId(1)
28	combo_box:SetText("1 second")
29	ComboBoxInit(combo_box, 10)
30
31	combo_box=FtkComboBox.Create(win, width + 10, height/4, width, 50);
32	combo_box:SetId(2)
33	combo_box:SetText("2 second")
34	ComboBoxInit(combo_box, 3)
35
36	button=FtkButton.Create(win, width/2, height/2, width, 60);
37	button:SetText("Quit")
38	button:SetClickedListener("OnQuit")
39
40	combo_box=FtkComboBox.Create(win, 0, 3*height/4+5, width, 50)
41	combo_box:SetId(3)
42	combo_box:SetText("3 second")
43	ComboBoxInit(combo_box, 3)
44
45	combo_box=FtkComboBox.Create(win, width + 10, 3*height/4+5, width, 50);
46	combo_box:SetId(4)
47	combo_box:SetText("4 second")
48	ComboBoxInit(combo_box, 30)
49
50	win:SetFocus(button)
51	win:ShowAll(1)
52
53	return 1
54end
55
56Ftk.Init(1, {"combobox"})
57AppInit()
58Ftk.Run()
59