#ifndef	LIBRARIES_ASLBASE_H
#define	LIBRARIES_ASLBASE_H	1

/*
 ************************************************************************
 *									*
 * 12/3/89	ASLbase.h	by cdh					*
 *									*
 ************************************************************************
 *	First we need to include the Amiga Standard Include files...	*
 ************************************************************************
 */
#ifndef	EXEC_TYPES_H
#include	<EXEC/Types.h>
#endif

#ifndef	EXEC_LISTS_H
#include	<EXEC/Lists.h>
#endif

#ifndef	EXEC_ALERTS_H
#include	<EXEC/Alerts.h>
#endif

#ifndef	EXEC_LIBRARIES_H
#include	<EXEC/Libraries.h>
#endif

#ifndef	EXEC_SEMAPHORES_H
#include	<EXEC/Semaphores.h>
#endif

#ifndef	LIBRARIES_DOS_H
#include	<Libraries/DOS.h>
#endif

#ifndef INTUITION_INTUITION_H
#include <intuition/intuition.h>
#endif

#ifndef UTILITY_HOOKS_H
#include <utility/hooks.h>
#endif

/*
 ************************************************************************
 *	Check for MANX/Lattice and define the differences...		*
 ************************************************************************
 *	At the moment MANX 3.6 does not have prototypes or the		*
 *	wonderful #pragma statements of Lattice 5.0...			*
 *	And, no __stdargs in MANX either...				*
 ************************************************************************
 */

#ifdef	AZTEC_C
#define	NO_PROTOTYPES	1
#define	C_Args
#endif

#ifdef	LATTICE
#define	C_Args		__stdargs
#endif

/*
 ************************************************************************
 *	Standard definitions for arp library information		*
 ************************************************************************
 */
#define	AslName		"asl.library"	/* Name of library... */
#define	AslVersion	14L		/* Current version... */
#define	AslRevision	0

/*
 ************************************************************************
 *	The current ASL library node...					*
 ************************************************************************
 */
struct	AslBase	{
	struct Library	LibNode;	/* Standard library node	*/
	struct Library	*UtiBase;	/* Cached UtiBase		*/
	struct Library	*DosBase; 	/* Cached DosBase		*/
	struct Library	*GfxBase; 	/* Cached GfxBase		*/
	struct Library	*IntuiBase;	/* Cached IntuitionBase		*/
	BPTR		SegList; 	/* Pointer to loaded libcode (a BPTR).	*/
	};

/*
 ************************************************************************
 *	The ASL file requester data structure...			*
 ************************************************************************
 */
struct FileRequester	{
			BYTE	*rf_Hail;		/* Hailing text			*/
			BYTE	*rf_File;		/* Filename array (FCHARS + 1)	*/
			BYTE	*rf_Dir;		/* Directory array (DSIZE + 1)	*/
		struct	Window	*rf_Window;		/* Window requesting or NULL	*/
			UBYTE	rf_FuncFlags;		/* Set bitdef's below		*/
			UBYTE	rf_Flags2;		/* New flags...			*/
			VOID	(*rf_Function)();	/* Your function, see bitdef's	*/
			WORD	rf_LeftEdge;		/* To be used later...		*/
			WORD	rf_TopEdge;
			};

/*
 ************************************************************************
 * The following are the defines for rf_FuncFlags.  These bits tell	*
 * FileRequest() what your rf_UserFunc is expecting, and what		*
 * FileRequest() should call it for.					*
 *									*
 * You are called like so:						*
 * rf_Function(Mask, Object)						*
 * ULONG	Mask;							*
 * CPTR		*Object;						*
 *									*
 * The Mask is a copy of the flag value that caused FileRequest() to	*
 * call your function. You can use this to determine what action you	*
 * need to perform, and exactly what Object is, so you know what to do	*
 * and what to return.							*
 ************************************************************************
 */
#define	RFB_SAVE	5L /* For a SAVE operation, set this bit	*/

