/*************************************************************************************
 FindFile.h	 Header file for FindFile

 FindFile.h 1.7 1993/04/03 13:34:06 RUSS Exp

 1.7

 FindFile.h
 * Revision 1.7  1993/04/03  13:34:06  RUSS
 * Fixed crashing problem when starting a second FindFile.
 *
 * Revision 1.6  1993/04/03  02:05:56  RUSS
 * Added newgadget. Altered controlPanel to accomodate.
 * New function proto added.
 *
 * Revision 1.5  1993/04/01  21:52:45  RUSS
 * Widened window. Other alterations to conform
 * to the new display format and new gadget.
 *
 * Revision 1.4  1993/02/28  00:39:57  RUSS
 * Changed controlpanel to use arrays of gadgetpointers
 *
 * Revision 1.3  1993/02/27  15:59:35  RUSS
 * Moved system include files to the front of
 * the header
 *
 * Revision 1.2  1993/02/27  15:48:24  RUSS
 * Added structure defs and #defines to
 * this file.
 *
 * Revision 1.1  1993/02/27  00:42:46  RUSS
 * Initial revision
 *

************************************************************************************/

/*** Include Files ***/

#include <date.h>
#define INTUI_V36_NAMES_ONLY
#include <exec/types.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <libraries/commodities.h>
#include <libraries/asl.h>
#include <dos/dos.h>
#include <dos/dosextens.h>
#include <clib/alib_protos.h>
#include <clib/commodities_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <pragmas/commodities_lib.h>
#include <pragmas/dos_lib.h>
#include <pragmas/exec_lib.h>
#include <pragmas/gadtools_lib.h>
#include <pragmas/graphics_lib.h>
#include <pragmas/intuition_lib.h>

/***************************** Global Constants **********************************/

#define NAME	   "FindFile"
#define MAXSTR	   256
#define MAXPAT	   ( MAXSTR * 2 ) + 4
#define OPEN_WINDOW 1
#define FF_WIDTH    460
#define FF_HEIGHT   165

/*** Useful debugging macros **/

/*#define DEBUG*/
#ifdef DEBUG
#define DB( x )      printf("%s():",__FUNC__ );puts( x );
#define DBf( x , y ) printf("%s():",__FUNC__ );printf( x , y );
#else
#define DB( x )
#define DBf( x , y )
#endif

/** Gadget ID's **/

enum
{
  ID_PATGAD,ID_DEVGAD,ID_FILEREQ,ID_FOUNDLIST,
  ID_SEARCH,ID_HIDE,ID_QUIT,ID_ABORT,
  ID_NUMGADS
};

/***************************** Structure Defs ************************************/

struct foundNode {
  struct Node	fn_Node;
  UBYTE   fn_Name[MAXSTR];
};

struct controlPanel {
  struct Window *ffWindow;
  SHORT   lastX,
     lastY;
  BOOL	   centerWindow;
  BOOL	   ignoreIcons;
  BOOL	   sortList;
  UBYTE   ignoreIconsPat[MAXPAT];
  struct VisualInfo *ffWinVi;
  struct Gadget *ffWinGadList;
  struct Gadget *ffWinGads[ ID_NUMGADS ];
  struct FileRequester *ffFileReq;
  UBYTE searchString[MAXSTR];
  UBYTE searchPattern[MAXPAT];
  UBYTE searchPath[MAXSTR];
  WORD	 numDevs;
  STRPTR *devList;
  struct MinList foundList;
  UWORD  numFound;
  UWORD  currFound;
  struct {
       struct MsgPort *cxPort;
       CxObj	  *ffBroker;
       UBYTE	   cxHotKeyString[MAXSTR];
       LONG	cxPriority;
  } cxInterface;
};

/***************************** Function Prototypes *******************************/

void Init( struct controlPanel * );
void SetUp( struct controlPanel * , int , char ** );
void Shutdown( struct controlPanel * , int );

ULONG GetWaitMask( struct controlPanel * );

void OpenFFWindow( struct controlPanel * );
void CloseFFWindow( struct controlPanel * );
void HandleFFWindowCommand( struct controlPanel * );

void CreateFFGadgets( struct controlPanel *, int , BYTE);
void CenterWindow( struct Screen *, WORD *, WORD * );
struct foundNode *NodeAddress( struct MinList * , UWORD );
BOOL QuitCheck( struct controlPanel * );

void  Bstrcpy( UBYTE * , BSTR );
STRPTR *GetDevList( struct controlPanel * );
void  FreeDevList( STRPTR * );
BOOL  ScanDir( STRPTR , struct controlPanel * );
BOOL  MatchFile( struct controlPanel *, STRPTR );

void AddPathNode( STRPTR , BPTR );
void DeletePathNode( STRPTR );
struct foundNode *AddFoundNode( struct MinList *, STRPTR , BOOL );
void DeleteFoundList( struct MinList * );
void AddFoundFile( struct controlPanel *, BPTR, STRPTR );

void OpenCxInterface( struct controlPanel * );
void CloseCxInterface( struct controlPanel * );
void HandleCxCommand( struct controlPanel * );

void DoFileRequest( struct controlPanel * );

void CMD_Show( struct controlPanel * );
void CMD_Hide( struct controlPanel * );
void CMD_Search( struct controlPanel * );
void CMD_Quit( struct controlPanel * );

