Wild Life: xdisplaylist.c File Reference

Wild Life 2.30

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros
Data Structures | Macros | Typedefs | Functions | Variables
xdisplaylist.c File Reference

x windows display functions More...

Go to the source code of this file.

## Data Structures
struct | wl_Line
struct | wl_Rectangle
struct | wl_Arc
struct | wl_String
struct | wl_GraphicClosure
struct | wl_PostScriptClosure
struct | wl_Polygon
union | wl_DisplayElt

## Macros
#define | AllocDisplayElt() malloc (sizeof (DisplayElt))
#define | FreeDisplayElt(E) free (E)
#define | BUF_SIZE 512

## Typedefs
typedef struct wl_Line | Line
typedef struct wl_Rectangle | Rectangle
typedef struct wl_Arc | Arc
typedef struct wl_String | String
typedef struct wl_GraphicClosure | GraphicClosure
typedef struct wl_PostScriptClosure | PostScriptClosure
typedef struct wl_Polygon | Polygon
typedef union wl_DisplayElt | DisplayElt
typedef DisplayElt * | RefDisplayElt

## Functions
static ListLinks * | x_get_links_of_display_list (DisplayElt *elt)
| x_get_links_of_display_list More...
ListHeader * | x_display_list ()
| x_display_list More...
void | x_set_gc (Display *display, GC gc, long function, unsigned long color, long linewidth, Font font)
| x_set_gc More...
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 More...
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 More...
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 More...
void | x_record_polygon (ListHeader *displaylist, Action action, XPoint *points, long npoints, unsigned long function, unsigned long color, unsigned long linewidth)
| x_record_polygon More...
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 More...
static long | x_draw_elt (DisplayElt *elt, GraphicClosure *g)
| x_draw_elt More...
void | x_refresh_window (Display *display, Window window, Pixmap pixmap, GC pixmapgc, ListHeader *displaylist)
| x_refresh_window More...
static long | x_free_elt (DisplayElt *elt, long *closure)
| x_free_elt More...
void | x_free_display_list (ListHeader *displaylist)
| x_free_display_list More...
static void | x_postscript_prolog (long f)
| x_postscript_prolog More...
static char * | add_number (char *buf, long n)
| add_number More...
static char * | add_string (char *buf, char *s)
| add_string More...
static void | x_get_rgb_values (Display *display, Window window, unsigned long color, XColor *rgb)
| x_get_rgb_values More...
static long | x_postscript_elt (DisplayElt *elt, PostScriptClosure *psc)
| x_postscript_elt More...
long | x_postscript_window (Display *display, Window window, ListHeader *displaylist, char *filename)
| x_postscript_window More...

## Variables
static char * | prolog []
static char | nstr [BUF_SIZE]

## Detailed Description

x windows display functions

Definition in file xdisplaylist.c.

## Macro Definition Documentation

#define AllocDisplayElt | ( |  | ) | malloc (sizeof (DisplayElt))

Definition at line 169 of file xdisplaylist.c.

#define BUF_SIZE 512

Definition at line 610 of file xdisplaylist.c.

#define FreeDisplayElt | ( |  | E | ) | free (E)

Definition at line 170 of file xdisplaylist.c.

## Typedef Documentation

typedef struct wl_Arc Arc

typedef union wl_DisplayElt DisplayElt

typedef struct wl_GraphicClosure GraphicClosure

typedef struct wl_Line Line

typedef struct wl_Polygon Polygon

typedef struct wl_PostScriptClosure PostScriptClosure

typedef struct wl_Rectangle Rectangle

typedef DisplayElt* RefDisplayElt

Definition at line 99 of file xdisplaylist.c.

typedef struct wl_String String

## Function Documentation

static char * add_number | ( | char * | buf,
|  | long | n
| ) |  |
| static

add_number

Parameters

  buf | - char *buf
  n | - long n

Definition at line 621 of file xdisplaylist.c.

References BUF_SIZE, and nstr.

622 {
623 long m, i;
624 char *s;
625
626 for (m=n, i=1; m>=10; i++)
627 m /= 10;
628
629 if (i < BUF_SIZE && strlen (buf) + i < BUF_SIZE)
630 {
631 sprintf (nstr, "%ld ", n);
632 strcat (buf, nstr);
633 }
634
635 return buf;
636 }
BUF_SIZE
#define BUF_SIZE
Definition: xdisplaylist.c:610
nstr
static char nstr[BUF_SIZE]
Definition: xdisplaylist.c:612

static char * add_string | ( | char * | buf,
|  | char * | s
| ) |  |
| static

add_string

Parameters

  buf | - char *buf
  s | - char *s

Definition at line 645 of file xdisplaylist.c.

References BUF_SIZE.

646 {
647 if (strlen (buf) + strlen(s) < BUF_SIZE)
648 strcat (buf, s);
649
650 return buf;
651 }
BUF_SIZE
#define BUF_SIZE
Definition: xdisplaylist.c:610

ListHeader * x_display_list | ( |  | ) |

x_display_list

Definition at line 120 of file xdisplaylist.c.

References List_SetLinkProc(), and x_get_links_of_display_list().

121 {
122 ListHeader *display_list;
123
124 display_list = (ListHeader *) malloc (sizeof (ListHeader));
125 List_SetLinkProc (display_list, x_get_links_of_display_list);
126 return display_list;
127 }
x_get_links_of_display_list
static ListLinks * x_get_links_of_display_list(DisplayElt *elt)
x_get_links_of_display_list
Definition: xdisplaylist.c:110
List_SetLinkProc
void List_SetLinkProc(RefListHeader header, RefListGetLinksProc getLinks)
List_SetLinkProc.
Definition: list.c:24
wl_ListHeader
Definition: def_struct.h:291

