GliderPRO/Sources/DialogUtils.c

1 line
23 KiB
C
Raw Normal View History

//============================================================================ //---------------------------------------------------------------------------- // DialogUtils.c //---------------------------------------------------------------------------- //============================================================================ #include <ControlDefinitions.h> #include <LowMem.h> #include <NumberFormatting.h> #include "DialogUtils.h" #include "Externs.h" #define kActive 0 #define kInactive 255 //============================================================== Functions //-------------------------------------------------------------- BringUpDialog // Given a dialog pointer and a resource ID, this function brings it up<75> // centered, visible, and with the default button outlined. void BringUpDialog (DialogPtr *theDialog, short dialogID) { // CenterDialog(dialogID); *theDialog = GetNewDialog(dialogID, nil, kPutInFront); if (*theDialog == nil) RedAlert(kErrDialogDidntLoad); SetPort((GrafPtr)*theDialog); ShowWindow(GetDialogWindow(*theDialog)); DrawDefaultButton(*theDialog); } //-------------------------------------------------------------- GetPutDialogCorner // Determines the upper left corner coordinates needed to properly center<65> // the standard Mac PutFile dialog (when you save files). /* void GetPutDialogCorner (Point *theCorner) { DialogTHndl dlogHandle; Rect theScreen, dlogBounds; Byte wasState; theCorner->h = 64; theCorner->v = 64; theScreen = qd.screenBits.bounds; theScreen.top += LMGetMBarHeight(); OffsetRect(&theScreen, -theScreen.left, -theScreen.top); dlogHandle = (DialogTHndl)GetResource('DLOG', sfPutDialogID); if (dlogHandle != nil) { wasState = HGetState((Handle)dlogHandle); HLock((Handle)dlogHandle); dlogBounds = (**dlogHandle).boundsRect; OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top); theCorner->h = (theScreen.right - dlogBounds.right) / 2; theCorner->v = (theScreen.bottom - dlogBounds.bottom) / 3; HSetState((Handle)dlogHandle, wasState); } theCorner->v += LMGetMBarHeight(); } */ //-------------------------------------------------------------- GetPutDialogCorner // Determines the upper left corner coordinates needed to properly center<65> // the standard Mac GetFile dialog (when you open files). /* void GetGetDialogCorner (Point *theCorner) { DialogTHndl dlogHandle; Rect theScreen, dlogBounds; Byte wasState; theCorner->h = 64; theCorner->v = 64; theScreen = qd.screenBits.bounds; theScreen.top += LMGetMBarHeight(); OffsetRect(&theScreen, -theScreen.left, -theScreen.top); dlogHandle = (DialogTHndl)GetResource('DLOG', sfGetDialogID); if (dlogHandle != nil) { wasState = HGetState((Handle)dlogHandle); HLock((Handle)dlogHandle); dlogBounds = (**dlogHandle).boundsRect; OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top); theCorner->h = (theScreen.right - dlogBounds.right) / 2; theCorner->v = (theScreen.bottom - dlogBounds.bottom) / 3; HSetState((Handle)dlogHandle, wasState); } theCorner->v += LMGetMBarHeight(); } */ //-------------------------------------------------------------- CenterDialog // Given a resource ID for a dialog, this function properly centers it. /* void CenterDialog (SInt16 dialogID) { DialogTHndl dlogHandle; Rect theScreen, dlogBounds; SInt16 hPos, vPos; Byte wasState; theScreen = qd.screenBits.bounds; theScreen.top += LMGetMBarHeight(); dlogHandle = (DialogTHndl)GetResource('DLOG', dialogID); if (dlogHandle != nil) { wasState = HGetState((Handle)dlogHandle); HLock((Handle)dlogHandle); dlogBounds = (**dlogHandle).boundsRect; OffsetRect(&dlogBounds, -dlogBounds.left, -dlogBounds.top); hPos = ((theScreen.right - theScreen.left) - dlogBounds.right) / 2; vPos = ((theScreen.bottom - theScreen.top) - dlogBounds.bottom) / 3; OffsetRect(&dlogBounds, hPos, vPos + LMGetMBarHeight()); (**dlogHandle).boundsRect = dlogBounds; HSetState((Handle)dlogHandle, wasState); } } */ //-----------------------------------------------------