home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / dev / dropbox-1.1.lha / DropBox / src / DropEdit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-07  |  25.7 KB  |  1,081 lines

  1. /** DoRev Header ** Do not edit! **
  2. *
  3. * Name             :  DropEdit.c
  4. * Copyright        :  Copyright 1993 Steve Anichini. All Rights Reserved.
  5. * Creation date    :  26-Jun-93
  6. * Translator       :  SAS/C 5.1b
  7. *
  8. * Date       Rev  Author               Comment
  9. * ---------  ---  -------------------  ----------------------------------------
  10. * 15-Jul-93    2  Steve Anichini       Added editing of pattern list
  11. * 26-Jun-93    1  Steve Anichini       Split DropBox.c into DropBox.c and DropE
  12. * 26-Jun-93    0  Steve Anichini       Dummy
  13. *
  14. *** DoRev End **/
  15.  
  16. #include "DropBox.h"
  17. #include "window.h"
  18.  
  19. struct DBNode *curnode = NULL;
  20. struct PatNode *curpat = NULL;
  21. struct DBNode *Clip = NULL;
  22. UWORD LastSelected = 0;
  23.  
  24. void UpdateGadgets()
  25. {
  26.     struct Gadget *temp = NULL;
  27.     
  28.     if(curnode)
  29.     {
  30.         temp = FindGad(GD_Dest);
  31.                 
  32.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTST_String, 
  33.             (ULONG) curnode->db_Dest, TAG_END);
  34.             
  35.         temp = FindGad(GD_Command);
  36.                 
  37.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTST_String,
  38.             (ULONG) curnode->db_Com, TAG_END);
  39.             
  40.         temp = FindGad(GD_Template);
  41.             
  42.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTST_String,
  43.             (ULONG) curnode->db_Template, TAG_END);
  44.  
  45.         temp = FindGad(GD_Suppress);
  46.  
  47.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTCB_Checked,
  48.             (ULONG) !(curnode->db_Flags & DFLG_SUPOUTPUT), TAG_END);
  49.  
  50.         temp = FindGad(GD_Create);
  51.  
  52.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTCB_Checked,
  53.             (ULONG) curnode->db_Flags & DFLG_CREATE, TAG_END);
  54.  
  55.     }
  56.     else
  57.     {
  58.         temp = FindGad(GD_Dest);
  59.  
  60.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTST_String,
  61.             (ULONG) "", TAG_END);
  62.  
  63.         temp = FindGad(GD_Command);
  64.  
  65.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTST_String,
  66.             (ULONG) "", TAG_END);
  67.  
  68.         temp = FindGad(GD_Template);
  69.  
  70.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTST_String,
  71.             (ULONG) "", TAG_END);
  72.  
  73.         temp = FindGad(GD_Suppress);
  74.  
  75.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTCB_Checked,
  76.             (ULONG) FALSE, TAG_END);
  77.  
  78.         temp = FindGad(GD_Create);
  79.  
  80.         GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTCB_Checked,
  81.             (ULONG) FALSE, TAG_END);
  82.     }
  83. }
  84.  
  85. void UpdateDB()
  86. {
  87.     if(curnode)
  88.     {
  89.         if(stricmp(curnode->db_Dest, GetString(FindGad(GD_Dest))))
  90.             modified = TRUE;
  91.  
  92.         strcpy(curnode->db_Dest, GetString(FindGad(GD_Dest)));
  93.  
  94.         if(stricmp(curnode->db_Com, GetString(FindGad(GD_Command))))
  95.             modified = TRUE;
  96.  
  97.         strcpy(curnode->db_Com, GetString(FindGad(GD_Command)));
  98.  
  99.         if(stricmp(curnode->db_Template, GetString(FindGad(GD_Template))))
  100.             modified = TRUE;
  101.  
  102.         strcpy(curnode->db_Template, GetString(FindGad(GD_Template)));
  103.     }
  104. }
  105.  
  106. int ShowWindow()
  107. {
  108.     struct Gadget *temp = NULL;
  109.  
  110.     if(!DropBoxWnd)
  111.     {
  112.         if(SetupScreen())
  113.         {
  114.             winsigflag = 0;
  115.  
  116.             return NO_WINDOW;
  117.         }
  118.         else
  119.         {
  120.             /* Set Save Icons State */
  121.             DropBoxNewMenu[19].nm_Flags =
  122.                 (MainPrefs.gp_Flags&GFLG_SAVEICON)
  123.                 ?(DropBoxNewMenu[19].nm_Flags|CHECKED)
  124.                 :(DropBoxNewMenu[19].nm_Flags&(~CHECKED));
  125.  
  126.             /* Set Auto Check State */
  127.             DropBoxNewMenu[21].nm_Flags =
  128.                 (MainPrefs.gp_Flags&GFLG_CHECKCOM)
  129.                 ?(DropBoxNewMenu[21].nm_Flags|CHECKED)
  130.                 :(DropBoxNewMenu[21].nm_Flags&(~CHECKED));
  131.  
  132.             /* Set Use Select State */
  133.             DropBoxNewMenu[20].nm_Flags =
  134.                 (MainPrefs.gp_Flags&GFLG_SELECTWIN)
  135.                 ?(DropBoxNewMenu[20].nm_Flags|CHECKED)
  136.                 :(DropBoxNewMenu[20].nm_Flags&(~CHECKED));
  137.  
  138.             if(OpenDropBoxWindow())
  139.             {
  140.                 CloseDownScreen();
  141.  
  142.                 winsigflag = 0;
  143.  
  144.                 return NO_WINDOW;
  145.             }
  146.             else
  147.             {
  148.                 DrawImage(DropBoxWnd->RPort, &logoimage, 319, 125);
  149.  
  150.                 ModifyIDCMP(DropBoxWnd, DropBoxWnd->IDCMPFlags|IDCMP_VANILLAKEY);
  151.  
  152.                 winsigflag = 1<<(DropBoxWnd->UserPort->mp_SigBit);
  153.  
  154.                 curnode = NULL;
  155.                 curpat = NULL;
  156.                 temp = FindGad(GD_File_Types);
  157.  
  158.                 GT_SetGadgetAttrs(temp, DropBoxWnd, NULL, GTLV_Labels,
  159.                     (ULONG) DataBase, TAG_END);
  160.  
  161.                 UpdateGadgets();
  162.  
  163.                 return NO_ERROR;
  164.             }
  165.         }
  166.     }
  167.     else
  168.     {
  169.         WindowToFront(DropBoxWnd);
  170.  
  171.         if(ActivateWindow(DropBoxWnd))
  172.             DisplayBeep(NULL);
  173.     }
  174.  
  175.     return NO_ERROR;
  176. }
  177.  
  178. void HideWindow()
  179. {
  180.     if(DropBoxWnd)
  181.     {
  182.         DropBoxLeft = DropBoxWnd->LeftEdge;
  183.         DropBoxTop  = DropBoxWnd->TopEdge;
  184.         CleanWindow(DropBoxWnd);
  185.         CloseDropBoxWindow();
  186.     }
  187.  
  188.     if(Scr)
  189.         CloseDownScreen();
  190.  
  191.     winsigflag = 0;
  192. }
  193.  
  194. void SizeIOWindow()
  195. {
  196.     ULONG oldflags;
  197.     struct Window *sizewnd = NULL;
  198.  
  199.     oldflags = DropBoxWnd->IDCMPFlags;
  200.     ModifyIDCMP(DropBoxWnd, NULL);
  201.  
  202.     if(sizewnd = OpenWindowTags(NULL,
  203.         WA_Left, MainPrefs.gp_IOLeft, WA_Top,  MainPrefs.gp_IOTop,
  204.         WA_Width, max(MainPrefs.gp_IOWidth,80),
  205.         WA_Height, max(MainPrefs.gp_IOHeight,40),
  206.         WA_MinWidth, 80, WA_MinHeight, 40, WA_MaxWidth, ~0,WA_MaxHeight, ~0,
  207.         WA_DragBar, TRUE, WA_CloseGadget, TRUE, WA_SmartRefresh, TRUE,
  208.         WA_NoCareRefresh, TRUE, WA_IDCMP, IDCMP_CLOSEWINDOW,
  209.         WA_Title, (ULONG) IOTITLE, WA_PubScreen, (ULONG) Scr,
  210.         WA_AutoAdjust, TRUE, WA_SizeGadget, TRUE, WA_DepthGadget, TRUE,
  211.         WA_Activate, TRUE, TAG_END))
  212.     {
  213.         struct IntuiMessage *msg;
  214.         BOOL done = FALSE;
  215.  
  216.         while(!done)
  217.         {
  218.             WaitPort(sizewnd->UserPort);
  219.  
  220.             while(!done && (msg = (struct IntuiMessage *)
  221.                 GetMsg(sizewnd->UserPort)))
  222.             {
  223.                 if(msg->Class = IDCMP_CLOSEWINDOW)
  224.                     done = TRUE;
  225.  
  226.                 ReplyMsg((struct Message *)msg);
  227.             }
  228.         }
  229.  
  230.         MainPrefs.gp_IOLeft = sizewnd->LeftEdge;
  231.         MainPrefs.gp_IOTop  = sizewnd->TopEdge;
  232.         MainPrefs.gp_IOWidth = sizewnd->Width;
  233.         MainPrefs.gp_IOHeight = sizewnd->Height;
  234.         modified = TRUE;
  235.  
  236.         CloseWindow(sizewnd);
  237.     }
  238.  
  239.     ModifyIDCMP(DropBoxWnd, oldflags);
  240.  
  241. }
  242.  
  243. void SelectPat(struct PatNode *nd)
  244. {
  245.     curpat = nd;
  246.  
  247.     if(curpat && curnode)
  248.     {
  249.         LastSelected = NT_PATNODE;
  250.  
  251.         GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL,
  252.             GTLV_Selected,
  253.             (ULONG) PtrToOrd((struct Node *)curpat, curnode->db_Pats),
  254.             TAG_END);
  255.         GT_SetGadgetAttrs(FindGad(GD_Pattern), DropBoxWnd, NULL,
  256.             GA_Disabled, (ULONG) FALSE, TAG_END);
  257.         GT_SetGadgetAttrs(FindGad(GD_Pat_Del), DropBoxWnd, NULL,
  258.             GA_Disabled, (ULONG) FALSE, TAG_END);
  259.         GT_SetGadgetAttrs(FindGad(GD_Pat_Ins), DropBoxWnd, NULL,
  260.             GA_Disabled, (ULONG) FALSE, TAG_END);
  261.  
  262.         if(curpat != (struct PatNode *) curnode->db_Pats->lh_Head)
  263.             OnMenu(DropBoxWnd, FULLMENUNUM(1,4,0));
  264.         else
  265.             OffMenu(DropBoxWnd, FULLMENUNUM(1,4,0));
  266.         if(curpat != (struct PatNode *) curnode->db_Pats->lh_TailPred)
  267.             OnMenu(DropBoxWnd, FULLMENUNUM(1,5,0));
  268.         else
  269.             OffMenu(DropBoxWnd, FULLMENUNUM(1,5,0));
  270.  
  271.     }
  272.     else
  273.     {
  274.         if(curnode)
  275.         {
  276.             LastSelected = NT_DBNODE;
  277.  
  278.             if(curnode != (struct DBNode *) DataBase->lh_Head)
  279.                 OnMenu(DropBoxWnd, FULLMENUNUM(1,4,0));
  280.             else
  281.                 OffMenu(DropBoxWnd, FULLMENUNUM(1,4,0));
  282.             if(curnode != (struct DBNode *) DataBase->lh_TailPred)
  283.                 OnMenu(DropBoxWnd, FULLMENUNUM(1,5,0));
  284.             else
  285.                 OffMenu(DropBoxWnd, FULLMENUNUM(1,5,0));
  286.         }
  287.  
  288.         GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL,
  289.             GTLV_Selected, (ULONG) ~0,TAG_END);
  290.         GT_SetGadgetAttrs(FindGad(GD_Pattern), DropBoxWnd, NULL,
  291.             GA_Disabled, (ULONG) TRUE, TAG_END);
  292.         GT_SetGadgetAttrs(FindGad(GD_Pat_Del), DropBoxWnd, NULL,
  293.             GA_Disabled, (ULONG) TRUE, TAG_END);
  294.         GT_SetGadgetAttrs(FindGad(GD_Pat_Ins), DropBoxWnd, NULL,
  295.             GA_Disabled, (ULONG) TRUE, TAG_END);
  296.     }
  297. }
  298.  
  299. void Select(struct DBNode *nd)
  300. {
  301.     curnode = nd;
  302.     UpdateGadgets();
  303.  
  304.     if(curnode)
  305.     {
  306.         LastSelected = NT_DBNODE;
  307.  
  308.         GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL,
  309.             GTLV_Labels, (ULONG) curnode->db_Pats, TAG_END);
  310.  
  311.         SelectPat(NULL);
  312.  
  313.         GT_SetGadgetAttrs(FindGad(GD_Pat_Add), DropBoxWnd, NULL,
  314.             GA_Disabled, (ULONG) FALSE, TAG_END);
  315.         GT_SetGadgetAttrs(FindGad(GD_File_Types),DropBoxWnd, NULL,
  316.             GTLV_Selected, (ULONG) PtrToOrd((struct Node *)curnode,DataBase),
  317.             TAG_END);
  318.         GT_SetGadgetAttrs(FindGad(GD_Delete), DropBoxWnd, NULL,
  319.             GA_Disabled, (ULONG) FALSE, TAG_END);
  320.         GT_SetGadgetAttrs(FindGad(GD_Insert), DropBoxWnd, NULL,
  321.             GA_Disabled, (ULONG) FALSE, TAG_END);
  322.         GT_SetGadgetAttrs(FindGad(GD_Name), DropBoxWnd, NULL,
  323.             GA_Disabled, (ULONG) FALSE, TAG_END);
  324.         GT_SetGadgetAttrs(FindGad(GD_Pat_Add), DropBoxWnd, NULL,
  325.             GA_Disabled, (ULONG) FALSE, TAG_END);
  326.         GT_SetGadgetAttrs(FindGad(GD_Dest), DropBoxWnd, NULL,
  327.             GA_Disabled, (ULONG) FALSE, TAG_END);
  328.         /* GT_SetGadgetAttrs(FindGad(GD_DestGet), DropBoxWnd, NULL,
  329.             GA_Disabled, (ULONG) FALSE, TAG_END); Doesn't Support */
  330.         GT_SetGadgetAttrs(FindGad(GD_Command), DropBoxWnd, NULL,
  331.             GA_Disabled, (ULONG) FALSE, TAG_END);
  332.         /* GT_SetGadgetAttrs(FindGad(GD_ComGet), DropBoxWnd, NULL,
  333.             GA_Disabled, (ULONG) FALSE, TAG_END); Doesn't support */
  334.         GT_SetGadgetAttrs(FindGad(GD_Template), DropBoxWnd, NULL,
  335.             GA_Disabled, (ULONG) FALSE, TAG_END);
  336.         GT_SetGadgetAttrs(FindGad(GD_Suppress), DropBoxWnd, NULL,
  337.             GA_Disabled, (ULONG) FALSE, TAG_END);
  338.         GT_SetGadgetAttrs(FindGad(GD_Create), DropBoxWnd, NULL,
  339.             GA_Disabled, (ULONG) FALSE, TAG_END);
  340.  
  341.         if(curnode != (struct DBNode *) DataBase->lh_Head)
  342.             OnMenu(DropBoxWnd, FULLMENUNUM(1,4,0));
  343.         else
  344.             OffMenu(DropBoxWnd, FULLMENUNUM(1,4,0));
  345.  
  346.         if(curnode != (struct DBNode *) DataBase->lh_TailPred)
  347.             OnMenu(DropBoxWnd, FULLMENUNUM(1,5,0));
  348.         else
  349.             OffMenu(DropBoxWnd, FULLMENUNUM(1,5,0));
  350.  
  351.         OnMenu(DropBoxWnd, FULLMENUNUM(1, 0, 0));
  352.         OnMenu(DropBoxWnd, FULLMENUNUM(1, 1, 0));
  353.         if(Clip)
  354.             OnMenu(DropBoxWnd, FULLMENUNUM(1,2,0));
  355.         else
  356.             OffMenu(DropBoxWnd, FULLMENUNUM(1,2,0));
  357.     }
  358.     else
  359.     {
  360.         LastSelected = 0;
  361.  
  362.         SelectPat(NULL);
  363.  
  364.         GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL,
  365.             GTLV_Labels, (ULONG) NULL, TAG_END);
  366.         GT_SetGadgetAttrs(FindGad(GD_Delete), DropBoxWnd, NULL,
  367.             GA_Disabled, (ULONG) TRUE, TAG_END);
  368.         GT_SetGadgetAttrs(FindGad(GD_Insert), DropBoxWnd, NULL,
  369.             GA_Disabled, (ULONG) TRUE, TAG_END);
  370.         GT_SetGadgetAttrs(FindGad(GD_Name), DropBoxWnd, NULL,
  371.             GA_Disabled, (ULONG) TRUE, TAG_END);
  372.         GT_SetGadgetAttrs(FindGad(GD_Name), DropBoxWnd, NULL,
  373.             GA_Disabled, (ULONG) TRUE, TAG_END);
  374.         GT_SetGadgetAttrs(FindGad(GD_Pat_Add), DropBoxWnd, NULL,
  375.             GA_Disabled, (ULONG) TRUE, TAG_END);
  376.         GT_SetGadgetAttrs(FindGad(GD_Dest), DropBoxWnd, NULL,
  377.             GA_Disabled, (ULONG) TRUE, TAG_END);
  378.         /*GT_SetGadgetAttrs(FindGad(GD_DestGet), DropBoxWnd, NULL,
  379.             GA_Disabled, (ULONG) TRUE, TAG_END);*/
  380.         GT_SetGadgetAttrs(FindGad(GD_Command), DropBoxWnd, NULL,
  381.             GA_Disabled, (ULONG) TRUE, TAG_END);
  382. /*        GT_SetGadgetAttrs(FindGad(GD_ComGet), DropBoxWnd, NULL,
  383.             GA_Disabled, (ULONG) TRUE, TAG_END);*/
  384.         GT_SetGadgetAttrs(FindGad(GD_Template), DropBoxWnd, NULL,
  385.             GA_Disabled, (ULONG) TRUE, TAG_END);
  386.         GT_SetGadgetAttrs(FindGad(GD_Suppress), DropBoxWnd, NULL,
  387.             GA_Disabled, (ULONG) TRUE, TAG_END);
  388.         GT_SetGadgetAttrs(FindGad(GD_Create), DropBoxWnd, NULL,
  389.             GA_Disabled, (ULONG) TRUE, TAG_END);
  390.         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  391.             DropBoxWnd, NULL, GTLV_Selected, (ULONG) ~0, TAG_END);
  392.         OffMenu(DropBoxWnd, FULLMENUNUM(1, 4, 0));
  393.         OffMenu(DropBoxWnd, FULLMENUNUM(1, 5, 0));
  394.         OffMenu(DropBoxWnd, FULLMENUNUM(1, 0, 0));
  395.         OffMenu(DropBoxWnd, FULLMENUNUM(1, 1, 0));
  396.         OffMenu(DropBoxWnd, FULLMENUNUM(1, 2, 0));
  397.     }
  398. }
  399.  
  400. void HandleGadget(struct Gadget *gad, UWORD code)
  401. {
  402.     struct DBNode *temp = NULL;
  403.     struct PatNode *temp2 = NULL;
  404.     ULONG err = 0;
  405.     char tc[DEFLEN];
  406.  
  407.     if(gad == FindGad(GD_File_Types))
  408.     {
  409.         UpdateDB();
  410.         Select((struct DBNode *)OrdToPtr(code,DataBase));
  411.     }
  412.  
  413.     if(gad == FindGad(GD_Pat_View))
  414.         if(curnode)
  415.             SelectPat((struct PatNode *)OrdToPtr(code,curnode->db_Pats));
  416.  
  417.     if(gad == FindGad(GD_Add))
  418.         if(temp = (struct DBNode *) NewNode(NT_DBNODE))
  419.         {
  420.             UpdateDB();
  421.  
  422.             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  423.                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  424.  
  425.             AddNode((struct Node *)temp, DataBase);
  426.  
  427.             GT_SetGadgetAttrs(FindGad(GD_File_Types), DropBoxWnd, NULL, GTLV_Labels,
  428.                 (ULONG) DataBase, TAG_END);
  429.  
  430.             Select(temp);
  431.             ActivateGadget(FindGad(GD_Name), DropBoxWnd, NULL);
  432.  
  433.             modified = TRUE;
  434.         }
  435.         else
  436.             DisplayErr(NO_MEM);
  437.  
  438.     if(gad == FindGad(GD_Pat_Add))
  439.         if(curnode)
  440.             if(temp2 = (struct PatNode *) NewNode(NT_PATNODE))
  441.             {
  442.                 GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL, 
  443.                     GTLV_Labels, (ULONG) ~0, TAG_END);
  444.                     
  445.                 AddNode((struct Node *)temp2, curnode->db_Pats);
  446.                 
  447.                 GT_SetGadgetAttrs(FindGad(GD_Pat_View),DropBoxWnd, NULL, 
  448.                     GTLV_Labels, (ULONG) curnode->db_Pats, TAG_END);  
  449.                     
  450.                 SelectPat(temp2);
  451.                 ActivateGadget(FindGad(GD_Pattern), DropBoxWnd, NULL);
  452.                 
  453.                 modified = TRUE;
  454.             }
  455.             else
  456.                 DisplayErr(NO_MEM);
  457.         
  458.     if(gad == FindGad(GD_Insert))
  459.         if(temp = (struct DBNode *) NewNode(NT_DBNODE))
  460.         {
  461.             UpdateDB();
  462.             
  463.             GT_SetGadgetAttrs(FindGad(GD_File_Types), 
  464.                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  465.                 
  466.             InsertNode((struct Node *)temp, (struct Node *)curnode,DataBase);
  467.  
  468.             GT_SetGadgetAttrs(FindGad(GD_File_Types), DropBoxWnd, NULL, GTLV_Labels, 
  469.                 (ULONG) DataBase, TAG_END);
  470.                         
  471.             Select(temp);
  472.             ActivateGadget(FindGad(GD_Name), DropBoxWnd, NULL);
  473.             
  474.             modified = TRUE;
  475.         }
  476.         else
  477.             DisplayErr(NO_MEM);
  478.  
  479.     if(gad == FindGad(GD_Pat_Ins))
  480.         if(curnode)
  481.             if(temp2 = (struct PatNode *) NewNode(NT_PATNODE))
  482.             {
  483.                 GT_SetGadgetAttrs(FindGad(GD_Pat_View), 
  484.                     DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  485.                 
  486.                 InsertNode((struct Node *)temp2, 
  487.                     (struct Node *)curpat,curnode->db_Pats);
  488.  
  489.                 GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL, 
  490.                     GTLV_Labels, (ULONG) curnode->db_Pats, TAG_END);
  491.                         
  492.                 SelectPat(temp2);
  493.                 ActivateGadget(FindGad(GD_Pattern), DropBoxWnd, NULL);
  494.             
  495.                 modified = TRUE;
  496.             }
  497.             else
  498.                 DisplayErr(NO_MEM);
  499.                                 
  500.     if(gad == FindGad(GD_Delete))
  501.         if(curnode)
  502.         {
  503.             GT_SetGadgetAttrs(FindGad(GD_File_Types), 
  504.                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  505.             
  506.             temp = curnode;
  507.             if((struct Node *) temp == DataBase->lh_Head)
  508.                 curnode = (struct DBNode *) temp->db_Nd.ln_Succ;
  509.             else
  510.                 curnode = (struct DBNode *) temp->db_Nd.ln_Pred;
  511.             if(temp = (struct DBNode *)RemoveNode((struct Node *)temp,DataBase))
  512.                 FreeNode((struct Node *)temp);
  513.             
  514.             if(IsEmpty(DataBase))
  515.                 curnode = NULL;
  516.                         
  517.             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  518.                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  519.  
  520.             Select(curnode);
  521.  
  522.             modified = TRUE;
  523.         }
  524.  
  525.     if(gad == FindGad(GD_Pat_Del))
  526.         if(curnode)
  527.             if(curpat)
  528.             {
  529.                 GT_SetGadgetAttrs(FindGad(GD_Pat_View),DropBoxWnd,
  530.                     NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  531.                     
  532.                 temp2 = curpat;
  533.                 
  534.                 if((struct Node *) temp2 == curnode->db_Pats->lh_Head)
  535.                     curpat = (struct PatNode *) temp2->pat_Nd.ln_Succ;
  536.                 else
  537.                     curpat = (struct PatNode *) temp2->pat_Nd.ln_Pred;
  538.                     
  539.                 if(temp2 = (struct PatNode *)RemoveNode((struct Node *)temp2,
  540.                     curnode->db_Pats))
  541.                     FreeNode((struct Node *)temp2);
  542.                     
  543.                 if(IsEmpty(curnode->db_Pats))
  544.                     curpat = NULL;
  545.                     
  546.                 GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd,
  547.                     NULL, GTLV_Labels, (ULONG) curnode->db_Pats, TAG_END);
  548.                     
  549.                 SelectPat(curpat);
  550.                 
  551.                 modified = TRUE;
  552.             }
  553.             
  554.     if(gad == FindGad(GD_Sort))
  555.     {
  556.         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  557.             DropBoxWnd, NULL, GTLV_Labels, (ULONG) NULL, TAG_END);
  558.                         
  559.         if(err = Sort(&DataBase))
  560.             DisplayErr(err);
  561.  
  562.         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  563.             DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  564.  
  565.         Select(NULL);
  566.  
  567.         modified = TRUE;
  568.     }
  569.                         
  570.     if(gad == FindGad(GD_Name))
  571.         if(curnode)
  572.         {
  573.             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  574.                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  575.                         
  576.             if(stricmp(curnode->db_Name, GetString(gad)))
  577.                 modified = TRUE;
  578.                 
  579.             strcpy(curnode->db_Name, GetString(gad));
  580.             
  581.             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  582.                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  583.         }
  584.                         
  585.     if(gad == FindGad(GD_Pattern))
  586.         if(curpat && curnode)
  587.         {
  588.             GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL,
  589.                 GTLV_Labels, (ULONG) ~0, TAG_END);
  590.                 
  591.             if(stricmp(curpat->pat_Str, GetString(gad)))
  592.                 modified = TRUE;
  593.             
  594.             strcpy(curpat->pat_Str, GetString(gad));
  595.             
  596.             GT_SetGadgetAttrs(FindGad(GD_Pat_View), DropBoxWnd, NULL,
  597.                 GTLV_Labels, (ULONG) curnode->db_Pats, TAG_END);
  598.         }
  599.         
  600.     if(gad == FindGad(GD_Dest))
  601.         if(curnode)
  602.         {
  603.             if(stricmp(curnode->db_Dest, GetString(gad)))
  604.                 modified = TRUE;
  605.  
  606.             strcpy(curnode->db_Dest, GetString(gad));
  607.         }
  608.         
  609.     if(gad == FindGad(GD_DestGet))
  610.     {
  611.         strcpy(tc, GetString(FindGad(GD_Dest)));
  612.         GetDest(tc);
  613.         
  614.         if(stricmp(tc, GetString(FindGad(GD_Dest))))
  615.             modified = TRUE;
  616.             
  617.         GT_SetGadgetAttrs(FindGad(GD_Dest), DropBoxWnd, NULL,
  618.             GTST_String, (ULONG) tc, TAG_END);
  619.         
  620.         UpdateDB();
  621.     }
  622.     
  623.     if(gad == FindGad(GD_ComGet))
  624.     {
  625.         strcpy(tc, GetString(FindGad(GD_Command)));
  626.         GetCom(tc);
  627.         
  628.         if(stricmp(tc, GetString(FindGad(GD_Command))))
  629.             modified = TRUE;
  630.             
  631.         GT_SetGadgetAttrs(FindGad(GD_Command), DropBoxWnd, NULL,
  632.             GTST_String, (ULONG) tc, TAG_END);
  633.         UpdateDB();
  634.     }
  635.  
  636.     if(gad == FindGad(GD_Command))
  637.         if(curnode)
  638.             if(stricmp(curnode->db_Com, GetString(gad)))
  639.             {
  640.                 modified = TRUE;
  641.                 strcpy(curnode->db_Com, GetString(gad));
  642.             }
  643.  
  644.     if(gad == FindGad(GD_Template))
  645.         if(curnode)
  646.             if(stricmp(curnode->db_Template, GetString(gad)))
  647.             {
  648.                 char com[DEFLEN*2];
  649.                 struct WBArg targ;
  650.                 struct Process *myproc;
  651.  
  652.                 modified = TRUE;
  653.                 strcpy(curnode->db_Template, GetString(gad));
  654.  
  655.                 if(MainPrefs.gp_Flags & GFLG_CHECKCOM)
  656.                 {
  657.                     myproc = (struct Process *) FindTask(NULL);
  658.  
  659.                     targ.wa_Lock = myproc->pr_CurrentDir;
  660.                     targ.wa_Name = "Bob";
  661.  
  662.  
  663.                     if(err = CreateCommand(curnode, &targ, com))
  664.                     {
  665.                         DisplayErr(err);
  666.                         ActivateGadget(gad, DropBoxWnd, NULL);
  667.                     }
  668.  
  669.                 }
  670.  
  671.             }
  672.  
  673.     if(gad == FindGad(GD_Suppress))
  674.         if(curnode)
  675.         {
  676.             curnode->db_Flags = ToggleFlag(curnode->db_Flags,DFLG_SUPOUTPUT);
  677.             modified = TRUE;
  678.         }
  679.  
  680.     if(gad == FindGad(GD_Create))
  681.         if(curnode)
  682.         {
  683.             curnode->db_Flags = ToggleFlag(curnode->db_Flags, DFLG_CREATE);
  684.             modified = TRUE;
  685.         }
  686. }
  687.  
  688. void DisplayAbout()
  689. {
  690.     struct EasyStruct about =
  691.     {
  692.         sizeof(struct EasyStruct),
  693.         0,
  694.         NULL,
  695.         NULL,
  696.         NULL
  697.     };
  698.  
  699.     about.es_Title = ABOUT;
  700.     about.es_TextFormat = TEXTFORMAT;
  701.     about.es_GadgetFormat = GADGETFORMAT;
  702.  
  703.     EasyRequest(DropBoxWnd, &about, 0);
  704.  
  705. }
  706.  
  707. BOOL DisplayNewWarning()
  708. {
  709.     struct EasyStruct new =
  710.     {
  711.         sizeof(struct EasyStruct),
  712.         0,
  713.         NULL,
  714.         NULL,
  715.         NULL
  716.     };
  717.  
  718.     new.es_Title = NEW;
  719.     new.es_TextFormat = NEWTEXTFORMAT;
  720.     new.es_GadgetFormat = NEWGADGETFORMAT;
  721.  
  722.     return EasyRequest(DropBoxWnd, &new, 0);
  723. }
  724.  
  725. BOOL HandleMenu(ULONG menunum, ULONG itemnum, ULONG subnum)
  726. {
  727.     struct DBNode *temp = NULL;
  728.     struct PatNode *temp2 = NULL;
  729.     ULONG err;
  730.     BOOL hide = FALSE;
  731.  
  732.     switch(menunum)
  733.     {
  734.         case 0:
  735.             switch(itemnum)
  736.             {
  737.                 case 0: /* New */
  738.                     if(DisplayNewWarning())
  739.                     {
  740.                         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  741.                             DropBoxWnd, NULL, GTLV_Labels, NULL, TAG_END);
  742.  
  743.                         CleanDB();
  744.                         InitDB();
  745.                         InitIO(NULL, NULL, NULL);
  746.  
  747.                         modified = FALSE;
  748.                         FirstSave = TRUE;
  749.  
  750.                         GT_SetGadgetAttrs(FindGad(GD_File_Types), DropBoxWnd, NULL, GTLV_Labels,
  751.                             (ULONG) DataBase, TAG_END);
  752.  
  753.                         Select(NULL);
  754.                     }
  755.                     break;
  756.  
  757.                 case 2: /* Open */
  758.                     if(modified)
  759.                         modified = !Safe(DropBoxWnd);
  760.  
  761.                     if(!modified)
  762.                     {
  763.                         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  764.                             DropBoxWnd, NULL, GTLV_Labels, NULL, TAG_END);
  765.  
  766.                         FirstSave = FALSE;
  767.  
  768.                         ClearMenuStrip(DropBoxWnd);
  769.  
  770.                         PrefIO(FALSE);
  771.  
  772.                         ResetMenuStrip(DropBoxWnd, DropBoxMenus);
  773.  
  774.                         GT_SetGadgetAttrs(FindGad(GD_File_Types), DropBoxWnd, NULL, GTLV_Labels,
  775.                             (ULONG) DataBase, TAG_END);
  776.  
  777.                         Select(NULL);
  778.                     }
  779.                     break;
  780.  
  781.                 case 3: /* Save */
  782.                     if(FirstSave)
  783.                     {
  784.                         FirstSave = FALSE;
  785.                         PrefIO(TRUE);
  786.                     }
  787.                     else
  788.                         if(err = JustSave())
  789.                             DisplayErr(err);
  790.                         else
  791.                             modified = FALSE;
  792.                     break;
  793.                         
  794.                 case 4: /* Save as... */
  795.                     if(FirstSave)
  796.                         FirstSave = FALSE;
  797.                     PrefIO(TRUE);
  798.                     break;
  799.                                 
  800.                 case 6: /* About */
  801.                     DisplayAbout();
  802.                     break;
  803.                             
  804.                 case 8: /* Hide */
  805.                     hide = TRUE;
  806.                     break;
  807.                                     
  808.                 case 9: /* Quit */
  809.                     if(modified)
  810.                     {
  811.                         if(Safe(DropBoxWnd))
  812.                         {
  813.                             hide = TRUE;
  814.                             end_flag = TRUE;
  815.                         }
  816.                     }
  817.                     else
  818.                     {
  819.                         hide = TRUE;
  820.                         end_flag = TRUE;
  821.                     }
  822.                     break;
  823.             } /* Project Menu Switch */
  824.             break;
  825.                             
  826.         case 1: /* Edit Menu */
  827.             switch(itemnum)
  828.             {
  829.                 case 0: /* Cut */
  830.                     if(curnode)
  831.                     {
  832.                         FreeNode((struct Node *)Clip);
  833.                         Clip = NULL;
  834.                         
  835.                         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  836.                             DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  837.                         
  838.                         Clip = curnode;
  839.                         if((struct Node *) Clip == DataBase->lh_Head)
  840.                             curnode = (struct DBNode *) Clip->db_Nd.ln_Succ;
  841.                         else
  842.                             curnode = (struct DBNode *) Clip->db_Nd.ln_Pred;
  843.                             
  844.                         Clip = (struct DBNode *)RemoveNode((struct Node *)Clip,DataBase);
  845.                             
  846.                         if(IsEmpty(DataBase))
  847.                             curnode = NULL;
  848.                 
  849.                         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  850.                             DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  851.                             
  852.                         Select(curnode);
  853.                                 
  854.                         OnMenu(DropBoxWnd, FULLMENUNUM(1,2,0));
  855.                                     
  856.                         modified = TRUE;
  857.                     }
  858.                     break;
  859.                                 
  860.                 case 1: /* Copy */
  861.                     if(curnode)
  862.                     {
  863.                         if(Clip)
  864.                             FreeNode((struct Node *)Clip);
  865.                         Clip = NULL;
  866.                             
  867.                         if(Clip = (struct DBNode *)NewNode(NT_DBNODE))
  868.                         { 
  869.                             CopyDBNode(Clip, curnode);
  870.                             OnMenu(DropBoxWnd, FULLMENUNUM(1,2,0));
  871.                         }
  872.                         else
  873.                             DisplayErr(NO_MEM);
  874.                     }
  875.                     break;
  876.                     
  877.                 case 2: /* Paste */
  878.                     if(curnode)
  879.                     {
  880.                         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  881.                             DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  882.                             
  883.                         CopyDBNode(curnode, Clip);
  884.                         
  885.                         GT_SetGadgetAttrs(FindGad(GD_File_Types),
  886.                             DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  887.                         UpdateGadgets();
  888.                         
  889.                         modified = TRUE;
  890.                     }
  891.                     break;
  892.                                 
  893.                 case 4: /* Up */
  894.                     if(LastSelected == NT_DBNODE)
  895.                     {
  896.                         if(curnode && (curnode != (struct DBNode *) DataBase->lh_Head))
  897.                         {
  898.                             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  899.                                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  900.             
  901.                             temp = (struct DBNode *)curnode->db_Nd.ln_Pred;
  902.                             RemoveNode((struct Node *)curnode, DataBase);
  903.                             InsertNode((struct Node *)curnode, (struct Node *)temp,DataBase);
  904.     
  905.                             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  906.                                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  907.             
  908.                             Select(curnode);
  909.         
  910.                             modified = TRUE;
  911.                         }
  912.                     }
  913.                     else
  914.                         if(LastSelected == NT_PATNODE)
  915.                         if(curnode)
  916.                             if(curpat && (curpat != (struct PatNode *) curnode->db_Pats->lh_Head))
  917.                             {
  918.                                 GT_SetGadgetAttrs(FindGad(GD_Pat_View),
  919.                                     DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, 
  920.                                     TAG_END);
  921.             
  922.                                 temp2 = (struct PatNode *)
  923.                                     curpat->pat_Nd.ln_Pred;
  924.                             
  925.                                 RemoveNode((struct Node *)curpat, 
  926.                                     curnode->db_Pats);
  927.                                 InsertNode((struct Node *)curpat, 
  928.                                     (struct Node *)temp2,curnode->db_Pats);
  929.     
  930.                                 GT_SetGadgetAttrs(FindGad(GD_Pat_View),
  931.                                     DropBoxWnd, NULL, GTLV_Labels, 
  932.                                     (ULONG) curnode->db_Pats, TAG_END);
  933.             
  934.                                 SelectPat(curpat);
  935.         
  936.                                 modified = TRUE;
  937.                             }
  938.                     break;
  939.                                 
  940.                 case 5: /* Down */
  941.                     if(LastSelected == NT_DBNODE)
  942.                     {
  943.                         if(curnode && (curnode != (struct DBNode *) DataBase->lh_TailPred))
  944.                         {
  945.                             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  946.                                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) ~0, TAG_END);
  947.                 
  948.                             temp = (struct DBNode *)curnode->db_Nd.ln_Succ;
  949.                             RemoveNode((struct Node *)curnode,DataBase);
  950.                             Insert(DataBase, (struct Node *)curnode,(struct Node *) temp);
  951.             
  952.                             GT_SetGadgetAttrs(FindGad(GD_File_Types),
  953.                                 DropBoxWnd, NULL, GTLV_Labels, (ULONG) DataBase, TAG_END);
  954.         
  955.                             Select(curnode);
  956.         
  957.                             modified = TRUE;    
  958.                         }
  959.                     }
  960.                     else
  961.                         if(LastSelected == NT_PATNODE)
  962.                             if(curnode)
  963.                                 if(curpat && (curpat != (struct PatNode *) 
  964.                                     curnode->db_Pats->lh_TailPred))
  965.                                 {
  966.                                     GT_SetGadgetAttrs(FindGad(GD_Pat_View),
  967.                                         DropBoxWnd, NULL, GTLV_Labels, 
  968.                                         (ULONG) ~0, TAG_END);
  969.                 
  970.                                     temp2 = (struct PatNode *)
  971.                                         curpat->pat_Nd.ln_Succ;
  972.                                     RemoveNode((struct Node *)curpat,
  973.                                         curnode->db_Pats);
  974.                                     Insert(curnode->db_Pats, 
  975.                                         (struct Node *)curpat,
  976.                                         (struct Node *) temp2);
  977.             
  978.                                     GT_SetGadgetAttrs(FindGad(GD_Pat_View),
  979.                                         DropBoxWnd, NULL, GTLV_Labels, 
  980.                                         (ULONG) curnode->db_Pats, TAG_END);
  981.         
  982.                                     SelectPat(curpat);
  983.         
  984.                                     modified = TRUE;    
  985.                                 }
  986.                     break;
  987.                     
  988.             } /* Edit Menu Switch */
  989.             break;
  990.             
  991.         case 2: /* Options Menu */
  992.             switch(itemnum)
  993.             {
  994.                 case 0: /* Save Icons */
  995.                     MainPrefs.gp_Flags = 
  996.                         StatusCheck(GetItem(DropBoxMenus, 2, 0),
  997.                             MainPrefs.gp_Flags, GFLG_SAVEICON);
  998.                     modified = TRUE;
  999.                     break;
  1000.                     
  1001.                 case 1: /* Use Select Window */
  1002.                     MainPrefs.gp_Flags =
  1003.                         StatusCheck(GetItem(DropBoxMenus, 2,1),
  1004.                             MainPrefs.gp_Flags, GFLG_SELECTWIN);
  1005.                     modified = TRUE;
  1006.                     break;
  1007.                             
  1008.                 case 2: /* Auto-Check */
  1009.                     MainPrefs.gp_Flags = 
  1010.                         StatusCheck(GetItem(DropBoxMenus,2,2),
  1011.                             MainPrefs.gp_Flags, GFLG_CHECKCOM); 
  1012.                     modified = TRUE;
  1013.                     break;
  1014.                 
  1015.                 case 4: /* Size input/output window */
  1016.                     SizeIOWindow();
  1017.                     break;
  1018.                     
  1019.             }
  1020.             break;
  1021.                 
  1022.     } /* Menu Switch */
  1023.     
  1024.     return hide;
  1025. }
  1026.  
  1027. void HandleIntuiMsg()
  1028. {
  1029.     struct IntuiMessage *imsg = NULL;
  1030.     struct Gadget *gad = NULL;
  1031.     ULONG class;
  1032.     UWORD code, index;
  1033.     BOOL hide = FALSE;
  1034.     char temp[2];
  1035.     
  1036.     temp[1] = '\0';
  1037.     
  1038.     while(imsg = GT_GetIMsg(DropBoxWnd->UserPort))
  1039.     {
  1040.         gad = (struct Gadget *) imsg->IAddress;
  1041.         class = imsg->Class;
  1042.         code = imsg->Code;
  1043.         
  1044.         GT_ReplyIMsg(imsg);
  1045.         
  1046.         switch(class)
  1047.         {
  1048.             case IDCMP_VANILLAKEY:
  1049.                 temp[0] = (UBYTE)code;
  1050.                 for(index = 0; index < GLU_NUM; index++)
  1051.                     if(!strnicmp(temp,(char *) glu[index].gl_Key,1))
  1052.                     {
  1053.                         HandleGadget(FindGad(glu[index].gl_Gad),0);
  1054.                         break;
  1055.                     }
  1056.                 break;
  1057.                 
  1058.             case IDCMP_GADGETDOWN:
  1059.             case IDCMP_GADGETUP:
  1060.                 HandleGadget(gad, code);
  1061.                 break;
  1062.                 
  1063.             case IDCMP_CLOSEWINDOW:
  1064.                 hide = TRUE;
  1065.                 break;
  1066.             
  1067.             case IDCMP_REFRESHWINDOW:
  1068.                 GT_BeginRefresh(DropBoxWnd);
  1069.                 DrawImage(DropBoxWnd->RPort, &logoimage, 319, 125);
  1070.                 GT_EndRefresh(DropBoxWnd, TRUE);
  1071.                 break;
  1072.         
  1073.             case IDCMP_MENUPICK:
  1074.                 if(code != MENUNULL)
  1075.                     hide = HandleMenu(MENUNUM(code),ITEMNUM(code),SUBNUM(code));
  1076.         }
  1077.     }
  1078.     if(hide)
  1079.         HideWindow();
  1080. }
  1081.