home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d564 / dopro.lha / DoPro / src.lzh / DoProGad.c < prev    next >
C/C++ Source or Header  |  1991-10-07  |  18KB  |  452 lines

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /*              D O P R O   V1.5                                           */
  4. /*                                                                         */
  5. /***************************************************************************/
  6. /*                                                                         */
  7. /* This file defines the OpenScreenRequester. It is heavily using the new  */
  8. /* gadtools.library. Thanks to Matt Dillon for tpledit, an excellent tool  */
  9. /* and tutorial for using this library                                     */
  10. /*                                                                         */
  11. /***************************************************************************/
  12.  
  13. /* the window dimensions */
  14. #define WIN_LEFT   150
  15. #define WIN_TOP    100
  16. #define WIN_WIDTH  470
  17. #define WIN_HEIGHT 199
  18.  
  19. static ULONG NewDisplay, NormDisplay;
  20. static SHORT NormNr;
  21. static char  HexID[] = "0x00000000";
  22. static BOOL  Pal = TRUE;
  23.  
  24. /* the normal DisplayIDs from graphics/displayinfo.h */
  25. static ULONG NormalIDs[] =
  26. {
  27.  LORES_KEY, HIRES_KEY, SUPER_KEY, HAM_KEY, LORESLACE_KEY, HIRESLACE_KEY, SUPERLACE_KEY,
  28.  HAMLACE_KEY, LORESDPF_KEY, HIRESDPF_KEY, SUPERDPF_KEY, LORESLACEDPF_KEY, HIRESLACEDPF_KEY,
  29.  SUPERLACEDPF_KEY, LORESDPF2_KEY, HIRESDPF2_KEY, SUPERDPF2_KEY, LORESLACEDPF2_KEY,
  30.  HIRESLACEDPF2_KEY, SUPERLACEDPF2_KEY, EXTRAHALFBRITE_KEY, EXTRAHALFBRITELACE_KEY
  31. };
  32.  
  33. /* the vga DisplayIDs */
  34. static ULONG VGAIDs[] =
  35. {
  36.  VGAEXTRALORES_KEY, VGALORES_KEY, VGAPRODUCT_KEY, VGAHAM_KEY, VGAEXTRALORESLACE_KEY,
  37.  VGALORESLACE_KEY, VGAPRODUCTLACE_KEY, VGAHAMLACE_KEY, VGAEXTRALORESDPF_KEY, VGALORESDPF_KEY,
  38.  VGAPRODUCTDPF_KEY, VGAEXTRALORESLACEDPF_KEY, VGALORESLACEDPF_KEY, VGAPRODUCTLACEDPF_KEY,
  39.  VGAEXTRALORESDPF2_KEY, VGALORESDPF2_KEY, VGAPRODUCTDPF2_KEY, VGAEXTRALORESLACEDPF2_KEY,
  40.  VGALORESLACEDPF2_KEY, VGAPRODUCTLACEDPF2_KEY, VGAEXTRAHALFBRITE_KEY, VGAEXTRAHALFBRITELACE_KEY
  41. };
  42.  
  43. /* count the ID's */
  44. #define NormalNum (sizeof(NormalIDs)/sizeof(ULONG))
  45. #define VGANum    (sizeof(VGAIDs)/sizeof(ULONG))
  46.  
  47. /* used by the monitor gadget */
  48. static char *Monitors[] = {"PAL", "NTSC", NULL};
  49.  
  50. /* all my gadgets */
  51. enum Gads
  52. {
  53.  LeftEdge, TopEdge, Width, Height, Depth, Detail, Block, Res, Lace, Ham, EHB, Topaz,
  54.  Title, NormalID, Monitor, VGAID, DisplayID, LastGads
  55. };
  56.  
  57. static struct NewGadget NGAry[] = {
  58.     { 77,16,67,16,"LeftEdge",NULL,LeftEdge, PLACETEXT_LEFT,NULL },
  59.     { 77,34,67,16,"TopEdge",NULL,TopEdge, PLACETEXT_LEFT,NULL },
  60.     { 77,52,67,16,"Width",NULL,Width, PLACETEXT_LEFT,NULL },
  61.     { 78,70,67,16,"Height",NULL,Height, PLACETEXT_LEFT,NULL },
  62.     { 244,16,32,16,"Depth",NULL,Depth,PLACETEXT_LEFT,NULL },
  63.     { 244,34,43,16,"DetailPen",NULL,Detail,PLACETEXT_LEFT,NULL },
  64.     { 244,52,43,16,"BlockPen",NULL,Block,PLACETEXT_LEFT,NULL },
  65.     { 425,16,84,16,"HIRES",NULL,Res,PLACETEXT_LEFT,NULL },
  66.     { 425,30,84,16,"INTERLACE",NULL,Lace,PLACETEXT_LEFT,NULL },
  67.     { 425,44,84,16,"HAM",NULL,Ham,PLACETEXT_LEFT,NULL },
  68.     { 425,58,84,16,"EHB",NULL,EHB,PLACETEXT_LEFT,NULL },
  69.     { 425,76,84,16,"Topaz8",NULL,Topaz,PLACETEXT_LEFT,NULL},
  70.     { 244,70,120,16,"Title",NULL,Title,PLACETEXT_LEFT,NULL },
  71.     {  31,105,170,69,"Display_ID",NULL,NormalID,PLACETEXT_ABOVE,NULL },
  72.     { 134,180,67,16,"Monitor",NULL,Monitor,PLACETEXT_LEFT,NULL },
  73.     { 235,105,170,69,"VGA_ID",NULL,VGAID,PLACETEXT_ABOVE,NULL },
  74.     { 308,180,97,16,"NewDisplay",NULL,DisplayID,PLACETEXT_LEFT, NULL},
  75. };
  76.  
  77. static struct Gadget *Gadgets[LastGads];
  78.  
  79.  
  80. extern struct List List_NormalID, List_VGAID;
  81. static struct Node NodeAry_NormalID[] =
  82. {
  83.     { NodeAry_NormalID + 1, (struct Node *)&List_NormalID.lh_Head, 0, 0,"LORES"},
  84.     { NodeAry_NormalID + 2, NodeAry_NormalID + 0, 0, 0, "HIRES"},
  85.     { NodeAry_NormalID + 3, NodeAry_NormalID + 1, 0, 0, "SUPER"},
  86.     { NodeAry_NormalID + 4, NodeAry_NormalID + 2, 0, 0, "HAM"},
  87.     { NodeAry_NormalID + 5, NodeAry_NormalID + 3, 0, 0, "LORESLACE"},
  88.     { NodeAry_NormalID + 6, NodeAry_NormalID + 4, 0, 0, "HIRESLACE"},
  89.     { NodeAry_NormalID + 7, NodeAry_NormalID + 5, 0, 0, "SUPERLACE"},
  90.     { NodeAry_NormalID + 8, NodeAry_NormalID + 6, 0, 0, "HAMLACE"},
  91.     { NodeAry_NormalID + 9, NodeAry_NormalID + 7, 0, 0, "LORESDPF"},
  92.     { NodeAry_NormalID +10, NodeAry_NormalID + 8, 0, 0, "HIRESDPF"},
  93.     { NodeAry_NormalID +11, NodeAry_NormalID + 9, 0, 0, "SUPERDPF"},
  94.     { NodeAry_NormalID +12, NodeAry_NormalID +10, 0, 0, "LORESLACEDPF"},
  95.     { NodeAry_NormalID +13, NodeAry_NormalID +11, 0, 0, "HIRESLACEDPF"},
  96.     { NodeAry_NormalID +14, NodeAry_NormalID +13, 0, 0, "SUPERLACEDPF"},
  97.     { NodeAry_NormalID +15, NodeAry_NormalID +14, 0, 0, "LORESDPF2"},
  98.     { NodeAry_NormalID +16, NodeAry_NormalID +15, 0, 0, "HIRESDPF2"},
  99.     { NodeAry_NormalID +17, NodeAry_NormalID +16, 0, 0, "SUPERDPF2"},
  100.     { NodeAry_NormalID +18, NodeAry_NormalID +17, 0, 0, "LORESLACEDPF2"},
  101.     { NodeAry_NormalID +19, NodeAry_NormalID +18, 0, 0, "HIRESLACEDPF2"},
  102.     { NodeAry_NormalID +20, NodeAry_NormalID +19, 0, 0, "SUPERLACEDPF2"},
  103.     { NodeAry_NormalID +21, NodeAry_NormalID +20, 0, 0, "EXTRAHALFBRITE"},
  104.     { (struct Node *)&List_NormalID.lh_Tail, NodeAry_NormalID + 21, 0, 0,"EXTRAHALFBRITELACE"}
  105. };
  106.  
  107. static struct Node NodeAry_VGAID[] =
  108. {
  109.     { NodeAry_VGAID + 1, (struct Node *)&List_VGAID.lh_Head, 0, 0,"EXTRALORES"},
  110.     { NodeAry_VGAID + 2, NodeAry_VGAID + 0, 0, 0, "LORES"},
  111.     { NodeAry_VGAID + 3, NodeAry_VGAID + 1, 0, 0, "PRODUCT"},
  112.     { NodeAry_VGAID + 4, NodeAry_VGAID + 2, 0, 0, "HAM"},
  113.     { NodeAry_VGAID + 5, NodeAry_VGAID + 3, 0, 0, "EXTRALORESLACE"},
  114.     { NodeAry_VGAID + 6, NodeAry_VGAID + 4, 0, 0, "LORESLACE"},
  115.     { NodeAry_VGAID + 7, NodeAry_VGAID + 5, 0, 0, "PRODUCTLACE"},
  116.     { NodeAry_VGAID + 8, NodeAry_VGAID + 6, 0, 0, "HAMLACE"},
  117.     { NodeAry_VGAID + 9, NodeAry_VGAID + 7, 0, 0, "EXTRALORESDPF"},
  118.     { NodeAry_VGAID +10, NodeAry_VGAID + 8, 0, 0, "LORESDPF"},
  119.     { NodeAry_VGAID +11, NodeAry_VGAID + 9, 0, 0, "PRODUCTDPF"},
  120.     { NodeAry_VGAID +12, NodeAry_VGAID +10, 0, 0, "EXTRALORESLACEDPF"},
  121.     { NodeAry_VGAID +13, NodeAry_VGAID +11, 0, 0, "LORESLACEDPF"},
  122.     { NodeAry_VGAID +14, NodeAry_VGAID +13, 0, 0, "PRODUCTLACEDPF"},
  123.     { NodeAry_VGAID +15, NodeAry_VGAID +14, 0, 0, "EXTRALORESDPF2"},
  124.     { NodeAry_VGAID +16, NodeAry_VGAID +15, 0, 0, "LORESDPF2"},
  125.     { NodeAry_VGAID +17, NodeAry_VGAID +16, 0, 0, "PRODUCTDPF2"},
  126.     { NodeAry_VGAID +18, NodeAry_VGAID +17, 0, 0, "EXTRALORESLACEDPF2"},
  127.     { NodeAry_VGAID +19, NodeAry_VGAID +18, 0, 0, "LORESLACEDPF2"},
  128.     { NodeAry_VGAID +20, NodeAry_VGAID +19, 0, 0, "PRODUCTLACEDPF2"},
  129.     { NodeAry_VGAID +21, NodeAry_VGAID +20, 0, 0, "EXTRAHALFBRITE"},
  130.     { (struct Node *)&List_VGAID.lh_Tail, NodeAry_VGAID + 21, 0, 0,"EXTRAHALFBRITELACE"}
  131. };
  132.  
  133. static struct List List_NormalID =
  134. {
  135.  &NodeAry_NormalID[0], NULL, &NodeAry_NormalID[NormalNum-1], NULL, NULL
  136. };
  137.  
  138. static struct List List_VGAID =
  139. {
  140.  &NodeAry_VGAID[0], NULL, &NodeAry_VGAID[VGANum-1], NULL, NULL
  141. };
  142.  
  143. static struct Gadget *GList;
  144. static struct VisualInfo *VisInfo;
  145.  
  146. /* converts an unsigned long to a hex string, string must begin with 0x, no checking ! */
  147. static void Int2Hex(char *s, ULONG n)
  148. {
  149.  short i;
  150.  
  151.  for(i=9; i>1; i--)
  152.  {
  153.   s[i] = "0123456789ABCDEF"[n & 0x0F];
  154.   n >>= 4;
  155.  }
  156. }
  157.  
  158. /* default font */
  159. extern struct TextAttr MyAttr =
  160. {
  161.  "topaz.font", 8, NULL, NULL
  162. };
  163.  
  164. /* initializes and displays all my gadgets */
  165. /* original created by tpledit */
  166. static struct Gadget *InitGads(struct Screen *scr, struct NewScreen *ns)
  167. {
  168.  struct Gadget *gad;
  169.  UWORD          SigViewMode;
  170.  short          i;
  171.  
  172.  GList = NULL;
  173.  if ((VisInfo = GetVisualInfo(scr, TAG_END)) == NULL) return(NULL);
  174.  {
  175.   struct NewGadget *ng;
  176.   for (i = 0, ng = NGAry; i < sizeof(NGAry)/sizeof(NGAry[0]); ++i, ++ng)
  177.   {
  178.    ng->ng_VisualInfo = VisInfo;
  179.    ng->ng_TextAttr = &MyAttr;
  180.   }
  181.  }
  182.  if (!(gad = CreateContext(&GList))) return(NULL);
  183.  Gadgets[LeftEdge] = CreateGadget(INTEGER_KIND, gad, NGAry + 0,
  184.                                   GTIN_MaxChars, 4,
  185.                                   GTIN_Number, ns->LeftEdge,
  186.                                   TAG_END
  187.                                  );
  188.  if (!Gadgets[LeftEdge]) return(NULL);
  189.  Gadgets[TopEdge] = CreateGadget(INTEGER_KIND, Gadgets[LeftEdge], NGAry + 1,
  190.                                  GTIN_MaxChars, 4,
  191.                                  GTIN_Number, ns->TopEdge,
  192.                                  TAG_END
  193.                                 );
  194.  if (!Gadgets[TopEdge]) return(NULL);
  195.  Gadgets[Width] = CreateGadget(INTEGER_KIND, Gadgets[TopEdge], NGAry + 2,
  196.                                GTIN_MaxChars, 4,
  197.                                GTIN_Number, ns->Width,
  198.                                TAG_END
  199.                               );
  200.  if (!Gadgets[Width]) return(NULL);
  201.  Gadgets[Height] = CreateGadget(INTEGER_KIND, Gadgets[Width], NGAry + 3,
  202.                                GTIN_MaxChars, 4,
  203.                                GTIN_Number, ns->Height,
  204.                                TAG_END
  205.                               );
  206.  if (!Gadgets[Height]) return(NULL);
  207.  Gadgets[Depth] = CreateGadget(INTEGER_KIND, Gadgets[Height], NGAry + 4,
  208.                                GTIN_MaxChars, 2,
  209.                                GTIN_Number, ns->Depth,
  210.                                GA_Disabled, TRUE,
  211.                                TAG_END
  212.                               );
  213.  if (!Gadgets[Depth]) return(NULL);
  214.  Gadgets[Detail] = CreateGadget(INTEGER_KIND, Gadgets[Depth], NGAry + 5,
  215.                                 GTIN_MaxChars, 3,
  216.                                 GTIN_Number, ns->DetailPen,
  217.                                 GA_Disabled, TRUE,
  218.                                 TAG_END
  219.                                );
  220.  if (!Gadgets[Detail]) return(NULL);
  221.  Gadgets[Block] = CreateGadget(INTEGER_KIND, Gadgets[Detail], NGAry + 6,
  222.                                GTIN_MaxChars, 2,
  223.                                GTIN_Number, ns->BlockPen,
  224.                                GA_Disabled, TRUE,
  225.                                TAG_END
  226.                               );
  227.  if (!Gadgets[Block]) return(NULL);
  228.  Gadgets[Res] = CreateGadget(CHECKBOX_KIND, Gadgets[Block], NGAry + 7,
  229.                              GTCB_Checked, ns->ViewModes & HIRES,
  230.                              GA_Disabled, TRUE,
  231.                              TAG_END
  232.                             );
  233.  if (!Gadgets[Res]) return(NULL);
  234.  Gadgets[Lace] = CreateGadget(CHECKBOX_KIND, Gadgets[Res], NGAry + 8,
  235.                               GTCB_Checked, ns->ViewModes & LACE,
  236.                               GA_Disabled, TRUE,
  237.                               TAG_END
  238.                              );
  239.  if (!Gadgets[Lace]) return(NULL);
  240.  Gadgets[Ham] = CreateGadget(CHECKBOX_KIND, Gadgets[Lace], NGAry + 9,
  241.                              GTCB_Checked, ns->ViewModes & HAM,
  242.                              GA_Disabled, TRUE,
  243.                              TAG_END
  244.                             );
  245.  if (!Gadgets[Ham]) return(NULL);
  246.  Gadgets[EHB] = CreateGadget(CHECKBOX_KIND, Gadgets[Ham], NGAry + 10,
  247.                              GTCB_Checked, ns->ViewModes & EXTRA_HALFBRITE,
  248.                              GA_Disabled, TRUE,
  249.                              TAG_END
  250.                             );
  251.  if (!Gadgets[EHB]) return(NULL);
  252.  Gadgets[Topaz] = CreateGadget(CHECKBOX_KIND, Gadgets[EHB], NGAry + 11,
  253.                                GTCB_Checked, FALSE,
  254.                                GA_Disabled, ns->Font != NULL,
  255.                                TAG_END
  256.                               );
  257.  if (!Gadgets[Topaz]) return(NULL);
  258.  Gadgets[Title] = CreateGadget(STRING_KIND, Gadgets[Topaz], NGAry + 12,
  259.                                GTST_String, ns->DefaultTitle,
  260.                                GTST_MaxChars, 25,
  261.                                GA_Disabled, TRUE,
  262.                                TAG_END
  263.                               );
  264.  if (!Gadgets[Title]) return(NULL);
  265.  
  266.  /* find the actual (old ?) DisplayID */
  267.  SigViewMode = ns->ViewModes & (LACE|PFBA|EXTRA_HALFBRITE|DUALPF|HAM|HIRES);
  268.  for(NormNr=0; NormNr<NormalNum; NormNr++)
  269.   if (SigViewMode == NormalIDs[NormNr]) break;
  270.  if (NormNr == NormalNum) NormNr = 0;
  271.  NewDisplay = NormDisplay = NormalIDs[NormNr];
  272.  Gadgets[NormalID] = CreateGadget(LISTVIEW_KIND, Gadgets[Title], NGAry + 13,
  273.                                   GTLV_Labels, &List_NormalID,
  274.                                   GTLV_Selected, NormNr,
  275.                                   GTLV_ShowSelected, NULL,
  276.                                   TAG_END
  277.                                  );
  278.  if (!Gadgets[NormalID]) return(NULL);
  279.  
  280.  Gadgets[Monitor] = CreateGadget(CYCLE_KIND, Gadgets[NormalID], NGAry + 14,
  281.                                  GTCY_Labels, Monitors,
  282.                                  TAG_END
  283.                                 );
  284.  if(!Gadgets[Monitor]) return(NULL);
  285.  
  286.  Gadgets[VGAID] = CreateGadget(LISTVIEW_KIND, Gadgets[Monitor], NGAry + 15,
  287.                                GTLV_Labels, &List_VGAID,
  288.                                GTLV_ShowSelected, NULL,
  289.                                GA_Disabled, !MayUseProductivity,
  290.                                TAG_END
  291.                               );
  292.  if (!Gadgets[VGAID]) return(NULL);
  293.  
  294.  Int2Hex(HexID, NewDisplay);
  295.  Gadgets[DisplayID] = CreateGadget(STRING_KIND, Gadgets[VGAID], NGAry + 16,
  296.                                    GTST_String, HexID,
  297.                                    GTST_MaxChars, 10,
  298.                                    GA_Disabled, FALSE,
  299.                                    TAG_END
  300.                                   );
  301.  if (!Gadgets[DisplayID]) return(NULL);
  302.  
  303.  return(GList);
  304. }
  305.  
  306.  
  307.  
  308. static void FreeGads(void)
  309. {
  310.     FreeGadgets(GList);
  311.     if (VisInfo) FreeVisualInfo(VisInfo);
  312.     VisInfo = NULL;
  313.     GList = NULL;
  314. }
  315.  
  316. /* the OpenScreenRequester */
  317. /* stolen from test.c by Matt Dillon  ;-) */
  318. ULONG ScreenRequest(struct NewScreen *ns, BOOL *UseTopaz) /* stupid hack for topaz */
  319. {
  320.  struct Screen *scr;
  321.  struct Window *win;
  322.  struct Gadget *glist, *Gad;
  323.  ULONG  Num;
  324.  
  325.  if (scr = LockPubScreen(NULL))
  326.  {
  327.   if (glist = InitGads(scr, ns))
  328.   {
  329.    win = OpenWindowTags(NULL,
  330.                         WA_Flags,   WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|
  331.                                     WFLG_SIZEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE, 
  332.                         WA_IDCMP,   IDCMP_NEWSIZE|IDCMP_MOUSEBUTTONS|IDCMP_GADGETDOWN|
  333.                                     IDCMP_GADGETUP|IDCMP_MENUPICK|IDCMP_VANILLAKEY|
  334.                                     IDCMP_RAWKEY|IDCMP_CHANGEWINDOW|IDCMP_CLOSEWINDOW|
  335.                                     IDCMP_REFRESHWINDOW,
  336.                         WA_Left,    WIN_LEFT,
  337.                         WA_Top,     WIN_TOP,
  338.                         WA_Width,   WIN_WIDTH,
  339.                         WA_Height,  WIN_HEIGHT,
  340.                         WA_Title,   ProgTitle,
  341.                         WA_MinWidth,  32,
  342.                         WA_MinHeight, 32,
  343.                         WA_MaxWidth,  -1,
  344.                         WA_MaxHeight, -1,
  345.                         WA_AutoAdjust, 1,
  346.                         WA_PubScreen, NULL,
  347.                         WA_PubScreenFallBack, 1,
  348.                         WA_Gadgets, glist,
  349.                         TAG_END
  350.                        );
  351.    if (win)
  352.    {
  353.     struct IntuiMessage *im;
  354.     short notDone = 1;
  355.  
  356.     GT_RefreshWindow(win, NULL);
  357.     ScreenToFront(scr);
  358.  
  359.     while (notDone) 
  360.     {
  361.      WaitPort(win->UserPort);
  362.      while (im = GT_GetIMsg(win->UserPort))
  363.      {
  364.       switch(im->Class)
  365.       {
  366.        case IDCMP_CLOSEWINDOW:
  367.          notDone = 0;
  368.          break;
  369.        case IDCMP_REFRESHWINDOW:
  370.          GT_BeginRefresh(win);
  371.          GT_EndRefresh(win, TRUE);
  372.          break;
  373.        case IDCMP_GADGETUP:
  374.          Gad = (struct Gadget *)im->IAddress;
  375.          Num = ((struct StringInfo *)Gad->SpecialInfo)->LongInt;
  376.          switch(Gad->GadgetID)
  377.          {
  378.           case LeftEdge:
  379.             ns->LeftEdge = Num;
  380.             break;
  381.           case TopEdge:
  382.             ns->TopEdge = Num;
  383.             break;
  384.           case Width:
  385.             ns->Width = Num;
  386.             break;
  387.           case Height:
  388.             ns->Height = Num;
  389.             break;
  390.           case Topaz:
  391.             *UseTopaz = !*UseTopaz;
  392.              break;
  393.           case NormalID:
  394.             NormNr = im->Code;
  395.             NormDisplay = NormalIDs[NormNr];
  396.             NewDisplay = NormDisplay | (Pal ? PAL_MONITOR_ID : NTSC_MONITOR_ID);
  397.             Int2Hex(HexID, NewDisplay);
  398.             GT_SetGadgetAttrs(Gadgets[DisplayID], win, NULL,
  399.                               GTST_String, HexID,
  400.                               TAG_END
  401.                              );
  402.             GT_SetGadgetAttrs(Gadgets[VGAID], win, NULL,
  403.                               GTLV_Selected, ~0,
  404.                               TAG_END
  405.                              );
  406.             break;
  407.           case Monitor:
  408.             Pal = !im->Code;
  409.             NewDisplay = NormDisplay | (Pal ? PAL_MONITOR_ID : NTSC_MONITOR_ID);
  410.             Int2Hex(HexID, NewDisplay);
  411.             GT_SetGadgetAttrs(Gadgets[DisplayID], win, NULL,
  412.                               GTST_String, HexID,
  413.                               TAG_END
  414.                              );
  415.             GT_SetGadgetAttrs(Gadgets[VGAID], win, NULL,
  416.                               GTLV_Selected, ~0,
  417.                               TAG_END
  418.                              );
  419.             GT_SetGadgetAttrs(Gadgets[NormalID], win, NULL,
  420.                               GTLV_Selected, NormNr,
  421.                               TAG_END
  422.                              );
  423.             break;
  424.           case VGAID:
  425.             NewDisplay = VGAIDs[im->Code];
  426.             Int2Hex(HexID, NewDisplay);
  427.             GT_SetGadgetAttrs(Gadgets[DisplayID], win, NULL,
  428.                               GTST_String, HexID,
  429.                               TAG_END
  430.                              );
  431.             GT_SetGadgetAttrs(Gadgets[NormalID], win, NULL,
  432.                               GTLV_Selected, ~0,
  433.                               TAG_END
  434.                              );
  435.             break;
  436.          }
  437.          break;
  438.        default:
  439.          break;
  440.       }
  441.       GT_ReplyIMsg(im);
  442.      }
  443.     }
  444.     CloseWindow(win);
  445.    }
  446.    FreeGads();
  447.   }
  448.   UnlockPubScreen(NULL, scr);
  449.  }
  450.  return NewDisplay;
  451. }
  452.