home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / vopl / glvopl.lha / glvopl / gpp / legend.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-07  |  924 b   |  65 lines

  1.  
  2. #include "gpp.h"
  3. #include "vopl.h"
  4.  
  5. extern    float    hstrlength();
  6.  
  7. /*
  8.  * drawlegend
  9.  *
  10.  *    Draw a legend for gpp
  11.  */
  12. void
  13. drawlegend()
  14. {
  15.     float    ydiff, x, y;
  16.     char    buf[80];
  17.     int    i = 0;
  18.     graph    *p;
  19.  
  20.     ydiff = 2 * TEXTHEIGHT;
  21.     y = YMAX;
  22.     x =  XMAX + 3 * TEXTWIDTH;
  23.  
  24.     ortho2(-1.0, 1.75, -1.0, 1.25);
  25.     hcentertext(1);
  26.  
  27.     htextsize(TEXTWIDTH * 1.2, TEXTHEIGHT * 1.2);
  28.  
  29.     /*
  30.       * First draw all the marker symbols
  31.      */
  32.     for (i = 0; i < ngraphs; i++) {
  33.         color((i % 7) + 1);
  34.         move2(x, y);
  35.         hdrawchar('a' + i);
  36.         y -= ydiff;
  37.     }
  38.     x += TEXTWIDTH * 1.5;
  39.  
  40.     /*
  41.      * Now fill in the legends
  42.      */
  43.  
  44.     if (fontname[0])
  45.         hfont(fontname);
  46.     else
  47.         hfont("futura.l");
  48.  
  49.     htextsize(TEXTWIDTH * 1.2, TEXTHEIGHT * 1.2);
  50.  
  51.     y = YMAX;
  52.     i = 0;
  53.  
  54.     for (p = gp; p != (graph *)NULL; p = p->nxt) {
  55.         color((i++ % 7) + 1);
  56.         if (strlen(p->legend) != 0) {
  57.             move2(x + hstrlength(p->legend) / 2, y);
  58.             hcharstr(p->legend);
  59.             y -= ydiff;
  60.         }
  61.     }
  62.  
  63.     hcentertext(0);
  64. }
  65.