home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 July & August / Gamestar_64_2004-07-08_dvd.iso / Programy / winamp501_full.exe / $_14327_ / popupitem.m < prev    next >
Text File  |  2002-11-27  |  2KB  |  111 lines

  1. #include <lib/std.mi>
  2.  
  3. #define MARGIN 2
  4. #define MARGIN_PRE  2
  5. #define MARGIN_POST 6
  6.  
  7. #define CHECKMARK_WIDTH 10
  8. #define ARROW_WIDTH 10
  9.  
  10. Function setArrow(int want);
  11. Function setCheckmark(int want);
  12. Function updatePos();
  13.  
  14. Global Group mgrp;
  15. Global GuiObject background;
  16. Class GuiObject ItemSwitcher;
  17. Global int id;
  18. Global int want_checkmark;
  19. Global int want_arrow;
  20.  
  21. Global ItemSwitcher a, b, c, d;
  22. Global GuiObject _a, _b, _c;
  23.  
  24. System.onScriptLoaded() {
  25.   mgrp = getScriptGroup();
  26.   if (mgrp == NULL) {
  27.     messagebox("popupitem.maki: cannot run outside a group", "Error", 0, "");
  28.     return;
  29.   }
  30.  
  31.   _a = mgrp.getObject("popup.item.checkmark"); a = _a;
  32.   _b = mgrp.getObject("popup.item.text"); b = _b;
  33.   _c = mgrp.getObject("popup.item.submenuarrow"); c = _c;
  34.   background = mgrp.getObject("popup.background"); d = background;
  35.  
  36.   want_checkmark = -1;
  37.   want_arrow = -1;
  38. }
  39.  
  40. mgrp.onNotify(String command, String param, int a, int b) {
  41.   if (command == "id") id = StringToInteger(param);
  42.   if (command == "arrow") setArrow(StringToInteger(param));
  43.   if (command == "checkmark") setCheckMark(StringToInteger(param));
  44. }
  45.  
  46. ItemSwitcher.onEnterArea() {
  47.   background.cancelTarget();
  48.   background.setAlpha(255);
  49. }
  50.  
  51. ItemSwitcher.onLeaveArea() {
  52.   background.setTargetA(0);
  53.   background.setTargetSpeed(0.25);
  54.   background.gotoTarget();
  55. }
  56.  
  57. ItemSwitcher.onLeftButtonDown(int x, int y) {
  58.   mgrp.endModal(id);
  59. }
  60.  
  61. setArrow(int want) {
  62.   if (want_arrow == want) return;
  63.   want_arrow = want;
  64.   updatePos();
  65. }
  66.  
  67. setCheckmark(int want) {
  68.   if (want_checkmark == want) return;
  69.   want_checkmark = want;
  70.   updatePos();
  71. }
  72.  
  73. updatePos() {
  74.  
  75.   int x = MARGIN;
  76.   int mx = MARGIN;
  77.  
  78.   if (!want_checkmark) {
  79.    if (_a != NULL) {
  80.      _a.hide();
  81.     }
  82.   } else {
  83.    if (_a != NULL) {
  84.      _a.show();
  85.     }
  86.     x += CHECKMARK_WIDTH + MARGIN_PRE;
  87.     mx += CHECKMARK_WIDTH + MARGIN_PRE;
  88.   }
  89.  
  90.  
  91.   if (!want_arrow) {
  92.    if (_c != NULL) {
  93.       _c.hide();
  94.     }
  95.   } else {
  96.    if (_c != NULL) {
  97.       _c.show();
  98.     }
  99.     mx += ARROW_WIDTH + MARGIN_POST;
  100.   }
  101.  
  102.   mx += MARGIN;
  103.  
  104.   if (_b != NULL) {
  105.     _b.setXmlParam("x", IntegerToString(x));
  106.     _b.setXmlParam("w", "-" + IntegerToString(mx));
  107.   }
  108.  
  109. }
  110.  
  111.