[comp.sys.mac.programmer] LightSpeed C query

charles@tasis.utas.oz (Charles Lakos) (05/11/88)

In writing a DA using LightSpeed C version 2.13, I was continually frustrated 
by not having global variables documented in Inside MacIntosh properly 
initialised.  Variables such as screenBits, and patterns such as black, 
dkGray, etc were accessible but not initialised.  What is going on?

Is there anything special I have to be wary of in changing my DA to an INIT?

Charles Lakos.

ACSnet: charles@tasis.utas.oz
ARPA:   charles%tasis.utas.oz@uunet.uu.net
UUCP:   {enea,hplabs,mcvax,uunet,ukc}!munnari!tasis.utas.oz!charles
Snail:  Information Science Dept., University of Tasmania,
	GPO Box 252C, Hobart, TAS, 7001, Australia.

rs4u+@andrew.cmu.edu (Richard Siegel) (05/13/88)

Because Desk Accessories use A4 as the base for globals, instead of A5, the
QuickDraw globals will not be initialized properly. You should not use
QuickDraw globals from a desk accessory or device driver, for this reason.

If you need ScreenBits.bounds, the easy way to do it from a DA is to use
OpenPort to open a new Grafport; that GrafPort's portRect is equal to
screenBits.

As far as the patterns are concerned, you can use GetIndPattern() to get these
patterns from the standard system pattern list.


        -Rich

Rich Siegel
THINK Technologies

shane@pepe.cc.umich.edu (Shane Looker) (05/14/88)

In article <0WWkiAy00XcP0GR2Yn@andrew.cmu.edu> rs4u+@andrew.cmu.edu (Richard Siegel) writes:
>
>Because Desk Accessories use A4 as the base for globals, instead of A5, the
>QuickDraw globals will not be initialized properly. You should not use
>QuickDraw globals from a desk accessory or device driver, for this reason.

Here is a semi-related piece of trival about A4.  If you have a UserItem
in a dialog box the drawing procedure gets called from the ToolBox.  When
it gets called, A4 is not the same was when you called ModalDialog.  This
is quite alarming when you need to get at your Globals from inside the
procedure, AND  you are in a DA (driver).  The solution to the problem is
to put the value of A4 into the dataHandle of the the dialog box (it may 
either need to be extended or created), then MODIFY A4 while you are in 
the procedure, and replace it when you exit.

Fun Stuff.

Shane Looker
shane@pepe.cc.umich.edu 
uunet!umix!pepe.cc.umich.edu!shane
Looker@um.cc.umich.edu

lippin@jell-o.berkeley.edu (The Apathist) (05/15/88)

Recently rs4u+@andrew.cmu.edu (Richard Siegel) said:
>If you need ScreenBits.bounds, the easy way to do it from a DA is to use
>OpenPort to open a new Grafport; that GrafPort's portRect is equal to
>screenBits.
>
>As far as the patterns are concerned, you can use GetIndPattern() to get these
>patterns from the standard system pattern list.

	The one I found was thge most trouble was the arrow cursor --
I don't know of any way to get at it without the quickdraw globals.
It doesn't even have a resource ID.  But using InitCursor instead of
SetCursor takes care of that.

					--Tom Lippincott
					..ucbvax!math!lippin
					  lippin@math.berkeley.edu

	"It's a multi-purpose shape: a box."
					--David Byrne

tedj@hpcilzb.HP.COM (Ted Johnson) (05/15/88)

None of the QuickDraw global variables (screenBits, the pre-defined
patterns, etc.) are accessible from within a DA, because a DA indexes
global variables off of register A5 and a DA indexes its globals off 
register A4.

-Ted