static long x_draw_elt | ( | DisplayElt * | elt,
|  | GraphicClosure * | g
| ) |  |
| static

x_draw_elt

Parameters

  elt | - DisplayElt *elt
  g | - GraphicClosure *g

Definition at line 344 of file xdisplaylist.c.

References wl_Rectangle::action, wl_Arc::action, wl_String::action, wl_Polygon::action, wl_DisplayElt::action, wl_Arc::arcangle, wl_Line::color, wl_Rectangle::color, wl_Arc::color, wl_String::color, wl_Polygon::color, wl_GraphicClosure::display, wl_GraphicClosure::drawable, wl_String::font, wl_Line::function, wl_Rectangle::function, wl_Arc::function, wl_String::function, wl_Polygon::function, wl_GraphicClosure::gc, wl_Rectangle::height, wl_Arc::height, wl_Line::linewidth, wl_Rectangle::linewidth, wl_Arc::linewidth, wl_Polygon::linewidth, wl_Polygon::npoints, wl_Polygon::points, wl_Arc::startangle, wl_String::str, TRUE, wl_Rectangle::width, wl_Arc::width, wl_Rectangle::x, wl_Arc::x, wl_String::x, wl_Line::x0, wl_Line::x1, x_set_gc(), xDefaultFont, xDefaultLineWidth, wl_Rectangle::y, wl_Arc::y, wl_String::y, wl_Line::y0, and wl_Line::y1.

345 {
346 Line *line;
347 Arc *arc;
348 Rectangle *rectangle;
349 String *s;
350 Polygon *polygon;
351
352
353 switch (elt->action)
354 {
355 case DRAW_LINE:
356 line = (Line *) elt;
357 x_set_gc (g->display, g->gc, line->function,
358 line->color, line->linewidth, xDefaultFont);
359 XDrawLine (g->display, g->drawable, g->gc,
360 line->x0, line->y0, line->x1, line->y1);
361 break;
362
363 case DRAW_ARC:
364 case FILL_ARC:
365 arc = (Arc *) elt;
366 x_set_gc (g->display, g->gc, arc->function,
367 arc->color, arc->linewidth, xDefaultFont);
368 if (arc->action == DRAW_ARC)
369 XDrawArc (g->display, g->drawable, g->gc,
370 arc->x, arc->y,
371 arc->width, arc->height,
372 arc->startangle, arc->arcangle);
373 else
374 XFillArc (g->display, g->drawable, g->gc,
375 arc->x, arc->y,
376 arc->width, arc->height,
377 arc->startangle, arc->arcangle);
378 break;
379
380 case DRAW_RECTANGLE:
381 case FILL_RECTANGLE:
382 rectangle = (Rectangle *) elt;
383 x_set_gc (g->display, g->gc, rectangle->function,
384 rectangle->color, rectangle->linewidth, xDefaultFont);
385 if (rectangle->action == DRAW_RECTANGLE)
386 XDrawRectangle (g->display, g->drawable, g->gc,
387 rectangle->x, rectangle->y,
388 rectangle->width, rectangle->height);
389 else
390 XFillRectangle (g->display, g->drawable, g->gc,
391 rectangle->x, rectangle->y,
392 rectangle->width, rectangle->height);
393 break;
394
395 case DRAW_STRING:
396 case DRAW_IMAGE_STRING:
397 s = (String *) elt;
398 x_set_gc (g->display, g->gc, s->function,
399 s->color, xDefaultLineWidth, s->font);
400 if (s->action == DRAW_STRING)
401 XDrawString (g->display, g->drawable, g->gc,
402 s->x, s->y,
403 s->str, strlen (s->str));
404 else
405 XDrawImageString (g->display, g->drawable, g->gc,
406 s->x, s->y,
407 s->str, strlen (s->str));
408 break;
409
410 case DRAW_POLYGON:
411 case FILL_POLYGON:
412 polygon = (Polygon *) elt;
413 x_set_gc (g->display, g->gc, polygon->function,
414 polygon->color, polygon->linewidth, xDefaultFont);
415 if (polygon->action == FILL_POLYGON)
416 XFillPolygon (g->display, g->drawable, g->gc,
417 polygon->points, polygon->npoints,
418 Complex, CoordModeOrigin);
419 else
420 XDrawLines (g->display, g->drawable, g->gc,
421 polygon->points, polygon->npoints,
422 CoordModeOrigin);
423 break;
424
425 }
426
427 return TRUE;
428 }
xDefaultLineWidth
#define xDefaultLineWidth
Definition: def_const.h:944
wl_Polygon
Definition: xdisplaylist.c:78
wl_Arc::arcangle
int arcangle
Definition: xdisplaylist.c:44
wl_Polygon::function
long function
Definition: xdisplaylist.c:84
wl_Rectangle::height
int height
Definition: xdisplaylist.c:33
wl_Arc::linewidth
long linewidth
Definition: xdisplaylist.c:47
wl_Arc
Definition: xdisplaylist.c:40
wl_Rectangle::function
long function
Definition: xdisplaylist.c:34
wl_Polygon::npoints
long npoints
Definition: xdisplaylist.c:83
wl_Rectangle
Definition: xdisplaylist.c:29
wl_GraphicClosure::drawable
Drawable drawable
Definition: xdisplaylist.c:66
wl_String::y
int y
Definition: xdisplaylist.c:55
wl_Line::x1
int x1
Definition: xdisplaylist.c:22
wl_Line::linewidth
long linewidth
Definition: xdisplaylist.c:25
wl_Rectangle::color
long color
Definition: xdisplaylist.c:35
wl_Arc::startangle
int startangle
Definition: xdisplaylist.c:44
wl_Arc::width
int width
Definition: xdisplaylist.c:44
wl_Polygon::points
XPoint * points
Definition: xdisplaylist.c:82
wl_Line::y0
int y0
Definition: xdisplaylist.c:22
wl_String::str
char * str
Definition: xdisplaylist.c:56
wl_Polygon::linewidth
long linewidth
Definition: xdisplaylist.c:86
wl_String::action
Action action
Definition: xdisplaylist.c:53
wl_Line::color
long color
Definition: xdisplaylist.c:24
x_set_gc
void x_set_gc(Display *display, GC gc, long function, unsigned long color, long linewidth, Font font)
x_set_gc
Definition: xdisplaylist.c:142
wl_Arc::action
Action action
Definition: xdisplaylist.c:42
wl_Polygon::color
long color
Definition: xdisplaylist.c:85
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
wl_Rectangle::linewidth
long linewidth
Definition: xdisplaylist.c:36
wl_Polygon::action
Action action
Definition: xdisplaylist.c:80
wl_Rectangle::action
Action action
Definition: xdisplaylist.c:31
wl_DisplayElt::action
Action action
Definition: xdisplaylist.c:91
wl_Arc::function
long function
Definition: xdisplaylist.c:45
wl_Arc::x
int x
Definition: xdisplaylist.c:44
wl_Arc::color
long color
Definition: xdisplaylist.c:46
xDefaultFont
#define xDefaultFont
Definition: def_const.h:943
wl_String::color
long color
Definition: xdisplaylist.c:58
wl_Line
Definition: xdisplaylist.c:18
wl_Arc::height
int height
Definition: xdisplaylist.c:44
wl_String::function
long function
Definition: xdisplaylist.c:57
wl_Rectangle::y
int y
Definition: xdisplaylist.c:33
wl_Rectangle::x
int x
Definition: xdisplaylist.c:33
wl_Line::x0
int x0
Definition: xdisplaylist.c:22
wl_Line::function
long function
Definition: xdisplaylist.c:23
wl_String::x
int x
Definition: xdisplaylist.c:55
wl_Line::y1
int y1
Definition: xdisplaylist.c:22
wl_String
Definition: xdisplaylist.c:51
wl_Arc::y
int y
Definition: xdisplaylist.c:44
wl_GraphicClosure::display
Display * display
Definition: xdisplaylist.c:65
wl_String::font
long font
Definition: xdisplaylist.c:59
wl_Rectangle::width
int width
Definition: xdisplaylist.c:33
wl_GraphicClosure::gc
GC gc
Definition: xdisplaylist.c:67

