Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!msuinfo!mohawk.cps.msu.edu!tuceryan From: tuceryan@mohawk.cps.msu.edu (Mihran Tuceryan) Newsgroups: comp.windows.x Subject: What am I doing wrong? Message-ID: <1991Jan20.215551.15000@msuinfo.cl.msu.edu> Date: 20 Jan 91 21:55:51 GMT Sender: news@msuinfo.cl.msu.edu Reply-To: tuceryan@mohawk.cps.msu.edu (Mihran Tuceryan) Organization: PRIP Lab, Comp. Sci. Dept., MSU Lines: 63 The following is supposed to be a simple test program that draws a straight line in a window. The window appears but nothing is drawn. What is wrong with this program? Any help is appreciated. (the display is 8 bits deep and this is using Xw widgets). Mihran Tuceryan email: tuceryan@cps.msu.edu /************************************************* * xy.c: Draw a line from (x1,y1) to (x2,y2). *************************************************/ #include #include #include #include main(argc, argv) int argc; char *argv[]; { int x1, y1, x2, y2; Widget toplevel, canvas; GC gc; XGCValues gcv; Display *dpy; Window win; Arg args[10]; int n = 0; /* Initialize the Intrinsincs */ toplevel = XtInitialize (argv[0], "SATCS", NULL, 0, &argc, argv); dpy = XtDisplay(toplevel); /* Create the workspace widget. */ canvas = XtCreateManagedWidget ("canvas", XwworkSpaceWidgetClass, toplevel, NULL, 0); /* Alter widget size (p 23) */ n = 0; XtSetArg (args[n], XtNwidth, 400); n++; XtSetArg (args[n], XtNheight, 400); n++; XtSetArg (args[n], XtNforeground, WhitePixel(dpy, DefaultScreen(dpy))); n++; XtSetArg (args[n], XtNbackground, BlackPixel(dpy, DefaultScreen(dpy))); n++; XtSetValues (canvas, args, n); /* Realize the widgets */ XtRealizeWidget (toplevel); win = XtWindow(canvas); gcv.background = BlackPixel(dpy, DefaultScreen(dpy)); gcv.foreground = WhitePixel(dpy, DefaultScreen(dpy)); gcv.line_style = LineSolid; gcv.function = GXcopy; gc = XtGetGC(canvas, GCFunction | GCForeground | GCBackground | GCLineStyle, &gcv); x1 = 50; y1 = 50; x2 = 100; y2 = 100; XDrawLine(dpy, win, gc, x1, y1, x2, y2); XtMainLoop (); }