1 line
55 KiB
C
1 line
55 KiB
C
|
/* Copyright (c) 2017, Computer History Museum
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to
the limitations in the disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. */
#include "utl.h"
#define FILE_NUM 42
/*______________________________________________________________________
utl.c - Utilities.
Copyright <20> 1988, 1989, 1990 Northwestern University. Permission is granted
to use this code in your own projects, provided you give credit to both
John Norstad and Northwestern University in your about box or document.
This module exports miscellaneous reusable utility routines.
_____________________________________________________________________*/
#pragma segment utl
/*______________________________________________________________________
Global Variables.
_____________________________________________________________________*/
static SysEnvRec TheWorld; /* system environment record */
static Boolean GotSysEnviron = false;
/* true if sys environ has been
gotten */
static CursHandle *CursArray; /* ptr to array of cursor handles */
static short NumCurs; /* number of cursors to rotate */
static short TickInterval; /* number of ticks between rotations */
static short CurCurs; /* index of current cursor */
static short LastTick; /* tick count at loast rotation */
static ModalFilterProcPtr Filter; /* dialog filter proc */
static short CancelItem; /* item number of cancel button */
/*______________________________________________________________________
utl_CenterDlogRect - Center a dialog rectangle.
Entry: rect = rectangle.
centerMain = true to center on main (menu bar) screen.
centerMain = false to center on the screen containing
the maximum intersection with the frontmost window.
Exit: rect = rectangle offset so that it is centered on
the specified screen, with twice as much space below
the rect as above.
See HIN 6.
_____________________________________________________________________*/
void utl_CenterDlogRect (Rect *rect, Boolean centerMain)
{
Rect screenRect; /* screen rectangle */
short mBHeight; /* menu bar height */
GDHandle gd; /* gdevice */
Rect windRect; /* window rectangle */
Boolean hasMB; /* true if screen contains menu bar */
mBHeight = utl_GetMBarHeight();
if (centerMain) {
screenRect = GetScreenBounds();
} else {
utl_GetWindGD(FrontWindow(), &gd, &screenRect, &windRect, &hasMB);
if (!hasMB) mBHeight = 0;
};
OffsetRect(rec
|