Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!caen!kuhub.cc.ukans.edu!2fmlcalls From: 2fmlcalls@kuhub.cc.ukans.edu Newsgroups: comp.sys.mac.programmer Subject: Re: Question: scrolling in a window Message-ID: <1991Mar15.204959.29076@kuhub.cc.ukans.edu> Date: 16 Mar 91 02:49:59 GMT References: <1991Mar14.021122.292@husc3.harvard.edu> <1991Mar15.032155.305@husc3.harvard.edu> Organization: University of Kansas Academic Computing Services Lines: 28 In article <1991Mar15.032155.305@husc3.harvard.edu>, reiss@husc9.harvard.edu (Peter Reiss) writes: > I have implemented scroll bars in a program and they work, except that whenever > the user clicks in the arrow region, I am redrawing the entire picture. This > works, but does not look very good. I have noticed that most programs seem to > scroll graphics by shifting the current picture in one direction and drawing > in the extra area. How can I do this? Try : procedure ScrollRect (theRect:Rect; hScroll:Integer; vScroll:Integer; updateRgn:RgnHandle); theRect would be a rect in local coords of your window (be sure to SetPort() to your window before calling this). If the scroll bar is vertical, just pass 0 in for hScroll (or vise-versa if vice-versa). Be sure you have predefines updateRgn with xxx:=NewRgn. Once scrolled, the procedure will fill in your updateRgn with the rgn corresponding to the new 'white' (background) area exposed by the scroll. It is your job to fill in the newly exposed hole. You could use the rgn returned as a clipping region to your window port for a DrawPicture or CopyBits. That way the whole window isn't redrawn. Just set your clip back after the draw. For speed, ScrollRect is no faster (and maybe even a little slower) that a CopyBits from an offscreen port/bitMap. If the whole drawing is offscreen somewhere, just shift your srcRect in relation to the scroll bars and do a whole-window CopyBits. It ain't lightning fast, but nothing scroll-wise is on the Mac. john calhoun