tvlib34_h

/*
**	Copyright 1991, Universities Research Association.  All rights reserved.
*/
/******************************************************************************/
/* tvlib34.h
**
**	This is the include file for TVLIB34.C.
**	(This version is specifically intended for use with Metawindows
**	 version 3.4.)
**
**	V0.0	B S Hendricks / Accelerator Controls		26-Jan-89
**	Created
**
**	V0.1	B S Hendricks / Accelerator Controls		31-Jan-89
**	Created TVSCREEN and LXSCREEN structures
**
**	V0.2	B S Hendricks / Accelerator Controls		14-Feb-89
**	Updated procedure definitions
**
**	V0.3	B S Hendricks / Accelerator Controls		21-Feb-89
**	Added WINBLK, WINBOX, WINFLD, WINGET, WINMOV, WINRC, WINTTL,
**	WINXY, WINSIZ, WINOCC, WINSTK, WINTERSECT, TVBOX, and TVFILL
**	routines and began worrying about overlapping windows
**
**	V0.4	B S Hendricks / Accelerator Controls		08-Mar-89
**	Added WINSCL, WINGAP, and WINARC routines and modified LXARC,
**	WINTVM,	TVBOX, and WINHOL
**
**	V0.5	B S Hendricks / Accelerator Controls		09-Mar-89
**	Added mouse button definitions
**
**	V0.6	B S Hendricks / Accelerator Controls		22-May-89
**	Added TVCHAR, FNTCHR, TVFONT, and TVINFO routines
**
**	V0.7	B S Hendricks / Accelerator Controls		11-Aug-89
**	Added WNSCRS, TVBKGD, and TVSTYL routines
**
**	V0.8	B S Hendricks / Accelerator Controls		06-Sep-89
**	Added LXCATT and WINTXT routines as well as C callable versions
**	of several other routines
*/
/******************************************************************************/

#ifndef TVLIB34_DEFINED				/* do this only once */
#define	TVLIB34_DEFINED

#include	"pccns.h"

#ifndef __cplusplus
#include	"grcons34.h"	/* Metawindow definitions */
#include	"grport34.h"	/* Metawindow */
#include	"grextr34.h"	/* Metawindow ! beware far pointers */
#endif

#if PC_CONSOLE_ENV
#define	WDELETC(wid,row,col)	window_delete_c((wid),(row),(col))
#ifdef WDELET
#undef WDELET
#endif
#define	WDELET	window_delete
#else
#define	WDELETC(wid,row,col)	{\
				short	short_wid;\
				short	short_row;\
				short	short_col;\
				short_wid = (short) (wid);\
				short_row = (short) (row);\
				short_col = (short) (col);\
				WDELET(&short_wid,&short_row,&short_col);\
				}
#endif

/******************************************************************************/
/* 
**	defined constants
*/
/******************************************************************************/

