/* ************************************************************************ */
/* AK_GEN0_H (Headerfile for use with the "ak_gen0.library")                */
/* ************************************************************************ */
/* (c) 1989-93 by Andreas Ralph Kleinert. All rights reserved.              */
/* COMMERCIAL USE IS NOT ALLOWED WITHOUT SPECIAL PERMISSION BY THE AUTHOR ! */
/* ************************************************************************ */
/* Version          : V36.52                                                */
/* Last updated     : 08.01.1993                                            */
/* Compiler         : SAS/C V5.10a/b                                        */
/* Compiler-Options : (MakeFile)                                            */
/* ************************************************************************ */
/* Address          : Andreas Ralph Kleinert                                */
/*                    Grube Hohe Grethe 23                                  */
/*                    W-5900 Siegen 1                                       */
/*                    Germany                                               */
/* ************************************************************************ */

#ifndef AK_GEN0_H
#define AK_GEN0_H

#define AK_GEN0_VERSION  (36)
#define AK_GEN0_REVISION (52)

#define AK_GEN0_MINIMUM (35)

/* You should only use versions greater than V34, because of various reasons.
   Your specific "minimum" may be higher, if you make use of new functions.
*/

#include <intuition/intuitionbase.h>
#include <exec/memory.h>
#include <graphics/gfxbase.h>
#include <stdio.h>
#include <libraries/dos.h>

/* Defines */

#define N (NULL)
#define FIRST_SCREEN   ( (struct Screen *) IntuitionBase->FirstScreen )
#define CURRENT_WINDOW ( (struct Window *) IntuitionBase->ActiveWindow )
#define CURRENT_SCREEN ( (struct Screen *) IntuitionBase->ActiveScreen )
#define CURRENT_MOUSEX ( CURRENT_WINDOW->MouseX )
#define CURRENT_MOUSEY ( CURRENT_WINDOW->MouseY )
#define NEWWINDOW (sizeof(struct NewWindow))
#define WINDOW (sizeof(struct Window))
#define BORDER (sizeof(struct Border))
#define MENU (sizeof(struct Menu))
#define GADGET (sizeof(struct Gadget))
#define ITEXT (sizeof(struct IntuiText))
#define ITEM (sizeof(struct MenuItem))
#define SUBITEM ITEM
#define STRINGINFO (sizeof(struct StringInfo))
#define REQUESTER (sizeof(struct Requester))
#define PROPINFO (sizeof(struct PropInfo))
#define ALERT (sizeof(struct AlertData))
#define NEWSCREEN (sizeof(struct NewScreen))

/* Constants */

#define AK_FILEREQ_STRING_LEN (256) /* The Filerequester creates a string   */
                                    /* of this length.                      */
                                    /* This will not change (because of the */
                                    /* nice BCPL-like DOS) and can be used  */
                                    /* as a parameter to "FreeMem()".       */

/* Defines for "direntry[]" of AK_ReadDir() */

#define AKF_IS_FILE (FALSE) /* compatibility  (same as NULL)             */
#define AKF_IS_DIR  (TRUE)  /* compatibility  (same as 1<<1)             */
#define AKF_IS_VOL  (1<<2)  /* NEW in V35.99, only FileRequester PRIVATE */

/* Official defines sine V35.102 :

   These defines had changed since V35.98, but they were no longer compatible.
   This bug is now fixed, but also for compatibility, entries in "direntry[]"
   are limited to the values TRUE or FALSE, which means "Dir" or "Not Dir"
   (== "File").
   The use of the new define "AKF_IS_VOL" is only thought for PRIVATE use
   with the FileRequester's "Assigns"-Gadget.
   Do not use it.
*/   


/* Library-Bases (to be declared as externals)                      */
/* Define AKG_NOBASES if you use your own declarations/definitions. */

#ifndef AKG_NOBASES

struct IntuitionBase *IntuitionBase = N;
struct GfxBase       *GfxBase       = N;
struct AKBase        *AKBase        = N;
struct LayersBase    *LayersBase    = N; /* perhaps you'll seldom use it. */

#endif AKG_NOBASES

/* MACROs */

