home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright © 1994 Demos, inc.
- Written by: Dmitry Boldyrev
- */
-
- #include "utils.h"
-
- RgnHandle gOldVisRgn = NULL;
-
- void CenterRect(Rect srcRect, Rect* dstRect)
- {
- short width = (dstRect->right - dstRect->left);
- short height = (dstRect->bottom - dstRect->top);
-
- dstRect->left = srcRect.left + (((srcRect.right - srcRect.left) / 2) - (width / 2));
- dstRect->top = srcRect.top + (((srcRect.bottom - srcRect.top) / 2) - (height / 2));
- dstRect->right = dstRect->left + width;
- dstRect->bottom = dstRect->top + height;
- }
-
-
- void HideMenuBar(GrafPtr grafPort)
- {
- RgnHandle newVisRgn;
- GrafPtr savePort;
-
- GetPort(&savePort);
- SetPort(grafPort);
-
- // save off vis region
- gOldVisRgn = NewRgn();
- CopyRgn(grafPort->visRgn, gOldVisRgn);
-
- // expand the vis region to the port rect
- newVisRgn = NewRgn();
- RectRgn(newVisRgn, &grafPort->portRect);
- CopyRgn(newVisRgn, grafPort->visRgn);
- DisposeRgn(newVisRgn);
-
- SetPort(savePort);
- }
-
- void ShowMenuBar(GrafPtr grafPort)
- {
- GrafPtr savePort;
- RgnHandle junkRgn;
-
- GetPort(&savePort);
- SetPort(grafPort);
-
- // fill the rounded corners of the screen with black again
- junkRgn = NewRgn();
- CopyRgn(gOldVisRgn, junkRgn);
- DiffRgn(grafPort->visRgn, junkRgn, junkRgn);
-
- #ifdef dangerousPattern
- FillRgn(junkRgn, qd.black);
- #else
- FillRgn(junkRgn, &qd.black);
- #endif
-
- DisposeRgn(junkRgn);
-
- // restore the old vis region
- CopyRgn(gOldVisRgn, grafPort->visRgn);
- DisposeRgn(gOldVisRgn);
- gOldVisRgn = NULL;
-
- DrawMenuBar();
- }
-
- CGrafPtr CreateWindow(Rect *tempR, Str255 title, short win_type, long app_handle)
- {
- short mbarheight = GetMBarHeight();
- CGrafPtr wintemp;
-
- // if ( ( tempR->top < mbarheight ) && !gMenuBarHidden )
- // HideMenuBar();
-
- wintemp = (CWindowPtr)NewCWindow( nil, tempR, title, true, win_type, (WindowPtr)-1, false, app_handle );
- return( wintemp );
-
- }
-