home *** CD-ROM | disk | FTP | other *** search
/ EDUCORP 8 / Educorp2Compilation.sit / educorp2 / Demos / Aztec Source Level Debugger / demo / labelaxes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-14  |  1.1 KB  |  47 lines

  1. #include "barchart.h"
  2.  
  3. labelhorizontal(xyb, labels, howmany)
  4. struct XYBase *xyb;
  5. char *labels[];
  6. int howmany;
  7. {
  8.     short i, labelwidth, segmentwidth, currentx;
  9.     short actualy, actualx;
  10.     FontInfo fi;
  11.  
  12.     GetFontInfo(&fi);
  13.     segmentwidth = xyb->xlength/(howmany-1);
  14.     currentx = xyb->xaxis;
  15.     actualy = xyb->yaxis + 1 + fi.ascent + fi.descent + fi.descent;
  16.     for (i=0;i<howmany;i++) {
  17.         labelwidth = StringWidth(labels[i]);
  18.         labelwidth = labelwidth / 2;
  19.         actualx = currentx + segmentwidth * i - labelwidth;
  20.         MoveTo(actualx, actualy);
  21.         DrawString(labels[i]);
  22.     }
  23. }
  24.  
  25. labelvertical(xyb, labels, howmany)
  26. struct XYBase *xyb;
  27. char *labels[];
  28. int howmany;
  29. {
  30.     short i, labelwidth, segmentheight, currentx, currenty;
  31.     short actualy, actualx;
  32.     FontInfo fi;
  33.  
  34.     GetFontInfo(&fi);
  35.     segmentheight = xyb->ylength/(howmany-1);
  36.     currentx = xyb->xaxis - 2;
  37.     currenty = xyb->yaxis + (fi.ascent + fi.descent + fi.descent)/2;
  38.     for (i=0;i<howmany;i++) {
  39.         labelwidth = StringWidth(labels[i]);
  40.         actualx = currentx - labelwidth;
  41.         actualy = currenty - segmentheight * i;
  42.         MoveTo(actualx, actualy);
  43.         DrawString(labels[i]);
  44.     }
  45. }
  46.  
  47.