#define SIZE_PAL(window)  (WindowLimits(window, 0, 0, 640, 256))
#define SIZE_NTSC(window) (WindowLimits(window, 0, 0, 640, 200))

#define SET_MAX (SIZE_PAL(CURRENT_WINDOW)) /* OBSOLETE */

 /* SET_MAX is only included for compatibility.
    Use SIZE_PAL/SIZE_NTSC instead.
    V36.9 : Redefined as Sub-Macro of SIZE_PAL.
 */

#define xMEN(x) MENUNUM(x->Code)  /* NOTE : Use these, if possible         */
#define xITN(x) ITEMNUM(x->Code)  /*        or use the originals !!!       */
#define xSTN(x) SUBNUM(x->Code)

#define MEN xMEN(im)              /* OBSOLETE.                             */
#define ITN xITN(im)              /* NOTE : Use xMEN,xITN,xSTN instead !!! */
#define STN xSTN(im)

#define MEN_2 xMEN(im2)           /* OBSOLETE.                             */
#define ITN_2 xITN(im2)           /* NOTE : Use xMEN,xITN,xSTN instead !!! */
#define STN_2 xSTN(im2)

 /* MEN, ITN, STN (and MEN_2, ITN_2, STN_2) are only included for
    compatibility.
    Use xMEN, xITN, xSTN instead (or use the originals).
    V36.9 : Redefined as Sub-Macros of xMEN, xITN, xSTN.
 */


/* Standard-Values */

 /* If you make use of the obsolete ones of the above Macros, you also have
    to use the following variables (define AKG_NOVARS if you don't need
    them) :
 */

#ifndef AKG_NOVARS

struct IntuiMessage *im             = N; /* First Window  */
struct Window       *w              = N;

struct IntuiMessage *im_2           = N; /* Second Window */
struct Window       *w_2            = N;

#endif AKG_NOVARS


/* Structures, used or returned by functions of this library */

 /* Note : Up to V36.10 there is only one kind of Requester implemented :
           The FileRequester. It is possible, that the development of
           structures for other kinds of requesters will result in new
           (and different) structures for both : The FileRequester and the
           other Requesters.
           Nevertheless any new FileRequester-Structure WILL be compatible
           to this "old" (yet "new") one !
 */

struct AK_Requester /* structure for use with ak_gen0-requesters */
{
 APTR  akr_APTR;       /* RESERVED. ONLY FOR PRIVATE USE.                   */

 ULONG akr_Type;       /* Which type ? See flags below. DO NOT CHANGE !!!   */

 ULONG akr_Flags;      /* PRIVATE. (up to now)                              */
 ULONG akr_Reserved1;  /* PRIVATE. (up to now)                              */

 /* ENTRIES TO BE MODIFIED BY THE USER (BEGIN) */

 APTR  akr_Window;     /* Pointer to User-Window or NULL (CURRENT_WINDOW).  */

 LONG  akr_LeftEdge;   /* Distance to the left border of your Screen.       */
 LONG  akr_TopEdge;    /* Distance to the top border of your Screen.        */

 BYTE *akr_Title;      /* Pointer to title text for Window.  May be NULL.   */
 BYTE *akr_OKText;     /* Pointer to text for OK-Gadget.     May be NULL.   */
 BYTE *akr_CancelText; /* Pointer to text for Cancel-Gadget. May be NULL.   */

 LONG  akr_FGColor;    /* Foreground color (window). Default is -1.         */
 LONG  akr_BGColor;    /* Background color (window). Default is -1.         */
                       /* With ak_gen0-Requester only used for OK/Cancel    */
                       /* gadgets.                                          */

 ULONG akr_Default1;   /* These are values, which have different meanings   */
 ULONG akr_Default2;   /* for different requester types. OPTIONAL.          */
 ULONG akr_Default3;   /* See explanations below. Default is always NULL.   */

 /* ENTRIES TO BE MODIFIED BY THE USER (END) */

 APTR  akr_Tags;       /* RESERVED for future expansions. Always NULL.      */

