srinivas@ut-sally.UUCP (Srini Sankaran) (03/22/88)
The following code doesn't work if XTKVIEWPORT is defined.
It works (i.e., draw 10 circles) if it is not defined.
Can someone help me by explaining why?
-thanks
srinivas@sally.utexas.edu
...!ut-sally!srinivas
-----------------------BEGIN CODE-------------------------------------
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/Atoms.h>
#include <X11/Viewport.h>
#define XSIZE 512
#define YSIZE 512
static Arg arglist[] =
{
{XtNwidth, (XtArgVal)XSIZE},
{XtNheight,(XtArgVal)YSIZE},
} ;
int main(argc, argv)
unsigned int argc;
char **argv;
{
Widget toplevel, viewport;
Window win;
Display *dpy;
GC gc;
XSetWindowAttributes xswa;
int i;
toplevel = XtInitialize("FOO", "FOO", NULL, 0, &argc, argv);
viewport = XtCreateManagedWidget("viewport", viewportWidgetClass, toplevel,
arglist, XtNumber(arglist));
XtRealizeWidget(toplevel);
xswa.background_pixel = 0;
xswa.border_pixel = 1;
dpy = XtDisplay(viewport);
#ifdef XTKVIEWPORT /* Does not work */
win = XtWindow(viewport);
#else /* Works */
win = XCreateWindow(dpy, XtWindow(viewport),
0, 0, XSIZE, YSIZE, 2,
DefaultDepth(dpy, DefaultScreen(dpy)),
InputOutput, DefaultVisual(dpy, DefaultScreen(dpy)),
CWBackPixel | CWBorderPixel, &xswa);
XMapWindow(dpy, win);
#endif
gc = XCreateGC(dpy, win, 0, 0);
XSetForeground(dpy, gc, 1);
XSetBackground(dpy, gc, 0);
XSetLineAttributes(dpy, gc, 1, LineSolid, CapButt, JoinMiter);
for(;;)
{
for(i = 0 ; i < 10 ; i ++)
{
XDrawArc(dpy, win, gc, XSIZE >> 1, YSIZE >> 1,
i * (XSIZE >> 5) , i * (YSIZE >> 5), 0, 64*360);
XSync(dpy, 0);
}
}
}