/*
 *  CELLS       An Implementation of the WireWorld cellular automata
 *              as described in Scientific American, Jan 1990.
 *
 *              Copyright 1990 by Davide P. Cervone.
 *  You may use this code, provided this copyright notice is kept intact.
 *  See the CELLS.HELP file for complete information on distribution conditions.
 */

/*
 *  File:  cRequest.h           Structures used for all requesters and for
 *                              list gadgets
 */


#define MAXBUFFER       128             /* string buffer size */
#define MAXPNAME        30              /* part name size */
#define MAXFNAME        MAXBUFFER       /* file name size */

typedef struct ExtRequest EXTREQUEST;
typedef struct ListInfo   LISTINFO;
typedef struct ListItem   LISTITEM;


/*
 *  Extended Requester structure
 */

struct ExtRequest
{
   struct Requester er_Request;
   FUNCTION         er_GadgetDown;      /* function for Gadget Down */
   FUNCTION         er_GadgetUp;        /* function for Gadget Up */
   FUNCTION         er_MouseMove;       /* function for Mouse move */
   struct Gadget   *er_ActiveGadget;    /* gadget to activate automatically */
};


/*
 *  Linked list of items appearing in a list gadget on a requester 
 */

struct ListItem
{
   struct ListItem *Next,*Prev;
   char *Name;
   UWORD NameLen;
   UWORD Flags;
      #define LI_SELECTED   BIT(0)      /* this is the selected item */
      #define LI_NOFIRST    BIT(1)      /* kludge to prevent first character */
};                                      /*  of directory name from being */
                                        /*  copied to the name gadget

/*
 *  Structure that controls the list gadget within a requester
 */

struct ListInfo
{
   struct ExtRequest *Request;      /* the requester where this list exists */
   struct Gadget *Gadget;           /* the list gadget itself */
   struct Gadget *Name;             /* the name gadget for the list (or NULL) */
   struct Gadget *Slider;           /* the vertical slider for the list */
   struct ListItem *Item;           /* the list of items to be displayed */
   struct ListItem *ItemTop;        /* the item currently at the top */
   struct ListItem *ItemSelect;     /* the item currently selected */
   struct IntuiText *IText;         /* the IntuiText array for the list */
   struct Image *Image;             /* the Image array for the list */
   short Height;                    /* height in pixels */
   short Width;                     /* width in characters */
   short TopText;                   /* array index of the IText of top item */
   short TopItem;                   /* the position in the Item list */
   short SelectedItem;              /* the position in the item list */
      #define LI_NOSELECT   -1
   short ListLen;                   /* the length of the item list */
   UWORD Flags;                     /* flags */
};

extern LISTITEM *DoListHit();
extern LISTITEM *InitList();
