remove empty dir
[ghc-hetmet.git] / ghc / utils / hp2ps / Key.c
1 #include "Main.h"
2 #include <stdio.h>
3 #include <math.h>
4 #include "Defines.h"
5 #include "Dimensions.h"
6 #include "HpFile.h"
7 #include "Shade.h"
8
9 /* own stuff */
10 #include "Key.h"
11
12 static void KeyEntry PROTO((floatish, char *, floatish));
13
14 void Key()
15 {
16     intish i;
17     floatish c;
18     floatish dc;
19
20     for (i = 0; i < nidents; i++)    /* count identifiers */ 
21         ;
22
23     c  = graphy0;
24     dc = graphheight / (floatish) (i + 1);
25
26     for (i = 0; i < nidents; i++) {
27         c += dc;
28         KeyEntry(c, identtable[i]->name, ShadeOf(identtable[i]->name));
29     }
30 }
31
32
33
34 static void
35 KeyEntry(centreline, name, colour)
36   floatish centreline; char* name; floatish colour;
37 {
38     floatish namebase;
39     floatish keyboxbase;
40     floatish kstart;
41
42     namebase = centreline - (floatish) (NORMAL_FONT / 2);
43     keyboxbase = centreline - ((floatish) KEY_BOX_WIDTH / 2.0);
44
45     kstart = graphx0 + graphwidth;
46
47     fprintf(psfp, "%f %f moveto\n", kstart + borderspace, keyboxbase);
48     fprintf(psfp, "0 %d rlineto\n", KEY_BOX_WIDTH);
49     fprintf(psfp, "%d 0 rlineto\n", KEY_BOX_WIDTH);
50     fprintf(psfp, "0 %d rlineto\n", -KEY_BOX_WIDTH);
51     fprintf(psfp, "closepath\n");
52
53     fprintf(psfp, "gsave\n"); 
54     SetPSColour(colour);
55     fprintf(psfp, "fill\n");
56     fprintf(psfp, "grestore\n");
57     fprintf(psfp, "stroke\n");
58
59     fprintf(psfp, "HE%d setfont\n", NORMAL_FONT);
60     fprintf(psfp, "%f %f moveto\n", kstart + (floatish) KEY_BOX_WIDTH + 2 * borderspace, namebase);
61
62     fprintf(psfp, "(%s) show\n", name); 
63 }