Path: utzoo!attcan!uunet!mcvax!guido From: guido@cwi.nl (Guido van Rossum) Newsgroups: comp.sys.mac.programmer Subject: Re: What can you assume about the current port? Message-ID: <314@piring.cwi.nl> Date: 11 May 88 11:33:40 GMT References: <2799@polya.STANFORD.EDU> <1654@pt.cs.cmu.edu> Reply-To: guido@cwi.nl (Guido van Rossum) Organization: The Royal Society for Prevention of Cruelty to Amoebae Lines: 35 In article <1654@pt.cs.cmu.edu> dtw@f.gp.cs.cmu.edu (Duane Williams) writes: >I don't know what the current Apple dogma is regarding the User Interface >Guidelines, but an early version of the Guidelines said that "the user >should feel in control of the computer." Selecting the active window (by >clicking in it) is supposed to be the prerogative of the user and is one of >the ways of making the user "feel in control" of the machine. You are answering a different question. This is comp.sys.mac.PROGRAMMER: the question was about the 'current grafport', which is where quickdraw calls (by definition) will draw. It has nothing to do with the active window; e.g., while repainting a window you have to (temporarily) make it the current grafport, but of course that doesn't pop up its window. To answer the right question: unless you want to fix the alarm clock and distribute it with your program, you'll have to be conservative. Yes, it's a pain. But there are only a few cases you have to worry about. Inside Mac Volume I (is that volume still relevant? :-) says very clearly (somewhere at the beginning ofthe QuickDraw chapter) that *all* toolbox calls save and restore the port. This means that if the application sets the port, it'll in general stay set. Most toolbox routines also don't care what the port is set to when they are entered: the set it explicitly to the window in which they want to draw (unless by definition they draw in the current port, of course). There's one exception: ZoomWindow crashes spectacularly when the current port doesn't match the window. (I think this was a bug which was discovered too late, so they "fixed" it by putting a warning in Inside Mac IV). So, you don't have to be afraid that the toolbox changes the current port. For DA's, I think you are safe except just after an OpenDeskAcc; I believe that when a DA reveices a Control call the Device Mgr saves, sets and restores the port (but I haven't got my documentation handy). -- Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam guido@piring.cwi.nl or mcvax!piring!guido or guido%piring.cwi.nl@uunet.uu.net