home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d510 / atcopy.lha / ATCopy / NewIntroD.c < prev    next >
C/C++ Source or Header  |  1991-06-29  |  5KB  |  213 lines

  1. /* INCLUDES ********************************************************** */
  2.  
  3. #include <exec/types.h>
  4. #include <exec/io.h>
  5. #include <exec/memory.h>
  6. #include <libraries/dos.h>
  7. #include <intuition/intuition.h>
  8.  
  9.  
  10. /* get the PowerWindows 2.0 code */
  11. #include "NewIntroD.h"
  12.  
  13.  
  14. #define UNSELECT 0xff7f /* ~SELECTED */
  15.  
  16. #define Flag_B    'B'
  17. #define Flag_NC   'N'
  18. #define Flag_CR   'C'
  19. #define Flag_none '\0'
  20.  
  21. char Intro(char **pc,char *Option)
  22. {
  23.     USHORT              quit_flag = FALSE;
  24.     UWORD               code;
  25.     ULONG               class;
  26.     char                opt;
  27.     LONG                gnr,flag = FALSE;
  28.     struct Gadget       *gpt,*oldG;
  29.     struct StringInfo   *SI;
  30.  
  31.     struct Window       *wG;    /* we fetch the RastPort pointer from here */
  32.     struct RastPort     *rpG;
  33.     struct IntuiMessage *message;    /* the message the IDCMP sends us */
  34.  
  35.     none.Flags &= UNSELECT;
  36.     CR.Flags &= UNSELECT;
  37.     NC.Flags &= UNSELECT;
  38.     B.Flags &= UNSELECT;
  39.  
  40.     switch(*Option)
  41.     {
  42.         case 'N':
  43.         case 'n':    NC.Flags |= SELECTED;
  44.                 oldG = &NC;
  45.                 break;
  46.  
  47.         case 'C':
  48.         case 'c':    CR.Flags |= SELECTED;
  49.                 oldG = &CR;
  50.                 break;
  51.  
  52.         case 'B':
  53.         case 'b':    B.Flags |= SELECTED;
  54.                 oldG = &B;
  55.                 break;
  56.  
  57.         default:    none.Flags |= SELECTED;
  58.                 oldG = &none;
  59.                 break;
  60.     }
  61.     OK.NextGadget = &ABORT;
  62.     PATH.NextGadget = &OK;
  63.     B.NextGadget = &PATH;
  64.     CR.NextGadget = &B;
  65.     NC.NextGadget = &CR;
  66.     none.NextGadget = &NC;
  67.     NewWindowStructure1.FirstGadget = &none;
  68.     SI = (struct StringInfo *) PATH.SpecialInfo;
  69.     strncpy((char *) SI->Buffer,*pc,19);
  70.     SI->Buffer[19] = '\0';
  71.     
  72.     wG = (struct Window *) OpenWindow(&NewWindowStructure1);    /* open the window */
  73.     if ( wG == NULL )
  74.     {
  75.         return((char) 255);
  76.     }
  77.  
  78.     rpG = wG->RPort;    /* get a rastport pointer for the window */
  79.  
  80.     PrintIText(rpG,&IntuiTextList1,0L,0L);    /* Print the text if there is */
  81.     do
  82.     {
  83.         WaitPort(wG->UserPort);
  84.             while( (message = (struct IntuiMessage *)
  85.                 GetMsg(wG->UserPort) ) != NULL)
  86.             {
  87.                 code = message->Code;  /* MENUNUM */
  88.                 gpt = (struct Gadget *) message->IAddress;  /* Gadget */
  89.                 class = message->Class;
  90.                 RefreshGadgets(wG->FirstGadget,wG,NULL);
  91.                 ReplyMsg((struct Message *) message);
  92.                 if ( class == CLOSEWINDOW )
  93.                 {
  94.                     quit_flag = TRUE;
  95.                     flag = FALSE;
  96.                 }
  97.  
  98.                 if (( class == GADGETUP ) ||    /* Gagdets */
  99.                     ( class == GADGETDOWN ))
  100.                 {
  101.                     gnr = gpt->GadgetID;
  102.                     switch(gnr)
  103.                     {
  104.                         case 1:
  105.                         case 2:
  106.                         case 3:
  107.                         case 4:    RemoveGadget(wG,(struct Gadget *) &none);
  108.                             RemoveGadget(wG,(struct Gadget *) &CR);
  109.                             RemoveGadget(wG,(struct Gadget *) &NC);
  110.                             RemoveGadget(wG,(struct Gadget *) &B);
  111.                             oldG->Flags &= UNSELECT;
  112.                             AddGadget(wG,(struct Gadget *) &none,0);
  113.                             AddGadget(wG,(struct Gadget *) &CR,0);
  114.                             AddGadget(wG,(struct Gadget *) &NC,0);
  115.                             AddGadget(wG,(struct Gadget *) &B,0);
  116.                             RefreshGadgets(wG->FirstGadget,wG,NULL);
  117.                             if (none.Flags < SELECTED && CR.Flags < SELECTED 
  118.                                 && NC.Flags < SELECTED && B.Flags < SELECTED)
  119.                             {
  120.                                 oldG = &none;
  121.                                 RemoveGadget(wG,oldG);
  122.                                 RemoveGadget(wG,(struct Gadget *) &CR);
  123.                                 RemoveGadget(wG,(struct Gadget *) &NC);
  124.                                 RemoveGadget(wG,(struct Gadget *) &B);
  125.                                 oldG->Flags |= SELECTED;
  126.                                 AddGadget(wG,oldG,0);
  127.                                 AddGadget(wG,(struct Gadget *) &CR,0);
  128.                                 AddGadget(wG,(struct Gadget *) &NC,0);
  129.                                 AddGadget(wG,(struct Gadget *) &B,0);
  130.                                 RefreshGadgets(wG->FirstGadget,wG,NULL);
  131.                             }
  132.                             else
  133.                             {
  134.                                 oldG = gpt;
  135.                             }
  136.                             break;
  137.                         
  138.                         case 6: flag = TRUE;
  139.                             quit_flag = TRUE;
  140.                             break;
  141.                         
  142.                         case 7:    flag = FALSE;
  143.                             quit_flag = TRUE;
  144.                             break;
  145.  
  146.                         default:    ActivateGadget((struct Gadget *) &PATH,wG,NULL);
  147.                                 RefreshGadgets(wG->FirstGadget,wG,NULL);
  148.                     }
  149.                 }
  150.             }
  151.     }
  152.     while (quit_flag == FALSE);
  153.  
  154.     if (flag == FALSE)
  155.     {
  156.         CloseWindow(wG);
  157.         return((char) 255);
  158.         }
  159.     if (none.Flags >= SELECTED)
  160.     {
  161.         opt = Flag_none;
  162.     }
  163.     if (CR.Flags >= SELECTED)
  164.     {
  165.         opt = Flag_CR;
  166.     }
  167.     if (NC.Flags >= SELECTED)
  168.     {
  169.         opt = Flag_NC;
  170.     }
  171.     if (B.Flags >= SELECTED)
  172.     {
  173.         opt = Flag_B;
  174.     }
  175.     SI = (struct StringInfo *) PATH.SpecialInfo;
  176.     strcpy(*pc,(char *) SI->Buffer);
  177.  
  178.     CloseWindow(wG);
  179.     return(opt);
  180. }
  181.  
  182. struct AlertMessage
  183. {
  184.     SHORT LeftEdge;
  185.     BYTE  TopEdge;
  186.     char  AlertText[50];
  187.     BYTE  Flag;
  188. };
  189.  
  190. struct AlertMessage TimeOut[] =
  191. {
  192.     50, 24, "Achtung der PC/AT hat das letzte Datenpaket nicht", 255,
  193.     50, 34, "( richtig ? ) beantwortet.                       ", 255,
  194.     50, 44, "Daher wurde der Datentransfer eingestellt.       ", 255,
  195.     50, 64, "           Weiter mit linker / rechter Maustaste!", 0
  196. };
  197.  
  198. struct AlertMessage NoLib[] =
  199. {
  200.     50, 24, "Achtung, ich kann keine PC/AT Karte finden ?     ", 255,
  201.     50, 44, "Daher wurde das Programm abgebrochen!            ", 255,
  202.     50, 64, "           Weiter mit linker / rechter Maustaste!", 0
  203. };
  204.  
  205. extern char *CLI_Help =
  206.  "Datei(en) TO PC-pfad OPT [NC] keine Zeichensatzkonversion, aber LF in CRLF umwandeln\
  207. \n                         [CR] keine Umwandlung von LF in CRLF, aber Zeichensatzkonversion\
  208. \n                         [B]  bedeutet beides [NC] und [CR];\
  209. \n                         Aufruf ohne Optionen => Volle Konversion\n";
  210.  
  211. extern char *CLI_Template = "Datei(en)/...,TO/K,OPT/K";
  212.  
  213.