home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-06 | 3.6 KB | 134 lines | [TEXT/CWIE] |
- // Copyright (C) 1999 Eric Roccasecca. All rights reserved.
-
- #include "X_Ray_Priv.h"
-
-
- void DebugNum (long bugNum)
- {
- Str15 bugStr;
-
- NumToString (bugNum, bugStr);
- DebugStr (bugStr);
- }
-
- // This function is not copyrighted by Eric Roccasecca.
- // It very well might be copyrighted someone else.
- // Whoever you are, thanks for a handy function.
- void NumToHexString (long number, StringPtr string)
- {
- char clookup[16] = "0123456789ABCDEF";
-
- string[0] = 8;
- string[1] = clookup[(number & 0xf0000000)>>28];
- string[2] = clookup[(number & 0x0f000000)>>24];
- string[3] = clookup[(number & 0x00f00000)>>20];
- string[4] = clookup[(number & 0x000f0000)>>16];
- string[5] = clookup[(number & 0x0000f000)>>12];
- string[6] = clookup[(number & 0x00000f00)>>8];
- string[7] = clookup[(number & 0x000000f0)>>4];
- string[8] = clookup[(number & 0x0000000f)];
- }
-
-
- // This function is not copyrighted by Eric Roccasecca
- // It very well might be copyrighted someone else.
- // Whoever you are, thanks for a handy function.
- Boolean isPressed (unsigned short key)
- {
- unsigned char keyMap[16];
-
- GetKeys( (unsigned long *) keyMap);
- return ( ( keyMap[key>>3] >> (key & 7) ) & 1);
- }
-
-
- // takes a rect and sets it's upper left corner to zero, while maintaing
- // the horizontal and vertical dommensions
- void X_Ray_NormalizeRect (Rect *theRect)
- {
- theRect->right = theRect->right - theRect->left;
- theRect->bottom = theRect->bottom - theRect->top;
- theRect->top = 0;
- theRect->left = 0;
- }
-
- // converts a rect from local to global coordinates
- void X_Ray_LocalToGlobalRect (Rect *theRect)
- {
- Point localPoint;
-
- localPoint.h = theRect->left;
- localPoint.v = theRect->top;
- LocalToGlobal (&localPoint);
- OffsetRect (theRect, localPoint.h - theRect->left, localPoint.v - theRect->top);
- }
-
- // converts a rect from global to local coordinates
- void X_Ray_GlobalToLocalRect (Rect *theRect)
- {
- Point globalPoint;
-
- globalPoint.h = theRect->left;
- globalPoint.v = theRect->top;
- GlobalToLocal (&globalPoint);
- OffsetRect (theRect, globalPoint.h - theRect->left, globalPoint.v - theRect->top);
- }
-
- // converts a polygon from local to global coordinates
- void X_Ray_LocalToGlobalPoly (PolyHandle thePoly)
- {
- Point localPoint;
-
- localPoint.h = (*thePoly)->polyBBox.left;
- localPoint.v = (*thePoly)->polyBBox.top;
- LocalToGlobal (&localPoint);
- OffsetPoly (thePoly, localPoint.h - (*thePoly)->polyBBox.left, localPoint.v - (*thePoly)->polyBBox.top);
- }
-
- // converts a polygon from global to local coordinates
- void X_Ray_GlobalToLocalPoly (PolyHandle thePoly)
- {
- Point globalPoint;
-
- globalPoint.h = (*thePoly)->polyBBox.left;
- globalPoint.v = (*thePoly)->polyBBox.top;
- GlobalToLocal (&globalPoint);
- OffsetPoly (thePoly, globalPoint.h - (*thePoly)->polyBBox.left, globalPoint.v - (*thePoly)->polyBBox.top);
- }
-
- // converts a region from local to global coordinates
- void X_Ray_LocalToGlobalRgn (RgnHandle theRgn)
- {
- Point localPoint;
-
- localPoint.h = (*theRgn)->rgnBBox.left;
- localPoint.v = (*theRgn)->rgnBBox.top;
- LocalToGlobal (&localPoint);
- OffsetRgn (theRgn, localPoint.h - (*theRgn)->rgnBBox.left, localPoint.v - (*theRgn)->rgnBBox.top);
- }
-
- // converts a region from global to local coordinates
- void X_Ray_GlobalToLocalRgn (RgnHandle theRgn)
- {
- Point globalPoint;
-
- globalPoint.h = (*theRgn)->rgnBBox.left;
- globalPoint.v = (*theRgn)->rgnBBox.top;
- GlobalToLocal (&globalPoint);
- OffsetRgn (theRgn, globalPoint.h - (*theRgn)->rgnBBox.left, globalPoint.v - (*theRgn)->rgnBBox.top);
- }
-
-
- extern short X_RayDrawLevel;
-
- // a region verification utility function
- // useful for seeing what exactly is the shape of theRgn
- void ConfirmRgn (RgnHandle theRgn)
- {
- X_RayDrawLevel++;
- InvertRgn (theRgn);
- Debugger();
- InvertRgn (theRgn);
- X_RayDrawLevel--;
- }
-