Path: utzoo!attcan!uunet!lll-winken!ncis.llnl.gov!helios.ee.lbl.gov!pasteur!agate!bionet!csd4.milw.wisc.edu!mailrus!cornell!rochester!udel!burdvax!coltoff From: coltoff@PRC.Unisys.COM (Joel Coltoff) Newsgroups: comp.windows.x Subject: Re: Xlib and Widgets, again Message-ID: <9012@burdvax.PRC.Unisys.COM> Date: 20 Jan 89 22:31:46 GMT References: <16672@iuvax.cs.indiana.edu> Organization: Unisys Corporation, Paoli Research Center; Paoli, PA Lines: 44 In article <16672@iuvax.cs.indiana.edu> beckman@iuvax.cs.indiana.edu (Peter Beckman) writes: >dpy = XtDisplay(Widget); >myXGCV.foreground = WhitePixel(dpy, DefaultScreen(dpy)); >myXGCV.background = BlackPixel(dpy, DefaultScreen(dpy)); >valuemask = GCForeground | GCBackground; >gc = XtGetGC(Widget, valuemask, &myXGCV); >win = XtWindow(Widget); > >XFillRectangle(dpy,win,gc,0,0,400,400); Having just been down that road I'll take a shot at this. First of all you are changing entries in the values structure when you call XtGetGC(). This is a definite NO NO. Here is the code that works for me in my text widget. The copyMask is set to all values that XFillRectangle() uses minus those I'm going to change anyway. gc = XtGetGC(w, 0L, &values); gcCopy = XCreateGC(XtDisplay(w), XtWindow(w), 0L, &valuesCopy); copyMask = GCFillStyle | GCSubwindowMode | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin; XCopyGC(XtDisplay(w), gc, copyMask, gcCopy); /* * Modify the values in the writable version of the GC */ XSetFunction(XtDisplay(w), gcCopy, GXinvert); XSetPlaneMask(XtDisplay(w), gcCopy, foreground ^ background); XSetForeground(XtDisplay(w), gcCopy, AllPlanes); XFillRectangle(XtDisplay(w), XtWindow(w), gcCopy, X_pos, Y_pos, width, height ); /* * Free up the GCs */ XFreeGC(XtDisplay(w), gcCopy); XtDestroyGC(gc); Good Luck. -- - Joel {psuvax1,sdcrdcf}!burdvax!coltoff (UUCP) coltoff@burdvax.prc.unisys.com (ARPA)