[comp.windows.x] Help needed with GC's

coltoff@PRC.Unisys.COM (Joel Coltoff) (01/14/89)

First let me apologize if you get two copies of this. I cancelled the
first one but in looking at news queues it doesn't appear as though
it worked. Now to the matter at hand.

I stuck on a small problem with GC's and could use somebody's help.
My interface uses a text widget to supply information to and get responses
from a user. In some cases I need to the user to highlight multiple lines.
This means I need to manage the highlighting and slection mechanisms by
myself. The current code looks like this.

		*
		*
/*
 * Copy the selected line to itself but invert the area.
*/
	gc = DefaultGCOfScreen(XtScreen(w));
	XSetFunction(XtDisplay(w), gc, GXcopyInverted);
	XCopyArea(XtDisplay(w), XtWindow(w), XtWindow(w), gc,
		Xpos, Ypos, barWidth, barHeight, Xpos, Ypos );
	XSetFunction(XtDisplay(w), gc, GXcopy);
/*
 * Mark the current line as being selected.
*/
		*
		*

This works just great in monochrome but gives the wrong result in color.
What I want to know is what is quickest way to swap the foreground and
background pixels of a given rectangle that works on both monochrome and
color monitors? It is possible, but not convenient, to get the text on
the slected line and redraw it. Thanks in advance.
-- 
	- Joel
		{psuvax1,sdcrdcf}!burdvax!coltoff	(UUCP)
		coltoff@burdvax.prc.unisys.com		(ARPA)

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (01/14/89)

    What I want to know is what is quickest way to swap the foreground and
    background pixels of a given rectangle that works on both monochrome and
    color monitors?

When only two pixel values are involved, A and B, you can either
set the function to GXinvert and the plane mask to (A xor B) and
the foreground to all ones, or you can set the function to GXxor
and the foreground to (A xor B) and the plane mask to all ones.
Which one is faster will probably depend on the server.