Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!bbn.com!haines From: haines@bbn.com (Ted Haines) Newsgroups: comp.windows.x Subject: Xlib graphics within widgets Message-ID: <46739@bbn.COM> Date: 10 Oct 89 21:16:46 GMT Sender: news@bbn.COM Reply-To: haines@BBN.COM () Distribution: na Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 71 I am in the process of trying to learn a little X programming. We would like to be able to create simple graphics such as circles and rectangles connected by lines. I would like to be able to work at as high a level as possible within the standard X environment. In particular I would like to use the Athena widgets as much as possible. There are lots of examples of simple widget programming and it was easy to get them working. I have been trying for several days without success to find or create a simple example of using graphics within a widget window. The example below is one of dozens of failed attempts to do it myself. The environment is X11R3 on Sun 3/x. The widget graphics I have seen always create their own special purpose widget. Is this necessary? Isn't it possible to use Xlib calls within a widget environment? Could someone send me a simple working example. What is wrong with my attempt below? (The thing compiles and executes without error but does not draw the rectangle. I have tried variations using different widget types, various graphic routines, and various ways of setting up a graphics context but have never gotten graphics to come out.) Where could I have found the answer to this problem myself? What is good reference material and where can I find simple examples? Ted Haines Haines@bbn.com ___________________________________________________________ The following program creates a label widget but does not display a rectangle. #include #include #include Arg wargs[] = { XtNlabel, (XtArgVal) "Hello there, X", }; main(argc, argv) int argc; char **argv; { Widget toplevel, labWidg; Display * display; Drawable d; GC gc; XGCValues xgcv; toplevel = XtInitialize(argv[0], "XLabel", NULL, 0, &argc, argv); labWidg = XtCreateManagedWidget(argv[0], labelWidgetClass, toplevel, wargs, XtNumber(wargs)); XtRealizeWidget(toplevel); display = XtDisplay(labWidg); d = XtWindow(labWidg); gc = XtGetGC(labWidg, 0, &xgcv); XDrawRectangle(display, d, gc, 5,5, 10,20 ); XtMainLoop(); }