home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-16 | 3.5 KB | 124 lines | [TEXT/MMCC] |
- // ShowHideMBar.c
- //
- // David Hayward
- // Developer Technical Support
- // AppleLink: DEVSUPPORT
- //
- // Copyrite 1993, Apple Computer,Inc
- //
- // This file contains routines to sho/hide the
- // rounded corners in each monitor.
- //
- // 12/10/93 david first cut
-
-
- #include <QuickDraw.h>
- #include <LowMem.h>
-
- #include "ShowHideUtils.h"
- #include "ShowHideMenubar.h"
-
-
- /**\
- |**| ==============================================================================
- |**| GLOBALS
- |**| ==============================================================================
- \**/
- short gOldBarHgt = 20;
- short gMBarState = SHOW;
- RgnHandle mBarRgn;
-
-
- /**\
- |**| ==============================================================================
- |**| PRIVATE FUNCTION PROTOTYPES
- |**| ==============================================================================
- \**/
- void GetMBarRgn ( RgnHandle mBarRgn ) ;
-
-
- /**\
- |**| ==============================================================================
- |**| PUBLIC FUNCTIONS
- |**| ==============================================================================
- \**/
-
-
- /*------------------------------------------------------------------------------*\
- SetMBarState
- *------------------------------------------------------------------------------*
- changes the menubar state to either SHOW or HIDE
- \*------------------------------------------------------------------------------*/
- void SetMBarState (char vis)
- {
- static short first = true;
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- if (first) /* if its the 1st time called */
- {
- gOldBarHgt = GetMBarHeight(); /* remember the bar height */
- first = false;
- }
-
- if (vis == gMBarState) /* return if nothing would change */
- return;
-
- if (!vis) /* if HIDE */
- {
- LMSetMBarHeight(0); /* make the Menu Bar's height zero */
-
- mBarRgn = NewRgn();
- GetMBarRgn(mBarRgn); /* make a region for the mbar */
- UnionRgn(GrayRgn,mBarRgn,GrayRgn); /* tell the desktop it covers the menu bar */
-
- SH_ForceUpdate(mBarRgn);
- }
-
- else /* if SHOW */
- {
- LMSetMBarHeight(gOldBarHgt); /* make the menu bar's height normal */
-
- DiffRgn(GrayRgn, mBarRgn, GrayRgn); /* remove the menu bar from the desktop */
- DisposeRgn(mBarRgn); /* dispose to the bar region */
-
- DrawMenuBar(); /* redraw the menu bar */
- }
- gMBarState = !gMBarState; /* toggle the state */
- }
-
-
- /*------------------------------------------------------------------------------*\
- GetMBarState
- *------------------------------------------------------------------------------*
- an accessor to allow others to read private gMBarState global
- \*------------------------------------------------------------------------------*/
- char GetMBarState (void)
- {
- return gMBarState;
- }
-
-
- /**\
- |**| ==============================================================================
- |**| PRIVATE FUNCTIONS
- |**| ==============================================================================
- \**/
-
-
- /*------------------------------------------------------------------------------*\
- GetMBarRgn
- *------------------------------------------------------------------------------*
- uses globals to calculate the region for the MenuBar
- the RgnHandle mBarRgn must be allocated with NewRgn() before calling
- \*------------------------------------------------------------------------------*/
- void GetMBarRgn (RgnHandle mBarRgn)
- {
- Rect mBarRect;
-
- mBarRect = qd.screenBits.bounds; /* create a rect for the mbar */
- mBarRect.bottom = mBarRect.top + gOldBarHgt;
- RectRgn(mBarRgn, &mBarRect); /* make a region for the mbar */
- }
-
-
-