/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

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