void x_free_display_list | ( | ListHeader * | displaylist | ) |

x_free_display_list

Parameters

  displaylist | - ListHeader *displaylist

Definition at line 548 of file xdisplaylist.c.

References List_Enum(), NULL, and x_free_elt().

549 {
550 List_Enum (displaylist,( RefListEnumProc)x_free_elt, NULL);
551 }
x_free_elt
static long x_free_elt(DisplayElt *elt, long *closure)
x_free_elt
Definition: xdisplaylist.c:494
NULL
#define NULL
Definition: def_const.h:533
List_Enum
long List_Enum(RefListHeader header, RefListEnumProc proc, Ref closure)
List_Enum.
Definition: list.c:379
RefListEnumProc
int(* RefListEnumProc)()
Definition: def_struct.h:276

static long x_free_elt | ( | DisplayElt * | elt,
|  | long * | closure
| ) |  |
| static

x_free_elt

Parameters

  elt | - DisplayElt *elt
  closure | - long *closure

Definition at line 494 of file xdisplaylist.c.

References wl_DisplayElt::action, FreeDisplayElt, wl_Polygon::points, wl_String::str, and TRUE.

495 {
496 Line *line;
497 Arc *arc;
498 Rectangle *rectangle;
499 String *s;
500 Polygon *polygon;
501
502
503 /* free the attributes of the element */
504 switch (elt->action)
505 {
506 case DRAW_LINE:
507 /* no attribute to free ? */
508 break;
509
510 case DRAW_ARC:
511 case FILL_ARC:
512 /* no attribute to free ? */
513 break;
514
515 case DRAW_RECTANGLE:
516 case FILL_RECTANGLE:
517 /* no attribute to free ? */
518 break;
519
520 case DRAW_STRING:
521 case DRAW_IMAGE_STRING:
522 s = (String *) elt;
523 free (s->str);
524 break;
525
526 case DRAW_POLYGON:
527 case FILL_POLYGON:
528 polygon = (Polygon *) elt;
529 free (polygon->points);
530 break;
531
532 }
533
534 /* finaly, free the element itself */
535 FreeDisplayElt (elt);
536
537 return TRUE;
538 }
wl_Polygon
Definition: xdisplaylist.c:78
wl_Arc
Definition: xdisplaylist.c:40
wl_Rectangle
Definition: xdisplaylist.c:29
wl_Polygon::points
XPoint * points
Definition: xdisplaylist.c:82
wl_String::str
char * str
Definition: xdisplaylist.c:56
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
wl_DisplayElt::action
Action action
Definition: xdisplaylist.c:91
wl_Line
Definition: xdisplaylist.c:18
wl_String
Definition: xdisplaylist.c:51
FreeDisplayElt
#define FreeDisplayElt(E)
Definition: xdisplaylist.c:170

static ListLinks * x_get_links_of_display_list | ( | DisplayElt * | elt | ) |
| static

x_get_links_of_display_list

Parameters

  elt | - DisplayElt *elt

Definition at line 110 of file xdisplaylist.c.

111 {
112 return &((Line *) elt)->links;
113 }
wl_Line
Definition: xdisplaylist.c:18

