112 return &((
Line *) elt)->links;
142 void x_set_gc (Display *display, GC gc,
long function,
unsigned long color,
long linewidth, Font font)
145 unsigned long valuemask;
148 gcvalues.function =
function;
149 gcvalues.foreground = color;
150 valuemask = GCFunction | GCForeground;
154 gcvalues.line_width = linewidth;
155 valuemask |= GCLineWidth;
160 gcvalues.font = font;
164 XChangeGC (display, gc, valuemask, &gcvalues);
169 #define AllocDisplayElt() malloc (sizeof (DisplayElt))
170 #define FreeDisplayElt(E) free (E)
186 void x_record_line (
ListHeader *displaylist, Action action,
long x0,
long y0,
long x1,
long y1,
unsigned long function,
unsigned long color,
unsigned long linewidth)
221 void x_record_arc (
ListHeader *displaylist, Action action,
long x,
long y,
long width,
long height,
long startangle,
long arcangle,
unsigned long function,
unsigned long color,
unsigned long linewidth)
255 void x_record_rectangle (
ListHeader *displaylist, Action action,
long x,
long y,
long width,
long height,
unsigned long function,
unsigned long color,
unsigned long linewidth)
285 void x_record_polygon (
ListHeader *displaylist, Action action, XPoint *points,
long npoints,
unsigned long function,
unsigned long color,
unsigned long linewidth)
294 elt->
points = p = (XPoint *) malloc (npoints*2*
sizeof(
short));
295 for (; npoints > 0; npoints--, p++, points++)
318 void x_record_string (
ListHeader *displaylist, Action action,
long x,
long y,
char *str, Font font,
unsigned long function,
unsigned long color)
326 elt->
str = (
char *) malloc (strlen (str)+1);
327 strcpy (elt->
str, str);
328 *(elt->
str+strlen(str)) =
'\0';
360 line->
x0, line->
y0, line->
x1, line->
y1);
368 if (arc->
action == DRAW_ARC)
385 if (rectangle->
action == DRAW_RECTANGLE)
387 rectangle->
x, rectangle->
y,
391 rectangle->
x, rectangle->
y,
396 case DRAW_IMAGE_STRING:
400 if (s->
action == DRAW_STRING)
415 if (polygon->
action == FILL_POLYGON)
418 Complex, CoordModeOrigin);
449 XWindowAttributes attr;
454 XSetGraphicsExposures (display, pixmapgc, False);
457 XGetWindowAttributes (display, window, &attr);
461 XClearArea (display, pixmap, 0, 0,
462 attr.width, attr.height, False);
465 x_set_gc (display, pixmapgc, GXcopy, attr.backing_pixel,
468 XFillRectangle (display, pixmap, pixmapgc,
469 0, 0, attr.width, attr.height);
478 if (window != pixmap)
479 XCopyArea (display, pixmap, window, pixmapgc, 0, 0,
480 attr.width, attr.height, 0, 0);
521 case DRAW_IMAGE_STRING:
557 "/mt {moveto} def /lt {lineto} def /slw {setlinewidth} def\n",
558 "/np {newpath} def /st {stroke} def /fi {fill} def /cp {closepath} def\n",
559 "1 setlinecap 1 setlinejoin\n",
560 "/line {/lw exch def /b exch def /g exch def /r exch def\n",
561 " /y1 exch def /x1 exch def \n",
562 " /y0 exch def /x0 exch def\n",
563 " r 65535 div g 65535 div b 65535 div setrgbcolor\n",
564 " np lw slw x0 y0 mt x1 y1 lt st} def\n",
565 "/rect {/sf exch def /lw exch def\n",
566 " /b exch def /g exch def /r exch def\n",
567 " /h exch def /w exch def \n",
568 " /y exch def /x exch def\n",
569 " r 65535 div g 65535 div b 65535 div setrgbcolor\n",
570 " np lw slw x y mt x w add y lt x w add y h sub lt\n",
571 " x y h sub lt cp sf {st} {fi} ifelse} def\n",
572 "/earcdict 100 dict def\n",
573 "earcdict /mtrx matrix put\n",
574 "/earc {earcdict begin\n",
575 " /sf exch def /lw exch def\n",
576 " /b exch def /g exch def /r exch def\n",
577 " r 65535 div g 65535 div b 65535 div setrgbcolor\n",
578 " /ea exch def /sa exch def\n",
579 " /yr exch def /xr exch def /y exch def /x exch def\n",
580 " /savematrix mtrx currentmatrix def\n",
581 " np x y translate xr yr scale 0 0 1 sa ea arc\n",
582 " savematrix setmatrix lw slw sf {st} {fi} ifelse\n",
584 "/Helvetica findfont 18 scalefont setfont\n",
585 "/dstr {/sf exch def\n",
586 " /b exch def /g exch def /r exch def\n",
587 " /str exch def /y exch def /x exch def\n",
588 " r 65535 div g 65535 div b 65535 div setrgbcolor\n",
589 " x y mt str show} def\n",
604 for (i = 0;
prolog[i] != 0; i++)
626 for (m=n, i=1; m>=10; i++)
631 sprintf (
nstr,
"%ld ", n);
647 if (strlen (buf) + strlen(s) <
BUF_SIZE)
662 static void x_get_rgb_values (Display *display, Window window,
unsigned long color, XColor *rgb)
664 XWindowAttributes windowAttributes;
666 XGetWindowAttributes (display, window, &windowAttributes);
668 XQueryColor (display, windowAttributes.colormap, rgb);
711 ret = write (psc->
f, pbuf, strlen (pbuf));
727 if (rectangle->
action == DRAW_RECTANGLE)
739 ret = write (psc->
f, pbuf, strlen (pbuf));
756 if (arc->
action == DRAW_ARC)
768 ret = write (psc->
f, pbuf, strlen (pbuf));
772 case DRAW_IMAGE_STRING:
784 if (s->
action == DRAW_STRING)
790 ret = write (psc->
f, pbuf, strlen (pbuf));
811 for (i=1; i<polygon->
npoints; i++, p++)
821 ret = write (psc->
f, pbuf, strlen (pbuf));
841 XWindowAttributes windowAttributes;
849 if ((psc.
f = open (filename, O_CREAT|O_WRONLY|O_TRUNC,
850 S_IRUSR|S_IWUSR|S_IRWXG)) == -1)
852 Errorline (
"\n*** Error: cannot open file %s.\n", filename);
856 XGetWindowAttributes (display, window, &windowAttributes);
857 psc.
height = windowAttributes.height;
860 ret = write (psc.
f,
"showpage\n", strlen (
"showpage\n"));
#define xDefaultLineWidth
static long x_postscript_elt(DisplayElt *elt, PostScriptClosure *psc)
x_postscript_elt
void x_record_arc(ListHeader *displaylist, Action action, long x, long y, long width, long height, long startangle, long arcangle, unsigned long function, unsigned long color, unsigned long linewidth)
x_record_arc
static void x_get_rgb_values(Display *display, Window window, unsigned long color, XColor *rgb)
x_get_rgb_values
static void x_postscript_prolog(long f)
x_postscript_prolog
DisplayElt * RefDisplayElt
static char * add_number(char *buf, long n)
add_number
static long x_free_elt(DisplayElt *elt, long *closure)
x_free_elt
void x_record_rectangle(ListHeader *displaylist, Action action, long x, long y, long width, long height, unsigned long function, unsigned long color, unsigned long linewidth)
x_record_rectangle
static char nstr[BUF_SIZE]
long x_postscript_window(Display *display, Window window, ListHeader *displaylist, char *filename)
x_postscript_window
struct wl_PostScriptClosure PostScriptClosure
static ListLinks * x_get_links_of_display_list(DisplayElt *elt)
x_get_links_of_display_list
void List_Append(RefListHeader header, Ref atom)
void List_Append
struct wl_Polygon Polygon
void x_record_polygon(ListHeader *displaylist, Action action, XPoint *points, long npoints, unsigned long function, unsigned long color, unsigned long linewidth)
x_record_polygon
void Errorline(char *format,...)
Errorline.
unsigned long * GENERIC
unsigned long *GENERIC
void x_set_gc(Display *display, GC gc, long function, unsigned long color, long linewidth, Font font)
x_set_gc
#define TRUE
Standard boolean.
struct wl_Rectangle Rectangle
#define FALSE
Standard boolean.
void List_SetLinkProc(RefListHeader header, RefListGetLinksProc getLinks)
List_SetLinkProc.
static long x_draw_elt(DisplayElt *elt, GraphicClosure *g)
x_draw_elt
union wl_DisplayElt DisplayElt
struct wl_GraphicClosure GraphicClosure
void x_record_string(ListHeader *displaylist, Action action, long x, long y, char *str, Font font, unsigned long function, unsigned long color)
x_record_string
void x_free_display_list(ListHeader *displaylist)
x_free_display_list
long List_Enum(RefListHeader header, RefListEnumProc proc, Ref closure)
List_Enum.
#define AllocDisplayElt()
ListHeader * x_display_list()
x_display_list
static char * add_string(char *buf, char *s)
add_string
void x_record_line(ListHeader *displaylist, Action action, long x0, long y0, long x1, long y1, unsigned long function, unsigned long color, unsigned long linewidth)
x_record_line
void x_refresh_window(Display *display, Window window, Pixmap pixmap, GC pixmapgc, ListHeader *displaylist)
x_refresh_window
#define FreeDisplayElt(E)