/*
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred."
 *
 */
/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: frame.c 1.2 89/10/10 $@(#)grap:frame.c	1.3"

#include <stdio.h>
#include "grap.h"
#include "y.tab.h"

double	frame_ht;	/* default frame height */
double	frame_wid;	/* and width */

int	nsides	= 0;		/* how many sides given on this frame */
char	*sides[] = {
		"\tline from Frame.nw to Frame.ne",
		"\tline from Frame.sw to Frame.se",
		"\tline from Frame.sw to Frame.nw",
		"\tline from Frame.se to Frame.ne"
};
char	*newsides[4] = { 0, 0, 0, 0 };	/* filled in later */

frame()		/* pump out frame definition, reset for next */
{
	int i;

	fprintf(tfd, "\tframeht = %g\n", frame_ht);
	fprintf(tfd, "\tframewid = %g\n", frame_wid);
	fprintf(tfd, "Frame:\tbox ht frameht wid framewid with .sw at 0,0 ");
	if (nsides == 0)
		fprintf(tfd, "\n");
	else {
		fprintf(tfd, "invis\n");
		for (i = 0; i < 4; i++) {
			if (newsides[i]) {
				fprintf(tfd, "%s\n", newsides[i]);
				free(newsides[i]);
				newsides[i] = 0;
			} else
				fprintf(tfd, "%s\n", sides[i]);
		}
		nsides = 0;
	}
}

frameht(f)	/* set height of frame */
	double f;
{
	frame_ht = f;
}

framewid(f)	/* set width of frame */
	double f;
{
	frame_wid = f;
}

frameside(type, desc)	/* create and remember sides */
	int type;
	Attr *desc;
{
	int n;
	char buf[100];

	nsides++;
	switch (type) {
	case 0:		/* no side specified; kludge up all */
		frameside(TOP, desc);
		frameside(BOT, desc);
		frameside(LEFT, desc);
		frameside(RIGHT, desc);
		return;
	case TOP:	n = 0; break;
	case BOT:	n = 1; break;
	case LEFT:	n = 2; break;
	case RIGHT:	n = 3; break;
	}
	sprintf(buf, "%s %s", sides[n], desc_str(desc));
	newsides[n] = tostring(buf);
}
