/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

  1. app_win=nil
  2. function OnQuit(button)
  3. Ftk.Quit()
  4. return RET_OK
  5. end
  6. function OnTimer(data)
  7. percent=0
  8. for i=1,3 do
  9. progress_bar=app_win:Lookup(i);
  10. percent = progress_bar:GetPercent()
  11. progress_bar:SetPercent(percent + 10)
  12. end
  13. print("percent:" .. percent)
  14. if percent >= 100 then
  15. return RET_REMOVE
  16. end
  17. return RET_OK;
  18. end
  19. function AppInit()
  20. win=FtkAppWindow.Create()
  21. app_win=win
  22. win:SetText("Demo progressbar")
  23. win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
  24. width=win:Width()
  25. height=win:Height()
  26. progress_bar=FtkProgressBar.Create(win, 10, height/6, width-20, 20)
  27. progress_bar:SetId(1)
  28. progress_bar:SetPercent(20)
  29. progress_bar=FtkProgressBar.Create(win, 10, height/3, width-20, 20)
  30. progress_bar:SetId(2)
  31. progress_bar:SetPercent(20)
  32. progress_bar=FtkProgressBar.Create(win, 10, height/2, width-20, 20)
  33. progress_bar:SetId(3)
  34. progress_bar:SetPercent(20)
  35. button=FtkButton.Create(win, width/4, 3*height/4, width/2, 60)
  36. button:SetText("Quit")
  37. button:SetClickedListener("OnQuit")
  38. timer=FtkSourceTimer.Create(1000, "OnTimer")
  39. Ftk.DefaultMainLoop():AddSource(timer)
  40. win:ShowAll(1)
  41. return 1
  42. end
  43. Ftk.Init(1, {"progressbar"})
  44. AppInit()
  45. Ftk.Run()