[comp.sys.mac.programmer] window madness

yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (09/29/89)

Hi y'all. Riddle me this. I have an onscreen window. I have
a routine that draws a selection rect within that window, 
(FrameRects xoring a rect on and off).

For reasons too involved to bother you with, I will want the
selection rect to not be confined to the window's clipping
region. I want the user to allow this "selection rect" to
be drawn anywhere on the screen, on top of the desktop,
everthing! 

What exactly need I do? Change both the clipRgn & visRgn to
the screen boundaries temporarily, (didn't work 1st time thru)?
More? Less? Thanks!

>>>      Internet: yahnke@macc.wisc.edu        <<<
>>>   Mille voix chuchottent <<c'est vrai>>    <<<

jackiw@cs.swarthmore.edu (Nick Jackiw) (10/04/89)

In article <2485@dogie.macc.wisc.edu> yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) writes:
> For reasons too involved to bother you with, I will want the
> selection rect to not be confined to the window's clipping
> region. I want the user to allow this "selection rect" to
> be drawn anywhere on the screen, on top of the desktop,
> everthing! 
> >>>      Internet: yahnke@macc.wisc.edu        <<<

You can use GetWMgrPort (WindowManager chapter, IM-1) to get a GrafPtr to
the window-manager port, which contains all visible screen real estate
(or multiple screen realty, if you have the luxury). Then you'd SetPort to
this before drawing, and repeatedly (WMgr)LocalToGlobal and GlobalTo(your-
port)Local coordinates between the two ports.

Note that drawing in the WMgrPort is officially forbidden.  If you do it
entirely in XOR, winding up with the same screen you started with, and
*don't return to your event loop* before finishing, you can probably
get away with it though.  (During your event loop, Multifinder or a DA
or the Notification Manager might do some window drawing of their own
and screw up your XORing and your screen picture.)



-- 
     _  _|\____    Nick Jackiw | Visual Geometry Project | Math Department
   / /_/   O>  \   ------------+-------------------------+ Swarthmore College
   |       O>   |  215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
    \_Guernica_/   ------------+-------------------------+                 USA

lippin@wish-bone.berkeley.edu (The Apathist) (10/05/89)

Recently jackiw@ilium (Nick Jackiw) wrote:

>You can use GetWMgrPort (WindowManager chapter, IM-1) to get a GrafPtr to
>the window-manager port, which contains all visible screen real estate
>(or multiple screen realty, if you have the luxury). Then you'd SetPort to
>this before drawing, and repeatedly (WMgr)LocalToGlobal and GlobalTo(your-
>port)Local coordinates between the two ports.

A number of very strange occurances while trying this sort of thing
have convinced that Apple means it when they say "If you touch the
window manager port, you die."

A safer way is to make your own port, using OpenPort.  This gives you
the whole screen to play with, and you don't have to worry about the
system depending on the port's fields in some obscure way.

Again, do put the screen back the way you found it before letting
other programs get any time; they aren't expecting to have their
windows stomped on.

Finally, there is a tech note on this subject; it would be best to
read it before trying any of this.

					--Tom Lippincott
					  lippin@math.berkeley.edu

	"Thank you for observing all saftey precautions."
					--Dark Star

pepke@loligo (Eric Pepke) (10/05/89)

In article <1989Oct4.184445.4500@agate.berkeley.edu> lippin@math.berkeley.edu writes:
>A safer way is to make your own port, using OpenPort.  This gives you
>the whole screen to play with, and you don't have to worry about the
>system depending on the port's fields in some obscure way.
...
>Finally, there is a tech note on this subject; it would be best to
>read it before trying any of this.

Tech note 194.  Basically you declare a port, open it with OpenPort, and set
its visRgn to the return value of GetGrayRgn and its portRect to the bounds
of the region.

That's roughly what it says, anyway.

Eric Pepke                                     INTERNET: pepke@gw.scri.fsu.edu
Supercomputer Computations Research Institute  MFENET:   pepke@fsu
Florida State University                       SPAN:     scri::pepke
Tallahassee, FL 32306-4052                     BITNET:   pepke@fsu

Disclaimer: My employers seldom even LISTEN to my opinions.
Meta-disclaimer: Any society that needs disclaimers has too many lawyers.