home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
dialgmgr.sit
/
Centered.p
next >
Wrap
Text File
|
1989-11-28
|
1KB
|
61 lines
Unit Centered;
{ ⌐1986-1989 Bill Stackhouse }
{ Stackhouse Software }
{ Natick, MA 01760 }
Interface
Procedure Centered (Var theRect: Rect;
percentHorz, percentVert: Integer);
{ n where percent = 1/n in area excluding menu bar. if n < 0 then no adjustment is made. }
Implementation
Function GetInteger (address: Longint): Integer;
Type
IntegerPtr = ^Integer;
Var
intPtr: IntegerPtr;
Begin
intPtr := Integerptr(address);
GetInteger := intPtr^;
End; {GetInteger}
Procedure Centered (Var theRect: Rect;
percentHorz, percentVert: Integer);
{ n where percent = 1/n in area excluding menu bar. if n < 0 then no adjustment is made. }
Const
MBarHeight = $BAA;
Var
screenWidth, screenHeight: Integer;
dialogWidth, dialogHeight: Integer;
p: Point;
menubarHeight: Integer;
Begin
menubarHeight := GetInteger(MBarHeight);
With theRect Do
Begin
dialogWidth := right - left;
dialogHeight := bottom - top;
End;
With screenBits.bounds Do
Begin
screenWidth := right - left;
screenHeight := bottom - top - menubarHeight;
End;
If percentHorz > 0 Then
p.h := (screenWidth - dialogWidth) Div percentHorz
Else
p.h := theRect.left;
If percentVert > 0 Then
p.v := ((screenHeight - dialogHeight) Div percentVert)
Else
p.v := theRect.top - menubarHeight;
OffsetRect(theRect, p.h - theRect.left, p.v - theRect.top + menubarHeight);
End; {FileCenterDialog}
End.