Path: utzoo!attcan!uunet!lll-winken!ames!nrl-cmf!ukma!rutgers!njin!princeton!phoenix!ssroy From: ssroy@phoenix.Princeton.EDU (Steve Scot Roy) Newsgroups: comp.windows.x Subject: Novice question about using raw Xlib for drawing in a widget. Keywords: Xlib,Xt Message-ID: <5520@phoenix.Princeton.EDU> Date: 16 Jan 89 19:12:27 GMT Organization: Princeton University, NJ Lines: 48 Greetings ladies and gents, I am a novice Xt programmer and I have a question about something that has got to be easy but doesn't seem to be working the way I would think. All I want to do is, given a widget, Core or Composite or whatever, fill a rectangle in it with XFillRectangle. At least, once I can do that I can do what I really want to do. I open a toplevel with XtInitialize, create a managed widget with XtCreateManagedWidget, I set up translation table stuff so that it can read mouse and key events and do the proper things when they happen, and I realize the toplevel and dive into XtMainLoop. All of this works with no problem. Getting Expose events and drawing into the window you get with XtWindow(widget) doesn't seem to work, however. Allow me to explain more fully. First, if I put the line ": draw()\n" in my translation table draw() does not end up being called even though ": draw()\n" does cause draw to be called. What is the deal? Second, in my translation table I say to call the routine draw() on Enter events, and draw() is defined as follows: void draw(w,event,params,n) Widget w; XEvent *event; String *params; Cardinal *n; { XFillRectangle(XtDisplay(w),XtWindow(w),gc,10,10,100,100); } and in my main() I have gc = XtGetGC(toplevel,0L,&values); When I run it it does not bomb and die, and when in the debugger it does in fact go into the draw() routine, but nothing goes into the window. What am I missing? Have I provided enough information here? Sorry about such a stupid question, but the documentation I have doesn't talk about this at all. I get the impression that this is so easy once you know how to do it that they don't bother documenting it or showing examples of it. Thanks in advance. Steve Roy. Princeton Program of Applied and Computational Mathematics.