Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!usc!apple!dlyons From: dlyons@Apple.COM (David A. Lyons) Newsgroups: comp.sys.apple Subject: Re: Elementary (I assume) Window programming question Message-ID: <38777@apple.Apple.COM> Date: 19 Feb 90 23:15:02 GMT References: <9002161625.AA26906@tj.tis.com> Organization: Apple Computer Inc, Cupertino, CA Lines: 40 In article <9002161625.AA26906@tj.tis.com> lee@TIS.COM (Theodore Lee) writes: >In my spare time I've been browsing through the toolbox references and >TML examples, gearing myself up for doing some *REAL* programming. >One thought has come to mind -- is there any usual way of updating >windows without completely regenerating them? Suppose you have a big >window that took a lot of calculating to fill. [...] Someone else posted an answer to this last week, but I don't think they answered the question you were really asking. I think you're looking for a technique like this: Do your drawing to a QuickDraw port that isn't on the screen. When your window needs to be updated, copy part of the image from your offscreen grafport to the window. This way the time-consuming generation of the image is just done when necessary. To create an off-screen grafport, allocate 170 bytes of memory somewhere, call OpenPort on it, allocate enough memory for your offscreen pixelmap, set up a LocInfo record for your offscreen pixelmap, and use SetLocInfo to cram that LocInfo record into your port. (You may want to do a big EraseRect to clear your offscreen pixel map to the port's background pattern; I don't remember whether the background pattern is initialized to white for you with OpenPort or whether you have to set it yourself first.) When your window's content-draw procedure gets called, just do a PPToPort from the offscreen pixel map to the window (which is the current port, conveniently enough). If you need to make changes to the window's contents, do the drawing in the offscreen port and do an InvalRect or InvalRgn on the window to force an update. (Or do the same drawing over again in both ports. Whatever.) -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II Developer Technical Support | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.