#define		MAXROW		26		/* max # of screen rows */
#define		MAXCOL		80		/* max # of screen columns */
#define		DEF_ROW		26		/* default # of screen rows */
#define		DEF_COL		80		/* default # of screen columns */
#define		MIN_ROWS	12
#define		MAX_ROWS	26
#define		MIN_COLS	32
#define 	MAX_COLS	80
#define		CMPHDRSIZ	8		/* header size for compressed TV image */
#define		REPLACE		0		/* screen replace mode */
#define		OR		1		/* screen 'OR' mode */
#define		AND		2		/* screen 'AND' mode */
#define		XOR		3		/* screen 'XOR' mode */
#define		MAXPIX_X	640
#define		MAXPIX_Y	350
#define		VGA_MAXPIX_Y	480
#define		PIX_PER_COL	8
#define		PIX_PER_ROW	13
#define		VGA_PIX_PER_ROW	18
#define		MAXPIXROW	18		/* maximum number of pixels per row */
#define		DEFLT_EGA_FONT	16		/* Metawindows font # (EGA) */
#define		DEFLT_VGA_FONT	32		/* Metawindows font # (VGA) */
#define		DEFLT_EGA_LXFONT	3	/* font # for LXCATT */
#define		DEFLT_VGA_LXFONT	4	/* font # for LXCATT */
#define		MAX_LXFONT	6
#define 	MAX_WIN_SAV	20		/* max number of text windows to save */
#define		BLANK		0x20
#define		ON		1
#define		OFF		0
#define		NO_WAIT		0
#define		WAIT		1
#define		FLUSH 		1		/* flush TRUE */
#define		NO_FLUSH 	0		/* flush FALSE */
#define		MAX_VECTORS	100		/* max number chained vectors (even) */
#define		OFFSET_LOWER	('a' - 'A')	/* offset between upper and lower case */
#define		INTINI		1		/* initialization interrupt */
#define		INTTRM		2		/* termination interrupt */
#define		INTKB		3		/* keyboard interrupt */
#define		INTPER		4		/* periodic interrupt */
#define		INTKEY		5		/* key press interrupt */
#define		INTEDT		6		/* edit key interrupt */
#define		INTMID		7		/* middle mouse button interrupt */
#define		INTRGT		8		/* right mouse button interrupt */
#define		INTLM		9		/* left-middle mouse button interrupt */
#define		INTMR		10		/* middle-right mouse button interrupt */
#define		INTEXP		11		/* window expose interrupt */
#ifdef PERTM
#undef PERTM
#endif
#if PC_CONSOLE_ENV
#define		PERTM		0.06666666	/* time (sec) between periodic entries */
#else
#define		PERTM		0.054945	/* time (sec) between periodic ints */
#endif
#ifdef PERRT
#undef PERRT
#endif
#ifdef PC_CONSOLE_ENV
#define		PERRT		15.0		/* periodic entry rate in Hz (REAL) */
#else
#define		PERRT		18.2		/* periodic interrupt rate in Hz */
#endif
#define		PI		3.1415927
#define		TWO_PI		6.2831853
#define		DEGRAD		57.29578	/* number of degrees per radian */
#define		CINVAC		2.99792458E8	/* velocity of light in a vacuum (M/S) */

#ifdef EGA_DISP					/* EGA display processor */
#ifdef NEC_MSYNC2				/* NEC MultiSynch 2 monitor */
#define	ASPECT_RATIO	0.828
#else
#define	ASPECT_RATIO	1.0
#endif
#endif

#ifdef TWOBUTTON				/* 2 button mouse */
#define MOVEBUTTON	1
#endif

#ifdef THREEBUTTON				/* 3 button mouse */
#define MOVEBUTTON	2
#endif

/* Special display adapters not supported by Metawindows */

#define		VIDEO7_1024i	0x300		/* 1024i adapter by Video 7 */

