sundar@WHEATIES.AI.MIT.EDU (Sundar Narasimhan) (07/06/88)
Hi:
Does anyone know if the gc's modified by the XSetDashes() function
works to produce dashed lines correctly on the Suns? (I am using X11 on
a 3/60 monochrome running 3.4 SunOS)
(I ask this because I've tried using this function with the following
patterns as shown below always with the same result... i.e.all the
different gc's lines look like the same dotdash pattern (or maybe the
following way to use this function the wrong thing to do?))
Thanks,
-Sundar
static char dotted [] = { 8, 2 };
static char dotdash [] = { 8, 8, 8, 2};
static char dashed [] = { 8, 8};
static char dotdotdash[] = {8, 8, 8, 2, 4, 2};
static char dash3dot[] = {8, 2, 8, 2, 8, 2, 8, 8};
set_dashes_in_gc(dpy, gc, pat)
Display *dpy;
GC gc;
int pat;
{
switch(pat) {
case 0:
return;
case 1:
XSetDashes(dpy, gc, 0, dotted, 2);
break;
case 2:
XSetDashes(dpy, gc, 0, dotdash, 4);
break;
case 3:
XSetDashes(dpy, gc, 0, dashed, 2);
break;
case 4:
XSetDashes(dpy, gc, 0, dotdotdash, 6);
break;
case 5:
XSetDashes(dpy, gc, 0, dash3dot, 8);
break;
default:
break;
}
}
create_gcs()
{
XGCValues values;
Display *dpy = XtDisplay(top);
Screen *s = XtScreen(top);
register int i;
values.line_width = 1;
values.foreground = BlackPixelOfScreen(s);
for(i=0;i<MAXGC;i++) {
if(i == 0)
values.line_style = LineSolid;
else
values.line_style = LineOnOffDash;
gc[i] = XtGetGC((Widget) display,
(unsigned)(GCLineWidth|GCForeground|GCLineStyle),
&values);
set_dashes_in_gc(dpy, gc[i], i);
}
}
/* To be used with .. */
draw_line(x1, y1, x2, y2, pattern)
{
XDrawLine(XtDisplay(display),
XtWindow(display),
gc[pattern], x1, y1, x2, y2);
}