home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
macintosh-pascal
/
macintoshp-1.2-demos.sit.hqx
/
chap09pascal_demo
/
GDevicePascal.p
next >
Wrap
Text File
|
1996-12-24
|
4KB
|
153 lines
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
// GDevicePascal.p
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
//
// This program opens a small window, gets a handle to the GDevice record for the main
// device and displays some information obtained from that record.
//
// The program will run only on Macintoshes with Color QuickDraw.
//
// The program utilizes an 'ALRT' resource, a 'DITL' resource, and a 'WIND' resource.
//
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
program GDevicePascal(input, output);
{ ………………………………………………………………………………………………………………… include the following Universal Interfaces }
uses
Windows, Fonts, Menus, TextEdit, Quickdraw, Dialogs, QuickdrawText, Processes, Types,
Events, TextUtils, ToolUtils, Devices, GestaltEqu, LowMem, Segload;
{ ………………………………………………………………………………………………………………………………………………… define the following constants }
const
rAlert = 128;
rWindow = 128;
{ ……………………………………………………………………………………………………………………………………………………………………………………… global variables }
var
theErr, ignored : OSErr;
response : longint;
myWindowPtr : WindowPtr;
deviceHdl : GDHandle;
deviceType, bytesPerRow : integer;
theRect : Rect;
theString : string;
pixMapHdl : PixMapHandle;
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ start of main program }
begin
{ …………………………………………………………………………………………………………………………………………………………………… initialize managers }
InitGraf(@qd.thePort);
InitFonts;
InitWindows;
InitMenus;
TEInit;
InitDialogs(nil);
InitCursor;
{ …………………………………………………………………………………………………………………………………………………… check for Color QuickDraw }
theErr := Gestalt(gestaltQuickdrawVersion, response);
if (response < gestalt8BitQD) then
begin
ParamText('This program will run only on Macintoshes with Color QuickDraw',
'', '', '');
ignored := StopAlert(rAlert, nil);
ExitToShell;
end;
{ …………………………………………………………………………………………………………………………………………………………………………………… open a window }
myWindowPtr := GetNewWindow(128, nil, WindowPtr(-1));
if (myWindowPtr = nil) then
ExitToShell;
SetPort(myWindowPtr);
TextSize(10);
{ ………………………………………………………………………………………………… get handle to GDevice record for main device }
deviceHdl := LMGetMainDevice;
{ …………………………………………………………………………………………… print some information from the GDevice record }
MoveTo(10, 20);
deviceType := deviceHdl^^.gdType;
case (deviceType) of
0: begin
DrawString('Indexed device with variable CLUT.');
end;
1: begin
DrawString('Indexed device with fixed CLUT.');
end;
2: begin
DrawString('Direct device.');
end;
end;
{of case statement}
MoveTo(10, 40);
theRect := deviceHdl^^.gdRect;
DrawString('Boundary rectangle top = ');;
NumToString(longint(theRect.top), theString);
DrawString(theString);
MoveTo(10, 55);
DrawString('Boundary rectangle left = ');;
NumToString(longint(theRect.left), theString);
DrawString(theString);
MoveTo(10, 70);
DrawString('Boundary rectangle bottom = ');;
NumToString(longint(theRect.bottom), theString);
DrawString(theString);
MoveTo(10, 85);
DrawString('Boundary rectangle right = ');;
NumToString(longint(theRect.right), theString);
DrawString(theString);
MoveTo(10, 105);
pixMapHdl := deviceHdl^^.gdPMap;
DrawString('Pixel depth := ');
NumToString(longint(pixMapHdl^^.pixelSize), theString);
DrawString(theString);
MoveTo(10, 120);
bytesPerRow := BAnd(pixMapHdl^^.rowBytes, $7FFF);
DrawString('Bytes per row := ');
NumToString(longint(bytesPerRow), theString);
DrawString(theString);
MoveTo(10, 135);
DrawString('Total pixel image bytes = ');
NumToString(longint(bytesPerRow) * theRect.bottom, theString);
DrawString(theString);
MoveTo(10, 155);
if (pixMapHdl^^.hRes = $00480000) then
DrawString('Resolution = 72 dpi');
MoveTo(10, 175);
if (BitTst(@deviceHdl^^.gdFlags, screenActive))
then DrawString('Device is the current device')
else DrawString('Device is not the current device');
while not (Button) do ;
end.
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }