GlobalToLocal
GlobalToLocal Obtain local coordinates of global point
#include <Quickdraw.h> Quickdraw
void GlobalToLocal(thePoint );
Point *thePoint ; global Point; receives local coordinates
GlobalToLocal converts a point from global ( screen) coordinates to values
expressed in coordinates of the current GrafPort. It is used to obtain the local
address of a mouse-down event and as a step in converting between coordinates
of two different grafPorts.
thePoint is the address of a 4-byte Point structure, expressed in global
( screen) coordinates. Upon return, it will contain the coordinates of
that same position, expressed in the coordinate system of the current
Returns: none

Notes: The specified Point is converted, in place. Upon return, it is the same
physical location, expressed in global coordinates.
For instance, mouse-down events are reported in global coordinates, but
TextEdit and the Control Manager functions expect local ( window- relative)
coordinates. Thus, a typical sequence may include:
EventRecord myEvent;
short ctlCode;
GetNextEvent( everyEvent, &myEvent );
if ( myEvent.what ) == mouseDown {
GlobalToLocal( &myEvent.where ); /* get local equivalent */
ctlCode=FindControl( myEvent.where, myWindow, &myCtl );
if ( ctlCode == inThumb )
/*. . . etc. . . */
}
This function is also used as an intermediate step in converting between
coordinates of two different grafPorts (e.g., windows). For instance, to
convert the position of rectangle theRect from the coordinates of windowA
to the coordinates of windowB :
SetPort( windowA );
LocalToGlobal( & topLeft( theRect ) );
LocalToGlobal( & botRight( theRect ) );
SetPort( windowB );
GlobalToLocal( & topLeft( theRect ) );
GlobalToLocal( & botRight( theRect ) );
To convert between the coordinates of regions and polygons, calculate the
difference between the coordinate systems and use OffsetRect, OffsetRgn,
and OffsetPoly. See LocalToGlobal for an example.