[comp.sys.mac.programmer] Drawing all over the desktop

larsen@ginger.princeton.edu (Michael Larsen) (06/29/90)

I know that Apple doesn't want applications to draw all over the desktop.
Since I'm doing it anyway, though, I need advice in order to do it as cleanly 
as possible.  At the moment I'm checking screen depth and writing into video 
memory, but I would prefer a quickdraw solution.

THE PROBLEM:  Before you open any windows, you can draw freely on the desktop.
Once you open a window, however, all quickdrawing is clipped to its structure 
region. 

WHAT DOESN'T WORK:  I've tried (temporarily) setting WindowList to 0.
I've tried setting the strucRgn of the window to a screen-sized rectangle.
I've traced LineTo with MacsBugs to see where it finds the window dimension,
but the memory location doesn't seem to correspond to any of my global
variables or any low-memory global I know about.

This is a very basic quickdraw question, but none of the documentation I have
(Inside Macintosh, Tech Notes) seems to address it.  Anyone know the answer?

						-Michael Larsen

larsen@ginger.princeton.edu (Michael Larsen) (06/30/90)

In article <995@idunno.Princeton.EDU> larsen@ginger.Princeton.EDU (Michael Larsen) writes:
>
>THE PROBLEM:  Before you open any windows, you can draw freely on the desktop.
>Once you open a window, however, all quickdrawing is clipped to its structure 
>region. 

Thanks to all the people who replied, and enough already!  The answers
I received suggested two approaches.  One was to set thePort to DeskPort,
as documented in IM I.  Unfortunately, I can't find DeskPort in the index of my
copy of Inside Macintosh, nor is it defined in any of the obvious .h
files in Think C 3.0, so I can't comment on this approach.  The second 
suggestion was to change the *clipRgn* of thePort.  Apparently, 
NewWindow sets the clipRgn of the WMgrPort to the structure 
region of the newborn window.  Set the clipRgn to screenBits.bounds, 
and you can tromp all over the complement of the menu bar at will.

Thanks again to those who responded.

						-Michael Larsen

h+@nada.kth.se (06/30/90)

larsen@ginger.Princeton.EDU writes:
---
I know that Apple doesn't want applications to draw all over the desktop.
Since I'm doing it anyway, though, I need advice in order to do it as cleanly
as possible.  At the moment I'm checking screen depth and writing into video
memory, but I would prefer a quickdraw solution.
---

The stuff to do is drawing into the WMgrPort. This is as
compatible as it gets, though that isn't very. You have
to be VERY careful to restore everything as it was before
you call {Get/Wait}NextEvent. This means ony XORing, among
other things. (Well, if it's a game and you don't want it
to be MF compatible nor System 7 compatible, you don't have
to restore the drawings, just the state of the WMgrPort)

I have written an INIT that, among other things, needs to draw
in the WMgrPort, called SetWindow INIT. The source and the
init is available via FTP from rascal.ics.utexas.edu, and is
in the directory mac/hacking (if memory serves me right,
might be programming or somewhere completely else...)

Generally, it is a VERY BAD idea to draw outside of windows.
Only newly-converted MS-DOS programmers try and do this
without a good reason. (And I mean GOOD)

Happy hacking,

						h+