/**************************************************************************
 * GEMFBIND.H - Header file for low-level GEM bindings.
 *
 *	This header file contains items compatible with both GEMDEFS and OBDEFS
 *	from Alcyon C, or with AES.H and VDI.H from Lattice C.
 *
 *	Include this header file directly only if you want vanilla DRI-style
 *	bindings with no GemFast extensions or utilties.  Normally, a program
 *	would #include <gemfast.h> and this file would be #included from there.
 *
 *	If the macro NO_VDI is defined, VDI-related macros & protos are skipped.
 *	If the macro NO_AES is defined, AES-related macros & protos are skipped.
 *
 *	If you need the fd_addr field of an FDB/MFDB to be something other than
 *	a void* type, do a "#define FDADDR long" (or whatever type you need).
 *
 * Maintenance:
 *	02/01/93 - v1.9
 *			   > This has been split off from GEMFAST.H.  GemFast now works
 *				 by riding on top of whatever bindings system the host
 *				 compiler uses.  For HSC and GNU, gemfast is the bindings
 *				 system, and this header sets up the basic constants and
 *				 data types.  For other compilers, this header isn't used;
 *				 the stuff it contains can be found in the compiler's GEM
 *				 headers.
 *************************************************************************/

#ifndef GEMFBIND_H				/* Prevent multiple inclusion */
#define GEMFBIND_H

