home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / dv_x / dvix.zip / SPECIAL.C < prev    next >
C/C++ Source or Header  |  1992-10-02  |  3KB  |  114 lines

  1. /*
  2.  *    This program is Copyright (C) 1987 by the Board of Trustees of the
  3.  *    University of Illinois, and by the author Dirk Grunwald.
  4.  *
  5.  *    This program may be freely copied, as long as this copyright
  6.  *    message remaines affixed. It may not be sold, although it may
  7.  *    be distributed with other software which is sold. If the
  8.  *    software is distributed, the source code must be made available.
  9.  *
  10.  *    No warrenty, expressed or implied, is given with this software.
  11.  *    It is presented in the hope that it will prove useful.
  12.  *
  13.  *    Hacked in ignorance and despiration by jonah@db.toronto.edu
  14.  */
  15. #include <sys/types.h>
  16. #include <X11/Xlib.h>
  17. #include <X11/Xutil.h>
  18. #include <X11/cursorfont.h>
  19. #include <stdio.h>
  20. #include <ctype.h>
  21. #include "pxl.h"
  22.  
  23. /*
  24.  *      The code to handle the \specials generated by tpic was modified
  25.  *      by Dirk Grunwald using the code Tim Morgan at Univ. of Calif, Irvine
  26.  *      wrote for TeXsun.
  27.  */
  28.  
  29.     /* globals from xbmdvi.c */
  30.  
  31. extern char *prog;
  32. extern Display *dsp;
  33. extern struct bitmap *page_bm;
  34. extern GC gcc;
  35. extern double specialConv;
  36.  
  37. struct frame {
  38.         long pxl_h, dvi_h, pxl_v, dvi_v, w, x, y, z;
  39. };
  40.  
  41. extern struct frame *stack;
  42. extern int stackp;
  43.  
  44. #define PXL_H   stack[stackp].pxl_h
  45. #define PXL_V   stack[stackp].pxl_v
  46.  
  47.  
  48. #define COMLEN  4
  49.  
  50. void applicationDoSpecial(cp)
  51. char *cp;
  52. {
  53.     char command[COMLEN], *orig_cp;
  54.     register int len;
  55.  
  56.     orig_cp = cp;
  57.     while (isspace(*cp)) ++cp;
  58.     len = 0;
  59.     while (!isspace(*cp) && *cp && len < COMLEN-1) command[len++] = *cp++;
  60.     command[len] = '\0';
  61.     if (strcmp(command, "pn") == 0) set_pen_size(cp);
  62.     else if (strcmp(command, "fp") == 0) flush_path(0);
  63.     else if (strcmp(command, "ip") == 0) flush_path(1);
  64.     else if (strcmp(command, "da") == 0) flush_dashed(cp, 0);
  65.     else if (strcmp(command, "dt") == 0) flush_dashed(cp, 1);
  66.     else if (strcmp(command, "pa") == 0) add_path(cp);
  67.     else if (strcmp(command, "ar") == 0) arc(cp, 0);
  68.     else if (strcmp(command, "ia") == 0) arc(cp, 1);
  69.     else if (strcmp(command, "sp") == 0) flush_spline(0);
  70.     else if (strcmp(command, "sh") == 0) shade_last(cp);
  71.     else if (strcmp(command, "wh") == 0) whiten_last();
  72.     else if (strcmp(command, "bk") == 0) blacken_last();
  73.     else fprintf(stderr, "[%s] special \"%s\" not implemented\n",
  74.         prog, orig_cp);
  75. }
  76.  
  77. /* Things we need from dvi_draw, unfortunately */
  78. extern int pen_size, blacken, whiten, shade;
  79.  
  80. #define toint(x)        ((int) ((x) + 0.5))
  81. #define xconv(x) (toint(specialConv*(x)) + PXL_H)
  82. #define yconv(y) (toint(specialConv*(y)) + PXL_V)
  83.  
  84. /*
  85.  * Draw a line from (fx,fy) to (tx,ty).
  86.  * Right now, we ignore pen_size.
  87.  */
  88. void line_btw(fx, fy, tx, ty)
  89. int fx, fy, tx, ty;
  90. {
  91.     bitLine(page_bm, xconv(fx), yconv(fy), xconv(tx), yconv(ty));
  92. }
  93.  
  94. /*
  95.  * Draw a dot at (x,y)
  96.  */
  97. void dot_at(x, y)
  98. {
  99.     line_btw(x,y,x+1,y);
  100. }
  101.  
  102. /*
  103.  * Apply the requested attributes to the last path (box) drawn.
  104.  * Attributes are reset.
  105.  */
  106. void do_attribute_path(last_min_x, last_max_x, last_min_y, last_max_y)
  107. int last_min_x, last_max_x, last_min_y, last_max_y;
  108. {
  109. #ifdef lint
  110.     (void) (last_min_x + last_max_x + last_min_y + last_max_y);
  111. #endif
  112. }
  113.  
  114.