tabcontrol.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: tabcontrol.m
  4. Version: 1.0
  5. Type: maki
  6. Date: 30. Okt. 2007 - 17:40
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. -----------------------------------------------------
  12. ---------------------------------------------------*/
  13. #include <lib/std.mi>
  14. #include attribs/init_appearance.m
  15. Function updateTabPos();
  16. Function setAutoWidth(guiobject tab);
  17. Class Text WatchText;
  18. Global Boolean HAVE_ML = TRUE;
  19. Global GuiObject tabMl, tabVideo, tabVis, tabPl;
  20. Global WatchText txtMl, txtVideo, txtVis, txtPL;
  21. Global int startX, curX;
  22. Global Button btnMl, btnPl;
  23. System.onScriptLoaded ()
  24. {
  25. initAttribs_Appearance();
  26. HAVE_ML = stringToInteger(getParam());
  27. group sg = getScriptGroup();
  28. tabML = sg.findObject("switch.ml");
  29. btnMl = sg.findObject("switch.ml");
  30. txtMl = tabMl.findObject("bento.tabbutton.normal.text");
  31. tabPL = sg.findObject("switch.pl");
  32. btnPl = sg.findObject("switch.pl");
  33. txtPl = tabPl.findObject("bento.tabbutton.normal.text");
  34. tabVis = sg.findObject("switch.vis");
  35. txtVis = tabMl.findObject("bento.tabbutton.normal.text");
  36. tabVideo = sg.findObject("switch.video");
  37. txtVideo = tabMl.findObject("bento.tabbutton.normal.text");
  38. startX = tabMl.getGuiX();
  39. updateTabPos();
  40. }
  41. updateTabPos ()
  42. {
  43. curX = startX;
  44. if (!HAVE_ML)
  45. {
  46. tabMl.hide();
  47. }
  48. else
  49. {
  50. curX += setAutoWidth(tabMl) + 1;
  51. }
  52. if (pl_tab_attrib.getData() == "1")
  53. {
  54. tabPL.setXmlParam("x", integerToString(curX));
  55. curX += setAutoWidth(tabPL) + 1;
  56. tabPL.show();
  57. }
  58. else
  59. {
  60. tabPL.hide();
  61. }
  62. if (System.hasVideoSupport())
  63. {
  64. tabVideo.setXmlParam("x", integerToString(curX));
  65. curX += setAutoWidth(tabVideo) + 1;
  66. }
  67. else
  68. {
  69. tabVideo.hide();
  70. }
  71. // commented out because System.isSafeMode() is not recognized by mc.exe
  72. // if (!System.isSafeMode())
  73. // {
  74. tabVis.setXmlParam("x", integerToString(curX));
  75. curX += setAutoWidth(tabVis) + 1;
  76. // }
  77. // else
  78. // {
  79. // tabVis.hide();
  80. // }
  81. }
  82. int setAutoWidth (guiObject tab)
  83. {
  84. text source = tab.findObject("bento.tabbutton.normal.text");
  85. int x = stringToInteger(source.getXmlparam("x"));
  86. int w = source.getAutoWidth();
  87. tab.setXmlParam("w", integerToString(2*x+w));
  88. return 2*x + w;
  89. }
  90. pl_tab_attrib.onDataChanged ()
  91. {
  92. if (pl_tab_attrib.getData() == "0")
  93. {
  94. setPrivateString(getSkinName(), "Pledit_pos", "top");
  95. if (btnPl.getActivated())
  96. {
  97. btnMl.leftClick();
  98. btnMl.getParentLayout().sendAction("load_comp", "pledit", 0,0,0,0);
  99. }
  100. }
  101. updateTabPos();
  102. }