Path: utzoo!attcan!uunet!lll-winken!ames!ncar!husc6!bloom-beacon!ATHENA.MIT.EDU!kit From: kit@ATHENA.MIT.EDU (Chris D. Peterson) Newsgroups: comp.windows.x Subject: Re: Xlib and Widgets, again Message-ID: <8901262013.AA03017@DORA.MIT.EDU> Date: 26 Jan 89 20:13:55 GMT References: <9012@burdvax.PRC.Unisys.COM> Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 60 > From: coltoff@burdvax.prc.unisys.com (Joel Coltoff) > 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. [code deleted] There is nothing wrong with the call to XtGetCG above, As we have discussed before Joel you cannot change the attributes in a GC created with XtGetGC. (e.g. XSetForground() is a NO NO). But there is nothing wrong with specifying values in the call to XtGetGC(). Right: myXGCV.foreground = WhitePixel(dpy, DefaultScreen(dpy)); myXGCV.background = BlackPixel(dpy, DefaultScreen(dpy)); valuemask = GCForeground | GCBackground; gc = XtGetGC(Widget, valuemask, &myXGCV); Right: gc = XCreateGC(XtDisplay(w), XtWindow(w), 0L, &values); XSetFunction(XtDisplay(w), gcCopy, GXinvert); XSetPlaneMask(XtDisplay(w), gcCopy, foreground ^ background); XSetForeground(XtDisplay(w), gcCopy, AllPlanes); Wrong: gc = XtGetGC(w, 0L, &values); XSetFunction(XtDisplay(w), gcCopy, GXinvert); XSetPlaneMask(XtDisplay(w), gcCopy, foreground ^ background); XSetForeground(XtDisplay(w), gcCopy, AllPlanes); I hope this clears up any confusion. Chris D. Peterson MIT X Consortium / Project Athena Net: kit@athena.mit.edu Phone: (617) 253 - 1326 USMail: MIT - Room E40-321 77 Massachusetts Ave. Cambridge, MA 02139