Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!emory!gatech!bloom-beacon!eru!kth.se!sunic!mcsun!ukc!tcdcs!bofin!cjmchale From: cjmchale@cs.tcd.ie (Ciaran McHale) Newsgroups: comp.windows.x Subject: Re: Can "widgetClass" widget do graphics? Really? Message-ID: <1991Mar29.164058.18310@cs.tcd.ie> Date: 29 Mar 91 16:40:58 GMT References: <957@nddsun1.sps.mot.com> Organization: DSG, Dept. of Comp. Sci., Trinity College, Dublin. Lines: 35 In <957@nddsun1.sps.mot.com> cowan@soleil.sps.mot.com (Andrew H Cowan) writes: >A while back I saw mention of a "poor man's graphics" widget that >was created by using the core widget "widgetClass". I've tried >using this to create a simple graphics window in which I can >draw stuff, but to no avail. > >The following program creates a core widget "widgetClass" and a >pixmap. I draw a rectangle into the pixmap then "XCopyPlane" the >pixmap to the widget. Am I way off base? You should wait until you get an Expose event before you draw anything. Your program doesn't and that is why no graphics appear. The core widget (widgetClass) does not have any Expose callback resource so you can't register a callback routine onto it directly. Instead, you can use the function XtAddEventHandler() to get the intrinsics to invoke a procedure when an Expose event is received. Your expose handler will be passed the relevant widget as one of its parameters. Perform your drawing operations on the window returned by XtWindow(). (There is another function, XtDisplay(), which you'll also find useful.) An alternative would be to obtain/write a widget which does have an expose callback. Then you just register your expose handler via XtAddCallback() rather than use XtAddEventHandler(). Such a widget comes with the xball program which somebody posted a while back to (I think) comp.sources.x. If you want a copy, and can't find it locally, then send me email. It's 51k long, including the widget, docs and xball program. Ciaran. -- Ciaran McHale "There's a lot to be said for verbosity." ---- Department of Computer Science, Trinity College, Dublin 2, Ireland. \ / Telephone: +353-1-772941 ext 1538 FAX: +353-1-772204 \/ Telex: 93782 TCD EI email: cjmchale@cs.tcd.ie