 /* ======================================================================= */
 /* SIZE MAY GROW IN FUTURE VERSIONS. ONLY ALLOC WITH AK_AllocRequester() ! */
 /* FREE WITH AK_FreeRequester().                                           */
 /* ======================================================================= */
};

/* Alloc this structure with : AK_AllocRequester(AK_REQTYPE_FILE)
   Use this structure with   : - AK_NewFileRequester(structure)
                               - ... [ future ]
   Free this structure with  : AK_FreeRequester(structure)
*/


/* Flags for akr_Type AND AK_AllocRequester() */

#define AK_REQTYPE_FILE     (1<<1)
#define AK_REQTYPE_RESERVED (~(AK_REQTYPE_FILE))


/* Flags for akr_Flags : */

#define AK_REQFLAG_RESERVED (~(NULL)) /* PRIVATE. (up to now) */


/* Meaning of the akr_Default fields :

   - FileRequester (AK_REQTYPE_FILE) :

     - akr_Default1  : May contain the name of a Default-Directory or NULL.
     - akr_Default2  : May contain the name of a Default-File      or NULL.
     - akr_Default3  : Not supported yet.

   - Other Requesters :

     SORRY ! Not yet implemented !

*/


/* Declarations of the Library-Functions */

extern struct Screen * __saveds AK_Screen(long l, long t, long w, long h, long d,
                                  long dp, long bp, long vm, long ty,
                                  struct TextAttr *f, char *title, 
                                  struct BitMap *cbm);

extern struct Window * __saveds AK_Window(long l, long t, long w, long h, long d,
                                  long b, long idcmp, long flags,
                                  struct Gadget *fg, struct Image *cm,
                                  char *title, struct Screen *screen,
                                  struct BitMap *bm, long minw, long minh,
                                  long maxw, long maxh, long type);

extern struct Menu * __saveds AK_Menu(struct Menu *next, long l, long w, long flags,
                              char *name, struct MenuItem *item);

extern struct MenuItem * __saveds AK_MenuItem(struct MenuItem *next, long t, long w,
                                      long flags, long me, APTR itfi, 
                                      APTR sefi, long scut,
                                      struct MenuItem * subi);

extern struct MenuItem * __saveds AK_SubItem(struct MenuItem *next, long l, long t,
                                     long w, long flags, long me, APTR itfi,
                                     APTR sefi, long scut,
                                     struct MenuItem *subi);

extern struct Gadget * __saveds AK_Gadget(struct Gadget *next, long l, long t, long w,
                                  long h, long flags, long act, long type,
                                  APTR gadr, APTR selr, struct IntuiText *text,
                                  APTR sp, long id);

extern struct StringInfo * __saveds AK_StringInfo(long groesse, long maximum, 
                                          struct KeyMap *km);

extern struct Border * __saveds AK_Border(long l, long t, long f, long b, long d,
                                   long c, SHORT *xy, struct Border *next);

extern struct IntuiText * __saveds AK_IText(long f, long b, long d, long l, long t,
                                     struct TextAttr *font, char *text,
                                     struct IntuiText *next);

extern void   __saveds AK_GfxPrint(struct Window *w, char *text, long x, long y);

extern void   __saveds AK_IntuiPrint(struct Window *w, char *text, long x, long y);

extern void   __saveds AK_RefreshDisp(struct Screen *sc, struct Window *w);

extern long   __saveds AK_AutoRequester(struct Window *w, char *obertext, char *jatext,
                              char *neintext);

extern long   __saveds AK_Alert(char *text, long height);

extern char * __saveds AK_FileRequest(long xpos, long ypos, struct Screen *fscreen,
                                      struct Window *fwindow, long ftype);

extern long   __saveds AK_ReadDir(char *pathname, char **direntry, long *dirtype);

extern void   __saveds AK_WaitKey(long rawcode);

extern void   __saveds AK_WaitLeft(void);

extern long   __saveds AK_GetNum(long min, long max);

 /* NEW in V36 */

extern APTR   __saveds AK_AllocRequester(long type);

extern void   __saveds AK_FreeRequester(struct AK_Requester *ak_req);

extern char * __saveds AK_ExtFileRequest(struct AK_Requester *ak_req);

#endif AK_GEN0_H
