home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / µSim 1.0.5 / source / Scroll.c < prev    next >
Encoding:
Text File  |  1995-10-24  |  1.5 KB  |  65 lines  |  [TEXT/CWIE]

  1. /*
  2. Copyright © 1993,1994,1995 Fabrizio Oddone
  3. ••• ••• ••• ••• ••• ••• ••• ••• ••• •••
  4. This source code is distributed as freeware:
  5. you may copy, exchange, modify this code.
  6. You may include this code in any kind of application: freeware,
  7. shareware, or commercial, provided that full credits are given.
  8. You may not sell or distribute this code for profit.
  9. */
  10.  
  11. //#pragma load "MacDump"
  12.  
  13. #include    "UtilsSys7.h"
  14.  
  15. #include    "Scroll.h"
  16.  
  17. #if defined(FabSystem7orlater)
  18.  
  19. //#pragma segment Main
  20.  
  21. /* VScrollRect: ultra-fast vertical ScrollRect which does not fill
  22. with the background pattern; useful when drawing in srcCopy */
  23.  
  24. void VScrollRect(RectPtr r, short dv)
  25. {
  26. GrafPtr    port;
  27. Rect    src,dst;
  28. register short    left,top,right,bottom;
  29.  
  30. if (dv != 0) {
  31.     GetPort(&port);
  32.     left    = (*port->visRgn)->rgnBBox.left;
  33.     top        = (*port->visRgn)->rgnBBox.top;
  34.     right    = (*port->visRgn)->rgnBBox.right;
  35.     bottom    = (*port->visRgn)->rgnBBox.bottom;
  36.     if (r->left < left)        r->left = left;
  37.     if (r->top < top)        r->top = top;
  38.     if (r->right > right)    r->right = right;
  39.     if (r->bottom > bottom)    r->bottom = bottom;
  40.     
  41.     if (dv > 0) {
  42.         topLeft(src) = topLeft(*r);
  43.         src.right    = r->right;
  44.         src.bottom    = r->bottom - dv;
  45.         
  46.         dst.left    = r->left;
  47.         dst.top        = r->top + dv;
  48.         botRight(dst) = botRight(*r);
  49.         }
  50.     else {
  51.         src.left    = r->left;
  52.         src.top        = r->top - dv;
  53.         botRight(src) = botRight(*r);
  54.         
  55.         topLeft(dst) = topLeft(*r);
  56.         dst.right    = r->right;
  57.         dst.bottom    = r->bottom + dv;
  58.         }
  59.     CopyBits(&port->portBits, &port->portBits, &src, &dst, srcCopy, (RgnHandle)nil);
  60.     }
  61. }
  62.  
  63. #endif
  64.  
  65.