Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!bloom-beacon!EXPO.LCS.MIT.EDU!rws
From: rws@EXPO.LCS.MIT.EDU
Newsgroups: comp.windows.x
Subject: Re: Graphics Contexts
Message-ID: <8908111309.AA01519@expire.lcs.mit.edu>
Date: 11 Aug 89 13:09:53 GMT
References: <13369@bloom-beacon.MIT.EDU>
Sender: daemon@bloom-beacon.MIT.EDU
Organization: The Internet
Lines: 23


    What is the real difference between XCreateGC and XtGetGC.

XCreateGC gives you a private GC that you are free to modify.
XtGetGC gives you a possibly shared GC that you must not modify.

    Supposedly, I'm not supposed to moidify a GC created by XtGetGC but I
    have and it *seems* to work.

You are simply lucky, that no other part of your application (including
whatever widgets you use) has done an XtGetGC and gotten back the same
GC, and depends on the particular values not changing.

    What should I use when I have many options as in a draw program.
    Maintain multiple GCs and flip back & forth or modify existing?

This isn't an easy question to answer.  In some servers, switching between
"static" GCs is fastest, in other servers varying an attribute or two of a
single GC is fastest.  GCs also consume server memory.  I think the jury
is still out on whether the Xt approach of encouraging read-only GCs (of
which there might be a total of a dozen in a real application) is better
or worse than encouraging write-some GCs (in which the application would
have to worry about resetting one or two attributes before using).