home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 223.dms / 223.adf / Source / star10.c < prev    next >
C/C++ Source or Header  |  1988-07-25  |  22KB  |  670 lines

  1. /*=========================================================================
  2.   Star10.c -- This module builds and submits a requester in response to
  3.   the user's choice of 'change screen colors' from the OPTIONS  menu
  4.   of the Star Chart program. The requester lets the user modify the 
  5.   default color Palette for the starchart program.
  6.   This is really a general purpose Palette requester.
  7.  
  8.  
  9.   Credits for Star Chart:
  10.        Robert L. Hill of the Orange County, CA. Amiga Friends User Group
  11.                       wrote the original version of StarChart in AmigaBasic
  12.                       The star data and many of the main functions of this
  13.                       version are derived from that program.
  14.  
  15.        Ray R. Larson  wrote the c version 1.0 of StarChart, 'intuitionizing'
  16.                       and enhancing the speed and functions of the original.
  17.  
  18.   Copyright (c) 1986 by Ray R. Larson
  19.   
  20.   This program may be freely distributed and copied, but may not be sold
  21.   without the permission of the author. If you modify or enhance it, 
  22.   please include the above credits (and please send me a copy!).
  23.  
  24. Ray R. Larson
  25. 6425 Central Ave. #304
  26. El Cerrito, CA 94530
  27.  
  28. BitNet  LARSON@UCBCMSA
  29. =========================================================================*/
  30. /*------------Header file for all of the standard stuff----*/ 
  31. /*-------------plus definitions of global structures-------*/
  32. #include "star.h" 
  33.  
  34.  
  35. /*  Definitions for Gadget ID numbers               */ 
  36. #define PALETTEG   1
  37. #define  CANPALGAD   2
  38. #define  OKPALGAD   3
  39. #define  RESTRGAD   4
  40. #define BLUECTLG   8
  41. #define GREENCTLG  9
  42. #define REDCTLG    10
  43.  
  44. /**********************************************************************
  45.  *  Text attribute structures used in rendering IntuiTexts
  46.  **********************************************************************/
  47. extern struct TextAttr TxtAt_Plain,TxtAt_BIU,TxtAt_BU,TxtAt_BI,TxtAt_B,
  48.         TxtAt_IU,TxtAt_I,TxtAt_U;
  49.  
  50.  
  51. /* Text for the proportional gadgets */
  52. struct IntuiText red_label = {2,1,JAM2,-7,2,NULL,(UBYTE *)"R",NULL};
  53. struct IntuiText green_label = {2,1,JAM2,-7,2,NULL,(UBYTE *)"G",NULL};
  54. struct IntuiText blue_label = {2,1,JAM2,-7,2,NULL,(UBYTE *)"B",NULL};
  55. struct IntuiText brushtxt = {1,0,COMPLEMENT,60,38,NULL,
  56.                             (UBYTE *)"Selected Color",NULL};
  57.  
  58.  
  59. SHORT brushpairs[]=
  60.                 { -1,-1,  161,-1, 161,15, -1,15, -1,-1};
  61.  
  62.  
  63. /**********************************************************************
  64.  *  Border Definitions for PaletteReq requester
  65.  **********************************************************************/
  66.  
  67. SHORT PaletteReq_Pairs_1[] = {
  68.   0,     0,   
  69.   257,     0,   
  70.   257,     140,   
  71.   0,     140,   
  72.   0,     0    
  73. };
  74. struct Border PaletteReq_bord_1 = {
  75.   1,  1,       /* LeftEdge, TopEdge */
  76.   7,  1,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  77.   5,             /* Count of XY pairs */  
  78.   (SHORT *)&PaletteReq_Pairs_1, /* XY pairs */
  79.   NULL           /* Next Border */
  80. };
  81.  
  82. SHORT PaletteReq_Pairs_2[] = {
  83.   0,     0,   
  84.   251,     0,   
  85.   251,     137,   
  86.   0,     137,   
  87.   0,     0    
  88. };
  89. struct Border PaletteReq_bord_2 = {
  90.   3,  3,       /* LeftEdge, TopEdge */
  91.   1,  7,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  92.   5,             /* Count of XY pairs */  
  93.   (SHORT *)&PaletteReq_Pairs_2, /* XY pairs */
  94.   &PaletteReq_bord_1           /* Next Border */
  95. };
  96.  
  97.  
  98. /* border for the selected color box */
  99. struct Border boxborder =
  100.      {50,35,1,0,JAM1,5,&brushpairs[0],NULL};
  101.  
  102.  
  103. SHORT PalGadPairs[] = {
  104.   0,     0,   
  105.   160,     0,   
  106.   160,     20,   
  107.   0,     20,   
  108.   0,     0    
  109. };
  110. struct Border PalGadBord = {
  111.   -1,  -1,
  112.   1,  3,  JAM2,
  113.   5,
  114.   (SHORT *)&PalGadPairs,
  115.   NULL
  116. };
  117.  
  118. struct Gadget paletteGadg = {
  119.   NULL, 50, 10, 160, 20,
  120.   GADGHNONE,
  121.   RELVERIFY | GADGIMMEDIATE,
  122.   BOOLGADGET,
  123.   (APTR)&PalGadBord, 
  124.   NULL,
  125.   NULL,/* intuitext */
  126.   0x0,
  127.   NULL,
  128.   PALETTEG,
  129.   NULL
  130. };
  131.  
  132.  
  133. /* Images for the color proportional gadgets - filled in later  */
  134. struct Image r_shape, g_shape, b_shape;
  135.  
  136. /* Proportional info for the color prop gadgets */
  137. struct PropInfo r_prop, g_prop, b_prop;
  138.  
  139. /* global flags and body size for modifyprops */
  140. LONG propflags, propHbody;
  141.  
  142. /* The color prop gadgets themselves */
  143.       
  144. struct Gadget blue_control =
  145.    { &paletteGadg,       /* next in the line   */
  146.      50, 85,         /* Left and Top Edges */
  147.      160, 11,           /* Width, Height      */
  148.      GADGHCOMP,        /* Flags (complement) */
  149.      GADGIMMEDIATE |
  150.      RELVERIFY,        /* activation         */
  151.      PROPGADGET,       /* GadgetType         */
  152.      (APTR)&b_shape,   /* GadgetRender image */
  153.      NULL,             /* no SelectRender    */
  154.      &blue_label,      /* GadgetText         */
  155.      NULL,             /* no MutualExclude   */
  156.      (APTR)&b_prop,    /* SpecialInfo        */
  157.      BLUECTLG,         /* GadgetID           */
  158.      NULL,             /* No UserData        */
  159.     };
  160.  
  161. struct Gadget green_control =
  162.    { &blue_control,    /* next in the line   */
  163.      50, 70,         /* Left and Top Edges */
  164.      160, 11,           /* Width, Height      */
  165.      GADGHCOMP,        /* Flags (complement) */
  166.      GADGIMMEDIATE |
  167.      RELVERIFY,        /* activation         */
  168.      PROPGADGET,       /* GadgetType         */
  169.      (APTR)&g_shape,   /* GadgetRender image */
  170.      NULL,             /* no SelectRender    */
  171.      &green_label,     /* GadgetText         */
  172.      NULL,             /* no MutualExclude   */
  173.      (APTR)&g_prop,    /* SpecialInfo        */
  174.      GREENCTLG,     /* GadgetID           */
  175.      NULL,             /* No UserData        */
  176.     };
  177.  
  178. struct Gadget red_control =
  179.    { &green_control,    /* next in the line   */
  180.      50, 55,         /* Left and Top Edges */
  181.      160, 11,           /* Width, Height      */
  182.      GADGHCOMP,        /* Flags (complement) */
  183.      GADGIMMEDIATE |
  184.      RELVERIFY,        /* activation         */
  185.      PROPGADGET,       /* GadgetType         */
  186.      (APTR)&r_shape,   /* GadgetRender image */
  187.      NULL,             /* no SelectRender    */
  188.      &red_label,       /* GadgetText         */
  189.      NULL,             /* no MutualExclude   */
  190.      (APTR)&r_prop,    /* SpecialInfo        */
  191.      REDCTLG,          /* GadgetID           */
  192.      NULL,             /* No UserData        */
  193.     };
  194.  
  195.  
  196. /**********************************************************************
  197.  *  Border Definitions for okPal gadget
  198.  **********************************************************************/
  199.  
  200. SHORT okPal_Pairs_2[] = {
  201.   0,     0,   
  202.   88,     0,   
  203.   88,     17,   
  204.   0,     17,   
  205.   0,     0    
  206. };
  207. struct Border okPal_bord_2 = {
  208.   -1,  -1,       /* LeftEdge, TopEdge */
  209.   1,  7,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  210.   5,             /* Count of XY pairs */  
  211.   (SHORT *)&okPal_Pairs_2, /* XY pairs */
  212.   NULL           /* Next Border */
  213. };
  214.  
  215.  
  216. /**********************************************************************
  217.  *  IntuiTexts for the okPal gadget.
  218.  **********************************************************************/
  219.  
  220. struct IntuiText okPal_Text_0 = {
  221.    15, 0,     /* FrontPen, BackPen */
  222.    JAM2,       /* DrawMode */
  223.    12, 4,     /* LeftEdge, TopEdge */
  224.    &TxtAt_B, /* ITextFont Pointer */ 
  225.    /* The IText */
  226.    (UBYTE *)"   OK   ",
  227.    NULL
  228.  };
  229.  
  230.  
  231.  
  232. /**********************************************************************
  233.  *  Gadget Structure definition for the okPal gadget.
  234.  **********************************************************************/
  235.  
  236. struct Gadget okPal = {
  237.   &red_control,     /* NextGadget pointer */
  238.   150, 120,    /* LeftEdge, TopEdge  */
  239.   88, 17,    /* Width, Height      */
  240.   /* Gadget Flags */
  241.   GADGHCOMP,
  242.   /* Activation Flags */
  243.   RELVERIFY | GADGIMMEDIATE,
  244.   /* GadgetType */
  245.   BOOLGADGET | REQGADGET,
  246.   (APTR)&okPal_bord_2,   /*  GadgetRender */
  247.   NULL,    /* SelectRender */
  248.    &okPal_Text_0,  /* GadgetText */
  249.   0x0,    /* MutualExclude */
  250.   NULL,   /* SpecialInfo */
  251.   OKPALGAD,    /* GadgetID         */
  252.   0x1     /* UserData Pointer */
  253. };
  254.  
  255.  
  256. /**********************************************************************
  257.  *  Border Definitions for canPal gadget
  258.  **********************************************************************/
  259.  
  260. SHORT canPal_Pairs_3[] = {
  261.   0,     0,   
  262.   88,     0,   
  263.   88,     17,   
  264.   0,     17,   
  265.   0,     0    
  266. };
  267. struct Border canPal_bord_3 = {
  268.   -1,  -1,       /* LeftEdge, TopEdge */
  269.   1,  7,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  270.   5,             /* Count of XY pairs */  
  271.   (SHORT *)&canPal_Pairs_3, /* XY pairs */
  272.   NULL           /* Next Border */
  273. };
  274.  
  275.  
  276. /**********************************************************************
  277.  *  IntuiTexts for the canPal gadget.
  278.  **********************************************************************/
  279.  
  280. struct IntuiText canPal_Text_0 = {
  281.    15, 0,     /* FrontPen, BackPen */
  282.    JAM2,       /* DrawMode */
  283.    10, 4,     /* LeftEdge, TopEdge */
  284.    &TxtAt_B, /* ITextFont Pointer */ 
  285.    /* The IText */
  286.    (UBYTE *)" CANCEL ",
  287.    NULL
  288.  };
  289.  
  290.  
  291.  
  292. /**********************************************************************
  293.  *  Gadget Structure definition for the canPal gadget.
  294.  **********************************************************************/
  295.  
  296. struct Gadget canPal = {
  297.  &okPal,     /* NextGadget pointer */
  298.   20, 120,    /* LeftEdge, TopEdge  */
  299.   88, 17,    /* Width, Height      */
  300.   /* Gadget Flags */
  301.   GADGHCOMP,
  302.   /* Activation Flags */
  303.   RELVERIFY | GADGIMMEDIATE | ENDGADGET,
  304.   /* GadgetType */
  305.   BOOLGADGET | REQGADGET,
  306.   (APTR)&canPal_bord_3,   /*  GadgetRender */
  307.   NULL,    /* SelectRender */
  308.    &canPal_Text_0,  /* GadgetText */
  309.   0x0,    /* MutualExclude */
  310.   NULL,   /* SpecialInfo */
  311.   CANPALGAD,    /* GadgetID         */
  312.   0x1     /* UserData Pointer */
  313. };
  314.  
  315. /**********************************************************************
  316.  *  Border Definitions for restore gadget
  317.  **********************************************************************/
  318.  
  319. SHORT restPal_Pairs_3[] = {
  320.   0,     0,   
  321.   88,     0,   
  322.   88,     17,   
  323.   0,     17,   
  324.   0,     0    
  325. };
  326. struct Border restPal_bord_3 = {
  327.   -1,  -1,       /* LeftEdge, TopEdge */
  328.   1,  7,  JAM2,  /* FrontPen, BackPen, DrawMode*/
  329.   5,             /* Count of XY pairs */  
  330.   (SHORT *)&restPal_Pairs_3, /* XY pairs */
  331.   NULL           /* Next Border */
  332. };
  333.  
  334.  
  335. /**********************************************************************
  336.  *  IntuiTexts for the restPal gadget.
  337.  **********************************************************************/
  338.  
  339. struct IntuiText restPal_Text_0 = {
  340.    15, 0,     /* FrontPen, BackPen */
  341.    JAM2,       /* DrawMode */
  342.    7, 4,     /* LeftEdge, TopEdge */
  343.    &TxtAt_B, /* ITextFont Pointer */ 
  344.    /* The IText */
  345.    (UBYTE *)" RESTORE ",
  346.    NULL
  347.  };
  348.  
  349.  
  350.  
  351. /**********************************************************************
  352.  *  Gadget Structure definition for the restPal gadget.
  353.  **********************************************************************/
  354.  
  355. struct Gadget restPal = {
  356.  &canPal,     /* NextGadget pointer */
  357.   84, 100,    /* LeftEdge, TopEdge  */
  358.   88, 17,    /* Width, Height      */
  359.   /* Gadget Flags */
  360.   GADGHCOMP,
  361.   /* Activation Flags */
  362.   RELVERIFY | GADGIMMEDIATE,
  363.   /* GadgetType */
  364.   BOOLGADGET | REQGADGET,
  365.   (APTR)&restPal_bord_3,   /*  GadgetRender */
  366.   NULL,    /* SelectRender */
  367.    &restPal_Text_0,  /* GadgetText */
  368.   0x0,    /* MutualExclude */
  369.   NULL,   /* SpecialInfo */
  370.   RESTRGAD,    /* GadgetID         */
  371.   0x1     /* UserData Pointer */
  372. };
  373.  
  374.  
  375. /****************************************************************************
  376.  *  Global Structures 
  377.  ***************************************************************************/
  378.  
  379. /* the newwindow structure used in starchart*/
  380. extern struct NewWindow nw;
  381. extern struct Window *w;
  382. extern FLOAT MaxPlus, MaxWhite;
  383. /*------------------- color table definitions ------------------*/
  384.  
  385. extern UWORD defaultCT[32], CTable[32], *ctabptr;
  386. extern struct ColorMap *cmap;
  387. extern struct ViewPort *vport;
  388.  
  389. /****************************************************************************
  390.  * External function definitions
  391.  ***************************************************************************/
  392. extern struct IntuiMessage *GetMsg();
  393.  
  394. /****************************************************************************
  395.  * Requester structure and global pointer to it's gadget list.
  396.  ***************************************************************************/
  397. struct Requester PaletteRequester;
  398.  
  399. /****************************************************************************
  400.  *               The Code part of the SetColors module.
  401.  ***************************************************************************/
  402. SetColors()
  403. {
  404.   BOOL cancelchosen;
  405.   LONG iflags;
  406.   struct RastPort *reqrp;
  407.   UWORD tempCTable[32];
  408.   short i;
  409.  
  410.   /* store the current colortable in case the user cancels */
  411.   for(i=0;i<32;i++) tempCTable[i] = CTable[i];
  412.  
  413.   /* fix the IDCMP flags to report requester set and clear */
  414.   iflags = nw.IDCMPFlags;
  415.   iflags |= REQCLEAR;
  416.   ModifyIDCMP(w,iflags);
  417.   
  418.       /* set the flags and body sizes for the proportional gadgets */
  419.  
  420.       propflags = r_prop.Flags = g_prop.Flags = b_prop.Flags = FREEHORIZ | AUTOKNOB;
  421.       propHbody = r_prop.HorizBody = g_prop.HorizBody = b_prop.HorizBody = 0x1000;
  422.  
  423.       /* initialize the Palettetude requester */ 
  424.       InitPalReq();
  425.  
  426.       /* Put up the requester  */ 
  427.       Request(&PaletteRequester,w);
  428.       
  429.       reqrp = PaletteRequester.ReqLayer->rp;
  430.  
  431.     /* initialize the palette */
  432.     initpalette(reqrp,4);
  433.     
  434.     /* add the brush color box */
  435.     DrawBorder(reqrp, &boxborder,0L,0L);
  436.     
  437.     SetAPen(reqrp,0L);
  438.     RectFill(reqrp,50L,35L,210L,49L); /* fill in brush color box */
  439.     PrintIText(reqrp,&brushtxt,1L,1L);
  440.  
  441.       /* zap the prop gadgets to reflect the current color value */
  442.       ModifyProp(&red_control,w,&PaletteRequester,propflags,
  443.                 (LONG)((CTable[0] & 0xf00) << 4),0L,propHbody,0L);
  444.       ModifyProp(&green_control,w,&PaletteRequester,propflags,
  445.                 (LONG)((CTable[0] & 0x0f0) << 8),0L,propHbody,0L);
  446.       ModifyProp(&blue_control,w,&PaletteRequester,propflags, 
  447.                 (LONG)(CTable[0] << 12),0L,propHbody,0L);
  448.       RefreshGadgets(&red_control,w,&PaletteRequester);
  449.  
  450.       /* let the user fill in the parameters and wait for a cancel or ok. */  
  451.       cancelchosen = WaitPaletteReq(reqrp);
  452.       
  453.       /* if the user cancelled, reset to the Palette that was saved       */
  454.       if (cancelchosen) 
  455.          { LoadRGB4(vport,&tempCTable[0],32L);
  456.            for(i=0;i<32;i++) CTable[i] = tempCTable[i];
  457.          }
  458.  
  459. } /* SetColors */
  460.  
  461. /*
  462.  *  Init the Palette requester
  463.  */
  464. InitPalReq()
  465.   struct RastPort *reqrp;
  466.   
  467.   InitRequester(&PaletteRequester);
  468.   PaletteRequester.LeftEdge  = 110;
  469.   PaletteRequester.TopEdge   = 12;
  470.   PaletteRequester.Width     = 260;
  471.   PaletteRequester.Height    = 145;
  472.   PaletteRequester.ReqGadget = &restPal;
  473.   PaletteRequester.ReqText   = NULL;
  474.   PaletteRequester.BackFill  = 2;
  475.   PaletteRequester.Flags     = 0;
  476.   PaletteRequester.ReqBorder = &PaletteReq_bord_2;
  477.   
  478. }
  479.  
  480. /* initialize palette - this will set up a pallette for any depth of */
  481. /* screen.                                                           */
  482. initpalette(rp,depth)
  483.    struct RastPort *rp;
  484.    SHORT depth;
  485.    {
  486.      SHORT i, j, c_rows, n_colors, c_per_row;
  487.      LONG x, y, bx, by, boxw, boxh, pen;
  488.  
  489.      n_colors = 1 << depth;
  490.      if (n_colors > 8) c_rows = 2;
  491.      else c_rows = 1;
  492.  
  493.      c_per_row = n_colors / c_rows;
  494.  
  495.      boxw = (LONG)paletteGadg.Width/c_per_row;
  496.      boxh = (LONG)paletteGadg.Height/c_rows;
  497.      pen = 0L;
  498.      for (j = 0; j < c_rows; j++)
  499.         {
  500.           for (i=0; i < c_per_row; i++, pen++)
  501.              {
  502.                SetAPen(rp,pen);
  503.                x = ((LONG)i * boxw) + (LONG)paletteGadg.LeftEdge ;
  504.                y = ((LONG)j * boxh) + (LONG)paletteGadg.TopEdge ;
  505.                bx = x + boxw -1L;
  506.                by = y + boxh -1L;
  507.                RectFill(rp,x,y,bx,by); /* fill in color box */
  508.              }
  509.          }
  510.  
  511.    }
  512.  
  513.  
  514.  
  515.   
  516. /****************************************************************************
  517.  *  WaitPaletteReq - permit user to change the values in the requester gadgets
  518.  *                 and check the values they install until either the 
  519.  *                 CANCEL gadget is clicked or the OK gadget is clicked AND
  520.  *                 there are no outstanding input errors
  521.  ***************************************************************************/
  522. BOOL WaitPaletteReq(reqrp)
  523. struct RastPort *reqrp;
  524. {
  525.   ULONG  class = GADGETDOWN;
  526.   struct IntuiMessage *message;
  527.   struct Gadget *gadget;
  528.   BOOL cancelflag = FALSE;
  529.   LONG  errorflag = 0L, checkPal();
  530.   LONG curpen, color;
  531.   SHORT mousex, mousey;
  532.   BOOL prophit = FALSE;
  533.  
  534.   curpen = 0L;
  535.   while (class != REQCLEAR)
  536.     {
  537.     if ((message=(struct IntuiMessage *) GetMsg(w->UserPort)) == 0L)
  538.       {
  539.       Wait(1L<<w->UserPort->mp_SigBit);
  540.       continue;
  541.       }
  542.  
  543.     class  = message->Class;
  544.     mousex = message->MouseX;
  545.     mousey = message->MouseY;
  546.     gadget = (struct Gadget *) message->IAddress;
  547.     ReplyMsg(message);
  548.     switch (class)
  549.       {
  550.       case GADGETDOWN:
  551.          switch (gadget->GadgetID)
  552.         {
  553.                case BLUECTLG:
  554.                    case GREENCTLG:
  555.                    case REDCTLG:
  556.                         prophit = TRUE;
  557.                         break;
  558.  
  559.                  }
  560.               break;
  561.  
  562.       case GADGETUP: 
  563.          switch (gadget->GadgetID)
  564.         {
  565.                     case PALETTEG:
  566.                         /* ignore if the mouse is over the same color*/
  567.                         mousex = mousex - (LONG)PaletteRequester.LeftEdge;
  568.                         mousey = mousey - (LONG)PaletteRequester.TopEdge;
  569.                         if(( color = (LONG)
  570.                              ReadPixel(reqrp,(LONG)mousex,(LONG)mousey))
  571.                              == curpen) break;
  572.  
  573.                         SetAPen(reqrp,color);
  574.                         curpen = color;
  575.                         /* fill in brush color box */
  576.                         RectFill(reqrp,50L,35L,210L,49L);
  577.                         PrintIText(reqrp,&brushtxt,1L,1L);
  578.                /* zap the prop gadgets to show the current color value */
  579.                   ModifyProp(&red_control,w,&PaletteRequester,propflags,
  580.                             (LONG)((CTable[curpen] & 0xf00) << 4),0L,propHbody,0L);
  581.                   ModifyProp(&green_control,w,&PaletteRequester,propflags,
  582.                         (LONG)((CTable[curpen] & 0x0f0) << 8),0L,propHbody,0L);
  583.                   ModifyProp(&blue_control,w,&PaletteRequester,propflags, 
  584.                         (LONG)(CTable[curpen] << 12),0L,propHbody,0L);
  585.                   RefreshGadgets(&red_control,w,&PaletteRequester);
  586.                         break;
  587.  
  588.                case BLUECTLG:
  589.                    case GREENCTLG:
  590.                    case REDCTLG:
  591.                         /*Set the colors*/
  592.                         SetRGB4(vport,curpen,
  593.                                 (LONG)(r_prop.HorizPot >> 12),
  594.                                 (LONG)(g_prop.HorizPot >> 12),
  595.                                 (LONG)(b_prop.HorizPot >> 12));
  596.                         /* save color in CTable  - can be output */
  597.                         /* if the user wants a custom color table*/
  598.                         CTable[curpen] =
  599.                                 ((r_prop.HorizPot >> 4) & 0xf00) +
  600.                                 ((g_prop.HorizPot >> 8) & 0xf0) +
  601.                                 (b_prop.HorizPot >> 12);
  602.                         prophit = FALSE;
  603.                          break;
  604.  
  605.  
  606.                 case  RESTRGAD:  /* restore default colors */
  607.                         CTable[0] = 0x05A; /* register 0 is dark blue     */
  608.                         CTable[1] = 0xFFF; /* register 1 is white         */
  609.                         CTable[2] = 0x002; /* register 2 is Black (almost)*/
  610.                         CTable[3] = 0xFFF; /* register 4 is white         */
  611.                         CTable[4] = 0xEEE; /* register 5 is darker        */
  612.                         CTable[5] = 0xDDD; /* register 6 is darker        */
  613.                         CTable[6] = 0xCCC; /* register 7 is darrker       */
  614.                         CTable[7] = 0xBBB; /* register 8 is darker        */
  615.                         CTable[8] = 0xAAA; /* register 9 is darker        */
  616.                         CTable[9] = 0x999; /* register 10 is darker       */
  617.                         CTable[10] = 0x888;/* register 11 is medium gray  */
  618.                         CTable[11] = 0xF11;/* reqister 3 is bright red -  */
  619.                         CTable[12] = 0x00B;/* register 12 is dark blue    */
  620.                         CTable[13] = 0xF0F;/* register 13 is magenta      */
  621.                         CTable[14] = 0xFFF;/* register 14 is also white   */
  622.                         CTable[15] = 0xF80;/* register 15 is Orange       */
  623.  
  624.                     /* change the registers to the new  colors */
  625.                     LoadRGB4(vport,&CTable,32L);
  626.                     
  627.                /* zap the prop gadgets to show the current color value */
  628.                   ModifyProp(&red_control,w,&PaletteRequester,propflags,
  629.                        (LONG)((CTable[curpen] & 0xf00) << 4),0L,propHbody,0L);
  630.                   ModifyProp(&green_control,w,&PaletteRequester,propflags,
  631.                     (LONG)((CTable[curpen] & 0x0f0) << 8),0L,propHbody,0L);
  632.                   ModifyProp(&blue_control,w,&PaletteRequester,propflags, 
  633.                     (LONG)(CTable[curpen] << 12),0L,propHbody,0L);
  634.                   RefreshGadgets(&red_control,w,&PaletteRequester);
  635.  
  636.             break;
  637.             
  638.         case  CANPALGAD : 
  639.                      cancelflag = TRUE;
  640.                              break; 
  641.  
  642.                    case  OKPALGAD  :
  643.                   if (errorflag == 0) 
  644.                      EndRequest(&PaletteRequester,w);
  645.                  else DisplayBeep(w->WScreen);    
  646.                  break;
  647.  
  648.              } /* end of GADGETUP switch */
  649.  
  650.          case MOUSEMOVE:
  651.                if (prophit == FALSE) break;
  652.                else  
  653.                      /*Set the colors*/
  654.                      SetRGB4(vport,curpen,
  655.                             (LONG)(r_prop.HorizPot >> 12),
  656.                                 (LONG)(g_prop.HorizPot >> 12),
  657.                                 (LONG)(b_prop.HorizPot >> 12));
  658.         break;
  659.  
  660.  
  661.         } /* end of CLASS switch */
  662.     }/* end of while loop */
  663.     
  664.  
  665. return(cancelflag);
  666.        
  667. } /* WaitPaletteReq */
  668.    
  669.