static void x_get_rgb_values | ( | Display * | display,
|  | Window | window,
|  | unsigned long | color,
|  | XColor * | rgb
| ) |  |
| static

x_get_rgb_values

Parameters

  display | - Display *display
  window | - Window window
  color | -unsigned long color
  rgb | - XColor *rgb

Definition at line 662 of file xdisplaylist.c.

663 {
664 XWindowAttributes windowAttributes;
665
666 XGetWindowAttributes (display, window, &windowAttributes);
667 rgb->pixel = color;
668 XQueryColor (display, windowAttributes.colormap, rgb);
669 }

static long x_postscript_elt | ( | DisplayElt * | elt,
|  | PostScriptClosure * | psc
| ) |  |
| static

x_postscript_elt

Parameters

  elt | - DisplayElt *elt
  psc | - PostScriptClosure *psc

Definition at line 678 of file xdisplaylist.c.

References wl_Rectangle::action, wl_Arc::action, wl_String::action, wl_DisplayElt::action, add_number(), add_string(), wl_Arc::arcangle, BUF_SIZE, wl_Line::color, wl_Rectangle::color, wl_Arc::color, wl_String::color, wl_Polygon::color, wl_PostScriptClosure::display, wl_PostScriptClosure::f, wl_Rectangle::height, wl_Arc::height, wl_PostScriptClosure::height, wl_Line::linewidth, wl_Rectangle::linewidth, wl_Arc::linewidth, wl_Polygon::npoints, wl_Polygon::points, wl_Arc::startangle, wl_String::str, TRUE, wl_Rectangle::width, wl_Arc::width, wl_PostScriptClosure::window, wl_Rectangle::x, wl_Arc::x, wl_String::x, wl_Line::x0, wl_Line::x1, x_get_rgb_values(), wl_Rectangle::y, wl_Arc::y, wl_String::y, wl_Line::y0, and wl_Line::y1.

