home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Simple Slideshow / ShowHideMenubar.c < prev    next >
Encoding:
Text File  |  1995-06-16  |  3.5 KB  |  124 lines  |  [TEXT/MMCC]

  1. // ShowHideMBar.c
  2. //
  3. // David Hayward 
  4. // Developer Technical Support
  5. // AppleLink: DEVSUPPORT
  6. //
  7. // Copyrite 1993, Apple Computer,Inc
  8. //
  9. // This file contains routines to sho/hide the
  10. // rounded corners in each monitor.
  11. // 
  12. // 12/10/93    david    first cut
  13.  
  14.  
  15. #include <QuickDraw.h>
  16. #include <LowMem.h>
  17.  
  18. #include "ShowHideUtils.h"
  19. #include "ShowHideMenubar.h"
  20.  
  21.  
  22. /**\
  23. |**| ==============================================================================
  24. |**| GLOBALS
  25. |**| ==============================================================================
  26. \**/
  27. short            gOldBarHgt = 20;
  28. short            gMBarState = SHOW;
  29. RgnHandle        mBarRgn;
  30.  
  31.  
  32. /**\
  33. |**| ==============================================================================
  34. |**| PRIVATE FUNCTION PROTOTYPES
  35. |**| ==============================================================================
  36. \**/
  37. void GetMBarRgn ( RgnHandle mBarRgn ) ;
  38.  
  39.  
  40. /**\
  41. |**| ==============================================================================
  42. |**| PUBLIC FUNCTIONS
  43. |**| ==============================================================================
  44. \**/
  45.  
  46.  
  47. /*------------------------------------------------------------------------------*\
  48.     SetMBarState
  49.  *------------------------------------------------------------------------------*
  50.         changes the menubar state to either SHOW or HIDE
  51. \*------------------------------------------------------------------------------*/
  52. void SetMBarState (char vis)
  53. {
  54.     static short    first = true;
  55.     RgnHandle        GrayRgn = LMGetGrayRgn();
  56.     
  57.     if (first)                                /* if its the 1st time called */
  58.     {
  59.         gOldBarHgt = GetMBarHeight();        /* remember the bar height */
  60.         first = false;
  61.     }
  62.     
  63.     if (vis == gMBarState)                    /* return if nothing would change */
  64.         return;
  65.         
  66.     if (!vis)                                /* if HIDE */
  67.     {
  68.         LMSetMBarHeight(0);                    /* make the Menu Bar's height zero */
  69.         
  70.         mBarRgn = NewRgn();
  71.         GetMBarRgn(mBarRgn);                /* make a region for the mbar */
  72.         UnionRgn(GrayRgn,mBarRgn,GrayRgn);    /* tell the desktop it covers the menu bar */
  73.  
  74.         SH_ForceUpdate(mBarRgn);
  75.     }
  76.     
  77.     else                                    /* if SHOW */
  78.     {
  79.         LMSetMBarHeight(gOldBarHgt);        /* make the menu bar's height normal */
  80.         
  81.         DiffRgn(GrayRgn, mBarRgn, GrayRgn);    /* remove the menu bar from the desktop  */
  82.         DisposeRgn(mBarRgn);                /* dispose to the bar region */
  83.         
  84.         DrawMenuBar();                        /* redraw the menu bar */
  85.     }
  86.     gMBarState = !gMBarState;                /* toggle the state */
  87. }
  88.  
  89.  
  90. /*------------------------------------------------------------------------------*\
  91.     GetMBarState
  92.  *------------------------------------------------------------------------------*
  93.         an accessor to allow others to read private gMBarState global
  94. \*------------------------------------------------------------------------------*/
  95. char GetMBarState (void)
  96. {
  97.     return gMBarState;
  98. }
  99.  
  100.  
  101. /**\
  102. |**| ==============================================================================
  103. |**| PRIVATE FUNCTIONS
  104. |**| ==============================================================================
  105. \**/
  106.  
  107.  
  108. /*------------------------------------------------------------------------------*\
  109.     GetMBarRgn
  110.  *------------------------------------------------------------------------------*
  111.         uses globals to calculate the region for the MenuBar
  112.         the RgnHandle mBarRgn must be allocated with NewRgn() before calling
  113. \*------------------------------------------------------------------------------*/
  114. void GetMBarRgn (RgnHandle mBarRgn)
  115. {
  116.     Rect            mBarRect;
  117.  
  118.     mBarRect = qd.screenBits.bounds;            /* create a rect for the mbar */
  119.     mBarRect.bottom = mBarRect.top + gOldBarHgt;
  120.     RectRgn(mBarRgn, &mBarRect);                /* make a region for the mbar */
  121. }
  122.  
  123.  
  124.