2
* lines.c -- $Id: lines.c,v 1.1 2003/03/08 15:26:51 travo Exp $
3
* p_lines and p_disjoint for X11
5
* Copyright (c) 1998. See accompanying LEGAL file for details.
15
Display *dpy = s->xdpy->dpy;
16
GC gc = x_getgc(s, w, FillSolid);
17
int nmx = XMaxRequestSize(dpy)-3;
22
XDrawPoints(dpy, w->d, gc, x_pt_list, nmx, CoordModeOrigin);
25
if (p_signalling) p_abort();
32
Display *dpy = s->xdpy->dpy;
33
GC gc = x_getgc(s, w, FillSolid);
34
int nmx = XMaxRequestSize(dpy)-3;
39
XDrawLines(dpy, w->d, gc, x_pt_list, nmx, CoordModeOrigin);
42
if (p_signalling) p_abort();
49
Display *dpy = s->xdpy->dpy;
50
GC gc = x_getgc(s, w, FillSolid);
51
int nmx = (XMaxRequestSize(dpy)-3)/2;
52
int n = x_pt_count / 2;
56
/* note: assume here that XPoint[2] identical to XSegment */
57
XDrawSegments(dpy, w->d, gc, (XSegment *)x_pt_list, nmx);
60
if (p_signalling) p_abort();
63
static char dashed[] = { 5, 5 };
64
static char dotted[] = { 1, 3 };
65
static char dashdot[] = { 5, 2, 1, 2 };
66
static char dashdotdot[] = { 5, 2, 1, 2, 1, 2 };
67
static char *x_dash[] = { 0, dashed, dotted, dashdot, dashdotdot };
68
static int x_ndash[] = { 0, 2, 2, 4, 6 };
71
p_pen(p_win *w, int width, int type)
75
int disjoint = (type & P_SQUARE);
76
int same_type = (s->gc_type == type);
78
if (width<2) width = 0;
79
else if (width>100) width = 100;
81
if (s->gc_width==width && same_type) return;
84
if (type>4 || type<0) type = 0;
85
XSetLineAttributes(s->xdpy->dpy, gc, width,
86
type? LineOnOffDash : LineSolid,
87
disjoint? CapProjecting : CapRound,
88
disjoint? JoinMiter : JoinRound);
89
if (!same_type) s->gc_type = (type | disjoint);
93
/* dash pattern depends on linestyle */
94
int n = x_ndash[type];
96
XSetDashes(s->xdpy->dpy, gc, 0, x_dash[type], n);
98
/* dash pattern must scale with line thickness */
101
for (i=0 ; i<n ; i++)
102
dash[i] = x_dash[type][i]>1? width*x_dash[type][i] : 1;
103
XSetDashes(s->xdpy->dpy, gc, 0, dash, n);