#ifdef __cplusplus
  extern "C" {
#endif

/*----------------------------------------------------------------------------
 * under GNU, we only work if -mshort (16-bit-int) is used, until I get
 * around to working over the bindings to support 32-bit-int properly.
 *--------------------------------------------------------------------------*/

#if defined(__GNUC__) && !defined(__MSHORT__)
  #error The -mshort command line option must be used with this version of GemFast!
#endif

/*----------------------------------------------------------------------------
 * provide compiler independance for prototypes.
 *--------------------------------------------------------------------------*/

#ifndef __PROTO
  #if defined(LATTICE) || defined(__GNUC__) || defined(__TURBOC__)
	#define __PROTO(a) a
  #else
	#define __PROTO(a) ()
  #endif
#endif

/*----------------------------------------------------------------------------
 * VDI stuff.
 *--------------------------------------------------------------------------*/

#ifndef NO_VDI
								/* VDI inside fill styles  */
#define IS_HOLLOW	0
#define IS_SOLID	1
#define IS_PATTERN	2
#define IS_HATCH	3
#define IS_UDPTRN	4
								/* VDI inside fill patterns  */
#define IP_HOLLOW	0
#define IP_1PTRN	1
#define IP_2PTRN	2
#define IP_3PTRN	3
#define IP_4PTRN	4
#define IP_5PTRN	5
#define IP_6PTRN	6
#define IP_SOLID	7
							   /* VDI normal graphics drawing modes */
#define MD_REPLACE	1
#define MD_TRANS	2
#define MD_XOR		3
#define MD_ERASE	4
							   /* VDI bit blt rules */
#define ALL_WHITE	0
#define S_AND_D 	1
#define S_AND_NOTD	2
#define S_ONLY		3
#define NOTS_AND_D	4
#define D_ONLY		5
#define S_XOR_D 	6
#define S_OR_D		7
#define NOT_SORD	8
#define NOT_SXORD	9
#define D_INVERT	10
#define NOT_D		10
#define S_OR_NOTD	11
#define NOT_S		12
#define NOTS_OR_D	13
#define NOT_SANDD	14
#define ALL_BLACK	15
							   /* return values from vq_gdos() */
#define GDOS_NONE 0L				/* no GDOS installed */
#define GDOS_FSM  0x5F46534DL		/* '_FSM' */
#define GDOS_FNT  0x5F464E54L		/* '_FNT' */

/*-------------------------------------------------------------------------
 * FDB/MFDB structure (describes memory area for VDI blit)...
 *-----------------------------------------------------------------------*/

#ifndef FDADDR					/* v1.3:  this define has been added to  */
  #define FDADDR void*			/* help provide compatibility between	 */
#endif							/* bindings systems.					 */

typedef struct fdbstr {
	FDADDR	  fd_addr;
	short	  fd_w;
	short	  fd_h;
	short	  fd_wdwidth;
	short	  fd_stand;
	short	  fd_nplanes;
	short	  fd_r1;
	short	  fd_r2;
	short	  fd_r3;
} FDB, MFDB;

/*-------------------------------------------------------------------------
 * MFORM structure (describes mouse cursor data)...
 *-----------------------------------------------------------------------*/

typedef struct mfstr {
	short mf_xhot;
	short mf_yhot;
	short mf_nplanes;
	short mf_fg;
	short mf_bg;
	short mf_mask[16];
	short mf_data[16];
} MFORM;

/*----------------------------------------------------------------------------
 * VDI prototypes.	(vdicall() is for rolling your own new bindings in C.)
 *--------------------------------------------------------------------------*/

extern short   vdicall			  __PROTO((short _Contrl[], short _Intin[], short _Ptsin[], short _Intout[], short _Ptsout[]));
extern void    v_alpha_text 	  __PROTO((short _Hnd, char *_Str));
extern void    v_arc			  __PROTO((short _Hnd, short _X, short _Y, short _Radius, short _Begang, short _Endang));
extern void    v_bar			  __PROTO((short _Hnd, short _Pxy[]));
extern void    v_bit_image		  __PROTO((short _Hnd, char *_Filename, short _Aspect, short _X_scale, short _Y_scale, short _H_align, short _V_align, short *_Pxy));
extern void    v_cellarray		  __PROTO((short _Hnd, short _Pxy[], short _Row_length, short _Elements, short _Nrows, short _Write_mode, short _Colarray[]));
extern void    v_circle 		  __PROTO((short _Hnd, short _X, short _Y, short _Radius));
extern void    v_clear_disp_list  __PROTO((short _Hnd));
extern void    v_clrwk			  __PROTO((short _Hnd));
extern void    v_clsvwk 		  __PROTO((short _Hnd));
extern void    v_clswk			  __PROTO((short _Hnd));
extern void    v_contourfill	  __PROTO((short _Hnd, short _X, short _Y, short _Index));
extern void    v_curdown		  __PROTO((short _Hnd));
extern void    v_curhome		  __PROTO((short _Hnd));
extern void    v_curleft		  __PROTO((short _Hnd));
extern void    v_curright		  __PROTO((short _Hnd));
extern void    v_curtext		  __PROTO((short _Hnd, char *_Str));
extern void    v_curup			  __PROTO((short _Hnd));
extern void    v_dspcur 		  __PROTO((short _Hnd, short _X, short _Y));
extern void    v_eeol			  __PROTO((short _Hnd));
extern void    v_eeos			  __PROTO((short _Hnd));
extern void    v_ellarc 		  __PROTO((short _Hnd, short _X, short _Y, short _Xrad, short _Yrad, short _Begang, short _Endang));
extern void    v_ellipse		  __PROTO((short _Hnd, short _X, short _Y, short _Xrad, short _Yrad));
extern void    v_ellpie 		  __PROTO((short _Hnd, short _X, short _Y, short _Xrad, short _Yrad, short _Begang, short _Endang));
extern void    v_enter_cur		  __PROTO((short _Hnd));
extern void    v_escape2000 	  __PROTO((short _Hnd, short _Times));
extern void    v_exit_cur		  __PROTO((short _Hnd));
extern void    v_fillarea		  __PROTO((short _Hnd, short _Count, short _Pxy[]));
extern void    v_form_adv		  __PROTO((short _Hnd));
extern void    v_gchar			  __PROTO((short _Hnd, short _X, short _Y, char _Char));
extern void    v_get_pixel		  __PROTO((short _Hnd, short _X, short _Y, short *_Pel, short *_Indx));
extern short   v_gtext			  __PROTO((short _Hnd, short _X, short _Y, char *_Str));
extern void    v_hardcopy		  __PROTO((short _Hnd));
extern void    v_hide_c 		  __PROTO((short _Hnd));
extern void    v_justified		  __PROTO((short _Hnd, short _X, short _Y, char *str, short _Len, short _Word_space, short _Char_space));
extern void    v_meta_extents	  __PROTO((short _Hnd, short _Min_x, short _Min_y, short _Max_x, short _Max_y));
extern void    v_opnvwk 		  __PROTO((short _Work_in[], short *_Hnd, short _Work_out[]));
extern void    v_opnwk			  __PROTO((short _Work_in[], short *_Hnd, short _Work_out[]));
extern void    v_output_window	  __PROTO((short _Hnd, short *_Pxy));
extern void    v_pieslice		  __PROTO((short _Hnd, short _X, short _Y, short _Radius, short _Begang, short _Endang));
extern void    v_pline			  __PROTO((short _Hnd, short _Count, short _Pxy[]));
extern void    v_pmarker		  __PROTO((short _Hnd, short _Count, short _Pxy[]));
extern void    v_rbox			  __PROTO((short _Hnd, short _Pxy[]));
extern void    v_rfbox			  __PROTO((short _Hnd, short _Pxy[]));
extern void    v_rmcur			  __PROTO((short _Hnd));
extern void    v_rvoff			  __PROTO((short _Hnd));
extern void    v_rvon			  __PROTO((short _Hnd));
extern void    v_show_c 		  __PROTO((short _Hnd, short _Reset));
extern void    v_sound			  __PROTO((short _Hnd, short _Frequency, short _Dration));
extern void    v_updwk			  __PROTO((short _Hnd));
extern void    v_write_meta 	  __PROTO((short _Hnd, short _Num_intin, short *_A_intin, short _Num_ptsin, short *_A_ptsin));
extern void    vex_butv 		  __PROTO((short _Hnd, void *_New_p, void **_Old));
extern void    vex_curv 		  __PROTO((short _Hnd, void *_New_p, void **_Old));
extern void    vex_motv 		  __PROTO((short _Hnd, void *_New_p, void **_Old));
extern void    vex_timv 		  __PROTO((short _Hnd, void *_Time_addr, void **_Otime_addr, short *_Time_conv));
extern void    vm_coords		  __PROTO((short _Hnd, short _Llx, short _Lly, short _Urx, short _Ury));
extern void    vm_filename		  __PROTO((short _Hnd, char *_Filename));
extern void    vm_pagesize		  __PROTO((short _Hnd, short _Pgwidth, short _Pgheight));
extern void    vq_cellarray 	  __PROTO((short _Hnd, short _Pxy[], short _Row_len, short _Nrows, short *_El_used, short *_Rows_used, short *_Status, short _Color[]));
extern void    vq_chcells		  __PROTO((short _Hnd, short *_N_rows, short *_N_cols));
extern short   vq_color 		  __PROTO((short _Hnd, short _Index, short _Flag, short _Rgb[]));
extern void    vq_curaddress	  __PROTO((short _Hnd, short *_Cur_row, short *_Cur_col));
extern void    vq_dimensions	  __PROTO((short _Hnd, short *_Xdimension, short *_Ydimension));
extern void    vq_extnd 		  __PROTO((short _Hnd, short _Flag, short _Work_out[]));
extern unsigned long vq_gdos	  __PROTO((void));
extern void    vq_key_s 		  __PROTO((short _Hnd, short *_State));
extern void    vq_mouse 		  __PROTO((short _Hnd, short *_Pstatus, short *_X, short *_Y));
extern void    vq_scan			  __PROTO((short _Hnd, short *_G_slice, short *_G_page, short *_A_slice, short *_A_page, short *_Div_fac));
extern short   vq_tabstatus 	  __PROTO((short _Hnd));
extern void    vqf_attributes	  __PROTO((short _Hnd, short _Atrib[]));
extern void    vqin_mode		  __PROTO((short _Hnd, short _Dev, short *_Mode));
extern void    vql_attributes	  __PROTO((short _Hnd, short _Atrib[]));
extern void    vqm_attributes	  __PROTO((short _Hnd, short _Atrib[]));
extern short   vqp_filmname 	  __PROTO((short _Hnd, short _Index, char *_Name));
extern void    vqt_attributes	  __PROTO((short _Hnd, short _Atrib[]));
extern void    vqt_extent		  __PROTO((short _Hnd, char *_Str, short _Extent[]));
extern void    vqt_fontinfo 	  __PROTO((short _Hnd, short *_Minade, short *_Maxade, short _Distances[], short *_Maxwidth, short _Effects[]));
extern short   vqt_name 		  __PROTO((short _Hnd, short _Element, char *_Name));
extern short   vqt_width		  __PROTO((short _Hnd, short _Char, short *_Cw, short *_Ldelta, short *_Rdelta));
extern void    vr_recfl 		  __PROTO((short _Hnd, short _Pxy[]));
extern void    vr_trnfm 		  __PROTO((short _Hnd, void *_Src, void *_Dst));
extern void    vro_cpyfm		  __PROTO((short _Hnd, short _Mode, short _Pxy[], void *src, void *dst));
extern void    vrq_choice		  __PROTO((short _Hnd, short _Cin, short *_Cout));
extern void    vrq_locator		  __PROTO((short _Hnd, short _X, short _Y, short *_Xout, short *_Yout, short *_Term));
extern void    vrq_string		  __PROTO((short _Hnd, short _Len, short _Echo, short _Echoxy[], char *_Str));
extern void    vrq_valuator 	  __PROTO((short _Hnd, short _In, short *_Out, short *_Term));
extern void    vrt_cpyfm		  __PROTO((short _Hnd, short _Mode, short _Pxy[], void *src, void *dst, short color[]));
extern void    vs_clip			  __PROTO((short _Hnd, short _Clip_flag, short _Pxy[]));
extern void    vs_color 		  __PROTO((short _Hnd, short _Index, short _Rgb[]));
extern void    vs_curaddress	  __PROTO((short _Hnd, short _Row, short _Col));
extern short   vs_mute			  __PROTO((short _Hnd, short _Action));
extern short   vs_palette		  __PROTO((short _Hnd, short _Palette));
extern void    vsc_expose		  __PROTO((short _Hnd, short _State));
extern void    vsc_form 		  __PROTO((short _Hnd, short _Form[]));
extern short   vsf_color		  __PROTO((short _Hnd, short _Index));
extern short   vsf_interior 	  __PROTO((short _Hnd, short _Style));
extern short   vsf_perimeter	  __PROTO((short _Hnd, short _Vis));
extern short   vsf_style		  __PROTO((short _Hnd, short _Style));
extern void    vsf_udpat		  __PROTO((short _Hnd, short _Pat[], short _Planes));
extern short   vsin_mode		  __PROTO((short _Hnd, short dev, short _Mode));
extern short   vsl_color		  __PROTO((short _Hnd, short _Index));
extern void    vsl_ends 		  __PROTO((short _Hnd, short _Begstyle, short _Endstyle));
extern short   vsl_type 		  __PROTO((short _Hnd, short _Style));
extern void    vsl_udsty		  __PROTO((short _Hnd, short _Pat));
extern short   vsl_width		  __PROTO((short _Hnd, short _Width));
extern short   vsm_choice		  __PROTO((short _Hnd, short *_Choice));
extern short   vsm_color		  __PROTO((short _Hnd, short _Index));
extern void    vsm_height		  __PROTO((short _Hnd, short _Height));
extern short   vsm_locator		  __PROTO((short _Hnd, short _X, short _Y, short *_Xout, short *_Yout, short *_Term));
extern short   vsm_string		  __PROTO((short _Hnd, short _Len, short _Echo, short _Echoxy[], char *_Str));
extern short   vsm_type 		  __PROTO((short _Hnd, short _Symbol));
extern void    vsm_valuator 	  __PROTO((short _Hnd, short _In, short *_Out, short *_Term, short *_Status));
extern void    vsp_film 		  __PROTO((short _Hnd, short _Index, short _Lightness));
extern void    vst_alignment	  __PROTO((short _Hnd, short _Hin, short _Vin, short *_Hout, short *_Vout));
extern short   vst_color		  __PROTO((short _Hnd, short _Index));
extern short   vst_effects		  __PROTO((short _Hnd, short _Effects));
extern short   vst_font 		  __PROTO((short _Hnd, short _Font));
extern short   vst_height		  __PROTO((short _Hnd, short _Height, short *_Charw, short *_Charh, short *_Cellw, short *_Cellh));
extern short   vst_load_fonts	  __PROTO((short _Hnd, short _Select));
extern short   vst_point		  __PROTO((short _Hnd, short _Point, short *_Charw, short *_Charh, short *_Cellw, short *_Cellh));
extern short   vst_rotation 	  __PROTO((short _Hnd, short _Ang));
extern void    vst_unload_fonts   __PROTO((short _Hnd, short _Select));
extern short   vswr_mode		  __PROTO((short _Hnd, short _Mode));
extern void    vt_alignment 	  __PROTO((short _Hnd, short _Dx, short _Dy));
extern void    vt_axis			  __PROTO((short _Hnd, short _Xres, short _Yres, short *_Xset, short *_Yset));
extern void    vt_origin		  __PROTO((short _Hnd, short _Xorigin, short _Yorigin));
extern void    vt_resolution	  __PROTO((short _Hnd, short _Xres, short _Yres, short *_Xset, short *_Yset));


#endif /* NO_VDI */

/*----------------------------------------------------------------------------
 * AES stuff.
 *--------------------------------------------------------------------------*/

#ifndef NO_AES

									/* font types */
#define IBM 		3
#define SMALL		5
#define TE_SYSTEM	3
#define TE_SMALL	5

									/* evnt_multi options */
#define MU_KEYBD	0x0001
#define MU_BUTTON	0x0002
#define MU_M1		0x0004
#define MU_M2		0x0008
#define MU_MESAG	0x0010
#define MU_TIMER	0x0020
									/* evnt_mouse options */
#define MU_MENTRY	0x0000
#define MU_MEXIT	0x0001
									/* keyboard states */
#define K_RSHIFT	0x0001
#define K_LSHIFT	0x0002
#define K_CTRL		0x0004
#define K_ALT		0x0008
									/* event message values */
#define MN_SELECTED 10
#define WM_REDRAW	20
#define WM_TOPPED	21
#define WM_CLOSED	22
#define WM_FULLED	23
#define WM_ARROWED	24
#define WM_HSLID	25
#define WM_VSLID	26
#define WM_SIZED	27
#define WM_MOVED	28
#define WM_NEWTOP	29
#define AC_OPEN 	40
#define AC_CLOSE	41
#define CT_UPDATE	50				/* these are XControl messages... */
#define CT_MOVE 	51
#define CT_NEWTOP	52
#define CT_KEY		53
									/* form_dial opcodes */
#define FMD_START	0
#define FMD_GROW	1
#define FMD_SHRINK	2
#define FMD_FINISH	3
									/* rsrc_gaddr structure types */
#define ROOT		0
#define R_TREE		0
#define R_OBJECT	1
#define R_TEDINFO	2
#define R_ICONBLK	3
#define R_BITBLK	4
#define R_STRING	5
#define R_IMAGEDATA 6
#define R_OBSPEC	7
#define R_TEPTEXT	8
#define R_TEPTMPLT	9
#define R_TEPVALID	10
#define R_IBPMASK	11
#define R_IBPDATA	12
#define R_IBPTEXT	13
#define R_BIPDATA	14
#define R_FRSTR 	15
#define R_FRIMG 	16
									/* Window Attributes */
#define NAME		0x0001
#define CLOSER		0x0002
#define FULLER		0x0004
#define MOVER		0x0008
#define INFO		0x0010
#define SIZER		0x0020
#define UPARROW 	0x0040
#define DNARROW 	0x0080
#define VSLIDE		0x0100
#define LFARROW 	0x0200
#define RTARROW 	0x0400
#define HSLIDE		0x0800
									/* wind_calc options */
#define WC_BORDER	0
#define WC_WORK 	1
									/* wind_get options */
#define WF_KIND 	1
#define WF_NAME 	2
#define WF_INFO 	3
#define WF_WORKXYWH 4
#define WF_CURRXYWH 5
#define WF_PREVXYWH 6
#define WF_FULLXYWH 7
#define WF_HSLIDE	8
#define WF_VSLIDE	9
#define WF_TOP		10
#define WF_FIRSTXYWH 11
#define WF_NEXTXYWH 12
#define WF_RESVD	13
#define WF_NEWDESK	14
#define WF_HSLSIZE	15
#define WF_VSLSIZE	16
#define WF_SCREEN	17
#define WF_COLOR	18
#define WF_DCOLOR	19
									/* window elements	*/
#define W_BOX		0
#define W_TITLE 	1
#define W_CLOSER	2
#define W_NAME		3
#define W_FULLER	4
#define W_INFO		5
#define W_DATA		6
#define W_WORK		7
#define W_SIZER 	8
#define W_VBAR		9
#define W_UPARROW	10
#define W_DNARROW	11
#define W_VSLIDE	12
#define W_VELEV 	13
#define W_HBAR		14
#define W_LFARROW	15
#define W_RTARROW	16
#define W_HSLIDE	17
#define W_HELEV 	18
									/* arrow messages */
#define WA_UPPAGE	0
#define WA_DNPAGE	1
#define WA_UPLINE	2
#define WA_DNLINE	3
#define WA_LFPAGE	4
#define WA_RTPAGE	5
#define WA_LFLINE	6
#define WA_RTLINE	7
									/* wind_update options */
#define END_UPDATE	0
#define BEG_UPDATE	1
#define END_MCTRL	2
#define BEG_MCTRL	3
									/* graf_mouse mouse types*/
#define ARROW			0
#define TEXT_CRSR		1
#define HOURGLASS		2			/* this name used by MWC */
#define BUSYBEE 		2			/* because I always forget the underbar */
#define BUSY_BEE		2
#define BEE 			2
#define POINT_HAND		3
#define FLAT_HAND		4
#define THIN_CROSS		5
#define THICK_CROSS 	6
#define OUTLN_CROSS 	7
#define USER_DEF		255
#define M_OFF			256
#define M_ON			257
								/* max depth of search or draw	*/
#define MAX_DEPTH	8
								/* object types */
#define G_BOX		20
#define G_TEXT		21
#define G_BOXTEXT	22
#define G_IMAGE 	23
#define G_USERDEF	24
#define G_PROGDEF	24
#define G_IBOX		25
#define G_BUTTON	26
#define G_BOXCHAR	27
#define G_STRING	28
#define G_FTEXT 	29
#define G_FBOXTEXT	30
#define G_ICON		31
#define G_TITLE 	32
								/* object flags */
#define NONE		0x0000
#define SELECTABLE	0x0001
#define DEFAULT 	0x0002
#define EXIT		0x0004
#define EDITABLE	0x0008
#define RBUTTON 	0x0010
#define LASTOB		0x0020
#define TOUCHEXIT	0x0040
#define HIDETREE	0x0080
#define INDIRECT	0x0100
#define SUBMENU 	0x0800			/* TOS 4.0x hierarchical menus */
								/* Object states */
#define NORMAL		0x0000
#define SELECTED	0x0001
#define CROSSED 	0x0002
#define CHECKED 	0x0004
#define DISABLED	0x0008
#define OUTLINED	0x0010
#define SHADOWED	0x0020
								/* Object colors	*/
#define WHITE		0
#define BLACK		1
#define RED 		2
#define GREEN		3
#define BLUE		4
#define CYAN		5
#define YELLOW		6
#define MAGENTA 	7
#define LWHITE		8
#define LBLACK		9
#define LRED		10
#define LGREEN		11
#define LBLUE		12
#define LCYAN		13
#define LYELLOW 	14
#define LMAGENTA	15
								/* editable text field definitions */
#define EDSTART 	0
#define EDINIT		1
#define EDCHAR		2
#define EDEND		3
								/* editable text justification */
#define TE_LEFT 	0
#define TE_RIGHT	1
#define TE_CNTR 	2

/**************************************************************************
 * data structures and types...
 *************************************************************************/

/*-------------------------------------------------------------------------
 * OBJECT structure...
 *-----------------------------------------------------------------------*/

typedef struct object {
	short			  ob_next;		  /* -> object's next sibling     */
	short			  ob_head;		  /* -> head of object's children */
	short			  ob_tail;		  /* -> tail of object's children */
	unsigned short	  ob_type;		  /* type of object 			  */
	unsigned short	  ob_flags; 	  /* options					  */
	unsigned short	  ob_state; 	  /* state						  */
	long			  ob_spec;		  /* whatever...				  */
	short			  ob_x; 		  /* upper left corner of object  */
	short			  ob_y; 		  /* upper left corner of object  */
	short			  ob_width; 	  /* width of obj				  */
	short			  ob_height;	  /* height of obj				  */
} OBJECT;

/*-------------------------------------------------------------------------
 * GRECT structure (an AES-style rectangle, describes via width/height)...
 *-----------------------------------------------------------------------*/

typedef struct grect {
	short g_x;
	short g_y;
	short g_w;
	short g_h;
} GRECT;

/*-------------------------------------------------------------------------
 * TEDINFO structure...
 *-----------------------------------------------------------------------*/

typedef struct text_edinfo {
	char   *te_ptext;			  /* ptr to text			   */
	char   *te_ptmplt;			  /* ptr to template		   */
	char   *te_pvalid;			  /* ptr to validation chrs.   */
	short  te_font; 			  /* font					   */
	short  te_junk1;			  /* junk word				   */
	short  te_just; 			  /* justification			   */
	short  te_color;			  /* color information word    */
	short  te_junk2;			  /* junk word				   */
	short  te_thickness;		  /* border thickness		   */
	short  te_txtlen;			  /* length of text string	   */
	short  te_tmplen;			  /* length of template string */
} TEDINFO;

/*-------------------------------------------------------------------------
 * ICONBLK structure...
 *-----------------------------------------------------------------------*/

typedef struct icon_block {
	short  *ib_pmask;
	short  *ib_pdata;
	char   *ib_ptext;
	short  ib_char;
	short  ib_xchar;
	short  ib_ychar;
	short  ib_xicon;
	short  ib_yicon;
	short  ib_wicon;
	short  ib_hicon;
	short  ib_xtext;
	short  ib_ytext;
	short  ib_wtext;
	short  ib_htext;
} ICONBLK;

/*-------------------------------------------------------------------------
 * BITBLK structure...
 *-----------------------------------------------------------------------*/

typedef struct bit_block {
	short  *bi_pdata;				  /* ptr to bit forms data	*/
	short  bi_wb;					  /* width of form in bytes */
	short  bi_hl;					  /* height in lines		*/
	short  bi_x;					  /* source x in bit form	*/
	short  bi_y;					  /* source y in bit form	*/
	short  bi_color;				  /* fg color of blt		*/
} BITBLK;

/*-------------------------------------------------------------------------
 * PARMBLK structure (passed to a userdraw func when drawing an object)...
 *-----------------------------------------------------------------------*/

typedef struct parm_blk {
	OBJECT	  *pb_tree;
	short	  pb_obj;
	short	  pb_prevstate;
	short	  pb_currstate;
	short	  pb_x,  pb_y,	pb_w,  pb_h;
	short	  pb_xc, pb_yc, pb_wc, pb_hc;
	long	  pb_parm;
} PARMBLK;

/*-------------------------------------------------------------------------
 * USERBLK/APPLBLK structure (defines a userdraw object)...
 *-----------------------------------------------------------------------*/

typedef struct user_blk {
	long (*ub_code) __PROTO((PARMBLK *));
	long ub_parm;
} USERBLK, APPLBLK;

#define appl_blk user_blk

/*----------------------------------------------------------------------------
 * TOS 4.0x hiearchical menu structures.
 *	(I gotta learn what this stuff is all about!)
 *--------------------------------------------------------------------------*/

typedef struct _menu
{
	OBJECT *mn_tree;	/* the object tree of the menu */
	short	mn_menu;	/* the parent object of the menu items */
	short	mn_item;	/* the starting menu item */
	short	mn_scroll;	/* the scroll field status of the menu
						   0  - The menu will not scroll
						   !0 - The menu will scroll if the number of menu
								items exceed the menu scroll height. The
								non-zero value is the object at which
								scrolling will begin.  This will allow one
								to have a menu in which the scrollable region
								is only a part of the whole menu.  The value
								must be a menu item in the menu.
								menu_settings can be used to change the menu
								scroll height.
						 NOTE:	If the scroll field status is !0, the menu
								items must consist entirely of G_STRINGS. */
	short	mn_keystate; /* The CTRL, ALT, SHIFT Key state at the time the
								mouse button was pressed. */
} MENU;

/* menu_settings uses a new structure for setting and inquiring the submenu
 * delay values and the menu scroll height.  The delay values are measured in
 * milliseconds and the height is based upon the number of menu items.
 */

typedef struct _mn_set
{
	long  Display;	  /*  the submenu display delay 	*/
	long  Drag; 	  /*  the submenu drag delay		*/
	long  Delay;	  /*  the single-click scroll delay */
	long  Speed;	  /*  the continuous scroll delay	*/
	short Height;	  /*  the menu scroll height		*/
} MN_SET;

/*-------------------------------------------------------------------------
 * RSHDR structure...
 *-----------------------------------------------------------------------*/

typedef struct rshdr {
	short			  rsh_vrsn; 	  /* Resource structure version # */
	unsigned short	  rsh_object;	  /* Offset to first object 	  */
	unsigned short	  rsh_tedinfo;	  /* Offset to first tedinfo	  */
	unsigned short	  rsh_iconblk;	  /* Offset to first iconblk	  */
	unsigned short	  rsh_bitblk;	  /* Offset to first bitblk 	  */
	unsigned short	  rsh_frstr;	  /* Offset to free string index  */
	unsigned short	  rsh_string;	  /* Offset to string data		  */
	unsigned short	  rsh_imdata;	  /* Offset to image data		  */
	unsigned short	  rsh_frimg;	  /* Offset to free image index   */
	unsigned short	  rsh_trindex;	  /* Offset to tree index		  */
	unsigned short	  rsh_nobs; 	  /* Number of objects			  */
	unsigned short	  rsh_ntree;	  /* Number object trees		  */
	unsigned short	  rsh_nted; 	  /* Number of tedinfo structs	  */
	unsigned short	  rsh_nib;		  /* Number of iconblk structs	  */
	unsigned short	  rsh_nbb;		  /* Number of bitblk structs	  */
	unsigned short	  rsh_nstring;	  /* Number of free strings 	  */
	unsigned short	  rsh_nimages;	  /* Number of free images		  */
	unsigned short	  rsh_rssize;	  /* total bytes in resource	  */
} RSHDR;

/**************************************************************************
 * declarations of all global vars defined by gemfast bindings...
 *************************************************************************/

/*
 * these are valid after appl_init()
 */

extern void 	*aespb[6];		 /* the AES parmblk, an array of 6 ptrs    */
extern short	aescontrol[5];	 /* the AES control structure, 5 shorts    */
extern short	global[];		 /* global[] is aliased by following names */
extern short	gl_apversion;	 /* the AES version number				   */
extern short	gl_apcount; 	 /* max # of concurrent AES applications   */
extern short	gl_apid;		 /* id of the current application		   */
extern long 	gl_apprivate;	 /* anything the applicaton wants to store */
extern OBJECT	**gl_apptree;	 /* pointer to array of object tree ptrs   */
extern long 	gl_ap1resv; 	 /* old name for pointer to rsc data	   */
extern RSHDR	*gl_aprshdr;	 /* pointer to head of rsc data 		   */
extern short	gl_ap2resv[6];	 /* unused entries in global array		   */

/*----------------------------------------------------------------------------
 * AES prototypes.
 *--------------------------------------------------------------------------*/

extern short  appl_init 	 __PROTO((void));
extern short  appl_read 	 __PROTO((short ApId, short Length, void *ApPbuff));
extern short  appl_write	 __PROTO((short ApId, short Length, void *ApPbuff));
extern short  appl_find 	 __PROTO((char *Name));
extern short  appl_tplay	 __PROTO((void *Mem, short Num, short Scale));
extern short  appl_trecord	 __PROTO((void *Mem, short Count));
extern short  appl_exit 	 __PROTO((void));
extern short  evnt_keybd	 __PROTO((void));
extern short  evnt_button	 __PROTO((short Clicks, short WhichButton,short WhichState, short *Mx, short *My,short *ButtonState, short *KeyState));
extern short  evnt_mouse	 __PROTO((short EnterExit, short InX, short InY, short InW,short InH, short *OutX, short *OutY,short *ButtonState, short *KeyState));
extern short  evnt_mesag	 __PROTO((short MesagBuf[]));
extern short  evnt_timer	 __PROTO((unsigned short locount, unsigned short hicount));
extern short  evnt_multi	 __PROTO((short Type, short Clicks, short WhichButton,short WhichState, short EnterExit1, short In1X,short In1Y, short In1W, short In1H,
								short EnterExit2, short In2X, short In2Y,short In2W, short In2H, short MesagBuf[],unsigned short I1, unsigned short I2,short *OutX, short *OutY,short *ButtonState, short *KeyState, short *Key,short *ReturnCount));
extern short  evnt_dclick	 __PROTO((short ToSet, short SetGet));
extern short  form_do		 __PROTO((OBJECT *Tree, short StartObj));
extern short  form_dial 	 __PROTO((short Flag, short Sx, short Sy, short Sw, short Sh,short Bx, short By, short Bw, short Bh));
extern short  form_alert	 __PROTO((short DefButton, char *Str));
extern short  form_error	 __PROTO((short ErrorCode));
extern short  form_center	 __PROTO((OBJECT *Tree, short *Cx, short *Cy, short *Cw,short *Ch));
extern short  form_keybd	 __PROTO((OBJECT *Ktree, short Kobject, short Kobnext, short Kchar, short *Knxtobject, short *Knxtchar));
extern short  form_button	 __PROTO((OBJECT *Btree, short Bobject, short Bclicks,short *Bnxtobj));
extern short  fsel_input	 __PROTO((char *Path, char *File, short *ExitButton));
extern short  fsel_exinput	 __PROTO((char *Path, char *File, short *ExitButton,char *Prompt));
extern short  graf_rubberbox __PROTO((short Ix, short Iy, short Iw, short Ih, short *Fw, short *Fh));
extern short  graf_dragbox	 __PROTO((short Sw, short Sh, short Sx, short Sy, short Bx, short By, short Bw, short Bh, short *Fw, short *Fh));
extern short  graf_movebox	 __PROTO((short Sw, short Sh, short Sx, short Sy, short Dx, short Dy));
extern short  graf_growbox	 __PROTO((short Sx, short Sy, short Sw, short Sh, short Fx, short Fy, short Fw, short Fh));
extern short  graf_shrinkbox __PROTO((short Fx, short Fy, short Fw, short Fh, short Sx, short Sy, short Sw, short Sh));
extern short  graf_watchbox  __PROTO((OBJECT *Tree, short Object, short InState, short OutState));
extern short  graf_slidebox  __PROTO((OBJECT *Tree, short Parent, short Object, short Direction));
extern short  graf_handle	 __PROTO((short *Wchar, short *Hchar, short *Wbox, short *Hbox));
extern short  graf_mouse	 __PROTO((short Form, void *FormAddress));
extern short  graf_mkstate	 __PROTO((short *Mx, short *My, short *ButtonState, short *KeyState));
extern short  menu_bar		 __PROTO((OBJECT *Tree, short ShowFlag));
extern short  menu_icheck	 __PROTO((OBJECT *Tree, short Item, short CheckFlag));
extern short  menu_ienable	 __PROTO((OBJECT *Tree, short Item, short EnableFlag));
extern short  menu_tnormal	 __PROTO((OBJECT *Tree, short Item, short NormalFlag));
extern short  menu_text 	 __PROTO((OBJECT *Tree, short Item, char *Text));
extern short  menu_register  __PROTO((short ApId, char *MenuText));
extern short  objc_add		 __PROTO((OBJECT *Tree, short Parent, short Child));
extern short  objc_delete	 __PROTO((OBJECT *Tree, short Object));
extern short  objc_draw 	 __PROTO((OBJECT *Tree, short Start, short Depth, short Cx, short Cy, short Cw, short Ch));
extern short  objc_find 	 __PROTO((OBJECT *Tree, short Start, short Depth, short Mx, short My));
extern short  objc_offset	 __PROTO((OBJECT *Tree, short Object, short *X, short *Y));
extern short  objc_order	 __PROTO((OBJECT *Tree, short Object, short NewPos));
extern short  objc_edit 	 __PROTO((OBJECT *Tree, short Object, short Char, short Index, short Kind, short *NewIndex));
extern short  objc_change	 __PROTO((OBJECT *Tree, short Object, short Res, short Cx, short Cy, short Cw, short Ch, short NewState, short Redraw));
extern short  rsrc_load 	 __PROTO((char *Name));
extern short  rsrc_free 	 __PROTO((void));
extern short  rsrc_gaddr	 __PROTO((short Type, short Index, void *Address));
extern short  rsrc_saddr	 __PROTO((short Type, short Index, void *Address));
extern short  rsrc_obfix	 __PROTO((OBJECT *Tree, short Index));
extern short  scrp_read 	 __PROTO((char *Scrappath));
extern short  scrp_write	 __PROTO((char *Scrappath));
extern short  shel_read 	 __PROTO((char *Command, char *Tail));
extern short  shel_write	 __PROTO((short Exit, short Graphic, short Aes, char *Command, char *Tail));
extern short  shel_find 	 __PROTO((char *buf));
extern short  shel_envrn	 __PROTO((char *result, char *param));
extern short  shel_get		 __PROTO((char *Buf, short Len));
extern short  shel_put		 __PROTO((char *Buf, short Len));
extern short  wind_create	 __PROTO((short Parts, short Wx, short Wy, short Ww, short Wh));
extern short  wind_open 	 __PROTO((short WindowHandle, short Wx, short Wy, short Ww, short Wh));
extern short  wind_close	 __PROTO((short WindowHandle));
extern short  wind_delete	 __PROTO((short WindowHandle));
extern short  wind_get		 __PROTO((short WindowHandle, short What, short *W1, short *W2, short *W3, short *W4));
extern short  wind_set		 __PROTO((short WindowHandle, short What, ...));
extern short  wind_find 	 __PROTO((short X, short Y));
extern short  wind_update	 __PROTO((short Code));
extern short  wind_calc 	 __PROTO((short Type, short Parts, short InX, short InY, short InW, short InH, short *OutX, short *OutY, short *OutW, short *OutH));
extern void   wind_new		 __PROTO((void));
extern void   rc_copy		 __PROTO((GRECT *Src, GRECT *Dest));
extern short  rc_equal		 __PROTO((GRECT *Rect1, GRECT *Rect2));
extern short  rc_intersect	 __PROTO((GRECT *Src, GRECT *Dst));
extern void   rc_union		 __PROTO((GRECT *Src, GRECT *Dst));

extern short  scrp_clear	 __PROTO((void));

#endif /* NO_AES */

#ifdef __cplusplus
  }
#endif

#endif /* GEMFBIND_H */

