Pararena2/Sources/UnivUtilities.c

1 line
15 KiB
C
Raw Permalink Normal View History

/*============================================================*/ /*============================================================*/ /*== ==*/ /*== Universal Utility Routines ==*/ /*== ==*/ /*============================================================*/ /*============================================================*/ /*======================================================== Includes */ #include "UnivUtilities.h" /*======================================================== Local Variables */ short wasMenuBarHeight; /*======================================================== Functions */ /*======================================================== CenterDialog */ void CenterDialog (short dialogID) { DialogTHndl dlogHandle; Rect scrnRect, dlogBounds; short hPos, vPos; Byte wasState; scrnRect = screenBits.bounds; scrnRect.top += MBarHeight; dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID); if (dlogHandle != kNilPointer) { wasState = HGetState((Handle)dlogHandle); HLock((Handle)dlogHandle); dlogBounds = (**dlogHandle).boundsRect; OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top); hPos = ((scrnRect.right - scrnRect.left) - dlogBounds.right) / 2; vPos = ((scrnRect.bottom - scrnRect.top) - dlogBounds.bottom) / 3; OffsetRect(&dlogBounds, hPos, vPos + MBarHeight); (**dlogHandle).boundsRect = dlogBounds; HSetState((Handle)dlogHandle, wasState); } } /*======================================================== CenterAlert */ void CenterAlert (short alertID) { AlertTHndl alertHandle; Rect scrnRect, alertRect; short horiOff, vertOff; Byte wasState; scrnRect = screenBits.bounds; scrnRect.top += MBarHeight; alertHandle = (AlertTHndl)GetResource('ALRT', alertID); if (alertHandle != kNilPointer) { wasState = HGetState((Handle)alertHandle); HLock((Handle)alertHandle); alertRect = (**alertHandle).boundsRect; OffsetRect(&alertRect, -alertRect.left, -alertRect.top); horiOff = ((scrnRect.right - scrnRect.left) - alertRect.right) / 2; vertOff = ((scrnRect.bottom - scrnRect.top) - alertRect.bottom) / 3; OffsetRect(&alertRect, horiOff, vertOff + MBarHeight); (**alertHandle).boundsRect = alertRect; HSetState((Handle)alertHandle, wasState); } } /*======================================================== FlashDialogButton */ void FlashDialogButton (DialogPtr theDialog, short itemNumber) { Rect itemRect; Handle itemHandle; long dummyLong; short itemType; GetDItem(theDialog, itemNumber, &itemType, &itemHandle, &itemRect); HiliteControl((ControlHandle)itemHandle, inButton); Delay(8, &dummyLong); HiliteControl((ControlHandle)itemHandle, 0); } /*======================================================== DrawDefaultButton */ void DrawDefaultButton (DialogPtr theDialog, short itemNumber) { Rect itemRect; Handle itemHandle; short itemType; GetDItem(theDialog, itemNumber, &itemType, &itemHandle, &itemRect); InsetRect(&itemRect, -4, -4); PenSize(3, 3); FrameRoundRect(&itemRect, 19, 19); PenNormal(); } /*======================================================== SetDialogString */ void SetDialogString (DialogPtr theDialog, short item, StringPtr theString) { Rect itemRect; Handle itemHandle; short itemType; GetDItem(theDialog, item, &itemType, &itemHandle, &itemRect); SetIText(itemHandle, theString); } /*======================================================== SetDialogNumToStr */ void SetDialogNumToStr (DialogPtr theDialog, short item, long theNumber) { Str255 theString; Rect itemRect; Handle itemHandle; short itemType; NumToString(theNumber, theString); GetDItem(theDialog, item, &itemType, &itemHandle, &itemRect); SetIText(itemHandle, theString); } /*======================================================== SelectFromRadioGroup */ void SelectFromRadioGroup (DialogPtr theDialog, short setItem, short fromItem, short toItem) { Rect iRect; Handle iHandle; short iType, i; for (i = fromItem; i <= toItem;