home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / MyRegions.p < prev    next >
Encoding:
Text File  |  1996-12-22  |  1.2 KB  |  64 lines  |  [TEXT/CWIE]

  1. unit MyRegions;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types, QuickDraw;
  7.         
  8.     procedure LocalToGlobalRegion( rgn: RgnHandle );
  9.     procedure GlobalToLocalRegion( rgn: RgnHandle );
  10.     procedure OutlineRegion( rgn: RgnHandle );
  11.     procedure MakeRegionEmpty (rgn: RgnHandle);
  12.     procedure UnionRgnRect( rgn: RgnHandle; const r: Rect );
  13.  
  14. implementation
  15.  
  16.     procedure MakeRegionEmpty (rgn: RgnHandle);
  17.         var
  18.             r: Rect;
  19.     begin
  20.         SetRect(r, 0, 0, 0, 0);
  21.         RectRgn(rgn, r);
  22.     end;
  23.  
  24.     procedure LocalToGlobalRegion( rgn: RgnHandle );
  25.         var
  26.             where: Point;
  27.     begin
  28.         where := Point(0);
  29.         LocalToGlobal( where );
  30.         OffsetRgn( rgn, where.h, where.v );
  31.     end;
  32.  
  33.     procedure GlobalToLocalRegion( rgn: RgnHandle );
  34.         var
  35.             where: Point;
  36.     begin
  37.         where := Point(0);
  38.         GlobalToLocal( where );
  39.         OffsetRgn( rgn, where.h, where.v );
  40.     end;
  41.  
  42.     procedure OutlineRegion( rgn: RgnHandle );
  43.         var
  44.             temprgn: RgnHandle;
  45.     begin
  46.         temprgn := NewRgn;
  47.         CopyRgn( rgn, temprgn );
  48.         InsetRgn( temprgn, 1, 1 );
  49.         DiffRgn( rgn, temprgn, rgn );
  50.         DisposeRgn( temprgn );
  51.     end;
  52.  
  53.     procedure UnionRgnRect( rgn: RgnHandle; const r: Rect );
  54.         var
  55.             tmp: RgnHandle;
  56.     begin
  57.         tmp := NewRgn;
  58.         RectRgn( tmp, r );
  59.         UnionRgn( rgn, tmp, rgn );
  60.         DisposeRgn( tmp );
  61.     end;
  62.     
  63. end.
  64.