home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 550b.lha / Term_v1.8a / Source.LZH / ScreenPanel.c < prev    next >
C/C++ Source or Header  |  1991-07-17  |  17KB  |  627 lines

  1. /* $Revision Header * Header built automatically - do not edit! *************
  2.  *
  3.  *    (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
  4.  *
  5.  *    Name .....: ScreenPanel.c
  6.  *    Created ..: Monday 21-Jan-91 20:12
  7.  *    Revision .: 0
  8.  *
  9.  *    Date            Author          Comment
  10.  *    =========       ========        ====================
  11.  *    21-Jan-91       Olsen           Created this file!
  12.  *
  13.  * $Revision Header ********************************************************/
  14.  
  15. #include "TermGlobal.h"
  16.  
  17. enum    {    GAD_MODES,GAD_PALETTE,GAD_RED,GAD_GREEN,GAD_BLUE,GAD_MAKEPUBLIC,GAD_SHANGHAI,GAD_USE,GAD_CANCEL };
  18.  
  19. #define WIDTH    455
  20. #define HEIGHT    172
  21.  
  22.     /* The names of the 20 display modes. */
  23.  
  24. STATIC UBYTE *ModeNames[16] =
  25. {
  26.     "Hires",
  27.     "Hires Interlaced",
  28.     "Super Hires",
  29.     "Super Hires Interlaced",
  30.     "Productivity",
  31.     "Productivity Interlaced",
  32.  
  33.     "PAL Hires",
  34.     "PAL Hires Interlaced",
  35.     "PAL Super Hires",
  36.     "PAL Super Hires Interlaced",
  37.  
  38.     "NTSC Hires",
  39.     "NTSC Hires Interlaced",
  40.     "NTSC Super Hires",
  41.     "NTSC Super Hires Interlaced",
  42.  
  43.     "A2024 10 Hz",
  44.     "A2024 15 Hz"
  45. };
  46.  
  47. enum    { MEN_NEXT=1,MEN_PREV,MEN_COLOUR,MEN_RED,MEN_GREEN,MEN_BLUE,MEN_MAKEPUBLIC,MEN_SHANGHAI,MEN_USE,MEN_CANCEL,MEN_QUITPANEL };
  48.  
  49. STATIC struct NewMenu ScreenMenu[] =
  50. {
  51.     { NM_TITLE, "Project",             0 , 0, 0, (APTR)0},
  52.     {  NM_ITEM, "Next Mode",        "N", 0, 0, (APTR)MEN_NEXT},
  53.     {  NM_ITEM, "Previous Mode",        "P", 0, 0, (APTR)MEN_PREV},
  54.     {  NM_ITEM, NM_BARLABEL,         0 , 0, 0, (APTR)0},
  55.     {  NM_ITEM, "Colour",            "O", 0, 0, (APTR)MEN_COLOUR},
  56.     {  NM_ITEM, "Red",            "R", 0, 0, (APTR)MEN_RED},
  57.     {  NM_ITEM, "Green",            "G", 0, 0, (APTR)MEN_GREEN},
  58.     {  NM_ITEM, "Blue",            "B", 0, 0, (APTR)MEN_BLUE},
  59.     {  NM_ITEM, NM_BARLABEL,         0 , 0, 0, (APTR)0},
  60.     {  NM_ITEM, "Make Screen Public",    "M", 0, 0, (APTR)MEN_MAKEPUBLIC},
  61.     {  NM_ITEM, "`Shanghai' Windows",    "W", 0, 0, (APTR)MEN_SHANGHAI},
  62.     {  NM_ITEM, NM_BARLABEL,         0 , 0, 0, (APTR)0},
  63.     {  NM_ITEM, "Use",            "U", 0, 0, (APTR)MEN_USE},
  64.     {  NM_ITEM, "Cancel",            "C", 0, 0, (APTR)MEN_CANCEL},
  65.     {  NM_ITEM, NM_BARLABEL,         0 , 0, 0, (APTR)0},
  66.     {  NM_ITEM, "Quit",            "Q", 0, 0, (APTR)MEN_QUITPANEL},
  67.     { NM_END, 0,                 0 , 0, 0, (APTR)0}
  68. };
  69.  
  70. STATIC struct Node ModeNodes[16];
  71. STATIC struct List ModeList;
  72.  
  73. STATIC struct Gadget *
  74. CreateAllGadgets(LONG *ModeNumber,LONG *NumModes,struct Configuration *Config,struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
  75. {
  76.     struct Gadget        *Gadget;
  77.     struct NewGadget     NewGadget;
  78.     UWORD             Counter = 0;
  79.     BYTE             Count = 0,i,Mode;
  80.     BYTE             Limited;
  81.  
  82.     if(Gadget = CreateContext(GadgetList))
  83.     {
  84.         NewList(&ModeList);
  85.  
  86.         for(i = 0 ; i < 16 ; i++)
  87.             if(Config -> DisplayMode == ModeID[i])
  88.                 Mode = i;
  89.  
  90.         *NumModes = 0;
  91.  
  92.         if(Config -> ColourMode == COLOUR_EIGHT || Config -> ColourMode == COLOUR_SIXTEEN)
  93.             Limited = TRUE;
  94.         else
  95.             Limited = FALSE;
  96.  
  97.             /* This loop runs all possible display modes through `ModeNotAvailable'
  98.              * to determine which resolutions are not supported by the current
  99.              * monitor spec.
  100.              */
  101.  
  102.         for(i = 0 ; i < 16 ; i++)
  103.         {
  104.             if(!ModeNotAvailable(ModeID[i]))
  105.             {
  106.                 if(Limited)
  107.                 {
  108.                     if(((ModeID[i] & ~MONITOR_ID_MASK) == HIRES_KEY) || ((ModeID[i] & ~MONITOR_ID_MASK) == HIRESLACE_KEY))
  109.                     {
  110.                         ModeNodes[Count] . ln_Name = ModeNames[i];
  111.                         ModeNodes[Count] . ln_Type = i;
  112.  
  113.                         AddTail(&ModeList,&ModeNodes[Count++]);
  114.                     }
  115.                 }
  116.                 else
  117.                 {
  118.                     ModeNodes[Count] . ln_Name = ModeNames[i];
  119.                     ModeNodes[Count] . ln_Type = i;
  120.  
  121.                     AddTail(&ModeList,&ModeNodes[Count++]);
  122.                 }
  123.             }
  124.             else
  125.             {
  126.                 if(i == Mode)
  127.                     Mode = 0;
  128.             }
  129.         }
  130.  
  131.         *NumModes = Count;
  132.  
  133.         *ModeNumber = Mode;
  134.  
  135.         NewGadget . ng_Width        = 244;
  136.         NewGadget . ng_Height        = 60;
  137.         NewGadget . ng_GadgetText    = "Available Display Modes";
  138.         NewGadget . ng_TextAttr        = &DefaultFont;
  139.         NewGadget . ng_VisualInfo    = VisualInfo;
  140.         NewGadget . ng_GadgetID        = Counter;
  141.         NewGadget . ng_Flags        = NG_HIGHLABEL|PLACETEXT_LEFT;
  142.         NewGadget . ng_LeftEdge        = (strlen(NewGadget . ng_GadgetText) + 2) * 8 + 1;
  143.         NewGadget . ng_TopEdge        = 1 + TopEdge;
  144.  
  145.         GadgetArray[Counter++] = Gadget = CreateGadget(LISTVIEW_KIND,Gadget,&NewGadget,
  146.             GTLV_Labels,        &ModeList,
  147.             GTLV_ShowSelected,    NULL,
  148.             GTLV_Selected,        Mode,
  149.         TAG_DONE);
  150.  
  151.         NewGadget . ng_GadgetText    = "Edit Screen Palette";
  152.         NewGadget . ng_Width        = 244;
  153.         NewGadget . ng_Height        = 30;
  154.         NewGadget . ng_GadgetID        = Counter;
  155.         NewGadget . ng_TopEdge        = Gadget -> TopEdge + Gadget -> Height + 14;
  156.  
  157.         GadgetArray[Counter++] = Gadget = CreateGadget(PALETTE_KIND,Gadget,&NewGadget,
  158.             GTPA_Depth,        Config -> ColourMode == COLOUR_EIGHT ? 3 : Screen -> RastPort . BitMap -> Depth,
  159.             GTPA_Color,        0,
  160.             GTPA_IndicatorWidth,    NewGadget . ng_Width / (1 << 2),
  161.             GTPA_IndicatorHeight,    NewGadget . ng_Height,
  162.         TAG_DONE);
  163.  
  164.         NewGadget . ng_GadgetText    = "_Red   ";
  165.         NewGadget . ng_GadgetID        = Counter;
  166.         NewGadget . ng_Height        = 10;
  167.         NewGadget . ng_TopEdge        = Gadget -> TopEdge + Gadget -> Height + 31;
  168.  
  169.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  170.             GT_Underscore,        '_',
  171.             GTSL_Min,        0,
  172.             GTSL_Max,        15,
  173.             GTSL_Level,        0,
  174.             GTSL_LevelFormat,    "%2ld",
  175.             GTSL_MaxLevelLen,    2,
  176.         TAG_DONE);
  177.  
  178.         NewGadget . ng_GadgetText    = "_Green   ";
  179.         NewGadget . ng_GadgetID        = Counter;
  180.         NewGadget . ng_TopEdge        = Gadget -> TopEdge + Gadget -> Height + 2;
  181.  
  182.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  183.             GT_Underscore,        '_',
  184.             GTSL_Min,        0,
  185.             GTSL_Max,        15,
  186.             GTSL_Level,        0,
  187.             GTSL_LevelFormat,    "%2ld",
  188.             GTSL_MaxLevelLen,    2,
  189.         TAG_DONE);
  190.  
  191.         NewGadget . ng_GadgetText    = "_Blue   ";
  192.         NewGadget . ng_GadgetID        = Counter;
  193.         NewGadget . ng_TopEdge        = Gadget -> TopEdge + Gadget -> Height + 2;
  194.  
  195.         GadgetArray[Counter++] = Gadget = CreateGadget(SLIDER_KIND,Gadget,&NewGadget,
  196.             GT_Underscore,        '_',
  197.             GTSL_Min,        0,
  198.             GTSL_Max,        15,
  199.             GTSL_Level,        0,
  200.             GTSL_LevelFormat,    "%2ld",
  201.             GTSL_MaxLevelLen,    2,
  202.         TAG_DONE);
  203.  
  204.         NewGadget . ng_GadgetText    = "_Make Screen Public";
  205.         NewGadget . ng_GadgetID        = Counter;
  206.         NewGadget . ng_TopEdge        = Gadget -> TopEdge + Gadget -> Height + 4;
  207.  
  208.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  209.             GT_Underscore,    '_',
  210.             GTCB_Checked,    Config -> MakeScreenPublic,
  211.         TAG_DONE);
  212.  
  213.         NewGadget . ng_GadgetText    = "`Shanghai' _Windows";
  214.         NewGadget . ng_GadgetID        = Counter;
  215.         NewGadget . ng_TopEdge        = Gadget -> TopEdge + Gadget -> Height + 1;
  216.  
  217.         GadgetArray[Counter++] = Gadget = CreateGadget(CHECKBOX_KIND,Gadget,&NewGadget,
  218.             GT_Underscore,    '_',
  219.             GTCB_Checked,    Config -> ShanghaiWindows,
  220.         TAG_DONE);
  221.  
  222.         if(!Config -> MakeScreenPublic)
  223.             Gadget -> Flags |= GFLG_DISABLED;
  224.  
  225.         NewGadget . ng_Width        = 52;
  226.         NewGadget . ng_Height        = 12;
  227.         NewGadget . ng_GadgetText    = "_Use";
  228.         NewGadget . ng_GadgetID        = Counter;
  229.         NewGadget . ng_Flags        = 0;
  230.         NewGadget . ng_LeftEdge        = 10;
  231.         NewGadget . ng_TopEdge        = HEIGHT - 3 - NewGadget . ng_Height;
  232.  
  233.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  234.             GT_Underscore,    '_',
  235.         TAG_DONE);
  236.  
  237.         NewGadget . ng_GadgetText    = "_Cancel";
  238.         NewGadget . ng_GadgetID        = Counter;
  239.         NewGadget . ng_LeftEdge        = WIDTH - 10 - NewGadget . ng_Width;
  240.  
  241.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  242.             GT_Underscore,    '_',
  243.         TAG_DONE);
  244.     }
  245.  
  246.     return(Gadget);
  247. }
  248.  
  249. BYTE
  250. ScreenPanel(struct Configuration *MyConfig)
  251. {
  252.     struct Window    *PanelWindow;
  253.     struct Menu    *PanelMenu;
  254.     struct Gadget    *GadgetList;
  255.     struct Gadget    *GadgetArray[GAD_CANCEL + 1];
  256.     LONG         ModeNumber,NumModes;
  257.  
  258.     SHORT         i;
  259.  
  260.     CopyMem(MyConfig,&PrivateConfig,sizeof(struct Configuration));
  261.  
  262.     if(CreateAllGadgets(&ModeNumber,&NumModes,MyConfig,&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
  263.     {
  264.         if(PanelMenu = CreateMenus(ScreenMenu,
  265.             GTMN_FrontPen, 0,
  266.         TAG_DONE))
  267.         {
  268.             if(LayoutMenus(PanelMenu,VisualInfo,
  269.                 GTMN_TextAttr,&DefaultFont,
  270.             TAG_DONE))
  271.             {
  272.                 if(PanelWindow = OpenWindowTags(NULL,
  273.                     WA_Left,    (Screen -> Width - WIDTH) >> 1,
  274.                     WA_Top,        (Screen -> Height - HEIGHT) >> 1,
  275.                     WA_Width,    WIDTH,
  276.                     WA_Height,    HEIGHT,
  277.  
  278.                     WA_Activate,    TRUE,
  279.                     WA_DragBar,    TRUE,
  280.                     WA_DepthGadget,    TRUE,
  281.                     WA_RMBTrap,    TRUE,
  282.                     WA_DepthGadget,    TRUE,
  283.                     WA_CloseGadget,    TRUE,
  284.                     WA_CustomScreen,Screen,
  285.  
  286.                     WA_IDCMP,    IDCMP_CLOSEWINDOW | SLIDERIDCMP | CHECKBOXIDCMP | LISTVIEWIDCMP | IDCMP_MENUPICK,
  287.  
  288.                     WA_Title,    "Screen Preferences",
  289.                 TAG_DONE))
  290.                 {
  291.                     struct IntuiMessage    *Massage;
  292.                     ULONG             Class,Code;
  293.                     struct Gadget        *Gadget;
  294.                     BYTE             Terminated = FALSE;
  295.  
  296.                     LONG             ColourNumber = 0;
  297.                     BYTE             Red,Green,Blue;
  298.  
  299.                     PushWindow(PanelWindow);
  300.  
  301.                     Red    = (MyConfig -> Colours[ColourNumber] >> 8) & 0xF;
  302.                     Green    = (MyConfig -> Colours[ColourNumber] >> 4) & 0xF;
  303.                     Blue    = (MyConfig -> Colours[ColourNumber]     ) & 0xF;
  304.  
  305.                     AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  306.                     RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  307.                     GT_RefreshWindow(PanelWindow,NULL);
  308.  
  309.                     GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  310.                         GTSL_Level,Red,
  311.                     TAG_DONE);
  312.  
  313.                     GT_SetGadgetAttrs(GadgetArray[GAD_GREEN],PanelWindow,NULL,
  314.                         GTSL_Level,Green,
  315.                     TAG_DONE);
  316.  
  317.                     GT_SetGadgetAttrs(GadgetArray[GAD_BLUE],PanelWindow,NULL,
  318.                         GTSL_Level,Blue,
  319.                     TAG_DONE);
  320.  
  321.                     SetMenuStrip(PanelWindow,PanelMenu);
  322.  
  323.                     PanelWindow -> Flags &= ~WFLG_RMBTRAP;
  324.  
  325.                     while(!Terminated)
  326.                     {
  327.                         WaitPort(PanelWindow -> UserPort);
  328.  
  329.                         while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  330.                         {
  331.                             Class    = Massage -> Class;
  332.                             Code    = Massage -> Code;
  333.                             Gadget    = (struct Gadget *)Massage -> IAddress;
  334.  
  335.                             GT_ReplyIMsg(Massage);
  336.  
  337.                             if(Class == IDCMP_MENUPICK)
  338.                             {
  339.                                 struct MenuItem *MenuItem;
  340.  
  341.                                 while(Code != MENUNULL)
  342.                                 {
  343.                                     MenuItem = ItemAddress(PanelMenu,Code);
  344.  
  345.                                     switch((ULONG)MENU_USERDATA(MenuItem))
  346.                                     {
  347.                                         case MEN_QUITPANEL:    Class = IDCMP_CLOSEWINDOW;
  348.                                                     break;
  349.  
  350.                                         case MEN_NEXT:        if(ModeNumber == NumModes - 1)
  351.                                                         ModeNumber = 0;
  352.                                                     else
  353.                                                         ModeNumber++;
  354.  
  355.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_MODES],PanelWindow,NULL,
  356.                                                         GTLV_Selected,ModeNumber,
  357.                                                     TAG_DONE);
  358.  
  359.                                                     MyConfig -> DisplayMode = ModeID[ModeNumber];
  360.  
  361.                                                     break;
  362.  
  363.                                         case MEN_PREV:        if(ModeNumber == 0)
  364.                                                         ModeNumber = NumModes - 1;
  365.                                                     else
  366.                                                         ModeNumber--;
  367.  
  368.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_MODES],PanelWindow,NULL,
  369.                                                         GTLV_Selected,ModeNumber,
  370.                                                     TAG_DONE);
  371.  
  372.                                                     MyConfig -> DisplayMode = ModeID[ModeNumber];
  373.  
  374.                                                     break;
  375.  
  376.                                         case MEN_COLOUR:    switch(MyConfig -> ColourMode)
  377.                                                     {
  378.                                                         case COLOUR_EIGHT:    if(ColourNumber == 7)
  379.                                                                         ColourNumber = 0;
  380.                                                                     else
  381.                                                                         ColourNumber++;
  382.  
  383.                                                                     break;
  384.  
  385.                                                         default:        if(ColourNumber == (1 << Screen -> RastPort . BitMap -> Depth) - 1)
  386.                                                                         ColourNumber = 0;
  387.                                                                     else
  388.                                                                         ColourNumber++;
  389.  
  390.                                                                     break;
  391.                                                     }
  392.  
  393.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_PALETTE],PanelWindow,NULL,
  394.                                                         GTPA_Color,ColourNumber,
  395.                                                     TAG_DONE);
  396.  
  397.                                                     goto SetPalette;
  398.  
  399.                                         case MEN_RED:        if(Red == 15)
  400.                                                         Red = 0;
  401.                                                     else
  402.                                                         Red++;
  403.  
  404.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  405.                                                         GTSL_Level,Red,
  406.                                                     TAG_DONE);
  407.  
  408.                                                     SetRGB4(VPort,ColourNumber,Red,Green,Blue);
  409.  
  410.                                                     MyConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  411.                                                     break;
  412.  
  413.                                         case MEN_GREEN:        if(Green == 15)
  414.                                                         Green = 0;
  415.                                                     else
  416.                                                         Green++;
  417.  
  418.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  419.                                                         GTSL_Level,Red,
  420.                                                     TAG_DONE);
  421.  
  422.                                                     SetRGB4(VPort,ColourNumber,Red,Green,Blue);
  423.  
  424.                                                     MyConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  425.                                                     break;
  426.  
  427.                                         case MEN_BLUE:        if(Blue == 15)
  428.                                                         Blue = 0;
  429.                                                     else
  430.                                                         Blue++;
  431.  
  432.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  433.                                                         GTSL_Level,Red,
  434.                                                     TAG_DONE);
  435.  
  436.                                                     SetRGB4(VPort,ColourNumber,Red,Green,Blue);
  437.  
  438.                                                     MyConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  439.                                                     break;
  440.  
  441.                                         case MEN_MAKEPUBLIC:    Class = IDCMP_GADGETUP;
  442.                                                     Gadget = GadgetArray[GAD_MAKEPUBLIC];
  443.  
  444.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_MAKEPUBLIC],PanelWindow,NULL,
  445.                                                         GTCB_Checked,GadgetArray[GAD_MAKEPUBLIC] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
  446.                                                     TAG_DONE);
  447.  
  448.                                                     break;
  449.  
  450.                                         case MEN_SHANGHAI:    if(!(GadgetArray[GAD_SHANGHAI] -> Flags & GFLG_DISABLED))
  451.                                                     {
  452.                                                         Class = IDCMP_GADGETUP;
  453.                                                         Gadget = GadgetArray[GAD_SHANGHAI];
  454.  
  455.                                                         GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  456.                                                             GTCB_Checked,GadgetArray[GAD_SHANGHAI] -> Flags & GFLG_SELECTED ? FALSE : TRUE,
  457.                                                         TAG_DONE);
  458.                                                     }
  459.                                                     break;
  460.  
  461.                                         case MEN_USE:        Class = IDCMP_GADGETUP;
  462.                                                     Gadget = GadgetArray[GAD_USE];
  463.                                                     break;
  464.  
  465.                                         case MEN_CANCEL:    Class = IDCMP_GADGETUP;
  466.                                                     Gadget = GadgetArray[GAD_CANCEL];
  467.                                                     break;
  468.  
  469.                                         default:        break;
  470.                                     }
  471.  
  472.                                     Code = MenuItem -> NextSelect;
  473.                                 }
  474.                             }
  475.  
  476.                             if(Class == IDCMP_CLOSEWINDOW)
  477.                                 Terminated = TRUE;
  478.  
  479.                             if(Class == IDCMP_MOUSEMOVE)
  480.                             {
  481.                                 switch(Gadget -> GadgetID)
  482.                                 {
  483.                                     case GAD_RED:        Red = Code;
  484.  
  485.                                                 SetRGB4(VPort,ColourNumber,Red,Green,Blue);
  486.  
  487.                                                 MyConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  488.  
  489.                                                 break;
  490.  
  491.                                     case GAD_GREEN:        Green = Code;
  492.  
  493.                                                 SetRGB4(VPort,ColourNumber,Red,Green,Blue);
  494.  
  495.                                                 MyConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  496.  
  497.                                                 break;
  498.  
  499.                                     case GAD_BLUE:        Blue = Code;
  500.  
  501.                                                 SetRGB4(VPort,ColourNumber,Red,Green,Blue);
  502.  
  503.                                                 MyConfig -> Colours[ColourNumber] = (Red << 8) | (Green << 4) | (Blue);
  504.  
  505.                                                 break;
  506.  
  507.                                     default:        break;
  508.                                 }
  509.                             }
  510.  
  511.                             if(Class == IDCMP_GADGETUP)
  512.                             {
  513.                                 switch(Gadget -> GadgetID)
  514.                                 {
  515.                                     case GAD_MAKEPUBLIC:    if(!(Gadget -> Flags & GFLG_SELECTED))
  516.                                                 {
  517.                                                     GadgetArray[GAD_SHANGHAI] -> Flags &= ~GFLG_SELECTED;
  518.  
  519.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  520.                                                         GA_Disabled,TRUE,
  521.                                                     TAG_DONE);
  522.                                                 }
  523.                                                 else
  524.                                                 {
  525.                                                     GT_SetGadgetAttrs(GadgetArray[GAD_SHANGHAI],PanelWindow,NULL,
  526.                                                         GA_Disabled,FALSE,
  527.                                                     TAG_DONE);
  528.                                                 }
  529.  
  530.                                                 break;
  531.  
  532.                                     case GAD_MODES:        MyConfig -> DisplayMode = ModeID[Code];
  533.                                                 ModeNumber = Code;
  534.                                                 break;
  535.  
  536.                                     case GAD_PALETTE:    ColourNumber = Code;
  537.  
  538. SetPalette:                                            MyConfig -> Colours[ColourNumber] = GetRGB4(VPort -> ColorMap,ColourNumber);
  539.  
  540.                                                 Red    = (MyConfig -> Colours[ColourNumber] >> 8) & 0xF;
  541.                                                 Green    = (MyConfig -> Colours[ColourNumber] >> 4) & 0xF;
  542.                                                 Blue    = (MyConfig -> Colours[ColourNumber]     ) & 0xF;
  543.  
  544.                                                 GT_SetGadgetAttrs(GadgetArray[GAD_RED],PanelWindow,NULL,
  545.                                                     GTSL_Level,Red,
  546.                                                 TAG_DONE);
  547.  
  548.                                                 GT_SetGadgetAttrs(GadgetArray[GAD_GREEN],PanelWindow,NULL,
  549.                                                     GTSL_Level,Green,
  550.                                                 TAG_DONE);
  551.  
  552.                                                 GT_SetGadgetAttrs(GadgetArray[GAD_BLUE],PanelWindow,NULL,
  553.                                                     GTSL_Level,Blue,
  554.                                                 TAG_DONE);
  555.  
  556.                                                 break;
  557.  
  558.                                     case GAD_USE:        Terminated = TRUE;
  559.  
  560.                                                 if(MyConfig -> ColourMode == COLOUR_EIGHT)
  561.                                                 {
  562.                                                     for(i = 0 ; i < 8 ; i++)
  563.                                                         MyConfig -> Colours[i + 8] = MyConfig -> Colours[i];
  564.                                                 }
  565.  
  566.                                                 if(MyConfig == &Config)
  567.                                                 {
  568.                                                     CopyMem(&MyConfig -> Colours[0],&BlinkColours[0],sizeof(UWORD) * 16);
  569.  
  570.                                                     switch(MyConfig -> ColourMode)
  571.                                                     {
  572.                                                         case COLOUR_EIGHT:    for(i = 0 ; i < 8 ; i++)
  573.                                                                         BlinkColours[i + 8] = BlinkColours[0];
  574.  
  575.                                                                     break;
  576.  
  577.                                                         case COLOUR_SIXTEEN:    break;
  578.  
  579.                                                         case COLOUR_AMIGA:
  580.                                                         default:        BlinkColours[3] = BlinkColours[0];
  581.                                                                     break;
  582.                                                     }
  583.                                                 }
  584.  
  585.                                                 MyConfig -> MakeScreenPublic    = GadgetArray[GAD_MAKEPUBLIC] -> Flags & GFLG_SELECTED;
  586.                                                 MyConfig -> ShanghaiWindows    = GadgetArray[GAD_SHANGHAI] -> Flags & GFLG_SELECTED;
  587.  
  588.                                                 break;
  589.  
  590.                                     case GAD_CANCEL:    Terminated = TRUE;
  591.  
  592.                                                 CopyMem(&PrivateConfig,MyConfig,sizeof(struct Configuration));
  593.  
  594.                                                 LoadRGB4(VPort,&MyConfig -> Colours[0],16);
  595.  
  596.                                                 break;
  597.  
  598.                                     default:        break;
  599.                                 }
  600.                             }
  601.                         }
  602.                     }
  603.  
  604.                     PanelWindow -> Flags |= WFLG_RMBTRAP;
  605.  
  606.                     ClearMenuStrip(PanelWindow);
  607.  
  608.                     RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  609.  
  610.                     PopWindow();
  611.  
  612.                     CloseWindow(PanelWindow);
  613.                 }
  614.             }
  615.  
  616.             FreeMenus(PanelMenu);
  617.         }
  618.  
  619.         FreeGadgets(GadgetList);
  620.     }
  621.  
  622.     if(PrivateConfig . DisplayMode != MyConfig -> DisplayMode)
  623.         return(TRUE);
  624.     else
  625.         return(FALSE);
  626. }
  627.