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 / chap22pascal_demo / UDemos.p < prev    next >
Text File  |  1999-04-05  |  16KB  |  639 lines

  1. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  2. // UDemos.p
  3. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
  4.  
  5. unit UDemos;
  6.  
  7.  
  8.  
  9. interface
  10.  
  11. { ………………………………………………………………………………………………………………… include the following Universal Interfaces }
  12.  
  13. uses
  14.  
  15.     Windows, Fonts, Menus, TextEdit, Dialogs, SegLoad, ToolUtils, Devices, GestaltEqu, 
  16.     Resources, Sound, Notification, Icons, Processes, ColorPicker, Traps, LowMem, TextUtils;
  17.      
  18. { ……………………………………………………………………………………………………………………………………………………………………………………… global variables }
  19.  
  20. var
  21.  
  22. gNotificationRecord : NMRec;
  23. gStartingTickCount : longint;
  24. gNotificationDemoInvoked : boolean;
  25. gNotificationInQueue : boolean;
  26. gInBackground : boolean;
  27. gWindowPtr : WindowPtr; external;
  28. gColorQuickDraw : boolean; external;
  29. gProcessSerNum : ProcessSerialNumber; external;
  30.  
  31.     procedure DemosSegment;
  32.     procedure DoCommandPeriodAndStatusBar;
  33.     procedure DoSetUpNotification;
  34.     procedure DoDeviceLoopDraw(depth, deviceFlags : integer; targetDeviceHdl : GDHandle; 
  35.                 userData : longint);
  36.     procedure DoNullEvent;
  37.     procedure DoOSEvent(theEvent : EventRecord);
  38.     procedure DoColourPicker;
  39.     function  DoCheckSlotVInstallAvailable : boolean;
  40.     procedure DoZoomWindowMultiMonitors(theWindowPtr : WindowPtr; 
  41.                 zoomInOrOut : longint);
  42.  
  43.  
  44.  
  45. implementation
  46.  
  47. uses
  48.  
  49. { ……………………………………………………………………………………………………………………… include the following user-defined units }
  50.  
  51.     UMain;
  52.     
  53. { ………………………………………………………………………………………………………………………………………… function and procedure interfaces }
  54.  
  55.     procedure DoDrawStatusBar(modalDlgPtr : DialogPtr; barRect : Rect; 
  56.                 statusCurrent, statusMax : integer); forward;
  57.     function  DoCheckForCommandPeriod : boolean; forward;
  58.     procedure DoPrepareNotificationRecord; forward;
  59.     procedure DoDisplayMessageToUser; forward;
  60.     function  DoDecimalToHexadecimal(decimalNumber : UInt16) : string; forward;
  61.     function  TrapAvailable(theTrap : integer) : boolean; forward;
  62.     procedure DoRedoWindowContent(theWindowPtr : WindowPtr); forward;
  63.                 
  64. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DemosSegment }
  65.  
  66. procedure DemosSegment;
  67.  
  68.     begin
  69.     end;
  70.         {of procedure DemosSegment}
  71.  
  72. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoCommandPeriodAndStatusBar }
  73.  
  74. procedure DoCommandPeriodAndStatusBar;
  75.  
  76.     var
  77.     modalDlgPtr : DialogPtr;
  78.     barBackColour, barColour : RGBColor;
  79.     itemType : integer;
  80.     itemHdl : Handle;
  81.     itemRect : Rect;
  82.     a, b, c, temp1, temp2 : integer;
  83.     soundHdl : Handle;
  84.     theRect : Rect;
  85.     statusMax, statusCurrent : integer;
  86.     finalTicks : UInt32;
  87.     ignored : OSErr;
  88.     
  89.     begin
  90.     EraseRect(gWindowPtr^.portRect);
  91.  
  92.     modalDlgPtr := GetNewDialog(rDialog, nil, WindowPtr(-1));
  93.     if (modalDlgPtr = nil) then
  94.         ExitToShell;
  95.  
  96.     DrawDialog(modalDlgPtr);
  97.     SetPort(modalDlgPtr);
  98.  
  99.     if (gColorQuickDraw) then
  100.         begin
  101.         barBackColour.red := $BFFF;
  102.         barBackColour.green := $BFFF;
  103.         barBackColour.blue := $FFFF;
  104.  
  105.         barColour.red := $6FFF;
  106.         barColour.green := $6FFF;
  107.         barColour.blue := $6FFF;
  108.         end;
  109.  
  110.     GetDialogItem(modalDlgPtr, iUserItem, itemType, itemHdl, itemRect);
  111.     InsetRect(itemRect, -1, -1);
  112.     FrameRect(itemRect);
  113.     InsetRect(itemRect, 1, 1);
  114.  
  115.     if (gColorQuickDraw) then
  116.         begin
  117.         RGBBackColor(barBackColour);
  118.         FillRect(itemRect, qd.white);
  119.         RGBForeColor(barColour);
  120.         end;
  121.  
  122.     SetPort(gWindowPtr);
  123.  
  124.     statusMax := 2184;
  125.     statusCurrent := 0;
  126.  
  127.     for a := 0 to 7 do
  128.         begin
  129.         if (DoCheckForCommandPeriod) then
  130.             begin
  131.             soundHdl := GetResource('snd ', rBarkSound);
  132.             ignored := SndPlay(nil, SndListHandle(soundHdl), false);
  133.             ReleaseResource(soundHdl);
  134.             DisposeDialog(modalDlgPtr);
  135.  
  136.             SetPort(gWindowPtr);
  137.             EraseRect(gWindowPtr^.portRect);
  138.             MoveTo(115, 110);
  139.             ForeColor(blackColor);
  140.             DrawString('Operation cancelled at user request');
  141.  
  142.             Exit(DoCommandPeriodAndStatusBar);
  143.             end;
  144.         for temp1 := 0 to 20 do
  145.             begin
  146.             b := temp1 * 18 + 12;
  147.             for temp2 := 0 to 12 do
  148.                 begin
  149.                 c := temp2 * 18 + 8;
  150.                 SetRect(theRect, b + a, c + a, b + 16 - a, c + 16 - a);
  151.                 if (a < 3) then
  152.                     ForeColor(redColor)
  153.                 else if ((a > 2) and (a < 6)) then 
  154.                     ForeColor(greenColor)
  155.                 else if (a > 5) then
  156.                     ForeColor(blueColor);
  157.                 FrameRect(theRect);
  158.                 
  159.                 DoDrawStatusBar(modalDlgPtr, itemRect, statusCurrent, statusMax);
  160.                 statusCurrent := statusCurrent + 1;
  161.                 end;
  162.             Delay(2, finalTicks);
  163.             end;
  164.         end;
  165.  
  166.     DisposeDialog(modalDlgPtr);    
  167.     EraseRect(gWindowPtr^.portRect);
  168.     MoveTo(150, 110);
  169.     ForeColor(blackColor);
  170.     DrawString('Operation completed');
  171.     end;
  172.         {of procedure DoCommandPeriodAndStatusBar}
  173.  
  174. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDrawStatusBar }
  175.  
  176. procedure DoDrawStatusBar(modalDlgPtr : DialogPtr; barRect : Rect; 
  177.                                         statusCurrent, statusMax : integer);
  178.  
  179.     var
  180.     barMaxWidth : integer;
  181.     barRequiredWidth : real;
  182.     
  183.     begin
  184.     SetPort(modalDlgPtr);
  185.  
  186.     barMaxWidth := barRect.right - barRect.left;
  187.     barRequiredWidth := (statusCurrent / statusMax) * barMaxWidth;
  188.     barRect.right := barRect.left + trunc(barRequiredWidth);
  189.  
  190.     if (gColorQuickDraw) then
  191.         FillRect(barRect, qd.black)
  192.     else    
  193.         FillRect(barRect, qd.gray);
  194.  
  195.     SetPort(gWindowPtr);
  196.     end;
  197.         {of procedure DoDrawStatusBar}
  198.  
  199. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoCheckForCommandPeriod }
  200.  
  201. function  DoCheckForCommandPeriod : boolean;
  202.  
  203.     var
  204.     foundCommandPeriod : boolean;
  205.     eventQHdrPtr : QHdrPtr;
  206.     eventQElPtr : EvQElPtr;
  207.     keyCode : longint;
  208.     commandKeyDown : longint;
  209.  
  210.     begin
  211.     foundCommandPeriod := false;
  212.  
  213.     eventQHdrPtr := GetEvQHdr;
  214.     eventQElPtr := EvQElPtr(eventQHdrPtr^.qHead);
  215.  
  216.     while ((eventQElPtr <> nil) and not (foundCommandPeriod)) do
  217.         begin
  218.         if (eventQElPtr^.evtQWhat = keyDown) then
  219.             begin
  220.             keyCode := BAnd(eventQElPtr^.evtQMessage, charCodeMask);
  221.  
  222.             commandKeyDown := BAnd(eventQElPtr^.evtQModifiers, cmdKey);
  223.  
  224.             if (commandKeyDown <> 0) then
  225.                 if (keyCode = ord('.')) then
  226.                     foundCommandPeriod := true;
  227.             end;
  228.  
  229.         if not (foundCommandPeriod) then
  230.             eventQElPtr := EvQElPtr(eventQElPtr^.qLink);
  231.         end;
  232.  
  233.     DoCheckForCommandPeriod := foundCommandPeriod;
  234.     end;
  235.         {of function DoCheckForCommandPeriod}
  236.  
  237. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoSetUpNotification }
  238.  
  239. procedure DoSetUpNotification;
  240.  
  241.     begin
  242.     DoPrepareNotificationRecord;
  243.     gNotificationDemoInvoked := true;
  244.  
  245.     gStartingTickCount := TickCount;
  246.  
  247.     MoveTo(12, 100);
  248.     DrawString('Please click on the desktop now to make the Finder ');
  249.     DrawString('the frontmost application.');
  250.     MoveTo(42, 120);
  251.     DrawString('(This application will post a notification 10 seconds from now.)');
  252.     end;
  253.         {of procedure DoSetUpNotification}
  254.  
  255. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoPrepareNotificationRecord }
  256.  
  257. procedure DoPrepareNotificationRecord;
  258.  
  259.     var
  260.     iconSuiteHdl : Handle;
  261.     soundHdl : Handle;
  262.     stringHdl : StringHandle;
  263.     ignored : OSErr;
  264.     
  265.     begin
  266.     ignored := GetIconSuite(iconSuiteHdl, rIconFamily, svAllSmallData);
  267.     soundHdl := GetResource('snd ', rBarkSound);
  268.     stringHdl := GetString(rString);
  269.  
  270.     gNotificationRecord.qType := nmType;
  271.     gNotificationRecord.nmMark := 1;
  272.     gNotificationRecord.nmIcon := iconSuiteHdl;
  273.     gNotificationRecord.nmSound := soundHdl;
  274.     gNotificationRecord.nmStr := stringHdl^;
  275.     gNotificationRecord.nmResp := nil;
  276.     gNotificationRecord.nmRefCon := 0;
  277.     end;
  278.         {of procedure DoPrepareNotificationRecord}
  279.  
  280. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoNullEvent }
  281.  
  282. procedure DoNullEvent;
  283.  
  284.     var
  285.     frontProcessSerNum : ProcessSerialNumber;
  286.     isSameProcess : boolean;
  287.     ignored : OSErr;
  288.  
  289.     begin
  290.     if (gNotificationDemoInvoked) then
  291.         begin
  292.         if (TickCount > (gStartingTickCount + 600)) then
  293.             begin
  294.             ignored := GetFrontProcess(frontProcessSerNum);
  295.             ignored := SameProcess(frontProcessSerNum, gProcessSerNum, isSameProcess);
  296.             if not (isSameProcess) then
  297.                 begin
  298.                 ignored := NMInstall(NMRecPtr(@gNotificationRecord));
  299.                 gNotificationDemoInvoked := false;
  300.                 gNotificationInQueue := true;
  301.                 end
  302.             else begin
  303.                 DoDisplayMessageToUser;
  304.                 gNotificationDemoInvoked := false;
  305.                 end;
  306.  
  307.             EraseRect(gWindowPtr^.portRect);
  308.             end;
  309.         end;
  310.     end;
  311.         {of procedure DoNullEvent}
  312.  
  313. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoOSEvent }
  314.  
  315. procedure DoOSEvent(theEvent : EventRecord);
  316.  
  317.     begin
  318.     case (BAnd(BSR(theEvent.message, 24), $000000FF)) of
  319.     
  320.         suspendResumeMessage: begin
  321.             gInBackground := BAnd(theEvent.message, resumeFlag) = 0;
  322.             if (not (gInBackground) and gNotificationInQueue) then
  323.                 DoDisplayMessageToUser;
  324.             end;
  325.  
  326.         mouseMovedMessage: begin
  327.             end;
  328.         end;
  329.             {of case statement}
  330.     end;
  331.         {of procedure DoOSEvent}
  332.  
  333. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDisplayMessageToUser }
  334.  
  335. procedure DoDisplayMessageToUser;
  336.  
  337.     var
  338.     ignored : OSErr;
  339.     
  340.     begin
  341.     if (gNotificationInQueue) then
  342.         begin
  343.         ignored := NMRemove(NMRecPtr(@gNotificationRecord));
  344.         gNotificationInQueue := false;
  345.         end;
  346.  
  347.     ignored := NoteAlert(rAlert, nil);
  348.  
  349.     ignored := DisposeIconSuite(gNotificationRecord.nmIcon, false);
  350.     ReleaseResource(gNotificationRecord.nmSound);
  351.     ReleaseResource(Handle(gNotificationRecord.nmStr));
  352.     end;
  353.         {of procedure DoDisplayMessageToUser}
  354.  
  355. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoColourPicker }
  356.  
  357. procedure DoColourPicker;
  358.  
  359.     var
  360.     inColour, outColour, blackColour : RGBColor;
  361.     theRect : Rect;
  362.     where : Point;
  363.     prompt : Str255;
  364.     okButton : boolean;
  365.     theString : string;
  366.  
  367.     begin
  368.     prompt := 'Choose a rectangle colour:';
  369.     EraseRect(gWindowPtr^.portRect);
  370.  
  371.     inColour.red := $FFFF;
  372.     inColour.green := $0000;
  373.     inColour.blue := $0000;
  374.  
  375.     blackColour.red := $0000;
  376.     blackColour.green := $0000;
  377.     blackColour.blue := $0000;
  378.  
  379.     theRect := gWindowPtr^.portRect;
  380.     InsetRect(theRect, 50, 50);
  381.     RGBForeColor(inColour);
  382.     FillRect(theRect, qd.black);
  383.  
  384.     where.v := 0;
  385.     where.h := 0;
  386.  
  387.     okButton := GetColor(where, prompt, inColour, outColour);
  388.  
  389.     if (okButton) then
  390.         begin
  391.         RGBForeColor(outColour);
  392.         FillRect(theRect, qd.black);
  393.         RGBForeColor(blackColour);
  394.  
  395.         MoveTo(50, 20);
  396.         DrawString('Red Value: ');
  397.         theString := DoDecimalToHexadecimal(outColour.red);
  398.         MoveTo(115, 20);
  399.         DrawString(theString);
  400.  
  401.         MoveTo(50, 33);
  402.         DrawString('Green Value: ');
  403.         theString := DoDecimalToHexadecimal(outColour.green);
  404.         MoveTo(115, 33);
  405.         DrawString(theString);
  406.  
  407.         MoveTo(50, 46);
  408.         DrawString('Blue Value: ');
  409.         theString := DoDecimalToHexadecimal(outColour.blue);
  410.         MoveTo(115, 46);
  411.         DrawString(theString);
  412.         end
  413.     else begin
  414.         RGBForeColor(inColour);
  415.         FillRect(theRect, qd.black);
  416.         RGBForeColor(blackColour);
  417.         MoveTo(75, 125);
  418.         DrawString('Cancel button was clicked.  Rectangle remains red.');
  419.         end;
  420.     end;
  421.         {of procedure DoColourPicker}
  422.  
  423. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDecimalToHexadecimal }
  424.  
  425. function  DoDecimalToHexadecimal(decimalNumber : UInt16) : string;
  426.  
  427.     var
  428.     theString : string;
  429.     hexCharas : string;
  430.     a : integer;
  431.  
  432.     begin
  433.     theString := 'OxXXXX';
  434.     hexCharas := '0123456789ABCDEF';
  435.  
  436.     for a := 0 to 3 do 
  437.         begin
  438.         theString[6 - a] := hexCharas[BAnd(decimalNumber, $F) + 1];
  439.         decimalNumber := BSR(decimalNumber, 4);
  440.         end;
  441.  
  442.     DoDecimalToHexadecimal := theString;
  443.     end;
  444.         {of function DoDecimalToHexadecimal}
  445.  
  446. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoCheckSlotVInstallAvailable }
  447.  
  448. function  DoCheckSlotVInstallAvailable : boolean;
  449.  
  450.     begin
  451.     DoCheckSlotVInstallAvailable := TrapAvailable(_SlotVInstall);
  452.     end;
  453.         {of function DoCheckSlotVInstallAvailable}
  454.  
  455. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ TrapAvailable }
  456.  
  457. function  TrapAvailable(theTrap : integer) : boolean;
  458.  
  459.     var
  460.     theTrapType : TrapType;
  461.     trapMask : integer;
  462.     numToolboxTraps : integer;
  463.  
  464.     begin
  465.     trapMask := $0800;
  466.     
  467.     if (BAnd(theTrap,  trapMask) > 0) then
  468.         theTrapType := ToolTrap
  469.     else
  470.         theTrapType := OSTrap;
  471.  
  472.     if (theTrapType = ToolTrap) then
  473.         theTrap := BAnd(theTrap, $07FF);
  474.  
  475.     if (NGetTrapAddress(_InitGraf, ToolTrap) = NGetTrapAddress($AA6E, ToolTrap)) then
  476.         numToolboxTraps := $0200
  477.     else
  478.         numToolboxTraps := $0400;
  479.  
  480.     if (theTrap >= numToolboxTraps) then
  481.         theTrap := _Unimplemented;
  482.  
  483.     TrapAvailable := 
  484.        NGetTrapAddress(theTrap, theTrapType) <> NGetTrapAddress(_Unimplemented, ToolTrap);
  485.     end;
  486.         {of function TrapAvailable}
  487.  
  488. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDeviceLoopDraw }
  489.  
  490. procedure DoDeviceLoopDraw(depth, deviceFlags : integer; targetDeviceHdl : GDHandle; 
  491.                                                             userData : longint);
  492.  
  493.     var
  494.     theWindowPtr : WindowPtr;
  495.     theRect : Rect;
  496.     oldForeColour : RGBColor;
  497.     green: RGBColor;
  498.     red : RGBColor;
  499.     blue : RGBColor;
  500.             
  501.     begin
  502.     green.red := $6666;
  503.     green.green := $FFFF;
  504.     green.blue := $6666;
  505.     red.red := $FFFF;
  506.     red.green := $6666;
  507.     red.blue := $6666;
  508.     blue.red := $9999;
  509.     blue.green := $9999;
  510.     blue.blue := $FFFF;
  511.         
  512.     theWindowPtr := WindowPtr(userData);
  513.     EraseRect(theWindowPtr^.portRect);
  514.     
  515.     case (depth) of
  516.  
  517.         1, 2: begin
  518.             SetRect(theRect, 70, 40, 320, 200);
  519.             FillRect(theRect, qd.ltGray);
  520.             InsetRect(theRect, 30, 30);
  521.             FillRect(theRect, qd.gray);
  522.             InsetRect(theRect, 30, 30);
  523.             FillRect(theRect, qd.dkGray);
  524.             end;
  525.             
  526.         4, 8, 16, 32: begin
  527.             GetForeColor(oldForeColour);
  528.             SetRect(theRect, 70, 40, 320, 200);
  529.             RGBForeColor(green);
  530.             PaintRect(theRect);
  531.             InsetRect(theRect, 30, 30);
  532.             RGBForeColor(red);
  533.             PaintRect(theRect);
  534.             InsetRect(theRect, 30, 30);
  535.             RGBForeColor(blue);
  536.             PaintRect(theRect);
  537.             RGBForeColor(oldForeColour);            
  538.             end;
  539.         end;
  540.             {of case statement}
  541.     end;
  542.         {of procedure DoDeviceLoopDraw}
  543.  
  544. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoZoomWindowMultiMonitors }
  545.  
  546. procedure DoZoomWindowMultiMonitors(theWindowPtr : WindowPtr; zoomInOrOut : longint);
  547.  
  548.     var
  549.     oldPort : GrafPtr;
  550.     windRect, intersectRect, zoomRect : Rect;
  551.     titleBarHeight : integer;
  552.     winStateDataPtr : WStateDataPtr;
  553.     deviceHdl, zoomDeviceHdl : GDHandle;
  554.     intersectArea, greatestArea : longint;
  555.     sectFlag : boolean;
  556.     
  557.     begin
  558.     GetPort(oldPort);
  559.     SetPort(theWindowPtr);
  560.  
  561.     EraseRect(theWindowPtr^.portRect);
  562.  
  563.     windRect := theWindowPtr^.portRect;
  564.     LocalToGlobal(windRect.topLeft);
  565.     LocalToGlobal(windRect.botRight);
  566.     titleBarHeight := windRect.top - WindowPeek(theWindowPtr)^.strucRgn^^.rgnBBox.top - 1;
  567.  
  568.     if (zoomInOrOut = inZoomOut) then
  569.         begin
  570.         if not (gColorQuickDraw) then
  571.             begin
  572.             zoomRect := qd.screenBits.bounds;
  573.             zoomRect.top := zoomRect.top + LMGetMBarHeight + titleBarHeight;
  574.             InsetRect(zoomRect, 3, 3);
  575.  
  576.             winStateDataPtr := WStateDataPtr(WindowPeek(theWindowPtr)^.dataHandle);
  577.             winStateDataPtr^.stdState := zoomRect;
  578.             end
  579.         else begin
  580.             windRect.top := windRect.top - titleBarHeight;
  581.  
  582.             deviceHdl := LMGetDeviceList;
  583.             greatestArea := 0;
  584.  
  585.             while (deviceHdl <> nil) do
  586.                 begin
  587.                 if (TestDeviceAttribute(deviceHdl, screenDevice)) then 
  588.                     if (TestDeviceAttribute(deviceHdl, screenActive)) then
  589.                         begin
  590.                         sectFlag := SectRect(windRect, deviceHdl^^.gdRect, intersectRect);
  591.  
  592.                         intersectArea := longint((intersectRect.right - intersectRect.left) * 
  593.                                                          (intersectRect.bottom - intersectRect.top));
  594.  
  595.                         if (intersectArea > greatestArea) then
  596.                             begin
  597.                             greatestArea := intersectArea;
  598.                             zoomDeviceHdl := deviceHdl;
  599.                             end;
  600.                         
  601.                         deviceHdl := GetNextDevice(deviceHdl);
  602.                         end;
  603.                 end;
  604.             
  605.             if (zoomDeviceHdl = LMGetMainDevice) then
  606.                 titleBarHeight := titleBarHeight + LMGetMBarHeight;
  607.             
  608.             SetRect(zoomRect, zoomDeviceHdl^^.gdRect.left + 3, 
  609.                                     zoomDeviceHdl^^.gdRect.top + titleBarHeight + 3, 
  610.                                     zoomDeviceHdl^^.gdRect.right - 3, 
  611.                                     zoomDeviceHdl^^.gdRect.bottom - 3);
  612.             
  613.             winStateDataPtr := WStateDataPtr(WindowPeek(theWindowPtr)^.dataHandle);
  614.             winStateDataPtr^.stdState := zoomRect;
  615.             end;
  616.         end;
  617.  
  618.     ZoomWindow(theWindowPtr, zoomInOrOut, theWindowPtr = FrontWindow);
  619.     DoRedoWindowContent(theWindowPtr);
  620.     SetPort(oldPort);
  621.     end;
  622.         {of procedure DoZoomWindowMultiMonitors}
  623.  
  624. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoRedoWindowContent }
  625.  
  626. procedure DoRedoWindowContent(theWindowPtr : WindowPtr);
  627.  
  628.     begin
  629.     { Do scroll bar and TextEdit, etc, adjustments here as appropriate. }
  630.  
  631.     InvalRect(theWindowPtr^.portRect);
  632.     end;
  633.         {of procedure DoRedoWindowContent}
  634.  
  635. end.
  636.     {of unit UDemos}
  637.     
  638. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
  639.