home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / WIN_BMP / FRCICN13.ZIP / INTERFAC.C < prev    next >
C/C++ Source or Header  |  1994-02-15  |  39KB  |  1,536 lines

  1. /*
  2. Auto:        smake ForceIcon
  3. */
  4.  
  5.  
  6.  
  7. /* $Revision Header built automatically *************** (do not edit) ************
  8. **
  9. ** ⌐ Copyright by GuntherSoft
  10. **
  11. ** File             : SnakeSYS:CPrgs/Utils/ForceIcon/Interface.c
  12. ** Created on       : Friday, 22.10.93 16:28:10
  13. ** Created by       : Kai Iske
  14. ** Current revision : V1.0
  15. **
  16. **
  17. ** Purpose
  18. ** -------
  19. **   - User-Interface for ForceIcon
  20. **
  21. ** Revision V1.0
  22. ** --------------
  23. ** created on Friday, 22.10.93 16:28:10  by  Kai Iske.   LogMessage :
  24. **     --- Initial release ---
  25. **
  26. *********************************************************************************/
  27.  
  28.  
  29. #define    MainWinLeft    80
  30. #define    MainWinTop    25
  31. #define    MainWinWidth    457
  32. #define    MainWinHeight    126
  33. #define    EditWinLeft    102
  34. #define    EditWinTop    52
  35. #define    EditWinWidth    433
  36. #define    EditWinHeight    102
  37. #define    ManWinLeft    112
  38. #define    ManWinTop    60
  39. #define    ManWinWidth    438
  40. #define    ManWinHeight    41
  41.  
  42.  
  43.  
  44. /**********************************************************************/
  45. /*                      Routines for this module                      */
  46. /**********************************************************************/
  47. static struct VolEntry *AddNewVolume(char *Name, ULONG Type);
  48. static void SetGetFileState(struct Gadget *Gad, struct Window *Win, BOOL State);
  49.  
  50.  
  51.  
  52.  
  53.  
  54. /**********************************************************************/
  55. /*                        External structures                         */
  56. /**********************************************************************/
  57. extern struct List        VolumeList;
  58. extern struct SignalSemaphore    MySemaphore;
  59.  
  60.  
  61.  
  62. /**********************************************************************/
  63. /*                        Module`s structures                         */
  64. /**********************************************************************/
  65. struct    Window        *MainWinHandle    = NULL;        // Window handles
  66. struct    Window        *EditWinHandle    = NULL;
  67. struct    Window        *PosWinHandle    = NULL;
  68. struct    Window        *ManWinHandle    = NULL;
  69.  
  70.  
  71. static struct VisualInfo    *MainVisInfo    = NULL;
  72. static struct VisualInfo    *EditVisInfo    = NULL;
  73. static struct VisualInfo    *ManVisInfo    = NULL;
  74. static struct Gadget        *MainWinGList    = NULL;
  75. static struct Gadget        *EditWinGList    = NULL;
  76. static struct Gadget        *ManWinGList    = NULL;
  77. static struct Gadget        *MainWinGadgets[MAINWIN_CNT];
  78. static struct Gadget        *EditWinGadgets[EDITWIN_CNT];
  79. static struct Gadget        *ManWinGadgets[MANWIN_CNT];
  80. static struct _Object        *EditWinGet    = NULL;
  81. static struct TextAttr        MainWinTxtAttr,
  82.                 EditWinTxtAttr,
  83.                 ManWinTxtAttr;
  84. static char            MainWinFontName[40],
  85.                 EditWinFontName[40],
  86.                 ManWinFontName[40];
  87.  
  88. static char            MainTypeStr[40];
  89.  
  90. static struct List        VolList;
  91. static struct VolEntry        OrigEntry, *CloneEntry = NULL;
  92. static WORD            SelVolume, SelEdVolume, PosMode, ManualType;
  93. static LONG            SecsLeft, MinsLeft, SecsRight, MinsRight;
  94. static WORD            LastLeft, LastRight;
  95. static struct Requester        MainReq;
  96.  
  97.  
  98.  
  99.  
  100.  
  101. /**********************************************************************/
  102. /*                         Window definitions                         */
  103. /**********************************************************************/
  104. static UBYTE *EditPos1Labels[] = {
  105.     (UBYTE *)"Open position window",
  106.     (UBYTE *)"Close position window",
  107.     NULL };
  108.  
  109. static UBYTE *ManType2Labels[] = {
  110.     (UBYTE *)"Device",
  111.     (UBYTE *)"Volume",
  112.     NULL };
  113.  
  114. static UWORD MainWinGTypes[] = {
  115.     LISTVIEW_KIND,
  116.     LISTVIEW_KIND,
  117.     BUTTON_KIND,
  118.     BUTTON_KIND,
  119.     BUTTON_KIND,
  120.     BUTTON_KIND,
  121.     BUTTON_KIND,
  122.     BUTTON_KIND,
  123.     BUTTON_KIND,
  124.     BUTTON_KIND,
  125.     BUTTON_KIND,
  126.     BUTTON_KIND,
  127.     TEXT_KIND,
  128.     BUTTON_KIND
  129. };
  130.  
  131. static UWORD EditWinGTypes[] = {
  132.     CYCLE_KIND,
  133.     BUTTON_KIND,
  134.     BUTTON_KIND,
  135.     STRING_KIND,
  136.     STRING_KIND,
  137.     GENERIC_KIND,
  138.     CHECKBOX_KIND,
  139.     CYCLE_KIND,
  140.     CHECKBOX_KIND,
  141.     INTEGER_KIND,
  142.     INTEGER_KIND
  143. };
  144.  
  145. static UWORD ManWinGTypes[] = {
  146.     STRING_KIND,
  147.     BUTTON_KIND,
  148.     BUTTON_KIND,
  149.     CYCLE_KIND
  150. };
  151.  
  152. static struct NewGadget MainWinNGad[] = {
  153.     244, 17, 200, 56, (UBYTE *)"Ava_ilable Volumes/Devices", NULL, GD_MainVols, PLACETEXT_ABOVE|NG_HIGHLABEL, NULL, NULL,
  154.     13, 17, 200, 56, (UBYTE *)"Used _Volumes/Devices", NULL, GD_MainUseVols, PLACETEXT_ABOVE|NG_HIGHLABEL, NULL, NULL,
  155.     244, 69, 200, 12, (UBYTE *)"Add to _list", NULL, GD_MainAdd, PLACETEXT_IN, NULL, NULL,
  156.     13, 81, 100, 12, (UBYTE *)"_Edit entry...", NULL, GD_MainEdit, PLACETEXT_IN, NULL, NULL,
  157.     13, 93, 200, 12, (UBYTE *)"_Remove from list", NULL, GD_MainRemove, PLACETEXT_IN, NULL, NULL,
  158.     5, 112, 85, 12, (UBYTE *)"_Save", NULL, GD_MainSave, PLACETEXT_IN, NULL, NULL,
  159.     95, 112, 85, 12, (UBYTE *)"_Use", NULL, GD_MainUse, PLACETEXT_IN, NULL, NULL,
  160.     367, 112, 85, 12, (UBYTE *)"_Quit", NULL, GD_MainQuit, PLACETEXT_IN, NULL, NULL,
  161.     275, 112, 85, 12, (UBYTE *)"_Hide", NULL, GD_MainHide, PLACETEXT_IN, NULL, NULL,
  162.     244, 81, 200, 12, (UBYTE *)"Add _manually...", NULL, GD_MainManual, PLACETEXT_IN, NULL, NULL,
  163.     244, 93, 200, 12, (UBYTE *)"Resca_n list", NULL, GD_MainRescan, PLACETEXT_IN, NULL, NULL,
  164.     185, 112, 85, 12, (UBYTE *)"_About...", NULL, GD_MainAbout, PLACETEXT_IN, NULL, NULL,
  165.     13, 69, 200, 12, NULL, NULL, GD_MainType, 0, NULL, NULL,
  166.     113, 81, 100, 12, (UBYTE *)"_Copy...", NULL, GD_MainCopy, PLACETEXT_IN, NULL, NULL
  167. };
  168.  
  169. static struct NewGadget EditWinNGad[] = {
  170.     108, 51, 202, 12, (UBYTE *)"_Position", NULL, GD_EditPos, PLACETEXT_LEFT, NULL, NULL,
  171.     5, 88, 85, 12, (UBYTE *)"_Ok", NULL, GD_EditOk, PLACETEXT_IN, NULL, NULL,
  172.     343, 88, 85, 12, (UBYTE *)"_Cancel", NULL, GD_EditCancel, PLACETEXT_IN, NULL, NULL,
  173.     108, 6, 297, 14, (UBYTE *)"_Volume", NULL, GD_EditVol, PLACETEXT_LEFT, NULL, NULL,
  174.     108, 69, 181, 14, (UBYTE *)"Ico_n", NULL, GD_EditIcon, PLACETEXT_LEFT, NULL, NULL,
  175.     290, 69, 20, 14, NULL, NULL, GD_EditGet, 0, NULL, NULL,
  176.     318, 69, 26, 11, (UBYTE *)"_Use Icon", NULL, GD_EditUseIcon, PLACETEXT_RIGHT, NULL, NULL,
  177.     108, 21, 297, 12, (UBYTE *)"_Type", NULL, GD_EditType, PLACETEXT_LEFT, NULL, NULL,
  178.     318, 51, 26, 11, (UBYTE *)"_IconPos", NULL, GD_EditIconPos, PLACETEXT_RIGHT, NULL, NULL,
  179.     108, 36, 67, 14, (UBYTE *)"Current _X", NULL, GD_EditX, PLACETEXT_LEFT, NULL, NULL,
  180.     338, 36, 67, 14, (UBYTE *)"Current _Y", NULL, GD_EditY, PLACETEXT_LEFT, NULL, NULL
  181. };
  182.  
  183. static struct NewGadget ManWinNGad[] = {
  184.     82, 7, 346, 14, (UBYTE *)"_Entry", NULL, GD_ManVol, PLACETEXT_LEFT, NULL, NULL,
  185.     5, 27, 85, 12, (UBYTE *)"_Ok", NULL, GD_ManOk, PLACETEXT_IN, NULL, NULL,
  186.     349, 27, 85, 12, (UBYTE *)"_Cancel", NULL, GD_ManCancel, PLACETEXT_IN, NULL, NULL,
  187.     175, 27, 121, 12, (UBYTE *)"_Type", NULL, GD_ManType, PLACETEXT_LEFT, NULL, NULL
  188. };
  189.  
  190. static ULONG MainWinGTags[] = {
  191.     (GTLV_ShowSelected), NULL, (GT_Underscore), '_', (TAG_DONE),
  192.     (GTLV_ShowSelected), NULL, (GT_Underscore), '_', (TAG_DONE),
  193.     (GT_Underscore), '_', (GA_Disabled), TRUE, (TAG_DONE),
  194.     (GT_Underscore), '_', (GA_Disabled), TRUE, (TAG_DONE),
  195.     (GT_Underscore), '_', (GA_Disabled), TRUE, (TAG_DONE),
  196.     (GT_Underscore), '_', (TAG_DONE),
  197.     (GT_Underscore), '_', (TAG_DONE),
  198.     (GT_Underscore), '_', (TAG_DONE),
  199.     (GT_Underscore), '_', (TAG_DONE),
  200.     (GT_Underscore), '_', (TAG_DONE),
  201.     (GT_Underscore), '_', (TAG_DONE),
  202.     (GT_Underscore), '_', (TAG_DONE),
  203.     (GTTX_Border), TRUE, (TAG_DONE),
  204.     (GT_Underscore), '_', (GA_Disabled), TRUE, (TAG_DONE)
  205. };
  206.  
  207. static ULONG EditWinGTags[] = {
  208.     (GTCY_Labels), (ULONG)&EditPos1Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE),
  209.     (GT_Underscore), '_', (TAG_DONE),
  210.     (GT_Underscore), '_', (TAG_DONE),
  211.     (STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 128, (GT_Underscore), '_', (TAG_DONE),
  212.     (STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 256, (GT_Underscore), '_', (TAG_DONE),
  213.     (TAG_DONE),
  214.     (GT_Underscore), '_', (GTCB_Scaled), TRUE, (TAG_DONE),
  215.     (GTCY_Labels), (ULONG)&ManType2Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE),
  216.     (GT_Underscore), '_', (GTCB_Scaled), TRUE, (TAG_DONE),
  217.     (STRINGA_ExitHelp), TRUE, (GTIN_Number), 0, (GTIN_MaxChars), 4, (GT_Underscore), '_', (TAG_DONE),
  218.     (STRINGA_ExitHelp), TRUE, (GTIN_Number), 0, (GTIN_MaxChars), 4, (GT_Underscore), '_', (TAG_DONE)
  219. };
  220.  
  221. static ULONG ManWinGTags[] = {
  222.     (STRINGA_ExitHelp), TRUE, (GTST_MaxChars), 128, (GT_Underscore), '_', (TAG_DONE),
  223.     (GT_Underscore), '_', (TAG_DONE),
  224.     (GT_Underscore), '_', (TAG_DONE),
  225.     (GTCY_Labels), (ULONG)&ManType2Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE)
  226. };
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239. /**********************************************************************/
  240. /*                       Handle the main window                       */
  241. /**********************************************************************/
  242. BOOL OpenMainWin(void)
  243. {
  244.         // Initialize volume list
  245.  
  246.     NewList(&VolList);
  247.  
  248.         // Get list of available volumes
  249.  
  250.     if(GetDevVolList(&VolList))
  251.     {
  252.             // Try to open main window
  253.  
  254.         if(OpenWin(MainWinLeft,
  255.             MainWinTop,
  256.             MainWinWidth,
  257.             MainWinHeight,
  258.             &MainWinGList,
  259.             MAINWIN_CNT,
  260.             NULL,
  261.             MainWinNGad,
  262.             MainWinGTypes,
  263.             MainWinGTags,
  264.             MainWinGadgets,
  265.             &MainWinHandle,
  266.             "ForceIcon v"REVISION" ("REVDATE") - GiftWare, Kai Iske",
  267.             LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  268.             WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
  269.             5,
  270.             3,
  271.             447,
  272.             106,
  273.             &MainWinTxtAttr,
  274.             MainWinFontName,
  275.         &MainVisInfo))
  276.         {
  277.                 // Set right listview
  278.  
  279.             GT_SetGadgetAttrs(MainWinGadgets[GD_MainVols], MainWinHandle, NULL,
  280.                 GTLV_Labels,    &VolList,
  281.             TAG_DONE);
  282.  
  283.                 // Set left listview
  284.  
  285.             GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  286.                 GTLV_Labels,    &VolumeList,
  287.             TAG_DONE);
  288.  
  289.                 // Set variables for Window handling
  290.  
  291.             SelVolume    = SelEdVolume = -1;
  292.             LastLeft    = LastRight = -1;
  293.             SecsLeft    = MinsLeft = SecsRight = MinsRight = -1;
  294.         }
  295.         else
  296.             CloseMainWin();
  297.     }
  298.     else
  299.         FreeDevVolList(&VolList);
  300.  
  301.     if(!MainWinHandle)
  302.         DisplayError(ERR_NOMEM, NULL);
  303.  
  304.     return((BOOL)(MainWinHandle != NULL));
  305. }
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313. /**********************************************************************/
  314. /*                      Close main window again                       */
  315. /**********************************************************************/
  316. void CloseMainWin(void)
  317. {
  318.         // Unbusy window first
  319.  
  320.     UnBusyWindow(MainWinHandle, &MainReq);
  321.  
  322.         // Close window
  323.  
  324.     CloseWin(&MainWinHandle, &MainWinGList, &MainVisInfo, NULL);
  325.  
  326.         // Free volume list
  327.  
  328.     FreeDevVolList(&VolList);
  329. }
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. /**********************************************************************/
  337. /*                          Open Edit window                          */
  338. /**********************************************************************/
  339. BOOL OpenEditWin(void)
  340. {
  341.         // Try to open editor window
  342.  
  343.     if(OpenWin(EditWinLeft,
  344.         EditWinTop,
  345.         EditWinWidth,
  346.         EditWinHeight,
  347.         &EditWinGList,
  348.         EDITWIN_CNT,
  349.         &EditWinGet,
  350.         EditWinNGad,
  351.         EditWinGTypes,
  352.         EditWinGTags,
  353.         EditWinGadgets,
  354.         &EditWinHandle,
  355.         "ForceIcon v"REVISION" ("REVDATE") - GiftWare, Kai Iske",
  356.         LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  357.         WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
  358.         5,
  359.         3,
  360.         423,
  361.         83,
  362.         &EditWinTxtAttr,
  363.         EditWinFontName,
  364.     &EditVisInfo))
  365.     {
  366.             // Set gadgets
  367.  
  368.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditVol], EditWinHandle, NULL,
  369.             GTST_String,    OrigEntry.VolName,
  370.         TAG_DONE);
  371.  
  372.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditType], EditWinHandle, NULL,
  373.             GTCY_Active,    (ManualType = !(OrigEntry.Link.ln_Type == LDF_DEVICES)),
  374.         TAG_DONE);
  375.  
  376.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditX], EditWinHandle, NULL,
  377.             GTIN_Number,    OrigEntry.Left,
  378.         TAG_DONE);
  379.  
  380.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditY], EditWinHandle, NULL,
  381.             GTIN_Number,    OrigEntry.Top,
  382.         TAG_DONE);
  383.  
  384.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditIcon], EditWinHandle, NULL,
  385.             GTST_String,    OrigEntry.IconName,
  386.         TAG_DONE);
  387.  
  388.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditUseIcon], EditWinHandle, NULL,
  389.             GTCB_Checked,    OrigEntry.UseAlt,
  390.         TAG_DONE);
  391.  
  392.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditIcon], EditWinHandle, NULL,
  393.             GA_Disabled,    !OrigEntry.UseAlt,
  394.         TAG_DONE);
  395.  
  396.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditX], EditWinHandle, NULL,
  397.             GA_Disabled,    !OrigEntry.IconPos,
  398.         TAG_DONE);
  399.  
  400.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditY], EditWinHandle, NULL,
  401.             GA_Disabled,    !OrigEntry.IconPos,
  402.         TAG_DONE);
  403.  
  404.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditPos], EditWinHandle, NULL,
  405.             GA_Disabled,    !OrigEntry.IconPos,
  406.         TAG_DONE);
  407.  
  408.         GT_SetGadgetAttrs(EditWinGadgets[GD_EditIconPos], EditWinHandle, NULL,
  409.             GTCB_Checked,    OrigEntry.IconPos,
  410.         TAG_DONE);
  411.  
  412.         SetGetFileState(EditWinGadgets[GD_EditGet], EditWinHandle, !OrigEntry.UseAlt);
  413.  
  414.             // Set work mode variable
  415.  
  416.         PosMode = 0;
  417.     }
  418.     else
  419.         CloseEditWin();
  420.  
  421.     if(!EditWinHandle)
  422.         DisplayError(ERR_NOMEM, NULL);
  423.  
  424.     return((BOOL)(EditWinHandle != NULL));
  425. }
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432. /**********************************************************************/
  433. /*                        Close Editor window                         */
  434. /**********************************************************************/
  435. void CloseEditWin(void)
  436. {
  437.         // UnLock main window again
  438.  
  439.     UnBusyWindow(MainWinHandle, &MainReq);
  440.  
  441.         // Close position window
  442.  
  443.     ClosePosWin();
  444.  
  445.         // Close Editor window
  446.  
  447.     CloseWin(&EditWinHandle, &EditWinGList, &EditVisInfo, &EditWinGet);
  448. }
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. /**********************************************************************/
  458. /*                         Open manual window                         */
  459. /**********************************************************************/
  460. BOOL OpenManWin(void)
  461. {
  462.         // Try to open manual input window
  463.  
  464.     if(OpenWin(ManWinLeft,
  465.         ManWinTop,
  466.         ManWinWidth,
  467.         ManWinHeight,
  468.         &ManWinGList,
  469.         MANWIN_CNT,
  470.         NULL,
  471.         ManWinNGad,
  472.         ManWinGTypes,
  473.         ManWinGTags,
  474.         ManWinGadgets,
  475.         &ManWinHandle,
  476.         "ForceIcon v"REVISION" ("REVDATE") - GiftWare, Kai Iske",
  477.         LISTVIEWIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
  478.         WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
  479.         5,
  480.         3,
  481.         429,
  482.         22,
  483.         &ManWinTxtAttr,
  484.         ManWinFontName,
  485.     &ManVisInfo))
  486.     {
  487.         ManualType = 0;
  488.         ActivateGadget(ManWinGadgets[GD_ManVol], ManWinHandle, NULL);
  489.     }
  490.     else
  491.         CloseManWin();
  492.  
  493.     if(!ManWinHandle)
  494.         DisplayError(ERR_NOMEM, NULL);
  495.  
  496.     return((BOOL)(ManWinHandle != NULL));
  497. }
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505. /**********************************************************************/
  506. /*                        Close manual window                         */
  507. /**********************************************************************/
  508. void CloseManWin(void)
  509. {
  510.         // Unbusy main window first
  511.  
  512.     UnBusyWindow(MainWinHandle, &MainReq);
  513.  
  514.         // Close manual input window
  515.  
  516.     CloseWin(&ManWinHandle, &ManWinGList, &ManVisInfo, NULL);
  517. }
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524. /**********************************************************************/
  525. /*                        Open position window                        */
  526. /**********************************************************************/
  527. BOOL OpenPosWin(void)
  528. {
  529.     struct    Screen        *WBScreen;
  530.  
  531.         // Get info about WBScreen
  532.  
  533.     if((WBScreen = LockPubScreen("Workbench")))
  534.     {
  535.         PosWinHandle = OpenWindowTags(NULL,
  536.             WA_Left,    OrigEntry.Left,
  537.             WA_Top,        OrigEntry.Top,
  538.             WA_Width,    (EditWinHandle->IFont->tf_XSize * 8) + 30 + WBScreen->WBorLeft + WBScreen->WBorRight,
  539.             WA_Height,    WBScreen->WBorTop + WBScreen->Font->ta_YSize + 1,
  540.             WA_IDCMP,    IDCMP_CHANGEWINDOW,
  541.             WA_Flags,    WFLG_DEPTHGADGET|WFLG_DRAGBAR|WFLG_RMBTRAP,
  542.             WA_Title,    "IconPos",
  543.             WA_PubScreen,    WBScreen,
  544.         TAG_DONE);
  545.             // Unlock screen
  546.  
  547.         UnlockPubScreen(NULL, WBScreen);
  548.     }
  549.  
  550.  
  551.     if(!PosWinHandle)
  552.         DisplayError(ERR_NOMEM, NULL);
  553.  
  554.     return((BOOL)(PosWinHandle != NULL));
  555. }
  556.  
  557.  
  558.  
  559.  
  560. /**********************************************************************/
  561. /*                       Close Position window                        */
  562. /**********************************************************************/
  563. void ClosePosWin(void)
  564. {
  565.     if(PosWinHandle)
  566.         CloseWindow(PosWinHandle);
  567.     PosWinHandle = NULL;
  568. }
  569.  
  570.  
  571.  
  572. /**********************************************************************/
  573. /*                 Check for inputs from main window                  */
  574. /**********************************************************************/
  575. BOOL HandleMainWin(BOOL *QuitIT)
  576. {
  577.     struct    IntuiMessage    *MyMsg;
  578.     struct    Gadget        *MsgGad;
  579.     ULONG    MsgClass, CurrentSecs, CurrentMins;
  580.     UWORD    GadID, MsgQual, MsgCode;
  581.     BOOL    CloseIT = FALSE, KeyUse;
  582.  
  583.         // Loop for all messages
  584.  
  585.     while((MyMsg = (struct IntuiMessage *)GT_GetIMsg(MainWinHandle->UserPort)))
  586.     {
  587.         MsgClass    = MyMsg->Class;
  588.         MsgQual        = MyMsg->Qualifier;
  589.         MsgCode        = MyMsg->Code;
  590.         CurrentSecs    = MyMsg->Seconds;
  591.         CurrentMins    = MyMsg->Micros;
  592.  
  593.         if((MsgClass & (IDCMP_GADGETUP|IDCMP_GADGETDOWN)))
  594.         {
  595.             MsgGad    = (struct Gadget *)MyMsg->IAddress;
  596.             GadID    = MsgGad->GadgetID;
  597.         }
  598.  
  599.         CheckKeys(&MsgClass, &MsgCode, &GadID, &KeyUse, &MsgGad, &MainWinGadgets[0], MAINWIN_CNT);
  600.  
  601.         GT_ReplyIMsg(MyMsg);
  602.  
  603.         switch(MsgClass)
  604.         {
  605.             case IDCMP_CLOSEWINDOW :
  606.             {
  607.                 CloseIT    = TRUE;
  608.                 break;
  609.             }
  610.             case IDCMP_GADGETUP :
  611.             {
  612.                 switch(GadID)
  613.                 {
  614.                         // Save prefs to env:
  615.  
  616.                     case GD_MainUse :
  617.                     {
  618.                         SavePrefs(TRUE);
  619.                         CloseIT = TRUE;
  620.                         break;
  621.                     }
  622.                         // Save prefs to env: and envarc:
  623.  
  624.                     case GD_MainSave :
  625.                     {
  626.                         SavePrefs(FALSE);
  627.                         CloseIT = TRUE;
  628.                         break;
  629.                     }
  630.                         // Display about
  631.  
  632.                     case GD_MainAbout :
  633.                     {
  634.                         DisplayError(ERR_ABOUT, VERNUM, REVNUM, (ULONG)REVDATE, NULL);
  635.                         break;
  636.                     }
  637.  
  638.                         // Quit it
  639.  
  640.                     case GD_MainQuit :
  641.                     {
  642.                         *QuitIT    = TRUE;
  643.                         CloseIT    = TRUE;
  644.                         break;
  645.                     }
  646.                         // Hide all windows
  647.  
  648.                     case GD_MainHide :
  649.                     {
  650.                         CloseIT    = TRUE;
  651.                         break;
  652.                     }
  653.                         // Selected a new volume from the available ones ???
  654.  
  655.                     case GD_MainVols :
  656.                     {
  657.                         if((SelVolume = HandleListViewGad(MsgGad, MainWinHandle, KeyUse, MsgCode, MsgQual, SelVolume, 0, VolList.lh_Type - 1)) != -1)
  658.                         {
  659.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainAdd], MainWinHandle, NULL,
  660.                                 GA_Disabled,    FALSE,
  661.                             TAG_DONE);
  662.  
  663.                                 // Check for double-click
  664.  
  665.                             if(!KeyUse)
  666.                             {
  667.                                 if(LastRight == SelVolume)
  668.                                 {
  669.                                     if(DoubleClick(SecsRight, MinsRight, CurrentSecs, CurrentMins))
  670.                                     {
  671.                                         struct    VolEntry    *ThisEntry    = (struct VolEntry *)GetListEntry(&VolList, SelVolume);
  672.  
  673.                                         AddNewVolume(ThisEntry->VolName, ThisEntry->Link.ln_Type);
  674.                                     }
  675.                                 }
  676.                                 SecsRight    = CurrentSecs;
  677.                                 MinsRight    = CurrentMins;
  678.                                 LastRight    = SelVolume;
  679.                             }
  680.                         }
  681.                         break;
  682.                     }
  683.                     case GD_MainUseVols :
  684.                     {
  685.                             // Selected a new volume to edit ???
  686.  
  687.                         if((SelEdVolume = HandleListViewGad(MsgGad, MainWinHandle, KeyUse, MsgCode, MsgQual, SelEdVolume, 0, VolumeList.lh_Type - 1)) != -1)
  688.                         {
  689.                             strcpy(MainTypeStr, "Type: ");
  690.                             strcat(MainTypeStr, ManType2Labels[!(((struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume))->Link.ln_Type == LDF_DEVICES)]);
  691.  
  692.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainType], MainWinHandle, NULL,
  693.                                 GTTX_Text,    MainTypeStr,
  694.                             TAG_DONE);
  695.  
  696.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainEdit], MainWinHandle, NULL,
  697.                                 GA_Disabled,    FALSE,
  698.                             TAG_DONE);
  699.  
  700.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainCopy], MainWinHandle, NULL,
  701.                                 GA_Disabled,    FALSE,
  702.                             TAG_DONE);
  703.  
  704.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainRemove], MainWinHandle, NULL,
  705.                                 GA_Disabled,    FALSE,
  706.                             TAG_DONE);
  707.  
  708.                                 // Check for double-click
  709.  
  710.                             if(!KeyUse)
  711.                             {
  712.                                 if(LastLeft == SelEdVolume)
  713.                                 {
  714.                                     if(DoubleClick(SecsLeft, MinsLeft, CurrentSecs, CurrentMins))
  715.                                     {
  716.                                         struct    VolEntry    *EditEntry;
  717.  
  718.                                         if((EditEntry = (struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume)))
  719.                                         {
  720.                                             strcpy(OrigEntry.VolName, EditEntry->VolName);
  721.                                             strcpy(OrigEntry.IconName, EditEntry->IconName);
  722.                                             OrigEntry.Link.ln_Type    = EditEntry->Link.ln_Type;
  723.                                             OrigEntry.Left        = EditEntry->Left;
  724.                                             OrigEntry.Top        = EditEntry->Top;
  725.                                             OrigEntry.UseAlt    = EditEntry->UseAlt;
  726.                                             OrigEntry.IconPos    = EditEntry->IconPos;
  727.  
  728.                                             if(OpenEditWin())
  729.                                                 BusyWindow(MainWinHandle, &MainReq);
  730.                                         }
  731.                                     }
  732.                                 }
  733.                                 SecsLeft    = CurrentSecs;
  734.                                 MinsLeft    = CurrentMins;
  735.                                 LastLeft    = SelEdVolume;
  736.                             }
  737.                         }
  738.                         break;
  739.                     }
  740.                         // Add new entry to list
  741.  
  742.                     case GD_MainAdd :
  743.                     {
  744.                         struct    VolEntry    *VolEntry = (struct VolEntry *)GetListEntry(&VolList, SelVolume);
  745.  
  746.                         if(SelVolume != -1)
  747.                             AddNewVolume(VolEntry->VolName, VolEntry->Link.ln_Type);
  748.                         break;
  749.                     }
  750.                         // Remove active entry from list
  751.  
  752.                     case GD_MainRemove :
  753.                     {
  754.                         struct    VolEntry    *ThisEntry = (struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume);
  755.  
  756.                         if(ThisEntry)
  757.                         {
  758.                                 // Get semaphore
  759.  
  760.                             ObtainSemaphore(&MySemaphore);
  761.  
  762.                                 // Remove list from ListView
  763.  
  764.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  765.                                 GTLV_Labels,    ~0,
  766.                             TAG_DONE);
  767.  
  768.                                 // Remove entry and free memory
  769.  
  770.                             Remove((struct Node *)ThisEntry);
  771.                             FreeVec(ThisEntry);
  772.  
  773.                                 // One entry less
  774.  
  775.                             VolumeList.lh_Type--;
  776.  
  777.                                 // Set pointer to current entry
  778.  
  779.                             if(SelEdVolume >= VolumeList.lh_Type)
  780.                                 SelEdVolume--;
  781.  
  782.                                 // Still entries available ???
  783.  
  784.                             if(SelEdVolume > -1)
  785.                             {
  786.                                     // Reinstall list
  787.  
  788.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  789.                                     GTLV_Labels,    &VolumeList,
  790.                                     GTLV_Selected,    SelEdVolume,
  791.                                     GTLV_Top,    SelEdVolume,
  792.                                 TAG_DONE);
  793.  
  794.                                 strcpy(MainTypeStr, "Type: ");
  795.                                 strcat(MainTypeStr, ManType2Labels[!(((struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume))->Link.ln_Type == LDF_DEVICES)]);
  796.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainType], MainWinHandle, NULL,
  797.                                     GTTX_Text,    MainTypeStr,
  798.                                 TAG_DONE);
  799.                             }
  800.                             else
  801.                             {
  802.                                     // Disable gadgets
  803.  
  804.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  805.                                     GTLV_Labels,    NULL,
  806.                                 TAG_DONE);
  807.  
  808.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainEdit], MainWinHandle, NULL,
  809.                                     GA_Disabled,    TRUE,
  810.                                 TAG_DONE);
  811.  
  812.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainCopy], MainWinHandle, NULL,
  813.                                     GA_Disabled,    TRUE,
  814.                                 TAG_DONE);
  815.  
  816.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainRemove], MainWinHandle, NULL,
  817.                                     GA_Disabled,    TRUE,
  818.                                 TAG_DONE);
  819.  
  820.                                 strcpy(MainTypeStr, "");
  821.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainType], MainWinHandle, NULL,
  822.                                     GTTX_Text,    MainTypeStr,
  823.                                 TAG_DONE);
  824.                             }
  825.  
  826.                             ReleaseSemaphore(&MySemaphore);
  827.                         }
  828.                         break;
  829.                     }
  830.                         // Edit current entry using the Editor window
  831.  
  832.                     case GD_MainEdit :
  833.                     {
  834.                         struct    VolEntry    *EditEntry;
  835.  
  836.                         if((EditEntry = (struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume)))
  837.                         {
  838.                                 // Copy data from current entry to spare
  839.  
  840.                             strcpy(OrigEntry.VolName, EditEntry->VolName);
  841.                             strcpy(OrigEntry.IconName, EditEntry->IconName);
  842.                             OrigEntry.Link.ln_Type    = EditEntry->Link.ln_Type;
  843.                             OrigEntry.Left        = EditEntry->Left;
  844.                             OrigEntry.Top        = EditEntry->Top;
  845.                             OrigEntry.UseAlt    = EditEntry->UseAlt;
  846.                             OrigEntry.IconPos    = EditEntry->IconPos;
  847.  
  848.                             if(OpenEditWin())
  849.                                 BusyWindow(MainWinHandle, &MainReq);
  850.                         }
  851.                         break;
  852.                     }
  853.                         // Copy entry ???
  854.  
  855.                     case GD_MainCopy :
  856.                     {
  857.                         if((CloneEntry = (struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume)))
  858.                         {
  859.                             if(OpenManWin())
  860.                                 BusyWindow(MainWinHandle, &MainReq);
  861.                         }
  862.                         break;
  863.                     }
  864.  
  865.                         // Enter manually
  866.  
  867.                     case GD_MainManual :
  868.                     {
  869.                         if(OpenManWin())
  870.                             BusyWindow(MainWinHandle, &MainReq);
  871.                         break;
  872.                     }
  873.                         // Recan volume list
  874.  
  875.                     case GD_MainRescan :
  876.                     {
  877.                             // Remove list
  878.  
  879.                         GT_SetGadgetAttrs(MainWinGadgets[GD_MainVols], MainWinHandle, NULL,
  880.                             GTLV_Labels,    ~0,
  881.                         TAG_DONE);
  882.  
  883.                             // Free old list and get new
  884.  
  885.                         FreeDevVolList(&VolList);
  886.                         GetDevVolList(&VolList);
  887.  
  888.                             // Set pointer to current entry
  889.  
  890.                         if(SelVolume >= VolList.lh_Type)
  891.                             SelVolume = VolList.lh_Type - 1;
  892.  
  893.                             // Reinstall gadget
  894.  
  895.                         GT_SetGadgetAttrs(MainWinGadgets[GD_MainVols], MainWinHandle, NULL,
  896.                             GTLV_Labels,    &VolList,
  897.                         TAG_DONE);
  898.  
  899.                             // Set gadget state
  900.  
  901.                         if(!VolList.lh_Type)
  902.                         {
  903.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainAdd], MainWinHandle, NULL,
  904.                                 GA_Disabled,    TRUE,
  905.                             TAG_DONE);
  906.                         }
  907.                         else
  908.                         {
  909.                             if(SelVolume != -1)
  910.                             {
  911.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainAdd], MainWinHandle, NULL,
  912.                                     GA_Disabled,    FALSE,
  913.                                 TAG_DONE);
  914.                             }
  915.                         }
  916.                         break;
  917.                     }
  918.                 }
  919.                 break;
  920.             }
  921.         }
  922.     }
  923.  
  924.     return(CloseIT);
  925. }
  926.  
  927.  
  928.  
  929.  
  930.  
  931. /**********************************************************************/
  932. /*                  Handle inputs from Editor window                  */
  933. /**********************************************************************/
  934. BOOL HandleEditWin(void)
  935. {
  936.     struct    IntuiMessage    *MyMsg;
  937.     struct    Gadget        *MsgGad;
  938.     ULONG    MsgClass;
  939.     UWORD    GadID, MsgQual, MsgCode;
  940.     BOOL    CloseIT = FALSE, KeyUse;
  941.  
  942.         // Loop for all messages
  943.  
  944.     while((MyMsg = (struct IntuiMessage *)GT_GetIMsg(EditWinHandle->UserPort)))
  945.     {
  946.         MsgClass    = MyMsg->Class;
  947.         MsgQual        = MyMsg->Qualifier;
  948.         MsgCode        = MyMsg->Code;
  949.  
  950.         if((MsgClass & (IDCMP_GADGETUP|IDCMP_GADGETDOWN)))
  951.         {
  952.             MsgGad    = (struct Gadget *)MyMsg->IAddress;
  953.             GadID    = MsgGad->GadgetID;
  954.         }
  955.  
  956.         CheckKeys(&MsgClass, &MsgCode, &GadID, &KeyUse, &MsgGad, &EditWinGadgets[0], EDITWIN_CNT);
  957.  
  958.         GT_ReplyIMsg(MyMsg);
  959.  
  960.         switch(MsgClass)
  961.         {
  962.             case IDCMP_CLOSEWINDOW :
  963.             {
  964.                 CloseIT    = TRUE;
  965.                 break;
  966.             }
  967.             case IDCMP_GADGETUP :
  968.             {
  969.                 switch(GadID)
  970.                 {
  971.                         // Settings ok, copy to current entry
  972.  
  973.                     case GD_EditOk :
  974.                     {
  975.                         struct    VolEntry    *ToEntry = (struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume);
  976.  
  977.                         if(ToEntry)
  978.                         {
  979.                             LONG    NewSel = SelEdVolume;
  980.  
  981.                                 // Get semaphore
  982.  
  983.                             ObtainSemaphore(&MySemaphore);
  984.  
  985.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  986.                                 GTLV_Labels,    ~0,
  987.                             TAG_DONE);
  988.  
  989.                                 // Fill out structure
  990.  
  991.                             strcpy(ToEntry->VolName, ((struct StringInfo *)EditWinGadgets[GD_EditVol]->SpecialInfo)->Buffer);
  992.                             strcpy(ToEntry->IconName, ((struct StringInfo *)EditWinGadgets[GD_EditIcon]->SpecialInfo)->Buffer);
  993.                             if(!strstr(ToEntry->IconName, ".info") && strlen(ToEntry->IconName))
  994.                                 strcat(ToEntry->IconName, ".info");
  995.  
  996.                                 // Rearrange Node`s position
  997.  
  998.                             if(ToEntry->Link.ln_Type != OrigEntry.Link.ln_Type)
  999.                             {
  1000.                                 Remove((struct Node *)ToEntry);
  1001.  
  1002.                                 if(OrigEntry.Link.ln_Type == LDF_DEVICES)
  1003.                                     AddTail(&VolumeList, (struct Node *)ToEntry);
  1004.                                 else
  1005.                                     AddHead(&VolumeList, (struct Node *)ToEntry);
  1006.                                 SelEdVolume    = -1;
  1007.                                 NewSel        = ~0;
  1008.                             }
  1009.  
  1010.                             ToEntry->Link.ln_Type    = OrigEntry.Link.ln_Type;
  1011.                             ToEntry->Left        = OrigEntry.Left;
  1012.                             ToEntry->Top        = OrigEntry.Top;
  1013.                             ToEntry->UseAlt        = OrigEntry.UseAlt;
  1014.                             ToEntry->IconPos    = OrigEntry.IconPos;
  1015.  
  1016.                                 // Sort List again
  1017.  
  1018.                             if(NewSel == ~0)
  1019.                                 SortList(&VolumeList, TRUE);
  1020.  
  1021.                                 // Reset listview
  1022.  
  1023.                             GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  1024.                                 GTLV_Labels,    &VolumeList,
  1025.                                 GTLV_Selected,    NewSel,
  1026.                                 GTLV_Top,    0,
  1027.                             TAG_DONE);
  1028.  
  1029.                             if(NewSel == ~0)
  1030.                             {
  1031.                                     // Disable edit and remove gadgets
  1032.  
  1033.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainEdit], MainWinHandle, NULL,
  1034.                                     GA_Disabled,    TRUE,
  1035.                                 TAG_DONE);
  1036.  
  1037.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainCopy], MainWinHandle, NULL,
  1038.                                     GA_Disabled,    TRUE,
  1039.                                 TAG_DONE);
  1040.  
  1041.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainRemove], MainWinHandle, NULL,
  1042.                                     GA_Disabled,    TRUE,
  1043.                                 TAG_DONE);
  1044.  
  1045.                                 strcpy(MainTypeStr, "");
  1046.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainType], MainWinHandle, NULL,
  1047.                                     GTTX_Text,    MainTypeStr,
  1048.                                 TAG_DONE);
  1049.                             }
  1050.                             else
  1051.                             {
  1052.                                 strcpy(MainTypeStr, "Type: ");
  1053.                                 strcat(MainTypeStr, ManType2Labels[!(((struct VolEntry *)GetListEntry(&VolumeList, SelEdVolume))->Link.ln_Type == LDF_DEVICES)]);
  1054.                                 GT_SetGadgetAttrs(MainWinGadgets[GD_MainType], MainWinHandle, NULL,
  1055.                                     GTTX_Text,    MainTypeStr,
  1056.                                 TAG_DONE);
  1057.                             }
  1058.  
  1059.                                 // Release our semaphore
  1060.  
  1061.                             ReleaseSemaphore(&MySemaphore);
  1062.                         }
  1063.  
  1064.                         CloseIT = TRUE;
  1065.                         break;
  1066.                     }
  1067.                         // Cancel Editor window
  1068.  
  1069.                     case GD_EditCancel :
  1070.                     {
  1071.                         CloseIT = TRUE;
  1072.                         break;
  1073.                     }
  1074.                         // Change Type of entry
  1075.  
  1076.                     case GD_EditType :
  1077.                     {
  1078.                         ManualType = HandleCycleGad(MsgGad, EditWinHandle, KeyUse, MsgCode, MsgQual, ManualType, 0, 1);
  1079.  
  1080.                         OrigEntry.Link.ln_Type = (!ManualType) ? LDF_DEVICES : LDF_VOLUMES;
  1081.                         break;
  1082.                     }
  1083.                         // Set X position manually
  1084.  
  1085.                     case GD_EditX :
  1086.                     {
  1087.                         if(OrigEntry.IconPos)
  1088.                         {
  1089.                             LONG    Val    = ((struct StringInfo *)MsgGad->SpecialInfo)->LongInt;
  1090.  
  1091.                             if(Val >= 0)
  1092.                             {
  1093.                                 OrigEntry.Left    = Val;
  1094.                                 if(PosWinHandle)
  1095.                                     MoveWindow(PosWinHandle, OrigEntry.Left - PosWinHandle->LeftEdge, 0);
  1096.                             }
  1097.                             else
  1098.                             {
  1099.                                 DisplayError(ERR_NONEG, NULL);
  1100.                                 GT_SetGadgetAttrs(MsgGad, EditWinHandle, NULL,
  1101.                                     GTIN_Number,    OrigEntry.Left,
  1102.                                 TAG_DONE);
  1103.                             }
  1104.                         }
  1105.                         break;
  1106.                     }
  1107.                         // Set Y position manually
  1108.  
  1109.                     case GD_EditY :
  1110.                     {
  1111.                         if(OrigEntry.IconPos)
  1112.                         {
  1113.                             LONG    Val    = ((struct StringInfo *)MsgGad->SpecialInfo)->LongInt;
  1114.  
  1115.                             if(Val >= 0)
  1116.                             {
  1117.                                 OrigEntry.Top    = Val;
  1118.                                 if(PosWinHandle)
  1119.                                     MoveWindow(PosWinHandle, 0, OrigEntry.Top - PosWinHandle->TopEdge);
  1120.                             }
  1121.                             else
  1122.                             {
  1123.                                 DisplayError(ERR_NONEG, NULL);
  1124.                                 GT_SetGadgetAttrs(MsgGad, EditWinHandle, NULL,
  1125.                                     GTIN_Number,    OrigEntry.Top,
  1126.                                 TAG_DONE);
  1127.                             }
  1128.                         }
  1129.                         break;
  1130.                     }
  1131.  
  1132.                         // Open/Close position window
  1133.  
  1134.                     case GD_EditPos :
  1135.                     {
  1136.                         if(OrigEntry.IconPos)
  1137.                         {
  1138.                             PosMode = HandleCycleGad(MsgGad, EditWinHandle, KeyUse, MsgCode, MsgQual, PosMode, 0, 1);
  1139.  
  1140.                             if(PosMode)
  1141.                             {
  1142.                                 if(!OpenPosWin())
  1143.                                 {
  1144.                                     PosMode = 0;
  1145.                                     GT_SetGadgetAttrs(EditWinGadgets[GD_EditPos], EditWinHandle, NULL,
  1146.                                         GTCY_Active, PosMode,
  1147.                                     TAG_DONE);
  1148.                                 }
  1149.                             }
  1150.                             else
  1151.                                 ClosePosWin();
  1152.                         }
  1153.                         break;
  1154.                     }
  1155.                         // Set mode for Icon position
  1156.  
  1157.                     case GD_EditIconPos :
  1158.                     {
  1159.                         if(KeyUse)
  1160.                             OrigEntry.IconPos    = !OrigEntry.IconPos;
  1161.                         else
  1162.                             OrigEntry.IconPos    = MsgCode;
  1163.  
  1164.                         GT_SetGadgetAttrs(EditWinGadgets[GD_EditIconPos], EditWinHandle, NULL,
  1165.                             GTCB_Checked,    OrigEntry.IconPos,
  1166.                         TAG_DONE);
  1167.  
  1168.                         GT_SetGadgetAttrs(EditWinGadgets[GD_EditX], EditWinHandle, NULL,
  1169.                             GA_Disabled,    !OrigEntry.IconPos,
  1170.                         TAG_DONE);
  1171.  
  1172.                         GT_SetGadgetAttrs(EditWinGadgets[GD_EditY], EditWinHandle, NULL,
  1173.                             GA_Disabled,    !OrigEntry.IconPos,
  1174.                         TAG_DONE);
  1175.  
  1176.                         GT_SetGadgetAttrs(EditWinGadgets[GD_EditPos], EditWinHandle, NULL,
  1177.                             GA_Disabled,    !OrigEntry.IconPos,
  1178.                         TAG_DONE);
  1179.                         break;
  1180.                     }
  1181.                     case GD_EditGet :
  1182.                     {
  1183.                         char    BackName[256];
  1184.  
  1185.                             // Allowed to use alternative icon ???
  1186.  
  1187.                         if(OrigEntry.UseAlt)
  1188.                         {
  1189.                                 // Get it using ListView
  1190.  
  1191.                             strcpy(BackName, OrigEntry.IconName);
  1192.                             if(!GetFileName(EditWinHandle, "Select an icon", OrigEntry.IconName))
  1193.                                 strcpy(OrigEntry.IconName, BackName);
  1194.                             else
  1195.                             {
  1196.                                 if(!strstr(OrigEntry.IconName, ".info"))
  1197.                                     strcat(OrigEntry.IconName, ".info");
  1198.                             }
  1199.  
  1200.                             GT_SetGadgetAttrs(EditWinGadgets[GD_EditIcon], EditWinHandle, NULL,
  1201.                                 GTST_String,    OrigEntry.IconName,
  1202.                             TAG_DONE);
  1203.                         }
  1204.                         break;
  1205.                     }
  1206.                     case GD_EditUseIcon :
  1207.                     {
  1208.                         if(KeyUse)
  1209.                             OrigEntry.UseAlt = !OrigEntry.UseAlt;
  1210.                         else
  1211.                             OrigEntry.UseAlt = MsgCode;
  1212.  
  1213.                         GT_SetGadgetAttrs(MsgGad, EditWinHandle, NULL,
  1214.                             GTCB_Checked,    OrigEntry.UseAlt,
  1215.                         TAG_DONE);
  1216.  
  1217.                         GT_SetGadgetAttrs(EditWinGadgets[GD_EditIcon], EditWinHandle, NULL,
  1218.                             GA_Disabled,    !OrigEntry.UseAlt,
  1219.                         TAG_DONE);
  1220.  
  1221.                         SetGetFileState(EditWinGadgets[GD_EditGet], EditWinHandle, !OrigEntry.UseAlt);
  1222.                         break;
  1223.                     }
  1224.                 }
  1225.                 break;
  1226.             }
  1227.             case IDCMP_GADGETDOWN :
  1228.             {
  1229.                 switch(GadID)
  1230.                 {
  1231.                     case GD_EditVol :
  1232.                     {
  1233.                         ActivateGadget(MsgGad, EditWinHandle, NULL);
  1234.                         break;
  1235.                     }
  1236.                     case GD_EditIcon :
  1237.                     {
  1238.                         if(OrigEntry.UseAlt)
  1239.                         {
  1240.                             if(KeyUse && (MsgQual & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)))
  1241.                             {
  1242.                                 char    BackName[256];
  1243.  
  1244.                                 strcpy(BackName, OrigEntry.IconName);
  1245.                                 if(!GetFileName(EditWinHandle, "Select an icon", OrigEntry.IconName))
  1246.                                     strcpy(OrigEntry.IconName, BackName);
  1247.                                 else
  1248.                                 {
  1249.                                     if(!strstr(OrigEntry.IconName, ".info"))
  1250.                                         strcat(OrigEntry.IconName, ".info");
  1251.                                 }
  1252.  
  1253.                                 GT_SetGadgetAttrs(EditWinGadgets[GD_EditIcon], EditWinHandle, NULL,
  1254.                                     GTST_String,    OrigEntry.IconName,
  1255.                                 TAG_DONE);
  1256.                             }
  1257.                             else
  1258.                                 ActivateGadget(MsgGad, EditWinHandle, NULL);
  1259.                         }
  1260.                         break;
  1261.                     }
  1262.                     case GD_EditX :
  1263.                     case GD_EditY :
  1264.                     {
  1265.                         if(OrigEntry.IconPos)
  1266.                             ActivateGadget(MsgGad, EditWinHandle, NULL);
  1267.                         break;
  1268.                     }
  1269.                 }
  1270.                 break;
  1271.             }
  1272.             case IDCMP_ACTSTRGAD :
  1273.             {
  1274.                 ActivateGadget(MsgGad, EditWinHandle, NULL);
  1275.                 break;
  1276.             }
  1277.         }
  1278.     }
  1279.  
  1280.     return(CloseIT);
  1281. }
  1282.  
  1283.  
  1284.  
  1285.  
  1286. /**********************************************************************/
  1287. /*                  Handle input from manual window                   */
  1288. /**********************************************************************/
  1289. BOOL HandleManWin(void)
  1290. {
  1291.     struct    IntuiMessage    *MyMsg;
  1292.     struct    Gadget        *MsgGad;
  1293.     ULONG    MsgClass;
  1294.     UWORD    GadID, MsgCode, MsgQual;
  1295.     BOOL    CloseIT = FALSE, KeyUse;
  1296.  
  1297.         // Loop for all messages
  1298.  
  1299.     while((MyMsg = (struct IntuiMessage *)GT_GetIMsg(ManWinHandle->UserPort)))
  1300.     {
  1301.         MsgClass    = MyMsg->Class;
  1302.         MsgCode        = MyMsg->Code;
  1303.         MsgQual        = MyMsg->Qualifier;
  1304.  
  1305.         if((MsgClass & (IDCMP_GADGETUP|IDCMP_GADGETDOWN)))
  1306.         {
  1307.             MsgGad    = (struct Gadget *)MyMsg->IAddress;
  1308.             GadID    = MsgGad->GadgetID;
  1309.         }
  1310.  
  1311.         CheckKeys(&MsgClass, &MsgCode, &GadID, &KeyUse, &MsgGad, &ManWinGadgets[0], EDITWIN_CNT);
  1312.  
  1313.         GT_ReplyIMsg(MyMsg);
  1314.  
  1315.         switch(MsgClass)
  1316.         {
  1317.             case IDCMP_CLOSEWINDOW :
  1318.             {
  1319.                 CloneEntry    = NULL;
  1320.                 CloseIT        = TRUE;
  1321.                 break;
  1322.             }
  1323.             case IDCMP_GADGETUP :
  1324.             {
  1325.                 switch(GadID)
  1326.                 {
  1327.                         // On Ok, add a new volume to the list
  1328.  
  1329.                     case GD_ManOk :
  1330.                     {
  1331.                         if(!CheckExists(((struct StringInfo *)ManWinGadgets[GD_ManVol]->SpecialInfo)->Buffer))
  1332.                         {
  1333.                             struct    VolEntry    *ThisEntry = AddNewVolume(((struct StringInfo *)ManWinGadgets[GD_ManVol]->SpecialInfo)->Buffer, (!ManualType) ? LDF_DEVICES : LDF_VOLUMES);
  1334.  
  1335.                                 // Currently cloning an entry ??
  1336.  
  1337.                             if(CloneEntry && ThisEntry)
  1338.                             {
  1339.                                     // Clone remaining parts of entry
  1340.  
  1341.                                 strcpy(ThisEntry->IconName, CloneEntry->IconName);
  1342.                                 ThisEntry->Left        = CloneEntry->Left;
  1343.                                 ThisEntry->Top        = CloneEntry->Top;
  1344.                                 ThisEntry->UseAlt    = CloneEntry->UseAlt;
  1345.                                 ThisEntry->IconPos    = CloneEntry->IconPos;
  1346.                             }
  1347.  
  1348.                             CloneEntry    = NULL;
  1349.                             CloseIT        = TRUE;
  1350.                         }
  1351.                         else
  1352.                         {
  1353.                             CloneEntry    = NULL;
  1354.                             DisplayError(ERR_EXISTS, (ULONG)((struct StringInfo *)ManWinGadgets[GD_ManVol]->SpecialInfo)->Buffer, NULL);
  1355.                         }
  1356.                         break;
  1357.                     }
  1358.                     case GD_ManCancel :
  1359.                     {
  1360.                         CloneEntry    = NULL;
  1361.                         CloseIT        = TRUE;
  1362.                         break;
  1363.                     }
  1364.                     case GD_ManType :
  1365.                     {
  1366.                          ManualType = HandleCycleGad(MsgGad, ManWinHandle, KeyUse, MsgCode, MsgQual, ManualType, 0, 1);
  1367.                          break;
  1368.                     }
  1369.                 }
  1370.                 break;
  1371.             }
  1372.             case IDCMP_GADGETDOWN :
  1373.             {
  1374.                 switch(GadID)
  1375.                 {
  1376.                     case GD_ManVol :
  1377.                     {
  1378.                         ActivateGadget(MsgGad, ManWinHandle, NULL);
  1379.                         break;
  1380.                     }
  1381.                 }
  1382.                 break;
  1383.             }
  1384.             case IDCMP_ACTSTRGAD :
  1385.             {
  1386.                 ActivateGadget(MsgGad, ManWinHandle, NULL);
  1387.                 break;
  1388.             }
  1389.         }
  1390.     }
  1391.     return(CloseIT);
  1392. }
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400. /**********************************************************************/
  1401. /*                 Handle input from Position window                  */
  1402. /**********************************************************************/
  1403. void HandlePosWin(void)
  1404. {
  1405.     struct    IntuiMessage    *MyMsg;
  1406.     ULONG    MsgClass;
  1407.  
  1408.     while((MyMsg = (struct IntuiMessage *)GT_GetIMsg(PosWinHandle->UserPort)))
  1409.     {
  1410.         MsgClass    = MyMsg->Class;
  1411.  
  1412.         GT_ReplyIMsg(MyMsg);
  1413.  
  1414.             // Window was moved, so set the new values to the number gadgets
  1415.  
  1416.         if(MsgClass == IDCMP_CHANGEWINDOW)
  1417.         {
  1418.             OrigEntry.Left    = PosWinHandle->LeftEdge;
  1419.             OrigEntry.Top    = PosWinHandle->TopEdge;
  1420.  
  1421.             GT_SetGadgetAttrs(EditWinGadgets[GD_EditX], EditWinHandle, NULL,
  1422.                 GTIN_Number,    OrigEntry.Left,
  1423.             TAG_DONE);
  1424.  
  1425.             GT_SetGadgetAttrs(EditWinGadgets[GD_EditY], EditWinHandle, NULL,
  1426.                 GTIN_Number,    OrigEntry.Top,
  1427.             TAG_DONE);
  1428.         }
  1429.     }
  1430. }
  1431.  
  1432.  
  1433.  
  1434. /**********************************************************************/
  1435. /*                 Add a new entry to the volume list                 */
  1436. /**********************************************************************/
  1437. static struct VolEntry *AddNewVolume(char *Name, ULONG Type)
  1438. {
  1439.     struct    VolEntry    *NewEntry = NULL;
  1440.  
  1441.         // Check for exitance
  1442.  
  1443.     if(CheckExists(Name))
  1444.     {
  1445.         DisplayError(ERR_EXISTS, (ULONG)Name, NULL);
  1446.         return(NewEntry);
  1447.     }
  1448.  
  1449.         // Try to get our semaphore
  1450.  
  1451.     ObtainSemaphore(&MySemaphore);
  1452.  
  1453.         // Get memory for new entry
  1454.  
  1455.     if((NewEntry = AllocVec(sizeof(struct VolEntry), MEMF_CLEAR)))
  1456.     {
  1457.         GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  1458.             GTLV_Labels,    ~0,
  1459.         TAG_DONE);
  1460.  
  1461.         VolumeList.lh_Type++;
  1462.         SelEdVolume = -1;
  1463.  
  1464.             // Add entry and fill out structure
  1465.  
  1466.         if(Type == LDF_VOLUMES)
  1467.             AddHead(&VolumeList, (struct Node *)NewEntry);
  1468.         else
  1469.             AddTail(&VolumeList, (struct Node *)NewEntry);
  1470.  
  1471.         NewEntry->Link.ln_Name    = NewEntry->VolName;
  1472.         NewEntry->Link.ln_Type    = Type;
  1473.         strcpy(NewEntry->VolName, Name);
  1474.  
  1475.             // Sort the list again
  1476.  
  1477.         SortList(&VolumeList, TRUE);
  1478.  
  1479.             // reset listview
  1480.  
  1481.         GT_SetGadgetAttrs(MainWinGadgets[GD_MainUseVols], MainWinHandle, NULL,
  1482.             GTLV_Labels,    &VolumeList,
  1483.             GTLV_Selected,    ~0,
  1484.             GTLV_Top,    0,
  1485.         TAG_DONE);
  1486.  
  1487.             // Disable edit and remove gadgets
  1488.  
  1489.         GT_SetGadgetAttrs(MainWinGadgets[GD_MainEdit], MainWinHandle, NULL,
  1490.             GA_Disabled,    TRUE,
  1491.         TAG_DONE);
  1492.  
  1493.         GT_SetGadgetAttrs(MainWinGadgets[GD_MainCopy], MainWinHandle, NULL,
  1494.             GA_Disabled,    TRUE,
  1495.         TAG_DONE);
  1496.  
  1497.         GT_SetGadgetAttrs(MainWinGadgets[GD_MainRemove], MainWinHandle, NULL,
  1498.             GA_Disabled,    TRUE,
  1499.         TAG_DONE);
  1500.  
  1501.         strcpy(MainTypeStr, "");
  1502.         GT_SetGadgetAttrs(MainWinGadgets[GD_MainType], MainWinHandle, NULL,
  1503.             GTTX_Text,    MainTypeStr,
  1504.         TAG_DONE);
  1505.     }
  1506.     else
  1507.     {
  1508.         DisplayError(ERR_NOMEM, NULL);
  1509.         NewEntry    = NULL;
  1510.     }
  1511.  
  1512.         // Free our semaphore
  1513.  
  1514.     ReleaseSemaphore(&MySemaphore);
  1515.  
  1516.     return(NewEntry);
  1517. }
  1518.  
  1519.  
  1520.  
  1521. /**********************************************************************/
  1522. /*              Sets the state of a generic_kind gadget               */
  1523. /**********************************************************************/
  1524. static void SetGetFileState(struct Gadget *Gad, struct Window *Win, BOOL State)
  1525. {
  1526.     RemoveGList(Win, Gad, 1);
  1527.  
  1528.     if(!State)
  1529.         Gad->Flags &= ~GFLG_DISABLED;
  1530.     else
  1531.         Gad->Flags |= GFLG_DISABLED;
  1532.  
  1533.     AddGList(Win, Gad, -1, 1, NULL);
  1534.     RefreshGList(Gad, Win, NULL, 1);
  1535. }
  1536.