679 {
680 Line *line;
681 Arc *arc;
682 Rectangle *rectangle;
683 String *s;
684 Polygon *polygon;
685 char buf[BUF_SIZE];
686 char *pbuf;
687 XPoint *p;
688 XColor color;
689 long i;
690 int ret; // added bacause of compiler warning - should be checked below
691
692
693 buf[0] = 0;
694 pbuf = buf;
695
696 switch (elt->action)
697 {
698 case DRAW_LINE:
699 line = (Line *) elt;
700
701 pbuf = add_number (pbuf, line->x0);
702 pbuf = add_number (pbuf, psc->height - line->y0);
703 pbuf = add_number (pbuf, line->x1);
704 pbuf = add_number (pbuf, psc->height - line->y1);
705 x_get_rgb_values ((Display *)psc->display, psc->window, line->color, &color); // added cast DJD
706 pbuf = add_number (pbuf, color.red);
707 pbuf = add_number (pbuf, color.green);
708 pbuf = add_number (pbuf, color.blue);
709 pbuf = add_number (pbuf, line->linewidth);
710 pbuf = add_string (pbuf, "line\n");
711 ret = write (psc->f, pbuf, strlen (pbuf));
712 break;
713
714 case DRAW_RECTANGLE:
715 case FILL_RECTANGLE:
716 rectangle = (Rectangle *) elt;
717
718 pbuf = add_number (pbuf, rectangle->x);
719 pbuf = add_number (pbuf, psc->height - rectangle->y);
720 pbuf = add_number (pbuf, rectangle->width);
721 pbuf = add_number (pbuf, rectangle->height);
722 x_get_rgb_values ((Display *) psc->display, psc->window, rectangle->color, &color); // added cast DJD
723 pbuf = add_number (pbuf, color.red);
724 pbuf = add_number (pbuf, color.green);
725 pbuf = add_number (pbuf, color.blue);
726
727 if (rectangle->action == DRAW_RECTANGLE)
728 {
729 pbuf = add_number (pbuf, rectangle->linewidth);
730 pbuf = add_string (pbuf, "true ");
731 }
732 else
733 {
734 pbuf = add_number (pbuf, 1);
735 pbuf = add_string (pbuf, "false ");
736 }
737
738 pbuf = add_string (pbuf, "rect\n");
739 ret = write (psc->f, pbuf, strlen (pbuf));
740 break;
741
742 case DRAW_ARC:
743 case FILL_ARC:
744 arc = (Arc *) elt;
745 pbuf = add_number (pbuf, arc->x+arc->width/2);
746 pbuf = add_number (pbuf, psc->height - (arc->y+arc->height/2));
747 pbuf = add_number (pbuf, arc->width/2);
748 pbuf = add_number (pbuf, arc->height/2);
749 pbuf = add_number (pbuf, arc->startangle);
750 pbuf = add_number (pbuf, (arc->startangle+arc->arcangle)/64);
751 x_get_rgb_values ((Display *)psc->display, psc->window, arc->color, &color); // added cast DJD
752 pbuf = add_number (pbuf, color.red);
753 pbuf = add_number (pbuf, color.green);
754 pbuf = add_number (pbuf, color.blue);
755
756 if (arc->action == DRAW_ARC)
757 {
758 pbuf = add_number (pbuf, arc->linewidth);
759 pbuf = add_string (pbuf, "true ");
760 }
761 else
762 {
763 pbuf = add_number (pbuf, 1);
764 pbuf = add_string (pbuf, "false ");
765 }
766
767 pbuf = add_string (pbuf, "earc\n");
768 ret = write (psc->f, pbuf, strlen (pbuf));
769 break;
770
771 case DRAW_STRING:
772 case DRAW_IMAGE_STRING:
773 s = (String *) elt;
774 pbuf = add_number (pbuf, s->x);
775 pbuf = add_number (pbuf, psc->height - s->y);
776 pbuf = add_string (pbuf, "(");
777 pbuf = add_string (pbuf, s->str);
778 pbuf = add_string (pbuf, ") ");
779 x_get_rgb_values ((Display *)psc->display, psc->window, s->color, &color); // added cast DJD
780 pbuf = add_number (pbuf, color.red);
781 pbuf = add_number (pbuf, color.green);
782 pbuf = add_number (pbuf, color.blue);
783
784 if (s->action == DRAW_STRING)
785 pbuf = add_string (pbuf, "true ");
786 else
787 pbuf = add_string (pbuf, "false ");
788
789 pbuf = add_string (pbuf, "dstr\n");
790 ret = write (psc->f, pbuf, strlen (pbuf));
791 break;
792
793 case FILL_POLYGON:
794 polygon = (Polygon *) elt;
795
796 x_get_rgb_values ((Display *)psc->display, psc->window, polygon->color, &color); // added cast DJD
797 pbuf = add_number (pbuf, color.red);
798 pbuf = add_string (pbuf, "65535 div ");
799 pbuf = add_number (pbuf, color.green);
800 pbuf = add_string (pbuf, "65535 div ");
801 pbuf = add_number (pbuf, color.blue);
802 pbuf = add_string (pbuf, "65535 div ");
803 pbuf = add_string (pbuf, "setrgbcolor ");
804
805 p = polygon->points;
806 pbuf = add_string (pbuf, "np ");
807 pbuf = add_number (pbuf, p->x);
808 pbuf = add_number (pbuf, psc->height - p->y);
809 pbuf = add_string (pbuf, "mt\n");
810 ++p;
811 for (i=1; i<polygon->npoints; i++, p++)
812 {
813 pbuf = add_number (pbuf, p->x);
814 pbuf = add_number (pbuf, psc->height - p->y);
815 pbuf = add_string (pbuf, "lt ");
816 if (i%4==0)
817 pbuf = add_string (pbuf, "\n");
818 }
819
820 pbuf = add_string (pbuf, "cp fi\n");
821 ret = write (psc->f, pbuf, strlen (pbuf));
822 break;
823 }
824
825 return TRUE;
826 }
BUF_SIZE
#define BUF_SIZE
Definition: xdisplaylist.c:610
wl_Polygon
Definition: xdisplaylist.c:78
wl_Arc::arcangle
int arcangle
Definition: xdisplaylist.c:44
wl_Rectangle::height
int height
Definition: xdisplaylist.c:33
wl_Arc::linewidth
long linewidth
Definition: xdisplaylist.c:47
wl_Arc
Definition: xdisplaylist.c:40
x_get_rgb_values
static void x_get_rgb_values(Display *display, Window window, unsigned long color, XColor *rgb)
x_get_rgb_values
Definition: xdisplaylist.c:662
add_number
static char * add_number(char *buf, long n)
add_number
Definition: xdisplaylist.c:621
wl_Polygon::npoints
long npoints
Definition: xdisplaylist.c:83
wl_Rectangle
Definition: xdisplaylist.c:29
wl_PostScriptClosure::window
Drawable window
Definition: xdisplaylist.c:73
wl_String::y
int y
Definition: xdisplaylist.c:55
wl_PostScriptClosure::height
long height
Definition: xdisplaylist.c:75
wl_Line::x1
int x1
Definition: xdisplaylist.c:22
wl_PostScriptClosure::display
GENERIC display
Definition: xdisplaylist.c:72
wl_Line::linewidth
long linewidth
Definition: xdisplaylist.c:25
wl_Rectangle::color
long color
Definition: xdisplaylist.c:35
wl_Arc::startangle
int startangle
Definition: xdisplaylist.c:44
wl_Arc::width
int width
Definition: xdisplaylist.c:44
wl_Polygon::points
XPoint * points
Definition: xdisplaylist.c:82
wl_Line::y0
int y0
Definition: xdisplaylist.c:22
wl_String::str
char * str
Definition: xdisplaylist.c:56
wl_String::action
Action action
Definition: xdisplaylist.c:53
wl_Line::color
long color
Definition: xdisplaylist.c:24
wl_Arc::action
Action action
Definition: xdisplaylist.c:42
wl_Polygon::color
long color
Definition: xdisplaylist.c:85
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
wl_Rectangle::linewidth
long linewidth
Definition: xdisplaylist.c:36
wl_Rectangle::action
Action action
Definition: xdisplaylist.c:31
wl_DisplayElt::action
Action action
Definition: xdisplaylist.c:91
wl_PostScriptClosure::f
long f
Definition: xdisplaylist.c:74
wl_Arc::x
int x
Definition: xdisplaylist.c:44
wl_Arc::color
long color
Definition: xdisplaylist.c:46
wl_String::color
long color
Definition: xdisplaylist.c:58
wl_Line
Definition: xdisplaylist.c:18
wl_Arc::height
int height
Definition: xdisplaylist.c:44
wl_Rectangle::y
int y
Definition: xdisplaylist.c:33
wl_Rectangle::x
int x
Definition: xdisplaylist.c:33
wl_Line::x0
int x0
Definition: xdisplaylist.c:22
wl_String::x
int x
Definition: xdisplaylist.c:55
add_string
static char * add_string(char *buf, char *s)
add_string
Definition: xdisplaylist.c:645
wl_Line::y1
int y1
Definition: xdisplaylist.c:22
wl_String
Definition: xdisplaylist.c:51
wl_Arc::y
int y
Definition: xdisplaylist.c:44
wl_Rectangle::width
int width
Definition: xdisplaylist.c:33

static void x_postscript_prolog | ( | long | f | ) |
| static

x_postscript_prolog

Parameters

  f | - long f

