PageRenderTime 304ms CodeModel.GetById 161ms app.highlight 3ms RepoModel.GetById 139ms app.codeStats 0ms

/script_binding/lua/demo_label.lua

http://ftk.googlecode.com/
Lua | 61 lines | 45 code | 16 blank | 0 comment | 1 complexity | d4b4d745766e654e0c7ad189eadd52bc MD5 | raw file
 1times=4
 2app_win=nil
 3
 4function OnTimer()
 5	label = app_win:Lookup(100)	
 6	label:SetText("Quit after " .. times .. " seconds.")
 7	times=times-1
 8
 9	if times > 0 then 
10		return RET_OK 
11	else
12		Ftk.Quit()		
13		return RET_REMOVE
14	end
15end
16
17function AppInit()
18	win=FtkAppWindow.Create()
19	app_win=win
20	win:SetText("Demo Label")
21	win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
22
23	width=win:Width()
24	height=win:Height()
25
26	label=FtkLabel.Create(win, 10, 10, width - 20, 20)
27	label:SetText("????");
28
29	label=FtkLabel.Create(win, 10, 40, width - 20, 20)
30	label:SetText("English Text");
31
32	label=FtkLabel.Create(win, 50, height/2-30, width, 20)
33	label:SetText("Quit after 5 seconds.")
34	label:SetId(100)
35
36	label=FtkLabel.Create(win, 5, height/2, width-10, height/2-20)
37
38	gc=FtkGc.Create()
39	gc.mask=FTK_GC_BG
40	gc.bg.a = 0xff;
41	gc.bg.r = 0xF0;
42	gc.bg.g = 0xF0;
43	gc.bg.b = 0x80;
44	label:SetGc(FTK_WIDGET_INSENSITIVE, gc)
45	label:UnsetAttr(FTK_ATTR_TRANSPARENT)
46
47	label:SetText("????????????????????FTK??????????????????????????")
48
49	timer=FtkSourceTimer.Create(1000, "OnTimer")
50	Ftk.DefaultMainLoop():AddSource(timer)
51
52	win:ShowAll(1)
53
54	return RET_OK;
55end
56
57Ftk.Init(1, {"label"})
58AppInit()
59Ftk.Run()
60
61