@begin(header)
author: ackerman=ag@ics.uci.edu
show_author: ShowNone
author_organization: MIT
node_expert: ackerman=ag@ics.uci.edu 
expiration_date: 10/10/93
last_modifier: ackerman=ag@ics.uci.edu
last_mod_date: 10/10/91
mod_num: 1
@end(header)
-------------
Changing a GC
-------------

You can change the values in a GC through two sets of routines.  The first set
consists of a single routine, XChangeGC:


     XChangeGC(display, gc, valuemask, values)
           Display *display;
           GC gc;
           unsigned long valuemask;
           XGCValues *values;

which is similar in form to XCreateGC (see the Creating a GC tutorial for code
examples).  You can change any field of the GC struct through this routine.

The second set consists of a series of convenience routines that change one or
a few fields of the GC struct at a time.  Such routines include:

     XSetForeground(display, gc, foreground)
           Display *display;
           GC gc;
           unsigned long foreground;

     XSetBackground(display, gc, background)
           Display *display;
           GC gc;
           unsigned long background;

which set the foreground (drawing color) and background (secondary drawing
color) respectively.  A routine that changes several fields at once is:

     XSetLineAttributes(display, gc, line_width, line_style,
     cap_style, join_style)
           Display *display;
           GC gc;
           unsigned int line_width;
           int line_style;
           int cap_style;
           int join_style;

which sets the various line drawing attributes.  

As long as you call these convenience routines in series (that is, there are no
intervening Xlib calls between them), there is essentially no difference between
calling a series of convenience routines and calling XChangeGC.  That is, all the
changes are cached, and only one protocol request is made.

If you forget what the values of a GC are, you can query the GC with:

     Status XGetGCValues(display, gc, valuemask, values_return)
           Display *display;
           GC gc;
           unsigned long valuemask;
           XGCValues *values_return;

which is available only in R4 or later releases.  Note this call requires
that *you* allocate storage for the XGCValues struct:

	XGCValues the_values;

	if (XGetGCValues(the_display,the_GC, GCForeground | GCBackground,
			 &the_values)) == 0)
		{
			some error handling
		}

This call returns the foreground and background drawing colors for this GC.

If you need additional information on this topic, click the "I'm Unhappy"
button below to ask your question.