Definition at line 599 of file xdisplaylist.c.

References prolog.

600 {
601 long i;
602 int ret; // added bacause of compiler warning - should be checked below
603
604 for (i = 0; prolog[i] != 0; i++)
605 ret = write (f, prolog[i], strlen (prolog[i]));
606 }
prolog
static char * prolog[]
Definition: xdisplaylist.c:555

long x_postscript_window | ( | Display * | display,
|  | Window | window,
|  | ListHeader * | displaylist,
|  | char * | filename
| ) |  |

x_postscript_window

Parameters

  display | - Display *display
  window | - Window window
  displaylist | - ListHeader *displaylist
  filename | -char *filename

Definition at line 839 of file xdisplaylist.c.

References wl_PostScriptClosure::display, Errorline(), wl_PostScriptClosure::f, FALSE, wl_PostScriptClosure::height, List_Enum(), TRUE, wl_PostScriptClosure::window, x_postscript_elt(), and x_postscript_prolog().

840 {
841 XWindowAttributes windowAttributes;
842 PostScriptClosure psc;
843 int ret; // added bacause of compiler warning - should be checked below
844
845
846
847 psc.display = (GENERIC)display;
848 psc.window = window;
849 if ((psc.f = open (filename, O_CREAT|O_WRONLY|O_TRUNC,
850 S_IRUSR|S_IWUSR|S_IRWXG)) == -1)
851 {
852 Errorline ("\n*** Error: cannot open file %s.\n", filename);
853 return FALSE;
854 }
855
856 XGetWindowAttributes (display, window, &windowAttributes);
857 psc.height = windowAttributes.height;
858 x_postscript_prolog (psc.f);
859 List_Enum (displaylist,( RefListEnumProc)x_postscript_elt, &psc);
860 ret = write (psc.f, "showpage\n", strlen ("showpage\n"));
861 close (psc.f);
862
863 return TRUE;
864 }
x_postscript_elt
static long x_postscript_elt(DisplayElt *elt, PostScriptClosure *psc)
x_postscript_elt
Definition: xdisplaylist.c:678
x_postscript_prolog
static void x_postscript_prolog(long f)
x_postscript_prolog
Definition: xdisplaylist.c:599
wl_PostScriptClosure::window
Drawable window
Definition: xdisplaylist.c:73
wl_PostScriptClosure::height
long height
Definition: xdisplaylist.c:75
wl_PostScriptClosure::display
GENERIC display
Definition: xdisplaylist.c:72
wl_PostScriptClosure
Definition: xdisplaylist.c:70
Errorline
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
GENERIC
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
TRUE
#define TRUE
Standard boolean.
Definition: def_const.h:268
FALSE
#define FALSE
Standard boolean.
Definition: def_const.h:275
wl_PostScriptClosure::f
long f
Definition: xdisplaylist.c:74
List_Enum
long List_Enum(RefListHeader header, RefListEnumProc proc, Ref closure)
List_Enum.
Definition: list.c:379
RefListEnumProc
int(* RefListEnumProc)()
Definition: def_struct.h:276

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

Parameters

  displaylist | - ListHeader *displaylist
  action | - Action action
  x | - long x
  y | - long y
  width | - long width
  height | - long height
  startangle | - long startangle
  arcangle | - long arcangle
  function | - unsigned long function
  color | - unsigned long color
  linewidth | - unsigned long linewidth

Definition at line 221 of file xdisplaylist.c.

References wl_Arc::action, AllocDisplayElt, wl_Arc::arcangle, wl_Arc::color, wl_Arc::function, wl_Arc::height, wl_Arc::linewidth, List_Append(), wl_Arc::startangle, wl_Arc::width, wl_Arc::x, and wl_Arc::y.

222 {
223 Arc * elt;
224
225 elt = (Arc *) AllocDisplayElt ();
226 elt->action = action;
227 elt->x = x;
228 elt->y = y;
229 elt->width = width;
230 elt->height = height;
231 elt->startangle = startangle;
232 elt->arcangle = arcangle;
233 elt->function = function;
234 elt->color = color;
235 elt->linewidth = linewidth;
236 List_Append (displaylist, (Ref) elt);
237 }
wl_Arc::arcangle
int arcangle
Definition: xdisplaylist.c:44
wl_Arc::linewidth
long linewidth
Definition: xdisplaylist.c:47
wl_Arc
Definition: xdisplaylist.c:40
List_Append
void List_Append(RefListHeader header, Ref atom)
void List_Append
Definition: list.c:71
wl_Arc::startangle
int startangle
Definition: xdisplaylist.c:44
wl_Arc::width
int width
Definition: xdisplaylist.c:44
wl_Arc::action
Action action
Definition: xdisplaylist.c:42
wl_Arc::function
long function
Definition: xdisplaylist.c:45
wl_Arc::x
int x
Definition: xdisplaylist.c:44
wl_Arc::color
long color
Definition: xdisplaylist.c:46
wl_Arc::height
int height
Definition: xdisplaylist.c:44
AllocDisplayElt
#define AllocDisplayElt()
Definition: xdisplaylist.c:169
wl_Arc::y
int y
Definition: xdisplaylist.c:44
Ref
void * Ref
Definition: def_struct.h:272

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

Parameters

  displaylist | ListHeader *displaylist
  action | - Action action
  x0 | - long x0
  y0 | - long y0
  x1 | - long x1
  y1 | - long y1
  function | - unsigned long function
  color | - unsigned long color
  linewidth | - unsigned long linewidth

Definition at line 186 of file xdisplaylist.c.

References wl_Line::action, AllocDisplayElt, wl_Line::color, wl_Line::function, wl_Line::linewidth, List_Append(), wl_Line::x0, wl_Line::x1, wl_Line::y0, and wl_Line::y1.