#define	RFB_DOWILDFUNC	7L /* Call me with a FIB and a name, ZERO return accepts.	*/
#define	RFB_DOMSGFUNC	6L /* You get all IDCMP messages not for FileRequest()		*/
#define	RFB_DOCOLOR	5L /* Set this bit for that new and different look		*/
#define	RFB_NEWIDCMP	4L /* Force a new IDCMP (only if rf_Window != NULL)		*/
#define	RFB_NEWWINDFUNC	3L /* You get to modify the newwindow structure.		*/
#define	RFB_ADDGADFUNC	2L /* You get to add gadgets.					*/
#define	RFB_GEVENTFUNC	1L /* Function to call if one of your gadgets is selected.	*/
#define	RFB_LISTFUNC	0L /* Not implemented yet.					*/

#define	RFF_SAVE	(1L << RFB_SAVE)

#define	RFF_DOWILDFUNC	(1L << RFB_DOWILDFUNC)
#define	RFF_DOMSGFUNC	(1L << RFB_DOMSGFUNC)
#define	RFF_DOCOLOR	(1L << RFB_DOCOLOR)
#define	RFF_NEWIDCMP	(1L << RFB_NEWIDCMP)
#define	RFF_NEWWINDFUNC	(1L << RFB_NEWWINDFUNC)
#define	RFF_ADDGADFUNC	(1L << RFB_ADDGADFUNC)
#define	RFF_GEVENTFUNC	(1L << RFB_GEVENTFUNC)
#define	RFF_LISTFUNC	(1L << RFB_LISTFUNC)

/*
 ************************************************************************
 * The FR2B_ bits are for rf_Flags2 in the file requester structure	*
 ************************************************************************
 */
#define	FR2B_LONGPATH	0L /* Specify the rf_Dir buffer is 256 bytes long */

#define	FR2F_LONGPATH	(1L << FR2B_LONGPATH)

/*
 ************************************************************************
 *	The sizes of the different buffers... these are allocated by	*
 * the system, and are advisory for applications writers; they may	*
 * grow between releases.						*
 ************************************************************************
 */

#define	LONG_DSIZE	254L
#define	LONG_FSIZE	126L

#define	FR_FIRST_GADGET	0x7680L	/* User gadgetID's must be less than this value	*/

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

/*
 ************************************************************************
 *	The ASL font requester data structure...			*
 ************************************************************************
 */
struct FontRequester	{
	BYTE	*fo_Hail;		/* Hailing text for title	*/
	struct Window *fo_Window;	/* Window requesting or NULL	*/
	BYTE	*fo_Name;		/* Returned values for fontname	*/
	USHORT	fo_YSize;
	UBYTE	fo_Style;
	UBYTE	fo_Flags;
	UBYTE	fo_FrontPen;
	UBYTE	fo_BackPen;
	SHORT	fo_FuncFlags;
	SHORT	fo_LeftEdge;
	SHORT	fo_TopEdge;
	};

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

struct NewDList {
	SHORT	LeftEdge,TopEdge,Width,Height;

	UBYTE	FgPen,BgPen,BdPen,fill;

	SHORT	ItemHeight;
	USHORT	Flags;

	USHORT	GadgetID;
	struct Hook	*DLHook;
	};

/* nd_Flags bit definitions. */

#define	DLB_DRAWBORDER	0
#define	DLB_SIZEGAD	1

#define	DLF_DRAWBORDER	1
#define	DLF_SIZEGAD	2

/* Enumerated values for ScrollDList() function */
#define ST_UPONE	0
#define ST_DOWNONE	1
#define ST_UPDISPLAY	2
#define ST_DOWNDISPLAY	3
#define ST_TOP		4
#define ST_BOTTOM	5

/* This structure is set by the GetDListInfo call */
struct DListInfo {
	LONG	NumItems;
	LONG	TopItem;
	SHORT	DispItems;
	SHORT	Reserved1;
	LONG	Reserved2;
	};


