Important: The information in this document is obsolete and should not be used for new development.
NewGDevice
You can use theNewGDevicefunction to create a newGDevicerecord, although you generally don't need to, because Color QuickDraw uses this function to createGDevicerecords for your application automatically.
FUNCTION NewGDevice (refNum: Integer; mode: LongInt): GDHandle;
refNum- Reference number of the graphics device for which you are creating a
GDevicerecord. For most video devices, this information is set at system startup.mode- The device configuration mode. Used by the screen driver, this value sets the pixel depth and specifies color or black and white.
DESCRIPTION
For the graphics device whose driver is specified in therefNumparameter and whose mode is specified in themodeparameter, theNewGDevicefunction allocates a newGDevicerecord and all of its handles, and then calls theInitGDeviceprocedure to initialize the record. As its function result,NewGDevicereturns a handle to the newGDevicerecord. If the request is unsuccessful,NewGDevicereturnsNIL.The
NewGDevicefunction allocates the newGDevicerecord and all of its handles in the system heap, and theNewGDevicefunction sets all attributes in thegdFlagsfield of theGDevicerecord toFALSE. If your application creates aGDevicerecord, it can use theSetDeviceAttributeprocedure, described on page 5-21, to change the flag bits in thegdFlagsfield of theGDevicerecord toTRUE. Your application should never directly change thegdFlagsfield of theGDevicerecord; instead, your application should use only theSetDeviceAttributeprocedure.If your application creates a
GDevicerecord without a driver, it should set themodeparameter to -1. In this case,InitGDevicecannot initialize theGDevicerecord, so your application must perform all initialization of the record. AGDevicerecord's default mode is defined as 128; this is assumed to be a black-and-white mode. If you specify a value other than 128 in themodeparameter, the record'sgdDevTypebit in thegdFlagsfield of theGDevicerecord is set toTRUEto indicate that the graphics device is capable of displaying color.The
NewGDevicefunction doesn't automatically insert theGDevicerecord into the device list. In general, your application shouldn't createGDevicerecords, and if it ever does, it should never add them to the device list.SPECIAL CONSIDERATIONS
If your program usesNewGDeviceto create a graphics device without a driver,InitGDevicedoes nothing; instead, your application must initialize all fields of theGDevicerecord. After your application initializes the color table for theGDevicerecord, your application should call the Color Manager procedureMakeITableto build the inverse table for the graphics device.The
NewGDevicefunction may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.SEE ALSO
TheGDevicerecord is described on page 5-14. See Designing Cards and Drivers for the Macintosh Family, third edition, for more information about the device modes that you can specify in themodeparameter. The Color Manager is described in Advanced Color Imaging on the Mac OS.