home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / networking / misc / gadmget1.6.lha / GadMget1.6 / Source / mget_listview2.c < prev   
Encoding:
C/C++ Source or Header  |  1994-10-30  |  15.3 KB  |  593 lines

  1. #ifndef MGET_LISTVIEW2_C
  2. #define MGET_LISTVIEW2_C
  3.  
  4. /*
  5.  *  Source machine generated by GadToolsBox V2.0b
  6.  *  which is (c) Copyright 1991-1993 Jaba Development
  7.  *
  8.  *  GUI Designed by : Jeremy Friesner
  9.  */
  10.  
  11. #include <exec/types.h>
  12. #include <exec/libraries.h>
  13. #include <intuition/intuition.h>g
  14. #include <intuition/classes.h>
  15. #include <intuition/classusr.h>
  16. #include <intuition/imageclass.h>
  17. #include <intuition/gadgetclass.h>
  18. #include <libraries/gadtools.h>
  19. #include <graphics/displayinfo.h>
  20. #include <graphics/gfxbase.h>
  21. #include <clib/exec_protos.h>
  22. #include <clib/intuition_protos.h>
  23. #include <clib/gadtools_protos.h>
  24. #include <clib/graphics_protos.h>
  25. #include <clib/utility_protos.h>
  26. #include <clib/wb_protos.h>
  27.  
  28. #include <workbench/workbench.h>
  29. #include <workbench/startup.h>
  30. #include <string.h>
  31.  
  32. #include "mget_listview2.h"
  33. #include "Gadmget.h"
  34.  
  35. extern char pnamestring[];
  36. extern struct List *filelist;
  37. extern struct List *getlist;
  38. extern struct Gadget *findgadlist;
  39. extern void *findvi;
  40. extern int appwindow;
  41. extern char *pubscreenname;
  42. extern int screentype;
  43. extern UWORD windowwidth;
  44. extern UWORD windowheight;
  45. extern UWORD windowtop;
  46. extern UWORD windowleft;
  47. extern char windowtitle[];
  48. extern int windowisopen;
  49. extern int screenisopen;
  50. extern char sListFontName[];
  51. extern char sOutFileName[];
  52. extern int nListFontSize;
  53. int screenwidth,screenheight;
  54. extern FILE *fpOut;
  55. extern struct TextFont *listfontdata;  /* pointer to font data */
  56. extern struct GfxBase *GraphicsBase;        /* needed to determine default system font */
  57. extern BOOL BStartedFromWB;
  58. extern int nTopListTop;
  59. extern int nTopListHeight;
  60.     
  61.  
  62. struct Screen        *Scr = NULL;
  63. APTR                 VisualInfo = NULL;
  64. struct Window        *mgetWnd = NULL;
  65. struct Window            *findwindow = NULL;
  66. struct AppWindow        *appwin = NULL;
  67. struct AppMessage        *amsg = NULL;
  68. struct MsgPort         *awport = NULL;
  69. struct Gadget        *mgetGList = NULL;
  70. struct Menu          *mgetMenus = NULL;
  71. struct IntuiMessage  mgetMsg;
  72. struct Gadget        *mgetGadgets[2];
  73. UWORD                mgetLeft = 0;
  74. UWORD                mgetTop = 12;
  75. UWORD lastcode;
  76. ULONG appwinsig = 0L;
  77.  
  78. struct TextAttr topaz8 = {
  79.     ( STRPTR )"topaz.font", 8, 0x00, 0x00 };
  80.  
  81. struct TextAttr listfont = {
  82.     NULL, 0 , 0x00, 0x00 };
  83.  
  84. struct NewMenu mgetNewMenu[] = {
  85. /* 0  */    NM_TITLE, (STRPTR)"Project", NULL, 0L, NULL, NULL,
  86. /* 1  */    NM_ITEM, (STRPTR)"Open", (STRPTR)"O", 0, 0L, (APTR)mgetopenfile,
  87. /* 2  */ NM_ITEM, (STRPTR)"Append", (STRPTR)"A", 0, 0L, (APTR) mgetappend,
  88. /* 3  */    NM_ITEM, (STRPTR)"About", NULL, 0, 0L, (APTR)mgetabout,
  89. /* 4  */    NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0L, 0L, NULL,
  90. /* 5  */    NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, (APTR)mgetquit,
  91. /* 6  */    NM_TITLE,(STRPTR)"Search", NULL, 0L, NULL, NULL,
  92. /* 7  */    NM_ITEM, (STRPTR)"Find", (STRPTR)"F", 0, 0L, (APTR)mgetfind,
  93. /* 8  */    NM_ITEM, (STRPTR)"Find Next", (STRPTR)"N", 0, 0L, (APTR)mgetfindnext,
  94. /* 9  */    NM_ITEM, (STRPTR)"Case Sensitive", (STRPTR)"C", 0|CHECKIT, 0L, (APTR)mgetcase,
  95. /* 10 */ NM_TITLE,(STRPTR)"Sort", NULL, 0L, NULL, NULL,
  96. /* 11 */ NM_ITEM, (STRPTR)"Files List", NULL, 0L, NULL, NULL,
  97. /* 12 */ NM_SUB,  (STRPTR)"By Directory", (STRPTR)"!", 0L, NULL, (APTR)mgetfilesbydir,
  98. /* 13 */ NM_SUB,  (STRPTR)"By Size", (STRPTR)"@", 0L, NULL, (APTR)mgetfilesbysize,
  99. /* 14 */ NM_SUB,  (STRPTR)"By FileName", (STRPTR)"#", 0L, NULL, (APTR)mgetfilesbyname,
  100. /* 15 */ NM_SUB,  (STRPTR)"By Description", (STRPTR)"$", 0L, NULL, (APTR)mgetfilesbydesc,
  101. /* 16 */ NM_SUB,  (STRPTR)"Keep Sorted", NULL, 0|CHECKIT, 0L, (APTR) mgetfileskeep,
  102. /* 17 */ NM_ITEM, (STRPTR)"Get List", NULL, 0L, NULL, NULL,
  103. /* 18 */ NM_SUB,  (STRPTR)"By Directory", (STRPTR)"1", 0L, NULL, (APTR)mgetgetbydir,
  104. /* 19 */ NM_SUB,  (STRPTR)"By Size", (STRPTR)"2", 0L, NULL, (APTR)mgetgetbysize,
  105. /* 20 */ NM_SUB,  (STRPTR)"By FileName", (STRPTR)"3", 0L, NULL, (APTR)mgetgetbyname,
  106. /* 21 */ NM_SUB,  (STRPTR)"By Description", (STRPTR)"4", 0L, NULL, (APTR)mgetgetbydesc,
  107. /* 22 */ NM_SUB,  (STRPTR)"Keep Sorted", NULL, 0|CHECKIT, 0L, (APTR) mgetgetkeep,
  108. /* 23 */    NM_TITLE,(STRPTR)"Output", NULL, 0L, NULL, NULL,
  109. /* 24 */    NM_ITEM, (STRPTR)"Aminet Parse", NULL, 0|CHECKIT, 0L, (APTR)mgetnoparse,
  110. /* 25 */    NM_ITEM, (STRPTR)"Get Files", NULL, 0|CHECKIT, 0L, (APTR)mgetfiles,
  111. /* 26 */    NM_ITEM, (STRPTR)"Get Readmes", NULL, 0|CHECKIT, 0L, (APTR)mgetreadmes,
  112. /* 27 */    NM_ITEM, (STRPTR)"Split Commands", NULL, 0|CHECKIT, 0L, (APTR)mgetsplit,
  113. /* 28 */ NM_ITEM, (STRPTR)"Simple Paths", NULL, 0|CHECKIT, 0L, (APTR)mgetCD,
  114. /* 29 */    NM_ITEM, (STRPTR)"Line Length...", (STRPTR)"L", 0, 0L, (APTR)mgetlinelength,
  115. /* 30 */ NM_ITEM, (STRPTR)"Output Now", (STRPTR)"P", 0, 0L, (APTR)mgetoutput,
  116. /* 31 */ NM_ITEM, (STRPTR)"Output To...", NULL, 0, 0L, (APTR)mgetoutputfile,
  117. /* 32 */    NM_END, NULL, NULL, 0, 0L, NULL };
  118.  
  119. char GadgetTextString0[] = "";
  120.  
  121. struct NewGadget mgetNGad[] = {
  122.     0, 0, 0, 0, (UBYTE *)"Selectable Files", NULL, 0, PLACETEXT_ABOVE, NULL, (APTR)listviewgadgetClicked,
  123.     0, 0, 0, 0, (UBYTE *)"Selected Files",   NULL, 1, PLACETEXT_BELOW, NULL, (APTR)list2Clicked
  124. };
  125.  
  126. ULONG mgetGTags[] = {
  127.     (GT_Underscore), '_', 
  128.     (TAG_DONE)
  129. };
  130.  
  131. UWORD DriPens[] = {
  132.     ~0 };
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. int SetupScreen( void )
  140. {
  141. ULONG lflag = 0L;
  142. struct Screen *sTemp = NULL;
  143. struct DrawInfo *screen_drawinfo = NULL;
  144.     
  145.     Scr = NULL;
  146.         
  147.     switch (screentype)
  148.         {
  149.         case USE_PUBSCREEN:
  150.             Scr = LockPubScreen(pubscreenname);
  151.             if (Scr == NULL)
  152.                 {
  153.                 MakeReq("Couldn't lock public screen!",NULL,"Huh?"); 
  154.                 return(1L);
  155.                 }
  156.             screenwidth     = Scr->Width;
  157.             screenheight    = Scr->Height;
  158.             break;
  159.             
  160.         case USE_CUSTOMSCREEN:
  161.          if ((sTemp = LockPubScreen("Workbench")) != NULL)
  162.             {
  163.             lflag = GetVPModeID(&(sTemp->ViewPort));    
  164.             screenwidth  = sTemp->Width;
  165.             screenheight = sTemp->Height;
  166.             }
  167.             else
  168.             {
  169.             screenwidth  = 640;
  170.             screenheight = 400;
  171.             lflag = HIRESLACE_KEY;
  172.             }
  173.            
  174.          if (sTemp != NULL) UnlockPubScreen(NULL,sTemp);
  175.             
  176.          if ( ! ( Scr = OpenScreenTags(NULL, 
  177.                          SA_Left,            0,
  178.                         SA_Top,            0,
  179.                         SA_Width,        screenwidth,
  180.                         SA_Height,        screenheight,
  181.                         SA_Depth,        2,
  182.                         SA_Font,            NULL /* &GraphicsBase->DefaultFont */,
  183.                         SA_Type,            CUSTOMSCREEN,
  184.                         SA_DisplayID,    lflag,
  185.                         SA_AutoScroll,    TRUE,
  186.                         SA_Overscan,    OSCAN_TEXT,
  187.                         SA_Pens,            &DriPens[0],
  188.                         SA_Title,        pnamestring,
  189.                         TAG_DONE ))) 
  190.                                 return( 1L );
  191.             break;
  192.             
  193.         case USE_WBSCREEN:
  194.             Scr = LockPubScreen("Workbench");
  195.             if (Scr == NULL) {MakeReq("Couldn't lock Workbench Screen!",NULL,"Where is it?"); return(1L);}
  196.             screenwidth = Scr->Width;
  197.             screenheight = Scr->Height;
  198.             break;
  199.         }
  200.         
  201.     if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
  202.         return( 2L );
  203.  
  204.     return( 0L );
  205. }
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. void CloseDownScreen( void )
  214. {
  215.     if ( VisualInfo ) 
  216.         {
  217.         FreeVisualInfo( VisualInfo );
  218.         VisualInfo = NULL;
  219.         }
  220.  
  221.     switch(screentype)
  222.         {
  223.         case USE_CUSTOMSCREEN:
  224.             CloseScreen( Scr );
  225.             Scr = NULL;
  226.             break;
  227.         case USE_PUBSCREEN:
  228.             UnlockPubScreen(NULL,Scr);
  229.             break;
  230.         case USE_WBSCREEN:
  231.             UnlockPubScreen(NULL,Scr);
  232.             break;
  233.         }
  234.     
  235.     screenisopen = 0;        
  236. }    
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246. int HandlemgetIDCMP( void )
  247. {
  248.     struct IntuiMessage    *m;
  249.     struct MenuItem        *n;
  250.     int            (*func)();
  251.     BOOL            running = TRUE;
  252.     WORD        wtop = -1 , wleft = -1, wheight = -1 , wwidth= -1;
  253.     struct NewGadget ng;
  254.     struct Gadget    *g;
  255.  
  256.     while( m = GT_GetIMsg( mgetWnd->UserPort )) {
  257.  
  258.         CopyMem(( char * )m, ( char * )&mgetMsg, (long)sizeof( struct IntuiMessage ));
  259.         lastcode = m->Code;
  260.         
  261.         GT_ReplyIMsg( m );
  262.     
  263.         switch ( mgetMsg.Class ) {
  264.  
  265.             case    IDCMP_REFRESHWINDOW:
  266.                 GT_BeginRefresh( mgetWnd );
  267.                 GT_EndRefresh( mgetWnd, TRUE );
  268.                 break;
  269.  
  270.             case IDCMP_NEWSIZE:
  271.                 windowtop = mgetWnd->TopEdge;
  272.                 windowleft = mgetWnd->LeftEdge;
  273.                 windowheight = mgetWnd->Height;
  274.                 windowwidth = mgetWnd->Width;
  275.                 
  276.                 RemoveGList(mgetWnd, mgetGList, -1);
  277.                 FreeGadgets(mgetGList);
  278.                 
  279.                 EraseRect(mgetWnd->RPort,mgetWnd->BorderLeft, mgetWnd->BorderTop,
  280.                             mgetWnd->Width - mgetWnd->BorderRight - 1,
  281.                             mgetWnd->Height - mgetWnd->BorderBottom - 1);
  282.                             
  283.                 if (SetupGadgets(g, &ng) == 2L) 
  284.                     {
  285.                     MakeReq("ListView Gadget Setup Error",NULL,"I wish Jeremy would debug better");
  286.                     Cleanup();
  287.                     exit(10);
  288.                     }
  289.                 AddGList(mgetWnd, mgetGList, -1, -1, NULL);
  290.                 RefreshGList(mgetGList, mgetWnd, NULL, -1);
  291.                         
  292.                 GT_RefreshWindow(mgetWnd, NULL);
  293.                 RefreshWindowFrame(mgetWnd);
  294.                 
  295.                 ChangeWindowTitle();                
  296.                 
  297.                 
  298.                 GT_SetGadgetAttrs((struct Gadget *) mgetGadgets[0], mgetWnd, NULL, GTLV_Labels, filelist, TAG_END); 
  299.                 GT_SetGadgetAttrs((struct Gadget *) mgetGadgets[1], mgetWnd, NULL, GTLV_Labels, getlist, TAG_END); 
  300.                 break;
  301.                 
  302.             case    IDCMP_CLOSEWINDOW:
  303.                 running = mgetCloseWindow();
  304.                 break;
  305.  
  306.             case    IDCMP_GADGETUP:
  307.             case    IDCMP_GADGETDOWN:
  308.                 func = ( void * )(( struct Gadget * )mgetMsg.IAddress )->UserData;
  309.                 running = func();
  310.                 break;
  311.  
  312.             case    IDCMP_MENUPICK:
  313.                 while( mgetMsg.Code != MENUNULL ) {
  314.                     n = ItemAddress( mgetMenus, mgetMsg.Code );
  315.                     func = (void *)(GTMENUITEM_USERDATA( n ));
  316.                     running = func();
  317.                     mgetMsg.Code = n->NextSelect;
  318.                 }
  319.                 break;
  320.         }
  321.     }
  322.     return( running );
  323. }
  324.  
  325.  
  326.  
  327.  
  328.  
  329. int SetupGadgets(struct Gadget *gadlist, struct NewGadget *ng)
  330. {
  331.  UWORD        lc, tc;
  332.  UWORD        offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
  333.  UWORD        wheight = windowheight - offy;
  334.  UWORD        wwidth  = windowwidth  - offx;
  335.  UWORD        topedge[2], height[2];
  336.  BYTE           bSizeGadHeight = 8;        
  337.  struct List      *thislist = NULL; 
  338.            
  339.  topedge[0]    = offy;
  340.  height[0]     = ((int) (.7 * wheight));
  341.  topedge[1]    = topedge[0] + height[0] + 1;
  342.  height[1]     = windowheight - topedge[1] - bSizeGadHeight - 2;
  343.  
  344.     nTopListTop = topedge[0];
  345.     nTopListHeight = height[0];
  346.     
  347.     /* Put in correct font */
  348.     listfont.ta_Name  = sListFontName;
  349.     if (nListFontSize > 0) listfont.ta_YSize = nListFontSize; else listfont.ta_YSize = 12;
  350.     /* a reasonable default, hopefully! */
  351.     listfontdata = OpenDiskFont(&listfont);    
  352.     if (listfontdata == NULL)
  353.      {
  354.          /* load system default font */
  355.         AskFont(&Scr->RastPort,&listfont);
  356.         listfontdata = OpenDiskFont(&listfont);
  357.         if (listfontdata == NULL)
  358.              {
  359.              MakeReq("Couldn't open default font!",NULL,"Something's weird here...");
  360.              Cleanup();
  361.              exit(5);
  362.              }
  363.              if (strlen(sListFontName) > 0) 
  364.         {
  365.             MakeReq("Couldn't find specified font, Sorry!",NULL,"Um, Ok");
  366.             strncpy(sListFontName,NUL,1);
  367.             nListFontSize = listfont.ta_YSize;
  368.         }
  369.      }
  370.            
  371.     if ( ! ( gadlist = CreateContext( &mgetGList )))
  372.         return( 1L );
  373.  
  374.     for( lc = 0, tc = 0; lc < mget_CNT; lc++ ) 
  375.         {
  376.         
  377.         if (lc == 1) 
  378.             {
  379.             thislist = getlist;
  380.             }
  381.             else 
  382.             {
  383.             thislist = filelist;
  384.             }
  385.  
  386.             
  387.         CopyMem((char * )&mgetNGad[ lc ], (char * )ng, (long)sizeof( struct NewGadget ));
  388.  
  389.         ng->ng_VisualInfo = VisualInfo;
  390.         ng->ng_TextAttr   = &listfont;
  391.         ng->ng_LeftEdge   = offx;
  392.       ng->ng_TopEdge    = topedge[lc];
  393.         ng->ng_Width      = wwidth - offx;
  394.       ng->ng_Height     = height[lc];    
  395.        ng->ng_GadgetText = NULL;
  396.         ng->ng_Flags        = NULL;
  397.         ng->ng_GadgetID   = lc + 50;
  398.  
  399.         mgetGadgets[ lc ] = gadlist = CreateGadget(LISTVIEW_KIND, gadlist, ng, GTLV_Top, 0, TAG_END);
  400.         
  401.         while( mgetGTags[ tc ] ) tc += 2;
  402.         tc++;
  403.  
  404.         if ( NOT gadlist)
  405.         {
  406.             return( 2L );
  407.         }
  408.     }
  409. }
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419. int OpenmgetWindow( void)
  420. {
  421.     struct NewGadget ng;
  422.     struct Gadget    *g;
  423.     int titleheight = (Scr->WBorTop + Scr->RastPort.TxHeight + 1);
  424.     int nMinHeight;
  425.     
  426.     if (nListFontSize == 0) nListFontSize = listfont.ta_YSize;    /* get default setting */
  427.     
  428.     nMinHeight = (8 * (nListFontSize + 2));
  429.     if (nMinHeight < 90) nMinHeight = 90;
  430.     nMinHeight += titleheight;
  431.   
  432.     if ((windowwidth <= 0)||(windowwidth > screenwidth)) windowwidth  = screenwidth;
  433.     if (windowheight < nMinHeight) windowheight = nMinHeight;
  434.     
  435.     if ((windowheight <= 0)||(windowheight > screenheight)) windowheight = screenheight - titleheight;
  436.             
  437.     if ((windowleft <= 0)||(windowleft > screenwidth))        windowleft   = 0;
  438.     if ((windowleft+windowwidth) > screenwidth)    windowwidth -= windowleft;
  439.     if ((windowtop <= 0)||(windowtop > screenheight))       windowtop    = titleheight;
  440.     if ((windowtop+windowheight) > screenheight) windowheight -= windowtop;
  441.         
  442.     if ((windowwidth <= 0)||(windowwidth > screenwidth))    
  443.         {
  444.         windowwidth  = screenwidth;
  445.         windowleft = 0;
  446.         }
  447.         
  448.     if ((windowheight <= 0)||(windowheight > screenheight)) 
  449.         {
  450.         windowheight = screenheight - titleheight;
  451.         windowtop = titleheight;
  452.         }
  453.         
  454.     
  455.     if (SetupGadgets(g, &ng) == 2L) return(2L);    
  456.     
  457.     if ( ! ( mgetMenus = CreateMenus( mgetNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
  458.         return( 3L );
  459.     
  460.     LayoutMenus( mgetMenus, VisualInfo, TAG_DONE );    
  461.         
  462.     switch (screentype)
  463.         {
  464.         case USE_PUBSCREEN:
  465.             if ( ! ( mgetWnd = OpenWindowTags( NULL,
  466.                 WA_Left,        windowleft,
  467.                 WA_Top,        windowtop,
  468.                 WA_Width,         windowwidth,
  469.                 WA_Height,    windowheight,
  470.                 WA_PubScreen,    Scr,
  471.                 WA_PubScreenFallBack, TRUE,
  472.                 WA_IDCMP,    LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,
  473.                 WA_Flags,    WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  474.                 WA_Gadgets,    mgetGList,
  475.                 WA_Title,         windowtitle,
  476.                 WA_ScreenTitle,pnamestring,
  477.                 WA_MinWidth,    155,
  478.                 WA_MinHeight,    nMinHeight,
  479.                 WA_MaxWidth,    -1,
  480.                 WA_MaxHeight,    -1,
  481.                 TAG_DONE )))    
  482.                     return( 4L );
  483.             break;
  484.             
  485.         case USE_CUSTOMSCREEN:
  486.             if ( ! ( mgetWnd = OpenWindowTags( NULL,
  487.                 WA_Left,        windowleft,
  488.                 WA_Top,        windowtop,
  489.                 WA_Width,         windowwidth,
  490.                 WA_Height,    windowheight,
  491.                 WA_CustomScreen,    Scr,
  492.                 WA_IDCMP,    LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,
  493.                 WA_Flags,    WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  494.                 WA_Gadgets,    mgetGList,
  495.                 WA_Title,         windowtitle,
  496.                 WA_ScreenTitle,pnamestring,
  497.                 WA_MinWidth,    155,
  498.                 WA_MinHeight,    nMinHeight,
  499.                 WA_MaxWidth,    -1,
  500.                 WA_MaxHeight,    -1,
  501.                 TAG_DONE )))    
  502.                     return( 4L );
  503.             break;
  504.             
  505.         case USE_WBSCREEN:
  506.             if ( ! ( mgetWnd = OpenWindowTags( NULL,
  507.                 WA_Left,        windowleft,
  508.                 WA_Top,        windowtop,
  509.                 WA_Width,         windowwidth,
  510.                 WA_Height,    windowheight,
  511.                 WA_IDCMP,    LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,
  512.                 WA_Flags,    WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  513.                 WA_Gadgets,    mgetGList,
  514.                 WA_Title,         windowtitle,
  515.                 WA_ScreenTitle,pnamestring,
  516.                 WA_MinWidth,    155,
  517.                 WA_MinHeight,    nMinHeight,
  518.                 WA_MaxWidth,    -1,
  519.                 WA_MaxHeight,    -1,
  520.                 TAG_DONE )))    
  521.                     return( 4L );
  522.                     
  523.             if (appwindow == 1)
  524.                 {
  525.                 awport = CreateMsgPort();
  526.                 if (awport == NULL) 
  527.                     {
  528.                     appwindow = 0;
  529.                     return(4L);
  530.                     }
  531.  
  532.                 appwin = AddAppWindow(1, 0, mgetWnd, awport, NULL);
  533.                 
  534.                 if (appwin == NULL)
  535.                     {appwindow = 0;}
  536.                     else
  537.                     appwinsig = 1L << awport->mp_SigBit;
  538.                 }
  539.                 
  540.             break;
  541.         }    
  542.  
  543.     TurnOnAllMenuItems(mgetMenus);
  544.     SetMenuStrip( mgetWnd, mgetMenus ); 
  545.     GT_RefreshWindow( mgetWnd, NULL );
  546. return( 0L );
  547. }
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555. void ClosemgetWindow( void )
  556. {
  557.     if ( mgetMenus      ) {
  558.         ClearMenuStrip( mgetWnd );
  559.         FreeMenus( mgetMenus );
  560.         mgetMenus = NULL;    }
  561.  
  562.     if ( findwindow     ) { 
  563.          CloseWindow( findwindow );
  564.          FreeGadgets(findgadlist);
  565.          FreeVisualInfo(findvi);
  566.          findwindow = NULL;
  567.          }
  568.      
  569.      if (appwin) {
  570.          RemoveAppWindow(appwin);
  571.          
  572.          /* throw out any leftover messages */
  573.          while(amsg = (struct AppMessage *) GetMsg(awport))
  574.                  ReplyMsg((struct Message *) amsg);
  575.          DeleteMsgPort(awport);
  576.          }
  577.         
  578.     if ( mgetWnd        ) {
  579.         CloseWindow( mgetWnd );
  580.         windowisopen = 0;
  581.         mgetWnd = NULL;
  582.         }
  583.  
  584.     if ( mgetGList      ) {
  585.         FreeGadgets( mgetGList );
  586.         mgetGList = NULL;
  587.         }
  588. }
  589.  
  590.  
  591. #endif
  592.  
  593.