home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / BSDMenubarLib 1.0 / BSDMenubarLib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-03  |  2.4 KB  |  120 lines  |  [TEXT/CWIE]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Windows.h>
  4. #include <LowMem.h>
  5. #include <Menus.h>
  6. #include "BSDMenubarLib.h"
  7.  
  8. static short        save_mbar;
  9. static RgnHandle    mBarRgn, crnrRgn;
  10. static Boolean        mBarHidden;
  11. static Boolean        crnrHidden;
  12.  
  13. void UpdateScreen (RgnHandle rgn);
  14. void GetMBarRgn (RgnHandle mbarRgn);
  15. void GetCornerRgn (RgnHandle crnrRgn);
  16. void ShowMB (void);
  17. void HideMB (void);
  18. void ShowCorners (void);
  19. void HideCorners (void);
  20.  
  21. void UpdateScreen (RgnHandle rgn) {
  22. WindowRef    wpFirst;
  23.  
  24.     wpFirst = LMGetWindowList();
  25.     PaintBehind(wpFirst, rgn);
  26.     CalcVisBehind(wpFirst, rgn);
  27. }
  28.  
  29. void GetMBarRgn (RgnHandle mbarRgn) {
  30. Rect    mBarRect;
  31.     
  32.     mBarRect = qd.screenBits.bounds;
  33.     mBarRect.bottom = mBarRect.top + save_mbar;
  34.     RectRgn(mBarRgn, &mBarRect);
  35. }
  36.  
  37. void ShowMB (void) {
  38. RgnHandle    GrayRgn = LMGetGrayRgn();
  39.  
  40.     if (mBarHidden == false) return;
  41.     
  42.     LMSetMBarHeight(save_mbar);
  43.     DiffRgn(GrayRgn, mBarRgn, GrayRgn);
  44.     DisposeRgn(mBarRgn);
  45.     DrawMenuBar();
  46.     mBarHidden = false;
  47. }
  48.  
  49. void HideMB (void) {
  50. RgnHandle    GrayRgn = LMGetGrayRgn();
  51.  
  52.     if (mBarHidden == true) return;
  53.     
  54.     save_mbar = GetMBarHeight();
  55.     LMSetMBarHeight(0);
  56.     mBarRgn = NewRgn();
  57.     GetMBarRgn(mBarRgn);
  58.     UnionRgn(GrayRgn, mBarRgn, GrayRgn);
  59.     UpdateScreen(mBarRgn);
  60.     mBarHidden = true;
  61. }
  62.  
  63. void GetCornerRgn (RgnHandle crnrRgn) {
  64. Rect        mBarRect;
  65. RgnHandle    tmpRgn;
  66. RgnHandle    GrayRgn = LMGetGrayRgn();
  67. GDHandle    gDevice;
  68.  
  69.     tmpRgn = NewRgn();                            
  70.     gDevice = GetDeviceList();
  71.     while (gDevice != nil) {
  72.         RectRgn(tmpRgn, &(**gDevice).gdRect);
  73.         UnionRgn(crnrRgn,tmpRgn,crnrRgn);
  74.         gDevice = GetNextDevice(gDevice);
  75.     }
  76.     DiffRgn(crnrRgn,GrayRgn,crnrRgn);
  77.     mBarRect = qd.screenBits.bounds;
  78.     mBarRect.bottom = mBarRect.top + 20;
  79.     RectRgn(tmpRgn, &mBarRect);
  80.     DiffRgn(crnrRgn,tmpRgn,crnrRgn);
  81.     DisposeRgn(tmpRgn);
  82. }
  83.  
  84. void ShowCorners (void) {
  85. RgnHandle    GrayRgn = LMGetGrayRgn();
  86. GrafPtr        savePort;
  87.  
  88.     if (crnrHidden == false) return;
  89.     
  90.     GetPort(&savePort);
  91.     SetPort(LMGetWMgrPort());
  92.     SetClip(crnrRgn);
  93.     FillRgn(crnrRgn, &(qd.black));
  94.     SetPort(savePort);
  95.     DiffRgn(GrayRgn, crnrRgn, GrayRgn);
  96.     DisposeRgn(crnrRgn);
  97.     crnrHidden = false;
  98. }
  99.  
  100. void HideCorners (void) {
  101. RgnHandle    GrayRgn = LMGetGrayRgn();
  102.  
  103.     if (crnrHidden == true) return;
  104.     
  105.     crnrRgn = NewRgn();
  106.     GetCornerRgn(crnrRgn);
  107.     UnionRgn(GrayRgn,crnrRgn,GrayRgn);
  108.     UpdateScreen(crnrRgn);
  109.     crnrHidden = true;
  110. }
  111.  
  112. void ShowMenuBar (void) {
  113.     ShowMB();
  114.     ShowCorners();
  115. }
  116.  
  117. void HideMenuBar (void) {
  118.     HideMB();
  119.     HideCorners();
  120. }