home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / SRC / SUNPAS / PTEXT.C < prev    next >
C/C++ Source or Header  |  1994-04-27  |  2KB  |  222 lines

  1. #include <stdio.h>
  2. #include "vogle.h"
  3.  
  4. /*
  5.  * This should match the Pascal type 'varying [n] of char'
  6.  */
  7.  
  8. typedef struct {
  9.     int    n;
  10.     char    s[1];    /* SO compiler doesn't bitch about zero length */
  11. } Vstring;
  12.  
  13. #define COPYANDTERMINATE(buf, s, l)    strncpy(buf, s, l); buf[l] = '\0';
  14.  
  15. /*
  16.  * Font
  17.  */
  18. void
  19. Font(s)
  20.     Vstring    s;
  21. {
  22.     char    *p = (char *)s.s;
  23.     char    buf[BUFSIZ];
  24.  
  25.     COPYANDTERMINATE(buf, p, s.n);
  26.     font(buf);
  27. }
  28.  
  29. /*
  30.  * TextSize
  31.  */
  32. void
  33. TextSize(width, height)
  34.     float    width, height;
  35. {
  36.     textsize(width, height);
  37. }
  38.  
  39. /*
  40.  * BoxText
  41.  */
  42. BoxText(x, y, l, h, s)
  43.     float    x, y, l, h;
  44.     Vstring    s;
  45. {
  46.     char    *p = (char *)s.s;
  47.     char    buf[BUFSIZ];
  48.  
  49.     COPYANDTERMINATE(buf, p, s.n);
  50.     boxtext(x, y, l, h, buf);
  51. }
  52.  
  53. /*
  54.  * BoxFit
  55.  */
  56. BoxFit(l, h, nchars)
  57.     float    l, h;
  58.     int    nchars;
  59. {
  60.     boxfit(l, h, nchars);
  61. }
  62.  
  63. /*
  64.  * TextAng
  65.  */
  66. void
  67. TextAng(ang)
  68.     float    ang;
  69. {
  70.     textang(ang);
  71. }
  72.  
  73. /*
  74.  * DrawChar
  75.  */
  76. DrawChar(s)
  77.     char    s;
  78. {
  79.     drawchar(s);
  80. }
  81.  
  82. /*
  83.  * DrawStr
  84.  */
  85. DrawStr(s)
  86.     Vstring    s;
  87. {
  88.     char    *p = (char *)s.s;
  89.     char    buf[BUFSIZ];
  90.  
  91.     COPYANDTERMINATE(buf, p, s.n);
  92.     drawstr(buf);
  93. }
  94.  
  95. /*
  96.  * GetFontSize
  97.  */
  98. void
  99. GetFontSize(cw, ch)
  100.     double     *cw, *ch;
  101. {
  102.     getfontsize(cw, ch);
  103. }
  104.  
  105. /*
  106.  * GetCharSize
  107.  */
  108. void
  109. GetCharSize(c, cw, ch)
  110.     char    c;
  111.     double     *cw, *ch;
  112. {
  113.     getcharsize(c, cw, ch);
  114. }
  115.  
  116. /*
  117.  * FixedWidth
  118.  */
  119. void
  120. FixedWidth(i)
  121.     int    i;
  122. {
  123.     fixedwidth(i);
  124. }
  125.  
  126. /*
  127.  * CenterText
  128.  */
  129. void
  130. CenterText(i)
  131.     int    i;
  132. {
  133.     centertext(i);
  134. }
  135.  
  136. /*
  137.  * TextJustify
  138.  */
  139. void
  140. TextJustify(i)
  141.     int    i;
  142. {
  143.     textjustify(i);
  144. }
  145.  
  146. /*
  147.  * LeftJustify
  148.  */
  149. void
  150. LeftJustify()
  151. {
  152.     leftjustify();
  153. }
  154.  
  155. /*
  156.  * RightJustify
  157.  */
  158. void
  159. RightJustify()
  160. {
  161.     rightjustify();
  162. }
  163.  
  164. /*
  165.  * TopJustify
  166.  */
  167. void
  168. TopJustify()
  169. {
  170.     topjustify();
  171. }
  172.  
  173. /*
  174.  * BottomJustify
  175.  */
  176. void
  177. BottomJustify()
  178. {
  179.     bottomjustify();
  180. }
  181.  
  182. /*
  183.  * XcenterText
  184.  */
  185. void
  186. XcenterText()
  187. {
  188.     xcentertext();
  189. }
  190.  
  191. /*
  192.  * YcenterText
  193.  */
  194. void
  195. YcenterText()
  196. {
  197.     ycentertext();
  198. }
  199.  
  200. /*
  201.  * NumChars
  202.  */
  203. int
  204. NumChars()
  205. {
  206.     return(numchars());
  207. }
  208.  
  209. /*
  210.  * StrLength
  211.  */
  212. float
  213. StrLength(s)
  214.     Vstring    s;
  215. {
  216.     char    *p = (char *)s.s;
  217.     char    buf[BUFSIZ];
  218.  
  219.     COPYANDTERMINATE(buf, p, s.n);
  220.     return(strlength(buf));
  221. }
  222.