[comp.sys.mac.programmer] Centering Alerts

lipa@POLYA.STANFORD.EDU (William Lipa) (06/18/88)

Why isn't there any easy way to center alerts on both a Mac II and a regular
Mac? The ALRT resource had sufficient power when all Macs had the same screen
size, but now it needs updating. It should have a bit that represents whether
or not you want the Alert Manager to center the alert on the active window's
screen.

There are many examples of rough spots in the Mac operating system such as
this. Apple does a good job refining and enhancing the Mac interface from a
user's point of view, but life is getting increasingly difficult for the
programmer.

Without easier ways of doing things, programs will tend to implement less and
less of the user interface guidelines. Ultimately the users will suffer as
programs become less consistent.

Bill Lipa
lipa@polya.stanford.edu

dorourke@polyslo.UUCP (David O'Rourke) (06/19/88)

  It's not very difficult to implment a routine to do this, I have!  I have
a call called "CenterNewDialog" which takes the same parameters as GetNewDialog
but it centers the dialog before returning to the caller.  I think it's about 
8 - 12 lines of pascal.

  I don't really think it's a rough spot on the Mac's OS.  It's such a simple
routine I don't think it warrents ROM space.
-- 
David M. O'Rourke

Disclaimer: I don't represent the school.  All opinions are mine!

sho@tybalt.caltech.edu (Sho Kuwamoto) (06/20/88)

In article <3222@polyslo.UUCP> dorourke@polyslo.UUCP (David O'Rourke) writes:
>
>  It's not very difficult to implment a routine to do this, I have!  I have
>a call called "CenterNewDialog" which takes the same parameters as GetNewDialog
>but it centers the dialog before returning to the caller.  I think it's about 
>8 - 12 lines of pascal.
>
>  I don't really think it's a rough spot on the Mac's OS.  It's such a simple
>routine I don't think it warrents ROM space.
>-- 
>David M. O'Rourke

What happens when there is more than one screen?  Programmers may have
different ideas about how to deal with this, and other questions,
which leads inevitably to a less consistent user interface.  

BTW, is there some compelling reason why SF(Get/Put)File use regular
windows instead of color ones on a Mac II?  Maybe you need it to
insure that it works with modified SF dialog boxes.  I have never
actually put custom fields into the SF dialog box, and I don't have my
Inside Mac handy with me, but I'm assuming that the OS should be able
to tell whether or not the user has changed something...  The upshoot
of all of this is that when I use all 256 colors, they have to be
swapped out to make room for the old style QD colors.

-Sho
 (sho@tybalt.caltech.edu, sho@caltech.bitnet, ...!cit-vax!tybalt!sho)

tim@ism780c.isc.com (T.W."Tim" Smith, Knowledgian) (06/21/88)

Where should alerts be put on a multi-screen system?

I can think of several possibilities:

	1.	Same screen as menu bar

	2.	Same screen as active window

	3.	Same screen mouse is in

	4.	"center" of total desktop

	5.	Just put it anywhere, and beep a lot so the
		user knows there is one, and let him look
		for it :-)
-- 
Tim Smith				tim@ism780c.isc.com
"I don't practice what I preach because I'm not the
                       kind of person I'm preaching to" -- J.R. "Bob" Dobbs

conybear@moncsbruce.oz (Roland Conybeare) (07/04/88)

From article <10779@ism780c.isc.com>, by tim@ism780c.isc.com (T.W."Tim" Smith, Knowledgian):
> I can think of several possibilities:
> 
> 	1.	Same screen as menu bar
> 	2.	Same screen as active window
> 	3.	Same screen mouse is in
> 	4.	"center" of total desktop
> 	5.	Just put it anywhere, and beep a lot so the
> 		user knows there is one, and let him look
> 		for it :-)

How about 6. One copy of  the alert in each screen.

Roland Conybeare
conybear@moncsbruce.oz

