[comp.sys.mac] How to print things on menu bar

pwu@uwmacc.UUCP (Peter Wu) (01/24/87)

How can I print things (e.g. numbers) on the menu bar (at the
right side where it's not being used) and be able to update it
frequently (creating and destroying null menus are too much
overhead)?

This is only to be part of an application so there's no need to make
this routine permanent.

Sample code (any language) and/or discussion on what routines to
use would be very helpful.

peter
/*
** ARPA: pwu@unix.macc.wisc.edu              BITNET: WU at WISVMACC
** UUCP: {seismo|harvard|topaz|caip|ll-xn|                      <-+   
**        allegra|akgua|ucbvax|bellcore|ihnp4}!uwvax!uwmacc!pwu   |
**                                                                |
**   Uuhosts on this line may have faster delivery time.  --------+
*/

postman#@andrew.cmu.edu.UUCP (01/27/87)

ReSent-To:nntp-xmit#@andrew.cmu.edu
Return-path: <jv0l#@andrew.cmu.edu>
X-Andrew-Authenticated-as: 1752
To: outnews#ext.nn.comp.sys.mac@andrew.cmu.edu
Newsgroup: comp.sys.mac

Probably the easiest way to go about doing this would be to call the
getWMgrPort procedure which gives you a grafPtr to the screen.  This grafPtr
can be used to draw on the menu bar or on the desktop.  I have used this port
to make balls bounce around the desktop behind the windows.

Code would look something like this:

----
procedure giveMessage(what:str255);

  var
    oldPort,
    mgrPort: grafPtr;

  begin
    getPort(oldPort);
    getWMgrPort(mgrPort); {See window manager for details}
    setPort(mgrPort);
    moveTo(400,20); {or wherever}
    drawString(what);
    setPort(oldPort);
  end;
----
Justin
arpa: jv0l@andrew.cmu.edu

dalea@fai.UUCP (01/27/87)

In article <938@uwmacc.UUCP> pwu@uwmacc.UUCP (Peter Wu) writes:
>How can I print things (e.g. numbers) on the menu bar...

(much deleted)

The simplest method that I know of is to 1) save the current port, 2) set
the port to Window Manager Port, 3) position the cursor near the top and
write using Quickdraw.  The Window Manager Port is the entire screen
(unless your program has changed it) and is addressed as any other GrafPort.

Once you have written to the location that corresponds to the menu bar,
reset the current port to the previously saved port (i.e. your window).

Oh yes, any routine that redraws the menu bar will wipe out what you've 
written to the bar so it will need to be redone.

As a debug routine, try printing and erasing a number in the bar for
entry and exits from a loop.  Sure shows up slow areas of code!
 


-- 
--
		Dale M. Arends  (Fujitsu America Inc., San Jose, Calif.)
		seismo!amdahl!fai!dalea  -or-  ihnp4!pesnta!fai!dalea

The opinions expressed herein do not necessarily reflect those of my employer.
They are entirely my own if they make sense and I disavow them if they don't.