home *** CD-ROM | disk | FTP | other *** search
- #include <Types.h>
- #include <QuickDraw.h>
- #include <Windows.h>
- #include <LowMem.h>
- #include <Menus.h>
- #include "BSDMenubarLib.h"
-
- static short save_mbar;
- static RgnHandle mBarRgn, crnrRgn;
- static Boolean mBarHidden;
- static Boolean crnrHidden;
-
- void UpdateScreen (RgnHandle rgn);
- void GetMBarRgn (RgnHandle mbarRgn);
- void GetCornerRgn (RgnHandle crnrRgn);
- void ShowMB (void);
- void HideMB (void);
- void ShowCorners (void);
- void HideCorners (void);
-
- void UpdateScreen (RgnHandle rgn) {
- WindowRef wpFirst;
-
- wpFirst = LMGetWindowList();
- PaintBehind(wpFirst, rgn);
- CalcVisBehind(wpFirst, rgn);
- }
-
- void GetMBarRgn (RgnHandle mbarRgn) {
- Rect mBarRect;
-
- mBarRect = qd.screenBits.bounds;
- mBarRect.bottom = mBarRect.top + save_mbar;
- RectRgn(mBarRgn, &mBarRect);
- }
-
- void ShowMB (void) {
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- if (mBarHidden == false) return;
-
- LMSetMBarHeight(save_mbar);
- DiffRgn(GrayRgn, mBarRgn, GrayRgn);
- DisposeRgn(mBarRgn);
- DrawMenuBar();
- mBarHidden = false;
- }
-
- void HideMB (void) {
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- if (mBarHidden == true) return;
-
- save_mbar = GetMBarHeight();
- LMSetMBarHeight(0);
- mBarRgn = NewRgn();
- GetMBarRgn(mBarRgn);
- UnionRgn(GrayRgn, mBarRgn, GrayRgn);
- UpdateScreen(mBarRgn);
- mBarHidden = true;
- }
-
- void GetCornerRgn (RgnHandle crnrRgn) {
- Rect mBarRect;
- RgnHandle tmpRgn;
- RgnHandle GrayRgn = LMGetGrayRgn();
- GDHandle gDevice;
-
- tmpRgn = NewRgn();
- gDevice = GetDeviceList();
- while (gDevice != nil) {
- RectRgn(tmpRgn, &(**gDevice).gdRect);
- UnionRgn(crnrRgn,tmpRgn,crnrRgn);
- gDevice = GetNextDevice(gDevice);
- }
- DiffRgn(crnrRgn,GrayRgn,crnrRgn);
- mBarRect = qd.screenBits.bounds;
- mBarRect.bottom = mBarRect.top + 20;
- RectRgn(tmpRgn, &mBarRect);
- DiffRgn(crnrRgn,tmpRgn,crnrRgn);
- DisposeRgn(tmpRgn);
- }
-
- void ShowCorners (void) {
- RgnHandle GrayRgn = LMGetGrayRgn();
- GrafPtr savePort;
-
- if (crnrHidden == false) return;
-
- GetPort(&savePort);
- SetPort(LMGetWMgrPort());
- SetClip(crnrRgn);
- FillRgn(crnrRgn, &(qd.black));
- SetPort(savePort);
- DiffRgn(GrayRgn, crnrRgn, GrayRgn);
- DisposeRgn(crnrRgn);
- crnrHidden = false;
- }
-
- void HideCorners (void) {
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- if (crnrHidden == true) return;
-
- crnrRgn = NewRgn();
- GetCornerRgn(crnrRgn);
- UnionRgn(GrayRgn,crnrRgn,GrayRgn);
- UpdateScreen(crnrRgn);
- crnrHidden = true;
- }
-
- void ShowMenuBar (void) {
- ShowMB();
- ShowCorners();
- }
-
- void HideMenuBar (void) {
- HideMB();
- HideCorners();
- }