Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!snorkelwacker!bloom-beacon!bu.edu!bu-cs!dartvax!eleazar.dartmouth.edu!ari From: ari@eleazar.dartmouth.edu (Ari Halberstadt) Newsgroups: comp.sys.mac.programmer Subject: How to get the QD globals outside of an application Message-ID: <18350@dartvax.Dartmouth.EDU> Date: 6 Jan 90 19:59:51 GMT Sender: news@dartvax.Dartmouth.EDU Organization: Dartmouth College, Hanover, NH Lines: 42 Several people have been curious about how to access the QuickDraw globals from within an XCMD or XFCN. Here's a little routine I wrote for THINK C which you can call when you initialize your XCMD or XFCN. If I remember correctly, MPW uses a single global structure to store the QuickDraw globals. Thus, one BlockMove would suffice to implement this routine in MPW. /* QuickDraw global offsets off of A5 */ #define THEPORT 0 /* GrafPtr */ #define WHITE THEPORT-8 /* Pattern */ #define BLACK WHITE-8 /* Pattern */ #define GRAY BLACK-8 /* Pattern */ #define LTGRAY GRAY-8 /* Pattern */ #define DKGRAY LTGRAY-8 /* Pattern */ #define ARROW DKGRAY-68 /* Cursor */ #define SCREENBITS ARROW-14 /* BitMap */ #define RANDSEED SCREENBITS-4 /* long */ /* Setup the QuickDraw globals by getting them from their offsets off of A5 */ /* By Ari Halberstadt, 1990 */ static void SetupQDGlobals() { Ptr p; p = *((Ptr *) CurrentA5); thePort = (GrafPtr) (THEPORT + p); BlockMove(WHITE + p, white, sizeof(Pattern)); BlockMove(BLACK + p, black, sizeof(Pattern)); BlockMove(GRAY + p, gray, sizeof(Pattern)); BlockMove(LTGRAY + p, ltGray, sizeof(Pattern)); BlockMove(DKGRAY + p, dkGray, sizeof(Pattern)); BlockMove(ARROW + p, &arrow, sizeof(Cursor)); BlockMove(SCREENBITS + p, &screenBits, sizeof(BitMap)); randSeed = (long) (RANDSEED + p); /*I hope this line is correct...*/ } -- Ari Halberstadt '91, "Long live succinct signatures" ari@eleazar.dartmouth.edu Disclaimer: "Live Free or Die"