#if !PC_CONSOLE_ENV				/* define this only in the PC/Metawindow environment */
typedef struct
    {
    char	text[MAXROW][MAXCOL];		/* screen text */
    char	color[MAXROW][MAXCOL];		/* screen colors */
    int		nrows;				/* number of rows on TV */
    int		ncols;				/* number of cols on TV */
    int		pixchar_x;			/* pixels per character horz */
    int		pixchar_y;			/* pixels per character vert */
    int		curs_row;			/* text cursor row */
    int		curs_col;			/* text cursor col */
    int		scrl_locol;			/* TVWNDO low column */
    int		scrl_hicol;			/* TVWNDO high column */
    int		kb_color;			/* keyboard color codes */
    int		kb_upcase;			/* keyboard upper case flag */
    char	blinking;			/* blink processing needed flag */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ TVSCREEN;

typedef struct
    {
    unsigned char	initialized;		/* initialized when TRUE */
    int		writemode;			/* pixel write mode */
    char	blinking;			/* blinking when TRUE */
    int		blinkrate;			/* blink rate */
    int		fillmode;			/* circ & rect filled on TRUE */
    char	title[40];			/* title */
    short	text_size;			/* text size */
    short	text_rotation;			/* text rotation */
    short	text_additive;			/* additive text write */
    short	text_reverse;			/* reverse video text */
    short	text_angle;			/* text angle */
    short	curslim_x1;			/* cursor limit x1 */
    short	curslim_y1;			/* cursor limit y1 */
    short	curslim_x2;			/* cursor limit x2 */
    short	curslim_y2;			/* cursor limit y2 */
    int		linepattrn;			/* last dashed line pattern */
    int		linepatsiz;			/* last dashed pattern size */
    unsigned char	curs_type;		/* cursor type */
    unsigned char	curs_blink;		/* cursor blink on TRUE */
    unsigned char	curs_hotx;		/* cursor x hotspot */
    unsigned char	curs_hoty;		/* cursor y hotspot */
    int		linewidth;			/* line width */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ LXSCREEN;
#endif

#ifndef XCHAR_DEFINED
#define	XCHAR_DEFINED

typedef struct					/* TVMX character/color format */
    {
    char	ch;				/* (ASCII) character */
    char	xcolor;				/* color/blink codes */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ XCHAR;
#endif

#ifndef __cplusplus
typedef struct					/* window pointer save structure */
    {
    char	*tvdat;				/* pointer to saved text */
    image far	*metadat;			/* pointer to saved image */
    char	*miscdat;			/* pointer to misc window data */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ WINSAV;
#endif

typedef struct					/* compressed TV image structure */
    {
    char	ckwd[2];			/* checkword ('cm') */
    char	ncols;				/* number of character cols */
    char	nrows;				/* number of character rows */
    short	com_bytes;			/* compressed byte count */
    short	exp_chars;			/* expanded character count */
    char	cdata[2040];			/* compressed image data */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ TVCOMPRESS;

typedef struct					/* LX font data structure */
    {
    int		fntnum;				/* Metawindows font # */
    int		width;				/* character width in pixels */
    int		height;				/* character height in pixels */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ FONT_DATA;

typedef struct					/* clipping region save structure */
    {
    int		x1;
    int		y1;
    int		x2;
    int		y2;
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ CLIPRGN;

typedef struct _device
    {
    char	*devslash;
    int		devnum;
    char	*devdesc;
    int		devvres, devhres;
    int		devcolors;
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ device;


/******************************************************************************/
/*
**	function prototypes
*/
/******************************************************************************/

extern "C" {
#ifndef __cplusplus
void	CIRCLE(short *, short *, short *, short *);
void	circlec(int, int, int, int);

void	CloseWindow(rect *, image far *);
void	DELIMG(short *);
#endif
#ifndef CLIB_DEFINED
#define	dknob	DKNOB
void	DKNOB(short *, short *, short *, short *);
#endif
#ifndef __cplusplus
void	DSPLEX(void);
#endif
void	DSPTV(void);
#ifndef CBSLIB_DEFINED
#define	fntchr	FNTCHR
void	FNTCHR(short *, short *, short *, short *);
#endif
void	fntchrc(int, int, int, int);
//#if PC_CONSOLE_ENV
int	front_end_menu_text(char *text);
//#endif
void	GrQuery(void);
int	GTEVNT(char *, char *, short *);
#ifndef CLIB_DEFINED
#define	hilite	HILITE
void	HILITE(short *, short *, short *);
#endif
void	hilitec(int, int, int);
#ifndef CLIB_DEFINED
#define	imsure	IMSURE
int	IMSURE(short *, short *, short *);
#endif
int	imsurec(int, int, int);
#ifndef CLIB_DEFINED
#define	inbox	INBOX
int	INBOX(short *, short *, short *, short *);
#endif
int	inboxc(int, int, int, int);
#ifndef CLIB_DEFINED
#define	infld	INFLD
int	INFLD(short *, short *, short *);
#endif
int	infldc(int, int, int);
int	INRECT(short *, short *, short *, short *);
int	inrectc(int, int, int, int);
void	INTDAT(char *, char *, short *, short *);
#ifndef CLIB_DEFINED
#define	intype	INTYPE
void	INTYPE(short *, short *, short *);
#endif
int	INWIN(short *);
#ifndef CLIB_DEFINED
#define	lenchs	LENCHS
int	LENCHS(char *, short *);
#define	lxarc	LXARC
void	LXARC(short *, short *, short *, short *, short *, short *);
#endif
void	lxarcc(int, int, int, int, int, int);
#ifndef CLIB_DEFINED
#define	lxbmov	LXBMOV
void	LXBMOV(short *, short *, short *, short *, short *, short *, short *,
	       short *);
#define	lxcatt	LXCATT
void	LXCATT(short *, short *);
#endif
void	lxcattc(int, int);
#ifndef CLIB_DEFINED
#define	lxcir	LXCIR
void	LXCIR(short *, short *, short *, short *);
#endif
void	lxcirc(int, int, int, int);
#ifndef CLIB_DEFINED
#define	lxclim	LXCLIM
void	LXCLIM(short *, short *, short *, short *);
#define	lxclip	LXCLIP
void	LXCLIP(short *, short *, short *, short *);
#endif
void	lxclipc(int, int, int, int);
#ifndef CLIB_DEFINED
#define	lxcurs	LXCURS
void	LXCURS(short *, short *, short *);
#define	lxcvec	LXCVEC
void	LXCVEC(short *, short *, short *, short *);
#endif
void	lxcvecc(int, int, int, int);
void	LX_ELLIPSE(short *, short *, short *, short *, short *);
#ifndef CLIB_DEFINED
#define	lxeras	LXERAS
void	LXERAS(void);
#define	lxfill	LXFILL
void	LXFILL(short *, short *, short *, short *);
#endif
void	lxfillc(int, int, int, int);
#ifndef CLIB_DEFINED
#define	lxflsh	LXFLSH
void	LXFLSH(void);
#define	lxmode	LXMODE
void	LXMODE(short *);
#endif
void	lxmodec(int);
#ifndef CLIB_DEFINED
#define	lxpars	LXPARS
void	LXPARS(short *, short *, short *, short *, short *, short *, short *,
	       short *, short *);
#define	lxpatt	LXPATT
void	LXPATT(short *, short *);
#endif
void	lxpattc(int, int);
#ifndef CLIB_DEFINED
#define	lxpnt	LXPNT
void	LXPNT(short *, short *, short *);
#endif
void	lxpntc(int, int, int);
#ifndef CLIB_DEFINED
#define	lxrcmd	LXRCMD
void	LXRCMD(short *);
#endif
void	lxrcmdc(int);
#ifndef CLIB_DEFINED
#define	lxrect	LXRECT
void	LXRECT(short *, short *, short *, short *, short *);
#endif
void	lxrectc(int, int, int, int, int);
#ifndef __cplusplus
void	LX_RND_RECT(short *, short *, short *, short *, short *);
#endif
#ifndef CLIB_DEFINED
#define	lxrst	LXRST
void	LXRST(void);
#define	lxtext	LXTEXT
void	LXTEXT(short *, short *, char *, short *, short *);
#endif
void	lxtextc(int, int, char *, int, int);
#ifndef CLIB_DEFINED
#define	lxvec	LXVEC
void	LXVEC(short *, short *, short *, short *, short *);
#endif
void	lxvecc(int, int, int, int, int);
#ifndef CLIB_DEFINED
#define	lxvwid	LXVWID
void	LXVWID(short *);
#endif
void	lxvwidc(int);
#ifndef CBSLIB_DEFINED
#define	menu	MENU
void	MENU(short *, short *, short *, short *, short *, char *[], char *,
	     short *, short *, short *);
#endif
void	menuc(int, int, int, int, int, char *[], char *, short *, int, short *);
#ifndef CLIB_DEFINED
#define	movex	MOVEX
void	MOVEX(char *, short *, char *, short *, short *, char *);
#endif
void	NOECHO(short *);
void	noechoc(int);
#ifndef __cplusplus
image far *OpenWindow(rect *, short *);
#endif
#ifndef CLIB_DEFINED
#define	rdcurs	RDCURS
void	RDCURS(short *, short *);
#endif
int	RESIMG(short *);
int	RESTXT(void);
int	SAVIMG(short *);
int	SAVTXT(void);
void	SETPAL(short *, short *, short *);
void	SETPAT(short *, short *);
void	setpatc(int, short *);
void	STFILL(short *);
void	stfillc(int);
#ifndef CLIB_DEFINED
#define	term	TERM
void	TERM(void);
#define	tvbeep	TVBEEP
void	TVBEEP(void);
#endif
void	TVBKGD(short *);
void	tvbkgdc(int);
#ifndef CLIB_DEFINED
#define	tvblnk	TVBLNK
void	TVBLNK(short *, short *, short *);
#endif
void	tvblnkc(int, int, int);
#ifndef CLIB_DEFINED
#define	tvbox	TVBOX
void	TVBOX(short *, short *, short *, short *, short *, short *);
#endif
void	tvboxc(int, int, int, int, int, int);
#ifndef CLIB_DEFINED
#define	tvcase	TVCASE
void	TVCASE(short *);
#endif
void	tvcasec(int);
#ifndef CLIB_DEFINED
#define	tvceol	TVCEOL
void	TVCEOL(short *, short *);
#endif
void	tvceolc(int, int);
#ifndef CLIB_DEFINED
#define	tvceop	TVCEOP
void	TVCEOP(short *, short *);
#endif
void	tvceopc(int, int);
void	TVCHAR(short *, short *, char *, short *);
#ifndef CLIB_DEFINED
#define	tvcir	TVCIR
void	TVCIR(short *, short *, short *, short *);
void	tvcirc(int, int, int, int);
#endif
void	tv_clear_rectangle(int, int, int, int);
#ifndef CLIB_DEFINED
#define	tvclr	TVCLR
void	TVCLR(void);
#endif
int	TVCOL(short *);
#ifndef CLIB_DEFINED
#define	tvcolr	TVCOLR
void	TVCOLR(short *, short *, short *, short *);
#endif
void	tvcolrc(int, int, int, int);
#ifndef CLIB_DEFINED
#define	tvfill	TVFILL
void	TVFILL(short *, short *, char *, short *, short *);
#endif
void	tvfillc(int, int, char, int, int);
#ifndef CLIB_DEFINED
#define	tvflsh	TVFLSH
void	TVFLSH(void);
#endif
void	TVFONT(short *, char *, short *);
#ifndef CBSLIB_DEFINED
#define	tvhlin	TVHLIN
void	TVHLIN(short *, short *, short *, short *, short *);
#endif
void	tvhlinc(int, int, int, int, int);
void	TVINFO(short *, short *, short *, short *, short *, short *, short *,
	       short *);
void	TVINIT(void);
#ifndef CLIB_DEFINED
#define	tvkbat	TVKBAT
void	TVKBAT(short *);
#define	tvm	TVM
void	TVM(short *, short *, char *, short *, short *);
#endif
void	tvmc(int, int, char *, int, int);
void	TVMB(short *, short *, char *, short *, short *, short *);
void	tvmbc(int, int, char *, int, int, int);
#ifndef CLIB_DEFINED
#define	tvmx	TVMX
void	TVMX(short *, short *, XCHAR *, short *);
#endif
void	tvmxc(int, int, XCHAR *, int);
void	tv_make_text_rectangle(int, int, int, int, int);
#ifndef CLIB_DEFINED
#define	tvrfmt	TVRFMT
void	TVRFMT(short *, short *);
#endif
int	TVROW(short *);
#ifndef CLIB_DEFINED
#define	tvrst	TVRST
void	TVRST(void);
#define	tvscrl	TVSCRL
void	TVSCRL(short *, short *, short *);
#define	tvscrs	TVSCRS
void	TVSCRS(short *, short *);
#endif
void	tvscrsc(int, int);
#ifndef CLIB_DEFINED
#define	tvsfmt	TVSFMT
void	TVSFMT(short *, short *);
#endif
void	TVSTYL(short *);
void	tvstylc(int);
#ifndef CBSLIB_DEFINED
#define	tvvlin	TVVLIN
void	TVVLIN(short *, short *, short *, short *, short *);
#endif
void	tvvlinc(int, int, int, int, int);
#ifndef CLIB_DEFINED
#define	tvwndo	TVWNDO
void	TVWNDO(short *, short *);
#define	waitkb	WAITKB
void	WAITKB(short *, short *, short *, short *);
#define	wdelet	WDELET
int	WDELET(short *, short *, short *);
#endif
void	WINARC(short *, short *, short *, short *, short *, short *, short *);
void	winarcc(short *, int, int, int, int, int, int);
void	WINBLK(short *, char **, short *, short *, short *, short *, short *);
void	winblkc(int, char **, int, int, int, int, short *);
int	WINBOX(short *, short *, short *, short *, short *);
int	winboxc(short *, int, int, int, int);
void	WINCIR(short *, short *, short *, short *, short *);
void	wincirc(short *, int, int, int, int);
void	WINCLM(short *, short *);
void	WINCLP(short *, short *);
void	WINCVC(short *, short *, short *, short *, short *);
void	wincvcc(short *, int, int, int, int);
int	WINFLD(short *, short *, short *, short *);
int	winfldc(short *, int, int, int);
int	WINGAP(short *, short *, short *, short *);
void	WINGET(short *, short *, short *, short *, short *);
int	WINHOL(short *, short *, short *);
#ifndef __cplusplus
int	WINIMG(short *, short *, image far *(*));
#endif
void	WINLIM(short *, short *, short *, short *, short *);
void	WINLMT(short *);
void	WINMOV(short *, short *, short *, short *, short *);
int	WINOCC(short *);
void	WINPLY(short *, short *, short *, short *, short *);
void	winplyc(short *, int, int, int, int);
void	WINPNT(short *, short *, short *, short *);
void	winpntc(short *, int, int, int);
void	WINRC(short *, short *, short *);
int	WINRCT(short *, short *, short *, short *, short *);
int	winrctc(short *, int, int, int, int);
void	WINREC(short *, short *, short *, short *, short *, short *);
void	winrecc(short *, int, int, int, int, int);
void	WINSCL(short *, short *);
void	WINSIZ(short *, short *, short *, short *, short *);
void	WINSTK(short *, short *);
int	WINTERSECT(short *, short *);
char	*WINTTL(short *, short *, short *);
void	WINTVM(short *, short *, short *, char *, short *, short *);
void	wintvmc(short *, int, int, char *, int, int);
void	WINTXT(short *, short *, short *, char *, short *, short *);
void	wintxtc(short *, int, int, char *, int, int);
void	WINVEC(short *, short *, short *, short *, short *, short *);
void	winvecc(short *, int, int, int, int, int);
void	WINXY(short *, short *, short *, short *);
#ifndef CLIB_DEFINED
#define	wmake	WMAKE
int	WMAKE(short *, short *, short *, short *, char *, short *, short *,
	      char *, short *);
#endif
int	wmakec(int, int, int, int, char, int, int, char *, short *);
#ifndef CLIB_DEFINED
#define	wmenu	WMENU
void	WMENU(short *, short *, short *, short *, char *[], char *, short *,
	      short *);
#endif
void	wmenuc(int, int, int, int, char *[], char *, short *, int);
void	WNCURS(short *, short *, short *, short *);
void	WNERAS(short *);
void	WNPSCL(short *, short *, short *, short *, short *, short *);
void	WNSCRS(short *, short *, short *);
void	wnscrsc(short *, int, int);
void	WRAP(short *);
}

#endif