187 {
188 Line * elt;
189
190 elt = (Line *) AllocDisplayElt ();
191 elt->action = action;
192 elt->x0 = x0;
193 elt->y0 = y0;
194 elt->x1 = x1;
195 elt->y1 = y1;
196 elt->function = function;
197 elt->color = color;
198 elt->linewidth = linewidth;
199 List_Append (displaylist, (Ref) elt);
200 }
wl_Line::x1
int x1
Definition: xdisplaylist.c:22
wl_Line::linewidth
long linewidth
Definition: xdisplaylist.c:25
List_Append
void List_Append(RefListHeader header, Ref atom)
void List_Append
Definition: list.c:71
wl_Line::y0
int y0
Definition: xdisplaylist.c:22
wl_Line::action
Action action
Definition: xdisplaylist.c:20
wl_Line::color
long color
Definition: xdisplaylist.c:24
wl_Line
Definition: xdisplaylist.c:18
AllocDisplayElt
#define AllocDisplayElt()
Definition: xdisplaylist.c:169
wl_Line::x0
int x0
Definition: xdisplaylist.c:22
wl_Line::function
long function
Definition: xdisplaylist.c:23
wl_Line::y1
int y1
Definition: xdisplaylist.c:22
Ref
void * Ref
Definition: def_struct.h:272

void x_record_polygon | ( | ListHeader * | displaylist,
|  | Action | action,
|  | XPoint * | points,
|  | long | npoints,
|  | unsigned long | function,
|  | unsigned long | color,
|  | unsigned long | linewidth
| ) |  |

x_record_polygon

Parameters

  displaylist | - ListHeader *displaylist
  action | Action action
  points | - XPoint *points
  npoints | - long npoints
  function | - unsigned long function
  color | - unsigned long color
  linewidth | - unsigned long linewidth

Definition at line 285 of file xdisplaylist.c.

References wl_Polygon::action, AllocDisplayElt, wl_Polygon::color, wl_Polygon::function, wl_Polygon::linewidth, List_Append(), wl_Polygon::npoints, and wl_Polygon::points.

286 {
287 Polygon * elt;
288 XPoint *p;
289
290
291 elt = (Polygon *) AllocDisplayElt ();
292 elt->action = action;
293 elt->npoints = npoints;
294 elt->points = p = (XPoint *) malloc (npoints*2*sizeof(short));
295 for (; npoints > 0; npoints--, p++, points++)
296 *p = *points;
297 elt->function = function;
298 elt->color = color;
299 elt->linewidth = linewidth;
300 List_Append (displaylist, (Ref) elt);
301 }
wl_Polygon
Definition: xdisplaylist.c:78
wl_Polygon::function
long function
Definition: xdisplaylist.c:84
wl_Polygon::npoints
long npoints
Definition: xdisplaylist.c:83
List_Append
void List_Append(RefListHeader header, Ref atom)
void List_Append
Definition: list.c:71
wl_Polygon::points
XPoint * points
Definition: xdisplaylist.c:82
wl_Polygon::linewidth
long linewidth
Definition: xdisplaylist.c:86
wl_Polygon::color
long color
Definition: xdisplaylist.c:85
wl_Polygon::action
Action action
Definition: xdisplaylist.c:80
AllocDisplayElt
#define AllocDisplayElt()
Definition: xdisplaylist.c:169
Ref
void * Ref
Definition: def_struct.h:272

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

Parameters

  displaylist | - ListHeader *displaylist
  action | - Action action
  x | - long x
  y | - long y
  width | - long width
  height | - long height
  function | - unsigned long function
  color | - unsigned long color
  linewidth | - unsigned long linewidth

Definition at line 255 of file xdisplaylist.c.

References wl_Rectangle::action, AllocDisplayElt, wl_Rectangle::color, wl_Rectangle::function, wl_Rectangle::height, wl_Rectangle::linewidth, List_Append(), wl_Rectangle::width, wl_Rectangle::x, and wl_Rectangle::y.

256 {
257 Rectangle * elt;
258
259 elt = (Rectangle *) AllocDisplayElt ();
260 elt->action = action;
261 elt->x = x;
262 elt->y = y;
263 elt->width = width;
264 elt->height = height;
265 elt->function = function;
266 elt->color = color;
267 elt->linewidth = linewidth;
268 List_Append (displaylist, (Ref) elt);
269 }
wl_Rectangle::height
int height
Definition: xdisplaylist.c:33
wl_Rectangle::function
long function
Definition: xdisplaylist.c:34
wl_Rectangle
Definition: xdisplaylist.c:29
wl_Rectangle::color
long color
Definition: xdisplaylist.c:35
List_Append
void List_Append(RefListHeader header, Ref atom)
void List_Append
Definition: list.c:71
wl_Rectangle::linewidth
long linewidth
Definition: xdisplaylist.c:36
wl_Rectangle::action
Action action
Definition: xdisplaylist.c:31
wl_Rectangle::y
int y
Definition: xdisplaylist.c:33
AllocDisplayElt
#define AllocDisplayElt()
Definition: xdisplaylist.c:169
wl_Rectangle::x
int x
Definition: xdisplaylist.c:33
Ref
void * Ref
Definition: def_struct.h:272
wl_Rectangle::width
int width
Definition: xdisplaylist.c:33

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

Parameters

  displaylist | - ListHeader *displaylist
  action | - Action action
  x | - long x
  y | - long y
  str | - char *str
  font | - Font font
  function | - unsigned long function
  color | - unsigned long color

Definition at line 318 of file xdisplaylist.c.

References wl_String::action, AllocDisplayElt, wl_String::color, wl_String::font, wl_String::function, List_Append(), wl_String::str, wl_String::x, and wl_String::y.

