home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / dialgmgr.sit / Centered.p next >
Text File  |  1989-11-28  |  1KB  |  61 lines

  1. Unit Centered;
  2.  
  3. {        ⌐1986-1989            Bill Stackhouse                                    }
  4. {                                Stackhouse Software                                }
  5. {                                Natick, MA 01760                                }
  6.  
  7. Interface
  8.  
  9.  
  10.  
  11.     Procedure Centered (Var theRect: Rect;
  12.                                     percentHorz, percentVert: Integer);
  13. {    n   where percent = 1/n  in area excluding menu bar. if n < 0 then no adjustment is made. }
  14.  
  15. Implementation
  16.  
  17.     Function GetInteger (address: Longint): Integer;
  18.         Type
  19.             IntegerPtr = ^Integer;
  20.         Var
  21.             intPtr: IntegerPtr;
  22.     Begin
  23.         intPtr := Integerptr(address);
  24.         GetInteger := intPtr^;
  25.     End;        {GetInteger}
  26.  
  27.     Procedure Centered (Var theRect: Rect;
  28.                                     percentHorz, percentVert: Integer);
  29. {    n   where percent = 1/n  in area excluding menu bar. if n < 0 then no adjustment is made. }
  30.         Const
  31.             MBarHeight = $BAA;
  32.         Var
  33.             screenWidth, screenHeight: Integer;
  34.             dialogWidth, dialogHeight: Integer;
  35.             p: Point;
  36.             menubarHeight: Integer;
  37.     Begin
  38.         menubarHeight := GetInteger(MBarHeight);
  39.         With theRect Do
  40.         Begin
  41.             dialogWidth := right - left;
  42.             dialogHeight := bottom - top;
  43.         End;
  44.         With screenBits.bounds Do
  45.         Begin
  46.             screenWidth := right - left;
  47.             screenHeight := bottom - top - menubarHeight;
  48.         End;
  49.         If percentHorz > 0 Then
  50.             p.h := (screenWidth - dialogWidth) Div percentHorz
  51.         Else
  52.             p.h := theRect.left;
  53.         If percentVert > 0 Then
  54.             p.v := ((screenHeight - dialogHeight) Div percentVert)
  55.         Else
  56.             p.v := theRect.top - menubarHeight;
  57.         OffsetRect(theRect, p.h - theRect.left, p.v - theRect.top + menubarHeight);
  58.     End;        {FileCenterDialog}
  59.  
  60.  
  61. End.