struct DLHookMsg {
	SHORT	LeftEdge,TopEdge;
	SHORT	Width,Height;
	struct RastPort *RPort;
	LONG	Item;
	SHORT	Type;
	SHORT	MouseX,MouseY;
	};

/* Type defines for the DHHookMessage	*/
#define	DH_RENDER	0
#define	DH_SELECT	1

/* PRIVATE STRUCTURE!!!!! */
#define	ARROWHEIGHT	9
#define	BORDERWIDTH	16

struct DList {
	struct NewDList d;
	struct Window *ld_WindowPtr;
	struct RastPort *ld_RPort;

	SHORT	ld_X0,ld_Y0,ld_X1,ld_Y1;
	SHORT	ld_W0,ld_H0;

	LONG	ld_ItemCount;
	LONG	ld_TopItemNum;
	LONG	ld_OldTopItemNum;
	SHORT	ld_MaxScrItems;

	BOOL	ld_DisplayValid,ld_PropValid,ld_Special;
	SHORT	ld_Bias;

	struct Gadget	ld_UpArrow;
	struct Image	ld_UpArrowImg;

	struct Gadget	ld_DownArrow;
	struct Image	ld_DownArrowImg;

	struct Gadget	ld_ScrollBar;
	struct Image	ld_ScrollBarImg;
	struct PropInfo ld_ScrollBarInfo;

	struct Gadget	ld_SelectArea;
	struct RastPort ld_RastPort;

	USHORT	UpData[ARROWHEIGHT];
	USHORT	DownData[ARROWHEIGHT];
	};


/*
 ************************************************************************
 * Define NO_PROTOTYPES if your compiler does not handle them...	*
 ************************************************************************
 */
#ifdef	NO_PROTOTYPES
#define	ARGs(x)	()
#else
#define	ARGs(x)	x
#endif

/*
 ************************************************************************
 * Note that C_Args is a #define that, in LATTICE does __stdargs	*
 ************************************************************************
 */

struct	FileRequester	C_Args	*AllocFileRequest	ARGs(	(VOID) );
VOID			FreeFileRequest	ARGs( (struct FileRequester *) );
BYTE			*RequestFile	ARGs( (struct FileRequester *) );

struct	FontRequester	C_Args	*AllocFontRequest	ARGs(	(VOID) );
VOID			FreeFontRequest	ARGs( (struct FontRequester *) );
BYTE			*RequestFont	ARGs( (struct FontRequester *) );

struct DList		C_Args *CreateDList( struct NewDList *, struct Window *, struct Requester *);
VOID			FreeDList( struct DList *);

VOID			AddDListItems( struct DList *, LONG);
VOID			EmptyDList( struct DList *);

VOID			ScrollDList( struct DList *, LONG );
VOID			ScrollDListAbs( struct DList *, LONG);
VOID			GetDListInfo( struct DList *, struct DListInfo *);

VOID			DrawDList( struct DList *);
VOID			RefreshDList( struct DList *);
VOID			RefreshDListProp( struct DList *);

VOID			HandleDListEvent( struct DList *, struct IntuiMessage *);

#pragma libcall AslBase AllocFileRequest 1e 0
#pragma libcall AslBase FreeFileRequest 24 801
#pragma libcall AslBase RequestFile 2a 801
#pragma libcall AslBase AllocFontRequest 30 0
#pragma libcall AslBase FreeFontRequest 36 801
#pragma libcall AslBase RequestFont 3c 801

#pragma libcall AslBase CreateDList 42 a9803
#pragma libcall AslBase FreeDList 48 801

#pragma libcall AslBase AddDListItems 4e 802
#pragma libcall AslBase EmptyDList 54 801

#pragma libcall AslBase ScrollDList 5a 802
#pragma libcall AslBase ScrollDListAbs 60 802
#pragma libcall AslBase GetDListInfo 66 9802

#pragma libcall AslBase DrawDList 6c 801
#pragma libcall AslBase RefreshDList 72 801
#pragma libcall AslBase RefreshDListProp 78 801

#pragma libcall AslBase HandleDListEvent 7e 9802

#endif
