1 #ifndef lint
2 static char sccsid[] = "@(#)frame.c	1.1 (CWI) 85/07/19";
3 #endif lint
4 #include <stdio.h>
5 #include "grap.h"
6 #include "y.tab.h"
7 
8 double	frame_ht;	/* default frame height */
9 double	frame_wid;	/* and width */
10 
11 int	nsides	= 0;		/* how many sides given on this frame */
12 char	*sides[] = {
13 		"\tline from Frame.nw to Frame.ne",
14 		"\tline from Frame.sw to Frame.se",
15 		"\tline from Frame.sw to Frame.nw",
16 		"\tline from Frame.se to Frame.ne"
17 };
18 char	*newsides[4] = { 0, 0, 0, 0 };	/* filled in later */
19 
frame()20 frame()		/* pump out frame definition, reset for next */
21 {
22 	int i;
23 
24 	fprintf(tfd, "\tframeht = %g\n", frame_ht);
25 	fprintf(tfd, "\tframewid = %g\n", frame_wid);
26 	fprintf(tfd, "Frame:\tbox ht frameht wid framewid with .sw at 0,0 ");
27 	if (nsides == 0)
28 		fprintf(tfd, "\n");
29 	else {
30 		fprintf(tfd, "invis\n");
31 		for (i = 0; i < 4; i++) {
32 			if (newsides[i]) {
33 				fprintf(tfd, "%s\n", newsides[i]);
34 				free(newsides[i]);
35 				newsides[i] = 0;
36 			} else
37 				fprintf(tfd, "%s\n", sides[i]);
38 		}
39 		nsides = 0;
40 	}
41 }
42 
frameht(f)43 frameht(f)	/* set height of frame */
44 	double f;
45 {
46 	frame_ht = f;
47 }
48 
framewid(f)49 framewid(f)	/* set width of frame */
50 	double f;
51 {
52 	frame_wid = f;
53 }
54 
frameside(type,desc)55 frameside(type, desc)	/* create and remember sides */
56 	int type;
57 	Attr *desc;
58 {
59 	int n;
60 	char buf[100];
61 
62 	nsides++;
63 	switch (type) {
64 	case 0:		/* no side specified; kludge up all */
65 		frameside(TOP, desc);
66 		frameside(BOT, desc);
67 		frameside(LEFT, desc);
68 		frameside(RIGHT, desc);
69 		return;
70 	case TOP:	n = 0; break;
71 	case BOT:	n = 1; break;
72 	case LEFT:	n = 2; break;
73 	case RIGHT:	n = 3; break;
74 	}
75 	sprintf(buf, "%s %s", sides[n], desc_str(desc));
76 	newsides[n] = tostring(buf);
77 }
78