Francois.Laagel@ec.bull.fr (05/29/90)
I am writing a small widget set which is intended to be used to represent figures like histograms, pies charts and so on. One of my widgets needs a GC to redraw itself. The fill style must be FillStippled. XFillRectangle works with no trouble and uses the pixmap specified by the stipple member of the GC. But although O'Reilly Xlib programming manual states that XDrawRectangle doesn't care about stipples or tiles members of the GC, the fact is that my server (X11R3) uses the stipple even if the line_style member is set to LineSolid. So, what are the members of the GC which are meaningfull to XDrawRectangle as far as the line style is concerned ? Another question by the way, was is the diffrence between a thin line (gc.line_width == 0) and a wide line (gc.line_width == 1) ? Thanks in advance to anyone who could answer these few questions. Francois LAAGEL Here follows, two pieces of code concerning GC creation, and the Redisplay method of my widget. static void RecomputeGC(w) XmValueWidget w; { long valueMask; XGCValues gcValues; if(w->value.gc!=NULL) { XtReleaseGC(w,w->value.gc); w->value.gc=NULL; } valueMask=GCForeground | GCBackground | GCFillStyle | GCStipple | GCLineStyle | GCLineWidth; gcValues.foreground = w->value.foreground; gcValues.background = XtBackground(w); gcValues.fill_style = FillStippled; gcValues.stipple= stippleTable[w->value.stippleType].pixmap; gcValues.line_style=LineSolid; gcValues.line_width=0; w->value.gc=XtGetGC(w, valueMask, &gcValues); } static void Redisplay (w, event, region) XmValueWidget w; XEvent *event; Region region; { Display *display=XtDisplay(w); Window win=XtWindow(w); int width=XtWidth(w), height=XtHeight(w); XRectangle xr; #ifdef DEBUG fprintf(stderr,"Redisplay(%s)\n",XtName(w)); #endif if(w->core.visible) { XSetRegion(display, w->value.gc, region); xr.x=xr.y=(short)0; xr.width=(unsigned short)(width-1); xr.height=(unsigned short)(height-1); XDrawRectangles(display, win, w->value.gc,&xr,1); XFillRectangle(display, win, w->value.gc,1,1,width-2,height-2); XSync(XtDisplay(w), False); } }
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (05/29/90)
So, what are the members of the GC which are meaningfull to XDrawRectangle as far as the line style is concerned ? Such questions are answered in the standard Xlib and Protocol manuals. From the MIT Xlib manual, section 6.3.3, on XDrawRectangle and XDrawRectangles: Both functions use these GC components: function, plane-mask, line-width, line-style, join-style, fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask. They also use these GC mode-dependent components: foreground, background, tile, stipple, tile-stipple-x-origin, tile-stipple-y-origin, dash-offset, and dash-list. This information also appears in O'Reilly Volume 2 (at least the new addition I have). Another question by the way, was is the diffrence between a thin line (gc.line_width == 0) and a wide line (gc.line_width == 1) ? What pixels they affect. The semantics of thin lines are not contrained very much by the protocol, but there are specific semantics for wide lines. (We've seen several product servers that drew width 1 lines the same as width 0, but they're broken.) See the MIT Xlib manual, section 5.3 (pages 98 and 99 in the Digital Press book). Or see O'Reilly Volume 1 section 5.5.1 (at least in the edition I have).