mh2620@sarek.sbc.com (Mark Horstman) (09/27/90)
I'm trying to put a rubberbanding feature in my application with the following code to draw and undraw the rubberband (which looks a lot like the 'draw_box' routine in the O'Reilly X manual Volume 2 section 14.7.13): static GC RBgc = NULL; Widget iWidget; void drawRB( x, y, w, h ) int x, y; unsigned int w, h; { if ( w && h ) { if ( RBgc == NULL ) { RBgc = XCreateGC( XtDisplay( iWidget ), XtWindow( iWidget ), 0, NULL ); XSetForeground( XtDisplay( iWidget ), RBgc, BlackPixel( XtDisplay( iWidget ), DefaultScreen( XtDisplay( iWidget ) ) ) ); XSetBackground( XtDisplay( iWidget ), RBgc, WhitePixel( XtDisplay( iWidget ), DefaultScreen( XtDisplay( iWidget ) ) ) ); XSetFunction( XtDisplay( iWidget ), RBgc, GXxor ); } XDrawRectangle( XtDisplay( iWidget ), XtWindow( iWidget ), RBgc, x, y, w, h ); } } This works fine on the Sun sample server and on NCD X-terminals, but I can't get the rubberband to show up on anything else (I've tried an RS/6000, an IBM X-station, a Tektronics X-terminal, and a couple X servers for DOS). What am i doing wrong? +----------------------------------------------------------------------------+ | Mark A. Horstman Southwestern Bell Telephone | | mh2620@sarek.sbc.com St. Louis, MO | | OR uunet!sarek.sbc.com!mh2620 (314) 235-3417 | +----------------------------------------------------------------------------+
moraes@cs.toronto.edu (Mark Moraes) (10/01/90)
I use something like this to create GCs for rubberbanding.
GC
createxorgc(dpy, win, fgcol, bgcol)
Display *dpy;
Window win;
Pixel fgcol, bgcol;
{
XGCValues gcv;
gcv.foreground = fgcol ^ bgcol;
gcv.background = bgcol;
gcv.function = GXxor;
return XCreateGC(dpy, win, (GCForeground | GCBackground | GCFunction),
&gcv);
}