Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 11 - Miscellaneous / Reference
Functions and Methods / Utility Functions


Gestalt

Gestalt(selector)

Returns information about the Newton system; the type of information returned depends on the value of the selector parameter.

selector
A constant that specifies the type of information that is returned on the system. The following values are currently allowed: kGestalt_SystemInfo, kGestalt_Backlight, kGestaltArg_HasSoftContrast, and kGestaltArg_VolumeInfo.

return value
Depends on selector, see DISCUSSION.

DISCUSSION

The return value of this function depends on the value of selector, as follows:

Slot Descriptions

manufacturer
An integer indicating the manufacturer of the Newton Device.
machineType
An integer indicating the hardware type this ROM was built for.
ROMStage
A decimal integer indicating the language (English, German, French) and the stage of the ROM (alpha, beta, final).
ROMVersion
A packed integer indicating the major and minor ROM version numbers. You can use the following function to convert this number into an array, containing an integer for the ROM major and minor version numbers:

func (ROMVersionInteger)

begin local minor := BAND(ROMVersionInteger, 0xFFFF); local major := BAND(ROMVersionInteger>>16, 0xFFFF); [ Floor(StringToNumber(BAND(major>>12, 0xF) & BAND(major>>8, 0xF) & BAND(major>>4, 0xF) & BAND(major, 0xF))), Floor(StringToNumber(BAND(minor>>12, 0xF) & BAND(minor>>8, 0xF) & BAND(minor>>4, 0xF) & BAND(minor, 0xF)))] end

Here is another example of code to test if your Newton is running 2.x. The following expression evaluates to a non-nil value if the major version is 2:
BAND((*Gestalt(kGestalt_SystemInfo).ROMVersion)>>16, 0xFFFF) = 0x0002
IMPORTANT
Do not assume that if the Newton is running version 2.0 or later that a particular feature exists. You still need to test the Newton to make sure the feature exists.
Note
The machineType, ROMStage and ROMVersion slots provide internal configuration information and should not be relied on.
screenWidth
An integer representing the width of the screen in pixels. The width takes into account the current screen orientation.
For example, on the MessagePad 120, because the screen width is 240 and the screen height is 320, in portrait orientation *Gestalt returns a width of 240. If the screen is rotated, *Gestalt returns a width of 320.
screenHeight
An integer representing the height of the screen in pixels.
screenResolutionX
An integer representing the number of horizontal pixels per inch. For screens with square pixels, screenResolutionX equals screenResolutionY. On the MessagePad 120, for example, both screenResolutionX and screenResolutionY equal 85.
screenResolutionY
An integer representing the number of vertical pixels per inch.
screenDepth
The bit depth of the LCD screen. For the MessagePad 120, the LCD supports a monochrome screen depth of 1. The eMate 300 and MessagePad 200 have 4 bit depth LCD screens.
patchVersion
Returns 0 on an unpatched Newton and nonzero on a patched Newton.
ROMVersionString
The user-visible string that identifies the version of the installed ROM and the installed patch, if any.
The first part of the string is a "functionality level" indicating the OS version, such as 1.3, 2.0 or 2.1.
The second part of the string is a six-digit number in parentheses that is an encoded representation of ROM and system update information.
cpuType
A symbol specifying the type of CPU, possible values are 'strongArm, 'arm710a, and 'arm610a.
cpuSpeed
A real indicating the speed of the CPU in megahertz.

local result := Gestalt(kGestalt_Backlight);

if result and result[0] then // unit has backlighting else // unit does not have backlighting

Array Element Descriptions

hasSoftContrast
True or nil depending on whether there is a soft contrast control.

minContrast
Integer for the minimum contrast.

maxContrast
Integer for the maximum contrast.

You can use the values returned by this selector to set the LCDContrast user configuration variable.

Array Element Descriptions

hasInput
True or nil depending on whether the device can support sound input.
hasOutput
True or nil depending on whether the device can support sound output.
hardwareVolControl
True or nil depending on whether the device has a hardware volume control.
headphoneJack
True or nil depending on whether the device has a built-in headphone jack.
minAudibleDB
An integer, the minimal decibel level for output. The MessagePad 2000 is set to -31.9760.
numDVLevels
An integer, the number of levels between minAudibleDB and 0. The dB increment per level is minAudibleDB/numDVLevels. The MessagePad 2000 is set to 14.
devicesBitfield
A packed integer with information about the built-in sound devices. This integer contains the summation of the applicable device constants. Device constants are described in "Device Constants" in Chapter 7, "Sound." The two important ones are kInternalSpeaker and kInternalMic.
The following function returns nil / non-nil if the current device has an internal microphone (use kInternalSpeaker to check for an internal speaker):

HasMic := func()

begin local volInfo := Gestalt(kGestaltArg_VolumeInfo) ; return volInfo AND (BAND(volInfo[6], kInternalMic) <> 0); end

COMPATIBILITY

The kGestalt_Backlight and kGestaltArg_VolumeInfo selectors are not supported on 2.0 devices.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help