rdd@walt.cc.utexas.edu (Robert Dorsett) (12/16/89)

Is there an elegant (i.e., easy) way to center *alerts* on a screen?  I mean, 
apart from writing an alert-simulator?




Robert Dorsett                                   
Internet: rdd@rascal.ics.utexas.edu               
UUCP: ...cs.utexas.edu!rascal.ics.utexas.edu!rdd  

pratt@boulder.Colorado.EDU (Jonathan Pratt) (12/16/89)

In article <22417@ut-emx.UUCP> rdd@walt.cc.utexas.edu (Robert Dorsett) writes:
>Is there an elegant (i.e., easy) way to center *alerts* on a screen?  I mean, 
>apart from writing an alert-simulator?
>
>
>
>
>Robert Dorsett                                   
>Internet: rdd@rascal.ics.utexas.edu               
>UUCP: ...cs.utexas.edu!rascal.ics.utexas.edu!rdd  

/* Center a rectangle in middle of main screen. */
static void CenterRect(r)
register Rect *r;                                        
{                                         
int h,v;                                                                        
        OffsetRect(r,
                screenBits.bounds.left + screenBits.bounds.right - r->left-r->ri
ght >> 1,                                    
                screenBits.bounds.top + screenBits.bounds.bottom - r->top -r->bo
ttom >> 1 );
}                                                                             
                                                                              
int StdAlert(theID)                    
int theID;                   
{                    
AlertTHndl a;        
        if ( a=(AlertTHndl)GetResource('ALRT',theID) ) {
                CenterRect(&(**(a)).boundsRect);                                
                return Alert(theID,MyFilter);
        }
        SysBeep(0);
        return(OK);
}

Something like this has worked for me.

Jonathan

/* Jonathan Pratt          Internet: pratt@boulder.colorado.edu     *
 * Campus Box 525              uucp: ..!{ncar|nbires}!boulder!pratt *
 * University of Colorado                                           *
 * Boulder, CO 80309          Phone: (303) 492-4293                 */

wdh@well.UUCP (Bill Hofmann) (12/18/89)

In article <22417@ut-emx.UUCP> rdd@walt.cc.utexas.edu (Robert Dorsett) writes:
>Is there an elegant (i.e., easy) way to center *alerts* on a screen?  I mean, 
>apart from writing an alert-simulator?
Sure.  Read the ALRT resource into memory and manipulate the rectangle, being
sure to make it non-purgeable, then call Alert.  The Dialog Manager just does
a GetResource, so it'll find the resource you've read into memory and use
the bounding rect you've stuffed.

There's even a data type: AlertTemplate (IM I-423).  I use this method
extensively, on DLOGs as well (especially standard file).

-Bill

6500stom@hub.UUCP (12/18/89)

From article <15078@well.UUCP>, by wdh@well.UUCP (Bill Hofmann):
> In article <22417@ut-emx.UUCP> rdd@walt.cc.utexas.edu (Robert Dorsett) writes:
>>Is there an elegant (i.e., easy) way to center *alerts* on a screen?  I mean, 
>>apart from writing an alert-simulator?
> Sure.  Read the ALRT resource into memory and manipulate the rectangle, being
> sure to make it non-purgeable, then call Alert.  The Dialog Manager just does
> a GetResource, so it'll find the resource you've read into memory and use
> the bounding rect you've stuffed.
> 
> There's even a data type: AlertTemplate (IM I-423).  I use this method
> extensively, on DLOGs as well (especially standard file).

Also, be sure not to _center_ alerts, put them 1/3 of the way down
(measuring from the bottom of the menu bar to the bottom of the main
screen).  Center them left to right though, of course.

/            Josh Pritikin             T Ignorance is bliss.           \
| Internet:  6500stom@ucsbuxa.ucsb.edu | I must be in hell.            |
| AppleLink: Josh.P                    | My room is proof that entropi |
\ GEnie:     J.Pritikin                ! exists.                       /