Path: utzoo!attcan!uunet!mcsun!ukc!tcdcs!bofin!cjmchale From: cjmchale@cs.tcd.ie (Ciaran McHale) Newsgroups: comp.windows.x Subject: Re: porting unstructured graphics code to X Message-ID: <1991Mar1.111215.11134@cs.tcd.ie> Date: 1 Mar 91 11:12:15 GMT References: <1991Feb25.212501.1776@yogi.fhhosp.ab.ca> Organization: DSG, Dept. of Comp. Sci., Trinity College, Dublin. Lines: 36 In <1991Feb25.212501.1776@yogi.fhhosp.ab.ca> henry@yogi.fhhosp.ab.ca writes: >I have a pile of code that needs to run under X. It all uses >graphic primitive calls (lines, dots, crosses) that are PLOT-10 like. > >I'm unenthused about doing a lot of code rewrites to bundle graphics >code into repaint procedures. > >Is there any easy way to port the code so that I can just draw into >a window, and *not* have to worry about redrawing from Expose events? There are advantages and disadvantages to the following suggestion but here goes ... X allows the programmer to create a pixmap, which can be thought of as an off-screen window. The term "drawable" refers to either a pixmap or a window. Most [%] of the Xlib graphic routines to draw lines, circles etc work on drawables, i.e., either pixmaps of windows. So you could create a pixmap (using XCreatePixmap), and draw into that. Then your expose handler simply uses XCopyArea to copy from the pixmap to the exposed section of the window. [%] You can clear a window (via XClearWindow or XClearArea) but you can't clear a pixmap simply because a pixmap doesn't have a background colour. Instead, if you want to clear a pixmap then you should use XFillRectangle to fill it with a suitable "background" colour. Ciaran. -- Ciaran McHale "Verbosity says it all" ____ 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