home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Workbench / Pilotes / DisqueDur / Format64.lha / Format64 / Source / GetPrepInput.c < prev    next >
C/C++ Source or Header  |  1998-04-20  |  4KB  |  167 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <intuition/intuition.h>
  4. #include <dos/dos.h>
  5. #include <dos/filehandler.h>
  6. #include <workbench/startup.h>
  7. #include <libraries/gadtools.h>
  8. #include <workbench/icon.h>
  9. #include <devices/trackdisk.h>
  10. #include <dos/rdargs.h>
  11.  
  12. /*Prototypes for system functions*/
  13. #include <proto/exec.h>
  14. #include <proto/intuition.h>
  15. #include <proto/dos.h>
  16. #include <proto/gadtools.h>
  17. #include <proto/icon.h>
  18. #include <proto/graphics.h>
  19.  
  20. /*Other headers*/
  21. #include "Format.h"
  22. #include "gui.h"
  23. #include "string.h"
  24. #include "stdio.h"
  25.  
  26. extern BOOL FFS = FALSE;
  27. extern BOOL QuickFmt = FALSE;
  28. extern BOOL Verify = TRUE;
  29. extern BOOL Icon = TRUE;
  30. extern struct Library *ibase = NULL;
  31. extern struct Library *gbase = NULL;
  32. extern struct Library *GadToolsBase = NULL;
  33. extern struct Library *IconBase = NULL;
  34. extern BPTR StdErr = NULL;
  35. extern LONG args[6] = { NULL,NULL,0,0,0,0 };
  36. //extern Rect box;
  37. extern struct WBStartup *WBenchMsg;
  38.  
  39. /*Get input from the original window*/
  40. prepResult getPrepInput(void)
  41.     {
  42.    struct IntuiMessage *mesg;
  43.    ULONG class;
  44.    ULONG code;
  45.    struct Gadget *gadget;
  46.    struct TagItem tags[2];
  47.  
  48.    /*Setup tags that will be used to toggle the states of checkbox gadgets*/
  49.    tags[0].ti_Tag=GTCB_Checked;
  50.    tags[1].ti_Tag=TAG_DONE;
  51.    tags[1].ti_Data=NULL;
  52.  
  53.    /*Loop until the user presses 'OK' or 'Cancel'*/
  54.    for(;;)
  55.        {
  56.       /*Wait for input*/
  57.       Wait(1<<PrepWnd->UserPort->mp_SigBit);
  58.  
  59.       /*Get the input*/
  60.       mesg=GT_GetIMsg(PrepWnd->UserPort);
  61.  
  62.       /*Loop while there are messages to be processed*/
  63.       while(mesg != NULL)
  64.             {
  65.             /*Get the message type, etc.*/
  66.             class=mesg->Class;
  67.             code=mesg->Code;
  68.             gadget=(struct Gadget *)mesg->IAddress;
  69.  
  70.             /*Reply to the message*/
  71.             GT_ReplyIMsg(mesg);
  72.  
  73.             /*Act on the message*/
  74.             switch(class)
  75.                 {
  76.                 /*User clicked on close gadget.  Treat it as a click on 'Cancel'*/
  77.                 case CLOSEWINDOW:
  78.                     return(eQuit);
  79.  
  80.                 /*User pressed a gadget*/
  81.                 case GADGETUP:
  82.                     switch(gadget->GadgetID)
  83.                         {
  84.                         /*Checkbox gadgets*/
  85.                         /*(each toggles the appropriate status flag)*/
  86.                         case GD_FFSGadget:
  87.                             FFS=!FFS;
  88.                             break;
  89.                         case GD_IconGadget:
  90.                             Icon=!Icon;
  91.                             break;
  92.                         case GD_QuickFmtGadget:
  93.                             QuickFmt=!QuickFmt;
  94.                             break;
  95.                         case GD_VerifyGadget:
  96.                             Verify=!Verify;
  97.                             break;
  98.  
  99.                         /*OK*/
  100.                         case GD_OKGadget:
  101.                             return(eOK);
  102.  
  103.                         /*Cancel*/
  104.                         case GD_CancelGadget:
  105.                             return(eCancel);
  106.                         }
  107.                     break;
  108.  
  109.                     /*Keypress (gadget equivalents)*/
  110.                 case VANILLAKEY:
  111.                     switch(code)
  112.                         {
  113.                         /*Disk name*/
  114.                         case 'n':
  115.                         case 'N':
  116.                             ActivateGadget(PrepGadgets[GD_NameGadget], PrepWnd,NULL);
  117.                             break;
  118.  
  119.                         /*FFS*/
  120.                         case 'f':
  121.                         case 'F':
  122.                             tags[0].ti_Data=(FFS=!FFS);
  123.                             /*Toggle the checkmark state of the gadget*/
  124.                             GT_SetGadgetAttrsA(PrepGadgets[GD_FFSGadget], PrepWnd,NULL, tags);
  125.                             break;
  126.  
  127.                         /*Verify*/
  128.                         case 'v':
  129.                         case 'V':
  130.                             tags[0].ti_Data=(Verify=!Verify);
  131.                             GT_SetGadgetAttrsA(PrepGadgets[GD_VerifyGadget], PrepWnd,NULL, tags);
  132.                             break;
  133.  
  134.                         /*Quick Format*/
  135.                         case 'q':
  136.                         case 'Q':
  137.                             tags[0].ti_Data=(QuickFmt=!QuickFmt);
  138.                             GT_SetGadgetAttrsA(PrepGadgets[GD_QuickFmtGadget], PrepWnd,NULL, tags);
  139.                             break;
  140.  
  141.                         /*Create icons*/
  142.                         case 'r':
  143.                         case 'R':
  144.                             tags[0].ti_Data=(Icon=!Icon);
  145.                             GT_SetGadgetAttrsA(PrepGadgets[GD_IconGadget], PrepWnd,NULL, tags);
  146.                             break;
  147.  
  148.                         /*Cancel*/
  149.                         case 'c':
  150.                         case 'C':
  151.                             return(eCancel);
  152.  
  153.                         /*OK*/
  154.                         case 'o':
  155.                         case 'O':
  156.                             return(eOK);
  157.                         }
  158.                     break;
  159.                 }
  160.             /*Get the next message*/
  161.             mesg=GT_GetIMsg(PrepWnd->UserPort);
  162.             }
  163.         }
  164.     return(FALSE);
  165.     }
  166.  
  167.