/* Help.h v. 1.0.2 */

#include <exec/types.h>
#include <intuition/intuition.h>

enum	{TXT_HELP,GFX_HELP,SPEAK_HELP,		/* Help types */
	 MUSIC_HELP,ANIM_HELP,HYPER_HELP,
	 NTYPE};				/* total number */

/* **************************************************** */
/* flags to extract help info, to perform the linked    */
/* function, to signal GAD or MENU event, respectively  */
/* **************************************************** */

enum	{HLP_O=0x1,ACT_O,GAD_O,MENU_O};

#define  HLP_ON      HLP_O
#define  ACT_ON      (1<<ACT_O)
#define  GAD_ON      (1<<GAD_O)
#define  MENU_ON     (1<<MENU_O)

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

#define STRHELP         (NTYPE+3)
#define STRLUNG         80

#define MESSAGE         0x1   /* flag to switch version message */

/* **************************************************** */
/*                  1.3 or 2.0 help tool                */
/* **************************************************** */

#ifndef OS_2.0
#define WhereUser(x)       (APTR)((struct SuperItem *)x)->user;
#else
#define WhereUser(x)       MENU_USERDATA(x);
#endif

/* ***************************************************** */
/* for compatability with Amiga Help Tool v. 1.0 Library */
/*             do not use in new code                    */
/* ***************************************************** */

#define ExtractMenuHelp(a,b,c)         Extract(a,b,c,HLP_ON|MENU_ON)
#define OldExtractMenuHelp(a,b,c)      Extract(a,b,c,HLP_ON|MENU_ON)
#define EXTMENUHLP(a,b,c)              Extract(a,b,c,HLP_ON|MENU_ON)

#define ExtractMenuAction(b,c)         Extract(NULL,b,c,ACT_ON|MENU_ON)
#define EXTMENUACT(b,c)                Extract(NULL,b,c,ACT_ON|MENU_ON)

#define InitHelp(a,b)                  StartHelp(a,b,MESSAGE)

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

struct UserData {
   char *filehelp;
   USHORT type;
   APTR function, args;
};

struct ARexxArray {
   char ARexxCmd[30];
   struct UserData *UD;
};

/* only for 1.3 compatability */

/* The SuperItem structure provides space to store user informations.
   The MenuItem structure inside is repeated to disable the warning
   messages of the compiler.
 */

/* overloading MenuItem */

struct SuperItem {
   struct MenuItem *NextItem;
   SHORT LeftEdge, TopEdge;
   SHORT Width, Height;
   USHORT Flags;
   LONG MutualExclude;
   APTR ItemFill;
   APTR SelectFill;
   BYTE Command;
   struct MenuItem *SubItem;
   USHORT NextSelect;

   struct UserData *user; /* this is the only difference */
};

struct Help {
   char *help, *def, *language, *cmd[NTYPE], command[STRLUNG];
   USHORT cmdtype;
};

/* Help prototypes */

void  buildcmd(char cm[], char *, char *, char *);
int   Extract(struct Help *, APTR, UWORD, UWORD);
BOOL  ExtractARexx(struct Help *, char *, struct ARexxArray AR[], UWORD);
void  help(struct Help *);
int   LoadGad(char *TX[], int, struct Gadget *);
int   LoadMenu(char *TX[], int, struct Menu *);
int   LoadNewMenu(char *TX[], int, struct NewMenu NwMenu[]);
int   StartHelp(char *, struct Help *, BOOL);
void  SetDefaultHelp(struct Help *);
int   TxtR(char *, char **, int, int);
