🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #13778

Re: Macintosh programming. Help!

#13778
From: DMB
Date: Wed, 12 Nov 1986 15:03
75 lines
3567 bytes
  About scrolling and updating fast:

     If you want to scroll in primarily fixed, rectangular reqions then
nothing beats ScrollRect for speed and ease of use. However for kind of
arbitrary scrolling, and the fact that you want to update quickly, the
the following scenario is probably better. Notice this illustration uses
fixed size windows, but it's possible with sizeable windows, but perhaps
a bit more sticky.

(* Set up an offscreen bitmap *)

Var offscreenbits:Bitmap;  (* the offscreen bitmap *)
    savebits:Bitmap;  (* a temporary bitmap for the windows portbits *)

(* initialize it to the size of the window: *)
  offscreenbits.rowbytes := thewindow@.portbits.rowbytes;
  (* @ is really up arrow I can't seem to type it here *)
  offscreenbits.bounds := thewindow@.portbits.bounds;
  bitsize := (thewindow@.portrect.bottom-thewindow@.portrect.top) *
             tempbits.rowbytes * 8;
  offscreenbits.baseaddr := Newptr(sizeof(bitsize);

  (* Save the window's portbits in a temporary bitmap and set the windows
     portbits to our offscreen bitmap *)

  savebits := thewindow@.portbits;
  setportbits(offscreenbitmap); (* sets the frontwindows bitmap notice *)
  eraserect(thewindow@.portrect); (* clear out the offscreen bitmap *)

(* Whenever you draw you can just draw into the window like normal as in *)
invertrect(thewindow@.portrect);
invertrect(thewindow@.portrect);
(* etc.... *)
(* When ever you draw now, it won't appear on the screen *)
(* when you want to put up on the screen what you've drawn call a procedure
   to update the screen, Let's call it updatescreen *)

Procedure updateScreen;
begin
   SetPortBits(tempbits);
   CopyBits(offscreenbits,thewindow@.portbits,offscreenbits.bounds,
            thewindow@.portrect,mode,maskrgn);
   (* note: mode is the overlay transfer mode, you probably want SrcCopy *)
   (*       maskrgn is the rgn you want to copy, if nil the whole rect
            is copied *)
   SetPortBits(offscreenbitmap);
end;

(* As for quick updates, this procedure makes life simple, The mac keeps a rgn
   which is the rgn that has to be redrawn, when a window deactivates in front
   of it, or you move the window off screen or what ever. Therefore to update
   do the following *)

   case
   .......
     updateevt:begin
                  BeginUpdate(theupdatewindow);
                     UpdateScreen;
                  EndUpdate(theupdatewindow);
               end;
    .......
    (* notice theupdatewindow is the window returned by findwindow *)


   That should do it, notice again this assumes fixed size windows, if you
   allow variable sized windows you'll probably have to smudge this alittle
   for when you change the size of the window, but anyway....
   Hopefully i haven't made any silly mistakes, but then again i guess i hear
   about it if i did, there's nothing worse then getting misinfo.
   **** Good Luck ****

                                  dave brosius
                                  PSUVMA.bitnet
Insert comment here:
Technical Details
Message-ID: <8419DMB@PSUVMA>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!brl-adm!rutgers!sri-unix!hplabs!sdcrdcf!burdvax!psuvax1!psuvm.bitnet!dmb
References: 4501@reed.UUCP

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!brl-adm!rutgers!sri-unix!hplabs!sdcrdcf!burdvax!psuvax1!psuvm.bitnet!dmb
From: DMB@PSUVMA.BITNET
Newsgroups: comp.sys.mac,net.sources.mac
Subject: Re: Macintosh programming.  Help!
Message-ID: <8419DMB@PSUVMA>
Date: Wed, 12-Nov-86 10:03:55 EST
Article-I.D.: PSUVMA.8419DMB
Posted: Wed Nov 12 10:03:55 1986
Date-Received: Thu, 13-Nov-86 05:28:53 EST
References: 4501@reed.UUCP
Lines: 75