home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------
-
- HideShowMbar.c
-
- routine to hide or show the menu bar.
-
- ---------------------------------------------------------------*/
-
- #include "HideShowMbar.h"
- #include <Quickdraw.h>
- #include <LowMem.h>
-
- short gSavedMenuBarHeight = 20; // go default
-
- void HideShowMBAR(DoHide isDoHide)
- {
- RgnHandle grayRgnHandle, mbarRgnHandle;
- GDHandle theGDHandle;
- Rect modifiedScreenRect;
-
- theGDHandle = GetMainDevice();
- modifiedScreenRect = (*theGDHandle)->gdRect;
-
- if (isDoHide == eHide) { //then hide window
- //1) Save the gray region using LMGetGrayRgn();
- grayRgnHandle = LMGetGrayRgn();
- //2) Save the menubar region using LMGetMBarHeight() and RectRgn();
- mbarRgnHandle = NewRgn();
- SetRectRgn (mbarRgnHandle, 0, 0, modifiedScreenRect.right, LMGetMBarHeight() );
- gSavedMenuBarHeight = LMGetMBarHeight();
-
- //3) Set the menubar height to zero using LMSetMBarHeight()
- // see note below about saving height before setting it to zero
- LMSetMBarHeight(0);
- //4) Add the menubar region to the gray region using UnionRgn();
- UnionRgn (mbarRgnHandle, grayRgnHandle, grayRgnHandle );
- //5) Inval the old menu bar region with InvalRgn();
- InvalRgn( mbarRgnHandle ); //not sure if this will be necessary
- } else {
- //to restore the menubar -- Simply the reverse above.
-
- //1) Save the gray region using LMGetGrayRgn();
- grayRgnHandle = LMGetGrayRgn();
- //2) create new menubar region
- mbarRgnHandle = NewRgn();
- SetRectRgn (mbarRgnHandle, 0, 0, modifiedScreenRect.right, 20 );
- //3) Reset the menubar height
- //set to default Roman height--this won't work for non Roman Script systems
- //a better method is to save the mbar height from before you removed it
- //In that case, also use that height in the above line of code (replacing 20)
- LMSetMBarHeight(gSavedMenuBarHeight);
- //4) Remove the menubar region from the gray region
- DiffRgn (grayRgnHandle, mbarRgnHandle, grayRgnHandle );
- //5) Inval the old menu bar region with InvalRgn();
- InvalRgn( mbarRgnHandle ); //not sure if this will be necessary
- DrawMenuBar();
- } //end else
- }