/script_binding/lua/demo_check_button.lua

http://ftk.googlecode.com/ · Lua · 63 lines · 48 code · 15 blank · 0 comment · 0 complexity · 40858e2cd05ab89e0f13e763fd7adde1 MD5 · raw file

  1. function OnQuit(button)
  2. Ftk.Quit()
  3. return RET_OK
  4. end
  5. function OnClicked(button)
  6. print("OnClicked")
  7. return RET_OK
  8. end
  9. function AppInit()
  10. win=FtkAppWindow.Create()
  11. win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
  12. win:SetText("Demo check button")
  13. width=win:Width()
  14. height=win:Height()
  15. width = width/2 - 10;
  16. button=FtkCheckButton.Create(win, 0, 10, width, 50)
  17. button:SetText("show")
  18. button:SetClickedListener("OnClicked")
  19. button=FtkCheckButton.Create(win, width + 10, 10, width, 50)
  20. button:SetText("hide")
  21. button:SetClickedListener("OnClicked")
  22. group=FtkGroupBox.Create(win, 0, 60, 2 * width, 60)
  23. button=FtkCheckButton.CreateRadio(group, 0, 10, width, 50);
  24. button:SetText("Male")
  25. button:SetClickedListener("OnClicked")
  26. button=FtkCheckButton.CreateRadio(group, width + 10, 10, width, 50)
  27. button:SetText("Female")
  28. button:SetClickedListener("OnClicked")
  29. group=FtkGroupBox.Create(win, 0, 120, 2 * width, 60)
  30. button=FtkCheckButton.CreateRadio(group,0, 10, width, 50)
  31. button:SetText("1(???)")
  32. button:SetIconPosition(1)
  33. button:SetClickedListener("OnClicked")
  34. button=FtkCheckButton.CreateRadio(group, width + 10, 10, width, 50)
  35. button:SetText("2(???)")
  36. button:SetIconPosition(1)
  37. button:SetClickedListener("OnClicked")
  38. button=FtkButton.Create(win, width/2, 3*height/4, width, 60)
  39. button:SetText("Quit")
  40. button:SetClickedListener("OnQuit")
  41. win:SetText("check button demo")
  42. win:SetFocus(button)
  43. win:ShowAll(1)
  44. return 1
  45. end
  46. Ftk.Init(1, {"checkbutton"})
  47. AppInit()
  48. Ftk.Run()