home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / dr.str / Source / offScrPort.c < prev    next >
Encoding:
Text File  |  1993-05-29  |  1.3 KB  |  52 lines  |  [TEXT/KAHL]

  1. MkPort(GrafPort *newPort, Rect myRect)
  2. /* Create an off-screen port called newPort that is of size myRect */
  3. {
  4.     QDPtr    newSpace;
  5.     int        rwBytes;
  6.  
  7.     myRect.bottom = myRect.bottom - myRect.top;        /* Set it to have size of */
  8.     myRect.top = 0;                                    /* myRect, but positioned at */
  9.     myRect.right = myRect.right - myRect.left;        /* top-left corner */
  10.     myRect.left = 0;
  11.  
  12.     OpenPort(newPort);
  13.     newPort->portRect = myRect;
  14.     newPort->portBits.bounds = myRect;
  15.     SetRectRgn(newPort->visRgn, 0, 0, myRect.right, myRect.bottom);
  16.     SetRectRgn(newPort->clipRgn, 0, 0, myRect.right, myRect.bottom);
  17.  
  18.     rwBytes = ((myRect.right + 15) / 16) * 2;
  19.     newSpace = NewPtr((long)rwBytes * myRect.bottom);
  20.     if (MemErr)
  21.         return;
  22.  
  23.     newPort->portBits.rowBytes = rwBytes;
  24.     newPort->portBits.baseAddr = newSpace;
  25.     SetPort(newPort);
  26.     EraseRect(&(newPort->portRect));
  27. }
  28.  
  29.  
  30. GetWind(WindowPtr theWindow, GrafPort offPort)
  31. /* Copy bits from the off-screen port, into theWindow */
  32. {
  33.     GrafPtr    oldPort;
  34.     
  35.     GetPort(&oldPort);                        /* Save old port info */
  36.     SetPort(theWindow);                        /* Set port to drawing window */
  37.     
  38.     CopyBits(&offPort.portBits, &theWindow->portBits,
  39.             &theWindow->portRect, &theWindow->portRect,
  40.             srcCopy, 0L);
  41.     
  42.     SetPort(oldPort);                        /* Restore old port info */
  43. }
  44.  
  45.  
  46. ClearOff(GrafPort offPort)
  47. /* Erase all of the off-screen port, offPort */
  48. {
  49.     EraseRect(&(offPort.portBits.bounds));
  50. }
  51.  
  52.