319 { // font & str order was reversed DJD
320 String * elt;
321
322 elt = (String *) AllocDisplayElt ();
323 elt->action = action;
324 elt->x = x;
325 elt->y = y;
326 elt->str = (char *) malloc (strlen (str)+1); /* 11.9 */
327 strcpy (elt->str, str);
328 *(elt->str+strlen(str)) = '\0';
329 elt->function = function;
330 elt->color = color;
331 elt->font = font;
332 List_Append (displaylist, (Ref) elt);
333 }
wl_String::y
int y
Definition: xdisplaylist.c:55
List_Append
void List_Append(RefListHeader header, Ref atom)
void List_Append
Definition: list.c:71
wl_String::str
char * str
Definition: xdisplaylist.c:56
wl_String::action
Action action
Definition: xdisplaylist.c:53
wl_String::color
long color
Definition: xdisplaylist.c:58
wl_String::function
long function
Definition: xdisplaylist.c:57
AllocDisplayElt
#define AllocDisplayElt()
Definition: xdisplaylist.c:169
wl_String::x
int x
Definition: xdisplaylist.c:55
wl_String
Definition: xdisplaylist.c:51
wl_String::font
long font
Definition: xdisplaylist.c:59
Ref
void * Ref
Definition: def_struct.h:272

void x_refresh_window | ( | Display * | display,
|  | Window | window,
|  | Pixmap | pixmap,
|  | GC | pixmapgc,
|  | ListHeader * | displaylist
| ) |  |

x_refresh_window

Parameters

  display | - Display *display
  window | - Window window
  pixmap | - Pixmap pixmap
  pixmapgc | - GC pixmapgc
  displaylist | - ListHeader *displaylist

Definition at line 447 of file xdisplaylist.c.

References wl_GraphicClosure::display, wl_GraphicClosure::drawable, wl_GraphicClosure::gc, List_Enum(), x_draw_elt(), x_set_gc(), xDefaultFont, and xDefaultLineWidth.

448 {
449 XWindowAttributes attr;
450 GraphicClosure g;
451
452
453 /* disable the GraphicsExpose emitted by XCopyArea */
454 XSetGraphicsExposures (display, pixmapgc, False);
455
456 /* get the geometry of the window */
457 XGetWindowAttributes (display, window, &attr);
458
459 #if 0
460 /* does not work with a pixmap, only with windows !! @#@^&%#(*&! - jch */
461 XClearArea (display, pixmap, 0, 0,
462 attr.width, attr.height, False);
463 #endif
464
465 x_set_gc (display, pixmapgc, GXcopy, attr.backing_pixel,
466 xDefaultLineWidth, xDefaultFont);
467
468 XFillRectangle (display, pixmap, pixmapgc,
469 0, 0, attr.width, attr.height);
470
471 g.display = display;
472 g.drawable = pixmap;
473 g.gc = pixmapgc;
474
475 List_Enum (displaylist,(RefListEnumProc) x_draw_elt, &g);
476
477
478 if (window != pixmap)
479 XCopyArea (display, pixmap, window, pixmapgc, 0, 0,
480 attr.width, attr.height, 0, 0);
481
482 XSync (display, 0);
483 }
xDefaultLineWidth
#define xDefaultLineWidth
Definition: def_const.h:944
wl_GraphicClosure::drawable
Drawable drawable
Definition: xdisplaylist.c:66
x_set_gc
void x_set_gc(Display *display, GC gc, long function, unsigned long color, long linewidth, Font font)
x_set_gc
Definition: xdisplaylist.c:142
x_draw_elt
static long x_draw_elt(DisplayElt *elt, GraphicClosure *g)
x_draw_elt
Definition: xdisplaylist.c:344
xDefaultFont
#define xDefaultFont
Definition: def_const.h:943
List_Enum
long List_Enum(RefListHeader header, RefListEnumProc proc, Ref closure)
List_Enum.
Definition: list.c:379
RefListEnumProc
int(* RefListEnumProc)()
Definition: def_struct.h:276
wl_GraphicClosure
Definition: xdisplaylist.c:63
wl_GraphicClosure::display
Display * display
Definition: xdisplaylist.c:65
wl_GraphicClosure::gc
GC gc
Definition: xdisplaylist.c:67

void x_set_gc | ( | Display * | display,
|  | GC | gc,
|  | long | function,
|  | unsigned long | color,
|  | long | linewidth,
|  | Font | font
| ) |  |

x_set_gc

Parameters

  display | - Display *display
  gc | - GC gc
  function | - long function
  color | - unsigned long color
  linewidth | - long linewidth
  font | - Font font

Definition at line 142 of file xdisplaylist.c.

References xDefaultFont, and xDefaultLineWidth.

143 {
144 XGCValues gcvalues;
145 unsigned long valuemask;
146
147
148 gcvalues.function = function;
149 gcvalues.foreground = color;
150 valuemask = GCFunction | GCForeground;
151
152 if (linewidth != xDefaultLineWidth)
153 {
154 gcvalues.line_width = linewidth;
155 valuemask |= GCLineWidth;
156 }
157
158 if (font != xDefaultFont)
159 {
160 gcvalues.font = font;
161 valuemask |= GCFont;
162 }
163
164 XChangeGC (display, gc, valuemask, &gcvalues);
165 }
xDefaultLineWidth
#define xDefaultLineWidth
Definition: def_const.h:944
xDefaultFont
#define xDefaultFont
Definition: def_const.h:943

## Variable Documentation

char nstr[BUF_SIZE]
| static

Definition at line 612 of file xdisplaylist.c.

char* prolog[]
| static

Definition at line 555 of file xdisplaylist.c.