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
/
chap23pascal_demo
/
chap19pascal_demoPPC
/
CDEFsPascalPPC
/
CDEF2PascalPPC.p
< prev
next >
Wrap
Text File
|
1997-01-21
|
24KB
|
770 lines
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
// CDEF2PascalPPC.p Custom control definition function for slider control
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
//
// This CDEF displays:
//
// • A 3D coloured slider control on colour displays set to pixel depths greater than 1.
//
// • A black-and-white slider control on colour displays set to pixel depths less than
// 2.
//
// • A black-and-white slider control if Color QuickDraw is not present.
//
// The CDEF utilises two 'PICT' resources (purgeable). One resource contains the colour
// version of the slider control components. The other comprises the black and white
// version. The appearance of the coloured slider conforms to the specification for
// slider controls contained in the document Apple Greyscale Appearance for System 7.5
// published by Apple Computer Inc.
//
// ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
unit CDEF2Pascal;
{ ……………………………………………………………………………………………………………………………………………………………………… unit interface section }
interface
{ ………………………………………………………………………………………………………………… include the following Universal Interfaces }
uses
Controls, Fonts, Menus, Quickdraw, Processes, Types,
Memory, Events, ToolUtils, OSUtils, Devices, QDOffscreen, SegLoad, Retrace,
Traps, GestaltEqu, LowMem;
{ ………………………………………………………………………………………………………………………………………… procedure and function interfaces }
{$MAIN}
function main(varCode : integer; theControl : ControlHandle; message : integer;
param : longint) : longint;
{ ………………………………………………………………………………………………………………………………………………………… unit implementation section }
implementation
{ ………………………………………………………………………………………………………………………………………………… define the following constants }
const
kInactive = 255;
kIndicatorHeight = 16;
rTrackPict = 128;
{ ………………………………………………………………………………………………………………………………………………………………………………… user-defined types }
type
VBLRec = record
vblTaskRec : VBLTask;
inVBlankPeriod : boolean;
thisApplicationsA5 : longint;
end;
VBLRecPtr = ^VBLRec;
SliderDataRec = record
offScreenPort : GWorldPtr;
offScreenPortRect : Rect;
trackActiveRect : Rect;
trackInactiveRect : Rect;
indicatorActiveRect : Rect;
indicatorPressedRect : Rect;
indicatorInactiveRect : Rect;
compositeRect : Rect;
currentPort : GWorldPtr;
currentDevice : GDHandle;
ColorQuickDrawPresent : boolean;
mainSlotNumber : integer;
slotVInstallPresent : boolean;
dragMessageFlag : boolean;
VBLInstallFail : boolean;
end;
SliderDataPtr = ^SliderDataRec;
SliderDataHdl = ^SliderDataPtr;
{ ……………………………………………………………………………………………………………………………………………………………………………………… global variables }
var
theVBLTaskRD : VBLUPP; { For PowerPC }
gVBLRec : VBLRec; { For PowerPC }
{ …………………………………………………………………………………………………………………………………………………………… in-line glue for GetVBLRec }
{$IFC GENERATING68k} { For PowerPC }
function GetVBLRec : longint;
{$IFC NOT GENERATINGCFM}
inline $2E88;
{$ENDC}
{$ENDC} { For PowerPC }
{ ………………………………………………………………………………………………………………………………………… procedure and function interfaces }
procedure DoInitMessage(theControl : ControlHandle); forward;
procedure DoDrawMessage(theControl : ControlHandle); forward;
function DoTestMessage(theControl : ControlHandle;
param : longint) : longint; forward;
function DoDragMessage(theControl : ControlHandle) : longint; forward;
procedure DoDisposeMessage(theControl : ControlHandle); forward;
procedure CreateOffScreenGWorld(theControl : ControlHandle); forward;
procedure PixelDepthCheck(theControl : ControlHandle); forward;
procedure DrawControlActive(theControl : ControlHandle); forward;
procedure DrawControlInactive(theControl : ControlHandle); forward;
function CalcIndicatorRect(theControl : ControlHandle) : Rect; forward;
function InstallVBLTask(theControl : ControlHandle) : OSErr; forward;
procedure RemoveVBLTask(theControl : ControlHandle); forward;
procedure TheVBLTask; forward;
function CheckSlotVInstallAvailable : boolean; forward;
function CheckTrapAvailable(theTrap : integer) : boolean; forward;
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ main }
function main(varCode : integer; theControl : ControlHandle; message : integer;
param : longint) : longint;
var
oldPenState : PenState;
returnValue : longint;
{$IFC GENERATING68k} { For PowerPC }
oldA4, ignored : longint;
{$ENDC} { For PowerPC }
begin
{$IFC GENERATING68k} { For PowerPC }
oldA4 := SetCurrentA4;
{$ENDC} { For PowerPC }
GetPenState(oldPenState);
case (message) of
initCntl: begin
DoInitMessage(theControl);
returnValue := 0;
end;
drawCntl: begin
if (theControl^^.contrlVis <> 0) then
DoDrawMessage(theControl);
returnValue := 0;
end;
testCntl: begin
returnValue := DoTestMessage(theControl, param);
end;
dragCntl: begin
returnValue := DoDragMessage(theControl);
end;
dispCntl: begin
DoDisposeMessage(theControl);
returnValue := 0;
end;
otherwise begin
returnValue := 0;
end;
end;
{of case statement}
SetPenState(oldPenState);
main := returnValue;
{$IFC GENERATING68k} { For PowerPC }
ignored := SetA4(oldA4);
{$ENDC} { For PowerPC }
end;
{of main procedure}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoInitMessage }
procedure DoInitMessage(theControl : ControlHandle);
var
theErr : OSErr;
response : longint;
mainDeviceHdl : GDHandle;
mainDeviceRefNum : integer;
deviceCtlEntryHdl : DCtlHandle;
theSliderDataHdl : SliderDataHdl;
begin
theVBLTaskRD := NewVBLProc(ProcPtr(@TheVBLTask)); { For PowerPC }
theControl^^.contrlData := NewHandleClear(sizeof(SliderDataRec));
if (theControl^^.contrlData <> nil) then
begin
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
theSliderDataHdl^^.ColorQuickDrawPresent := true;
theSliderDataHdl^^.dragMessageFlag := false;
theSliderDataHdl^^.VBLInstallFail := true;
theErr := Gestalt(gestaltQuickdrawVersion, response);
if (response < gestalt8BitQD) then
theSliderDataHdl^^.ColorQuickDrawPresent := false;
HLock(Handle(theControl));
CreateOffScreenGWorld(theControl);
HUnlock(Handle(theControl));
theSliderDataHdl^^.slotVInstallPresent := CheckSlotVInstallAvailable;
if (theSliderDataHdl^^.slotVInstallPresent) then
begin
mainDeviceHdl := LMGetMainDevice;
mainDeviceRefNum := mainDeviceHdl^^.gdRefNum;
deviceCtlEntryHdl := GetDCtlEntry(mainDeviceRefNum);
theSliderDataHdl^^.mainSlotNumber :=
integer(AuxDCEHandle(deviceCtlEntryHdl)^^.dCtlSlot);
end;
end;
end;
{of procedure DoInitMessage}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDrawMessage }
procedure DoDrawMessage(theControl : ControlHandle);
begin
if (SliderDataHdl(theControl^^.contrlData)^^.ColorQuickDrawPresent) then
PixelDepthCheck(theControl);
if (theControl^^.contrlHilite = kInactive) then
DrawControlInactive(theControl)
else
DrawControlActive(theControl);
end;
{of procedure DoInitMessage}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoTestMessage }
function DoTestMessage(theControl : ControlHandle; param : longint) : longint;
var
indicatorRect : Rect;
mouseXY : Point;
theSliderDataHdl : SliderDataHdl;
begin
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
indicatorRect := CalcIndicatorRect(theControl);
mouseXY.v := HiWord(param);
mouseXY.h := LoWord(param);
if (PtInRect(mouseXY, indicatorRect)) then
begin
theSliderDataHdl^^.dragMessageFlag := true;
DrawControlActive(theControl);
theSliderDataHdl^^.dragMessageFlag := false;
DoTestMessage := kControlIndicatorPart;
end
else DoTestMessage := 0;
end;
{of procedure DoInitMessage}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDragMessage }
function DoDragMessage(theControl : ControlHandle) : longint;
var
indicatorRect, slopRect, trackRect : Rect;
indicatorHeight, indicatorHalfHeight, indicatorCentre, trackHeight : integer;
startMouseXY, currentMouseXY : Point;
controlValueRange, differenceMouseY : integer;
ratio : longreal;
myWindowPtr : WindowPtr;
theErr : OSErr;
theSliderDataHdl : SliderDataHdl;
begin
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
theSliderDataHdl^^.dragMessageFlag := true;
HLock(Handle(theControl));
indicatorHeight := kIndicatorHeight;
indicatorHalfHeight := indicatorHeight div 2;
trackRect := theControl^^.contrlRect;
InsetRect(trackRect, 0, indicatorHalfHeight + 4);
trackRect.bottom := trackRect.bottom + 1;
trackHeight := trackRect.bottom - trackRect.top;
controlValueRange := theControl^^.contrlMax - theControl^^.contrlMin;
ratio := longreal(controlValueRange / trackHeight);
myWindowPtr := theControl^^.contrlOwner;
slopRect := myWindowPtr^.portRect;
theErr := InstallVBLTask(theControl);
if (theErr = noErr) then
theSliderDataHdl^^.VBLInstallFail := false
else
theSliderDataHdl^^.VBLInstallFail := true;
indicatorRect := CalcIndicatorRect(theControl);
GetMouse(startMouseXY);
while (StillDown) do
begin
GetMouse(currentMouseXY);
differenceMouseY := startMouseXY.v - currentMouseXY.v;
if ((differenceMouseY <> 0) and (PtInRect(currentMouseXY, slopRect))) then
begin
indicatorRect.top := indicatorRect.top - differenceMouseY;
indicatorRect.bottom := indicatorRect.bottom - differenceMouseY;
indicatorCentre := indicatorRect.top + indicatorHalfHeight;
theControl^^.contrlValue := longint(trunc((trackRect.bottom
- indicatorCentre) * ratio));
if (theControl^^.contrlValue > theControl^^.contrlMax) then
theControl^^.contrlValue := theControl^^.contrlMax;
if (theControl^^.contrlValue < theControl^^.contrlMin) then
theControl^^.contrlValue := theControl^^.contrlMin;
DrawControlActive(theControl);
startMouseXY := currentMouseXY;
end;
end;
if not (theSliderDataHdl^^.VBLInstallFail) then
RemoveVBLTask(theControl);
theSliderDataHdl^^.dragMessageFlag := false;
DrawControlActive(theControl);
HUnlock(Handle(theControl));
DoDragMessage := 1;
end;
{of procedure DoInitMessage}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDisposeMessage }
procedure DoDisposeMessage(theControl : ControlHandle);
var
theRect : Rect;
theSliderDataHdl : SliderDataHdl;
begin
DisposeRoutineDescriptor(theVBLTaskRD); { For PowerPC }
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
theRect := theControl^^.contrlRect;
theRect.right := theRect.right + (theRect.right - theRect.left);
EraseRect(theRect);
if (theSliderDataHdl^^.offScreenPort <> nil) then
DisposeGWorld(theSliderDataHdl^^.offScreenPort);
if (theControl^^.contrlData <> nil) then
DisposeHandle(theControl^^.contrlData);
end;
{of procedure DoDisposeMessage}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ CreateOffScreenGWorld }
procedure CreateOffScreenGWorld(theControl : ControlHandle);
var
theSliderDataHdl : SliderDataHdl;
resourceOffset : integer;
pixMapHdl : PixMapHandle;
pictureHdl : PicHandle;
currentPortDepth : integer;
ignored : QDErr;
ignoredBool : boolean;
begin
resourceOffset := 0;
currentPortDepth := 1;
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
theSliderDataHdl^^.compositeRect := theControl^^.contrlRect;
OffsetRect(theSliderDataHdl^^.compositeRect, - theSliderDataHdl^^.compositeRect.left,
- theSliderDataHdl^^.compositeRect.top);
SetRect(theSliderDataHdl^^.trackActiveRect, 50, 0, 100, 139);
SetRect(theSliderDataHdl^^.trackInactiveRect, 100, 0, 150, 139);
SetRect(theSliderDataHdl^^.indicatorActiveRect, 0, 139, 16, 154);
SetRect(theSliderDataHdl^^.indicatorPressedRect, 16, 139, 32, 154);
SetRect(theSliderDataHdl^^.indicatorInactiveRect, 32, 139, 48, 154);
SetRect(theSliderDataHdl^^.offScreenPortRect, 0, 0, 150, 154);
GetGWorld(theSliderDataHdl^^.currentPort, theSliderDataHdl^^.currentDevice);
HLock(Handle(theSliderDataHdl));
ignored := NewGWorld(theSliderDataHdl^^.offScreenPort, 0,
theSliderDataHdl^^.offScreenPortRect, nil, nil, 0);
pixMapHdl := GetGWorldPixMap(theSliderDataHdl^^.offScreenPort);
ignoredBool := LockPixels(pixMapHdl);
SetGWorld(theSliderDataHdl^^.offScreenPort, nil);
EraseRect(theSliderDataHdl^^.offScreenPortRect);
if (theSliderDataHdl^^.ColorQuickDrawPresent) then
begin
pixMapHdl := GetGWorldPixMap(theSliderDataHdl^^.currentPort);
currentPortDepth := pixMapHdl^^.pixelSize;
end;
if (not (theSliderDataHdl^^.ColorQuickDrawPresent) or (currentPortDepth < 2)) then
resourceOffset := 1;
pictureHdl := GetPicture(rTrackPict + resourceOffset);
if (pictureHdl <> nil) then
begin
HNoPurge(Handle(pictureHdl));
DrawPicture(pictureHdl, theSliderDataHdl^^.offScreenPortRect);
HPurge(Handle(pictureHdl));
end;
SetGWorld(theSliderDataHdl^^.currentPort, theSliderDataHdl^^.currentDevice);
UnlockPixels(pixMapHdl);
HUnlock(Handle(theSliderDataHdl));
end;
{of procedure CreateOffScreenGWorld}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ PixelDepthCheck }
procedure PixelDepthCheck(theControl : ControlHandle);
var
theSliderDataHdl : SliderDataHdl;
pixMapHdl : PixMapHandle;
currentPortDepth, gworldPortDepth : integer;
begin
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
pixMapHdl := GetGWorldPixMap(theSliderDataHdl^^.currentPort);
currentPortDepth := pixMapHdl^^.pixelSize;
pixMapHdl := GetGWorldPixMap(theSliderDataHdl^^.offScreenPort);
gworldPortDepth := pixMapHdl^^.pixelSize;
if (currentPortDepth <> gworldPortDepth) then
begin
DisposeGWorld(theSliderDataHdl^^.offScreenPort);
CreateOffScreenGWorld(theControl);
end;
end;
{of procedure CreateOffScreenGWorld}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DrawControlActive }
procedure DrawControlActive(theControl : ControlHandle);
var
oldForeColour, oldBackColour : RGBColor;
theSliderDataHdl : SliderDataHdl;
myWindowPtr : WindowPtr;
pixMapHdl : PixMapHandle;
indicatorRect : Rect;
ignoredBool : boolean;
begin
GetForeColor(oldForeColour);
GetBackColor(oldBackColour);
HLock(Handle(theControl));
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
HLock(Handle(theSliderDataHdl));
myWindowPtr := WindowPtr(theControl^^.contrlOwner);
SetPort(myWindowPtr);
pixMapHdl := GetGWorldPixMap(theSliderDataHdl^^.offScreenPort);
ignoredBool := LockPixels(pixMapHdl);
ForeColor(blackColor);
BackColor(whiteColor);
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
theSliderDataHdl^^.trackActiveRect, theSliderDataHdl^^.compositeRect,
srcCopy, nil);
indicatorRect := CalcIndicatorRect(theControl);
OffsetRect(indicatorRect, -theControl^^.contrlRect.left,
-theControl^^.contrlRect.top);
if (theSliderDataHdl^^.dragMessageFlag) then
begin
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
theSliderDataHdl^^.indicatorPressedRect, indicatorRect, srcCopy, nil);
end
else begin
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
theSliderDataHdl^^.indicatorActiveRect, indicatorRect, srcCopy, nil);
end;
if ((theSliderDataHdl^^.dragMessageFlag) and
not (theSliderDataHdl^^.VBLInstallFail)) then
begin
if (gVBLRec.inVBlankPeriod) then
begin
gVBLRec.inVBlankPeriod := false;
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(myWindowPtr)^.portBits, theSliderDataHdl^^.compositeRect,
theControl^^.contrlRect, srcCopy, nil);
end;
end
else begin
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(myWindowPtr)^.portBits, theSliderDataHdl^^.compositeRect,
theControl^^.contrlRect, srcCopy, nil);
end;
UnlockPixels(pixMapHdl);
HUnlock(Handle(theSliderDataHdl));
HUnlock(Handle(theControl));
RGBForeColor(oldForeColour);
RGBBackColor(oldBackColour);
end;
{of procedure CreateOffScreenGWorld}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DrawControlInactive }
procedure DrawControlInactive(theControl : ControlHandle);
var
oldForeColour, oldBackColour : RGBColor;
theSliderDataHdl : SliderDataHdl;
myWindowPtr : WindowPtr;
pixMapHdl : PixMapHandle;
indicatorRect : Rect;
ignoredBool : boolean;
begin
GetForeColor(oldForeColour);
GetBackColor(oldBackColour);
HLock(Handle(theControl));
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
HLock(Handle(theSliderDataHdl));
myWindowPtr := WindowPtr(theControl^^.contrlOwner);
SetPort(myWindowPtr);
pixMapHdl := GetGWorldPixMap(theSliderDataHdl^^.offScreenPort);
ignoredBool := LockPixels(pixMapHdl);
ForeColor(blackColor);
BackColor(whiteColor);
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
theSliderDataHdl^^.trackInactiveRect, theSliderDataHdl^^.compositeRect,
srcCopy, nil);
indicatorRect := CalcIndicatorRect(theControl);
OffsetRect(indicatorRect, -theControl^^.contrlRect.left,
-theControl^^.contrlRect.top);
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
theSliderDataHdl^^.indicatorInactiveRect, indicatorRect, srcCopy, nil);
CopyBits(GrafPtr(theSliderDataHdl^^.offScreenPort)^.portBits,
GrafPtr(myWindowPtr)^.portBits, theSliderDataHdl^^.compositeRect,
theControl^^.contrlRect, srcCopy, nil);
UnlockPixels(pixMapHdl);
HUnlock(Handle(theSliderDataHdl));
HUnlock(Handle(theControl));
RGBForeColor(oldForeColour);
RGBBackColor(oldBackColour);
end;
{of procedure DrawControlInactive}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ CalcIndicatorRect }
function CalcIndicatorRect(theControl : ControlHandle) : Rect;
var
indicatorHeight, indicatorHalfHeight : integer;
trackRect, indicatorRect : Rect;
trackHeight, controlValue, controlMax, controlMin, indicatorCentre : integer;
ratio : longreal;
begin
indicatorHeight := kIndicatorHeight;
indicatorHalfHeight := indicatorHeight div 2;
trackRect := theControl^^.contrlRect;
InsetRect(trackRect, 0, indicatorHalfHeight + 4);
trackRect.bottom := trackRect.bottom + 1;
trackHeight := trackRect.bottom - trackRect.top;
controlValue := theControl^^.contrlValue;
controlMax := theControl^^.contrlMax;
controlMin := theControl^^.contrlMin;
ratio := longreal((controlValue) / (controlMax - controlMin));
indicatorCentre := trackRect.bottom - integer(trunc(ratio * trackHeight));
SetRect(indicatorRect, trackRect.left, indicatorCentre - indicatorHalfHeight,
trackRect.left + 16, indicatorCentre + indicatorHalfHeight - 1);
CalcIndicatorRect := indicatorRect;
end;
{of function CalcIndicatorRect}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ InstallVBLTask }
function InstallVBLTask(theControl : ControlHandle) : OSErr;
var
theErr : OSErr;
theSliderDataHdl : SliderDataHdl;
begin
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
gVBLRec.inVBlankPeriod := false;
gVBLRec.vblTaskRec.qType := vType;
gVBLRec.vblTaskRec.vblAddr := theVBLTaskRD; { For PowerPC }
gVBLRec.vblTaskRec.vblCount := 1;
gVBLRec.vblTaskRec.vblPhase := 0;
{$IFC GENERATING68K} { For PowerPC }
gVBLRec.thisApplicationsA5 := SetCurrentA5;
{$ENDC} { For PowerPC }
if (theSliderDataHdl^^.slotVInstallPresent) then
theErr := SlotVInstall(QElemPtr(@gVBLRec.vblTaskRec),
theSliderDataHdl^^.mainSlotNumber)
else
theErr := VInstall(QElemPtr(@gVBLRec.vblTaskRec));
InstallVBLTask := theErr;
end;
{of function InstallVBLTask}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ RemoveVBLTask }
procedure RemoveVBLTask(theControl : ControlHandle);
var
ignoredErr : OSErr;
theSliderDataHdl : SliderDataHdl;
begin
theSliderDataHdl := SliderDataHdl(theControl^^.contrlData);
if (theSliderDataHdl^^.slotVInstallPresent) then
ignoredErr := SlotVRemove(QElemPtr(@gVBLRec.vblTaskRec),
theSliderDataHdl^^.mainSlotNumber)
else
ignoredErr := VRemove(QElemPtr(@gVBLRec.vblTaskRec));
end;
{of function RemoveVBLTask}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ TheVBLTask }
procedure TheVBLTask;
{$IFC GENERATING68K} { For PowerPC }
var
theVBLRecPtr : VBLRecPtr;
currentA5 : longint;
ignoredLong : longint;
{$ENDC} { For PowerPC }
begin
{$IFC GENERATING68K} { For PowerPC }
theVBLRecPtr := VBLRecPtr(GetVBLRec);
currentA5 := SetA5(theVBLRecPtr^.thisApplicationsA5);
{$ENDC} { For PowerPC }
{$IFC GENERATING68K} { For PowerPC }
theVBLRecPtr^.inVBlankPeriod := true;
theVBLRecPtr^.vblTaskRec.vblCount := 1;
{$ELSEC} { For PowerPC }
gVBLRec.inVBlankPeriod := true; { For PowerPC }
gVBLRec.vblTaskRec.vblCount := 1; { For PowerPC }
{$ENDC} { For PowerPC }
{$IFC GENERATING68K} { For PowerPC }
ignoredLong := SetA5(currentA5);
{$ENDC} { For PowerPC }
end;
{of function TheVBLTask}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ CheckSlotVInstallAvailable }
function CheckSlotVInstallAvailable : boolean;
begin
CheckSlotVInstallAvailable := CheckTrapAvailable(_SlotVInstall);
end;
{of function CheckSlotVInstallAvailable}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ CheckTrapAvailable }
function CheckTrapAvailable(theTrap : integer) : boolean;
var
theTrapType : TrapType;
trapMask : integer;
numToolboxTraps : integer;
begin
trapMask := $0800;
if (BAnd(theTrap, trapMask) > 0) then
theTrapType := ToolTrap
else
theTrapType := OSTrap;
if (theTrapType = ToolTrap) then
theTrap := BAnd(theTrap, $07FF);
if (NGetTrapAddress(_InitGraf, ToolTrap) = NGetTrapAddress($AA6E, ToolTrap)) then
numToolboxTraps := $0200
else
numToolboxTraps := $0400;
if (theTrap >= numToolboxTraps) then
theTrap := _Unimplemented;
CheckTrapAvailable :=
(NGetTrapAddress(theTrap, theTrapType) <> NGetTrapAddress(_Unimplemented, ToolTrap));
end;
{of function CheckTrapAvailable}
end.
{of unit CDEF2Pascal}
{ ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }