thibaud@dabchick.stanford.EDU (04/25/91)
my problem is the following :
I am trying to set the GC function to GCxor in order to do rubberbanding.
Then I am displaying a series of rectangles to check what is the effect
of the GXxor.
The first rectangle ( R1 ) is displayed with GXcopy ( and appears on the screen ).
the second ( R2 ) is drawn with GXxor on white background and doesn't appear. why ?
the third ( R3 ) is drawn with GXxor on top of R1. It doesn't erase it. why ?
================================================================================
#include <X11/Xlib.h>
#include <stdlib.h>
main()
{
Display *display;
int screen;
Window window;
GC gc;
XEvent event;
XGCValues GCValues;
if( (display = XOpenDisplay( NULL )) == NULL ) exit(0);
screen = DefaultScreen( display );
window = XCreateSimpleWindow( display, RootWindow( display, screen ),
0,0,200,200,
1,
BlackPixel( display, screen ),
WhitePixel( display, screen ) );
gc = XCreateGC( display, RootWindow( display, screen ), 0, NULL );
XSetForeground( display, gc, BlackPixel(display,screen) );
XSetBackground( display, gc, WhitePixel(display,screen) );
XSelectInput( display, window, ExposureMask );
XMapWindow( display, window );
XNextEvent( display, &event ); /* to be sur that next drawings will appear */
/* the GC is still GXcopy */
XDrawRectangle( display, window, gc, 10, 10, 30, 30 );
XFlush( display );
sleep(2);
/* here I am changing the GC to GCxor */
XGetGCValues( display, gc, GCFunction, &GCValues );
GCValues.function = 0x6;
XChangeGC( display, gc, GCFunction, &GCValues );
XGetGCValues( display, gc, GCFunction, &GCValues );
XDrawRectangle( display, window, gc, 40, 40, 30, 30 );
XFlush( display );
sleep(2);
XDrawRectangle( display, window, gc, 10, 10, 30, 30 );
XFlush( display );
sleep(2);
XCloseDisplay( display );
exit(0);
}
================================================================================
Thank you for your help.
Thibaud