home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!hp-cv!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sr0o+
- From: sr0o+@andrew.cmu.edu (Steven Ritter)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Removing the menubar?
- Message-ID: <kePQOia00WBM04mmoS@andrew.cmu.edu>
- Date: 22 Jul 92 12:35:58 GMT
- References: <1992Jul21.201452.23920@nic.umass.edu>
- <1992Jul22.115153.20732@uswmrg.mrg.uswest.com.mrg.uswest.com>
- Organization: Doctoral student, Psychology, Carnegie Mellon, Pittsburgh, PA
- Lines: 93
- In-Reply-To: <1992Jul22.115153.20732@uswmrg.mrg.uswest.com.mrg.uswest.com>
-
- >In article <1992Jul21.201452.23920@nic.umass.edu> not in use,
- >wonko@titan.ucc.umass.edu writes:
- >>I am writing a program for a client that is VERY unmac in its operation
- >>and I need to remove the MenuBar from the screen. I am Using Lightspeed
- >>pascal 4.0 and have looked in all the inside macss as well as my other
- >>normal sources.
- >
- >First, I assume that the program is interactive? Just a guess, don't
- >InitMenus() in the first place. No?
- >
- >But why? Do they find menus offensive? Did they have a traumatic
- >experience with a menu as a child, or do they just want to remove
- >access to them to the user? What about when you are running
- >Multifinder/Sys7? I think there are a million questions that will
- >pop up here. Would it be sufficient just to have the Apple, File, and
- >Edit menus there? They wouldn't have to be functional, just stub in
- >the MenuChoice() code, and don't do anything after MenuSelect().
-
- Yeesh, we could all do without the lecture. The original poster said the
- program was "VERY unmac" so why not assume he had a good reason for it
- to be so? I've written a number of psychology experiments that hide the
- menubar because:
- 1. I need the extra screen real estate
- 2. It's visual distracting (for some tasks)
- 3. I would prefer that my subjects do the experiment rather than
- playing Tetris
-
- Anyway, here's the code:
-
- /*Code to hide the menubar*/
- /*Taken from the Usenet Mac Programmer's guide, page 258-260*/
- /*Call remove_menubar, passing a RgnHandle to hold the desktop region*/
- /*The function returns the height of the menubar*/
- /*Call restore_menubar to return everything to normal*/
-
-
- void SetMBarHeight(int newheight) {
- MBarHeight = newheight; /*MBarHeight is a low-mem global*/
- } /*It may not be supported in the future*/
-
-
- /*remove_menubar removes the menubar and adjusts the desktop*/
- /* so that the menu is gone*/
- /*It returns the original height of the menubar and sets gray_rgn to
- the*/ /*original gray region */
-
- int remove_menubar (RgnHandle gray_rgn) {
- int old_height;
- RgnHandle newgray_region;
- Rect newgray_rect;
-
- old_height = GetMBarHeight();
- SetMBarHeight(0); /*shrink menubar to 0*/
-
- newgray_region = NewRgn();
- CopyRgn(GetGrayRgn(),gray_rgn);
- SetRect(&newgray_rect,screenBits.bounds.left,screenBits.bounds.top,
- screenBits.bounds.right,screenBits.bounds.bottom);
- RectRgn(newgray_region,&newgray_rect);
- CopyRgn(newgray_region,GetGrayRgn());
- PaintOne((WindowPeek)0L,newgray_region);/*update desktop over menubar rgn*/
- CalcVis((WindowPeek)0L);
-
- DisposeRgn(newgray_region);
- return old_height;
- }
-
- /*restore_menubar puts it back*/
- void restore_menubar(int mbarheight,RgnHandle gray_rgn) {
- RgnHandle current_region;
- Rect mbarrect;
- RgnHandle mbar_region;
- WindowPeek front;
-
- SetRect(&mbarrect,screenBits.bounds.left,screenBits.bounds.top,
- screenBits.bounds.right,screenBits.bounds.top+mbarheight);
- mbar_region = NewRgn();
- RectRgn(mbar_region,&mbarrect);
- current_region = NewRgn();
- SetMBarHeight(mbarheight);
- CopyRgn(GetGrayRgn(),current_region);
- CopyRgn(gray_rgn,GetGrayRgn());
- front = (WindowPeek)FrontWindow();
- CalcVis(front);
- CalcVisBehind(front,mbar_region);
- CalcVisBehind(front,current_region);
- HiliteMenu(0);
- DrawMenuBar();
- DisposeRgn(current_region);
- DisposeRgn(mbar_region);
- }
-
- /*Steve*/
-