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 / chap20pascal_demoPPC / WDEFPascalPPC / WDEFPascalPPC.p next >
Text File  |  1997-01-09  |  19KB  |  685 lines

  1. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  2. // WDEFPascalPPC.p                Custom Window Definition Function for Floating Windows
  3. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊
  4. //
  5. // This WDEF creates a utility window whose appearance conforms to that specified in the
  6. // document titled Apple Grayscale Appearance for System 7.5 and published by Apple 
  7. // Computer, Inc. On black-and-white displays, the WDEF is drawn in black-and-white with
  8. // an appearance similar to the black-and-white floating windows found in many commercial
  9. // applications. The WDEF supports only one variation code. It provides for a close box 
  10. // but not for a zoom box or window title.  
  11. //
  12. // The WDEF utilises three 'cicn' resources (nonpurgeable), one for the close box in the
  13. // normal state, one for the close box in the pressed state, and one to paint the 
  14. // checkered pattern in the title bar.
  15. //
  16. // ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }
  17.  
  18. unit WDEFPascal;
  19.  
  20. { ……………………………………………………………………………………………………………………………………………………………………… unit interface section }
  21.  
  22. interface
  23.  
  24. { ………………………………………………………………………………………………………………… include the following Universal Interfaces }
  25.  
  26. uses
  27.  
  28.     Types, Windows;
  29.  
  30. { ………………………………………………………………………………………………………………………………………………… define the following constants }
  31.  
  32. const
  33.  
  34. rCloseEnabledIcon = 128;
  35. rClosePressedIcon = 129;
  36. rCheckPatternIcon = 130;
  37.  
  38. { ………………………………………………………………………………………………………………………………………………………………… main procedure interface }
  39.  
  40. {$MAIN}
  41.     function main(varCode : integer; theWindowPeek : WindowPeek; message : integer;
  42.                 param : longint) : longint;
  43.  
  44.  
  45.  
  46. { ………………………………………………………………………………………………………………………………………………………… unit implementation section }
  47.  
  48. implementation
  49.  
  50. { ………………………………………………………………………………………………………………… include the following Universal Interfaces }
  51.  
  52. uses
  53.  
  54.     Windows, Fonts, Menus, Quickdraw, ToolUtils, OSUtils, Devices, LowMem, 
  55.     GestaltEqu;
  56.  
  57. { ………………………………………………………………………………………………………………………………………………………………………………… user-defined types }
  58.  
  59. type
  60.  
  61. Globals = record
  62.     gColourQuickDrawPresent : boolean;
  63.     gColourDisplay : boolean;
  64.     gBlackPattern : Pattern;
  65.     gCloseEnabledHdl : CIconHandle;
  66.     gClosePressedHdl : CIconHandle;
  67.     gCheckPatternHdl : CIconHandle;
  68.     gWhite : RGBColor;
  69.     gGray1 : RGBColor;    
  70.     gGray2 : RGBColor;    
  71.     gGray3 : RGBColor;
  72.     gGray4 : RGBColor;
  73.     gGray6 : RGBColor;
  74.     gGray7 : RGBColor;
  75.     gGray8 : RGBColor;
  76.     gGray10 : RGBColor;
  77.     gBlack : RGBColor;
  78.     gToggle : boolean;
  79.     end;
  80. GlobalsPointer = ^Globals;
  81. GlobalsHandle = ^GlobalsPointer;
  82.  
  83. { ……………………………………………………………………………………………………………………………………………procedure and function interfaces }
  84.  
  85.     procedure DoInitMessage(theWindowPeek : WindowPeek); forward;
  86.     procedure DoDrawMessage(theWindowPeek : WindowPeek; param : longint); forward;
  87.     function  DoHitMessage(theWindowPeek : WindowPeek; param : longint) : longint; forward;
  88.     procedure DoCalcRgnsMessage(theWindowPeek : WindowPeek); forward;
  89.     procedure DrawWindowColour(theWindowPeek : WindowPeek); forward;
  90.     procedure DrawWindowMono(theWindowPeek : WindowPeek); forward;
  91.     procedure ToggleGoAway(theWindowPeek : WindowPeek); forward;
  92.     procedure DrawGoAwayBox(theWindowPeek : WindowPeek); forward;
  93.     procedure DrawGoAwayBoxPressed(theWindowPeek : WindowPeek); forward;
  94.     procedure GetGoAwayRect(theWindowPeek : WindowPeek; var theRect : Rect); forward;
  95.     procedure GetContentRect(theWindowPeek : WindowPeek; var theRect : Rect); forward;
  96.     procedure GetStructRect(theWindowPeek : WindowPeek; var theRect : Rect); forward;
  97.     procedure SyncPorts; forward;
  98.  
  99. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ main }
  100.  
  101. function  main(varCode : integer; theWindowPeek : WindowPeek; message : integer;
  102.             param : longint) : longint;
  103.  
  104.     var
  105.     result : longint;
  106.     oldPort : GrafPtr;
  107.     oldPenState : PenState;
  108.     {$IFC GENERATING68k}                                                     { For PowerPC }
  109.     oldA4, ignored : longint;
  110.     {$ENDC}                                                                     { For PowerPC }
  111.     begin
  112.     {$IFC GENERATING68K }                                                    { For PowerPC }
  113.     oldA4 := SetCurrentA4;
  114.     {$ENDC}                                                                  { For PowerPC }
  115.     
  116.     GetPenState(oldPenState);
  117.     GetPort(oldPort);
  118.     
  119.     if (theWindowPeek^.dataHandle <> nil) then
  120.         if (GlobalsHandle(theWindowPeek^.dataHandle)^^.gColourQuickDrawPresent) then
  121.             SyncPorts;
  122.  
  123.     result := 0;
  124.  
  125.     case (message) of
  126.  
  127.         wNew: begin
  128.             DoInitMessage(theWindowPeek);
  129.             end;
  130.  
  131.         wDraw: begin
  132.             if (theWindowPeek^.visible) then
  133.                 DoDrawMessage(theWindowPeek, param);
  134.             end;
  135.  
  136.         wHit: begin
  137.             result := DoHitMessage(theWindowPeek, param);
  138.             end;
  139.  
  140.         wCalcRgns: begin
  141.             DoCalcRgnsMessage(theWindowPeek);
  142.             end;
  143.         end;
  144.             {of case statement}
  145.  
  146.     SetPenState(oldPenState);
  147.     SetPort(oldPort);
  148.     main := result;
  149.     
  150.     {$IFC GENERATING68K }                                                    { For PowerPC }
  151.     ignored := SetA4(oldA4);
  152.     {$ENDC}                                                                  { For PowerPC }
  153.     end;
  154.         {of function main}
  155.         
  156. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoInitMessage }
  157.  
  158. procedure DoInitMessage(theWindowPeek : WindowPeek);
  159.  
  160.     var
  161.     theErr : OSErr;
  162.     response : longint;
  163.     mainDeviceHdl : GDHandle;
  164.     bitsPerPixel, a : integer;
  165.     dataHdl : GlobalsHandle;
  166.  
  167.     begin
  168.     dataHdl := GlobalsHandle(NewHandleClear(sizeof(Globals)));
  169.     
  170.     if (dataHdl <> nil) then
  171.         begin
  172.         dataHdl^^.gWhite.red := $FFFF;
  173.         dataHdl^^.gWhite.blue := $FFFF;
  174.         dataHdl^^.gWhite.green := $FFFF;
  175.         dataHdl^^.gGray1.red := $EEEE;    
  176.         dataHdl^^.gGray1.blue := $EEEE;
  177.         dataHdl^^.gGray1.green := $EEEE;
  178.         dataHdl^^.gGray2.red := $DDDD;    
  179.         dataHdl^^.gGray2.blue := $DDDD;
  180.         dataHdl^^.gGray2.green := $DDDD;
  181.         dataHdl^^.gGray3.red := $CCCC;
  182.         dataHdl^^.gGray3.blue := $CCCC;
  183.         dataHdl^^.gGray3.green := $CCCC;
  184.         dataHdl^^.gGray4.red := $BBBB;
  185.         dataHdl^^.gGray4.blue := $BBBB;
  186.         dataHdl^^.gGray4.green := $BBBB;
  187.         dataHdl^^.gGray6.red := $9999;
  188.         dataHdl^^.gGray6.blue := $9999;
  189.         dataHdl^^.gGray6.green := $9999;
  190.         dataHdl^^.gGray7.red := $8888;
  191.         dataHdl^^.gGray7.blue := $8888;
  192.         dataHdl^^.gGray7.green := $8888;
  193.         dataHdl^^.gGray8.red := $7777;
  194.         dataHdl^^.gGray8.blue := $7777;
  195.         dataHdl^^.gGray8.green := $7777;
  196.         dataHdl^^.gGray10.red := $5555;
  197.         dataHdl^^.gGray10.blue := $5555;
  198.         dataHdl^^.gGray10.green := $5555;
  199.         dataHdl^^.gBlack.red := $0000;
  200.         dataHdl^^.gBlack.blue := $0000;
  201.         dataHdl^^.gBlack.green := $0000;
  202.     
  203.         dataHdl^^.gColourQuickDrawPresent := false;
  204.         dataHdl^^.gColourDisplay := false;
  205.         dataHdl^^.gCloseEnabledHdl := nil;
  206.         dataHdl^^.gClosePressedHdl := nil;
  207.         dataHdl^^.gCheckPatternHdl := nil;
  208.     
  209.         theErr := Gestalt(gestaltQuickdrawVersion, response);
  210.         if (response >= gestalt8BitQD) then
  211.             begin
  212.             dataHdl^^.gColourQuickDrawPresent := true;
  213.  
  214.             mainDeviceHdl := LMGetMainDevice;
  215.             bitsPerPixel := mainDeviceHdl^^.gdPMap^^.pixelSize;
  216.             if (bitsPerPixel > 1) then
  217.                 dataHdl^^.gColourDisplay := true;
  218.             end;
  219.  
  220.         for a := 0 to 7 do
  221.             dataHdl^^.gBlackPattern.pat[a] := -1;
  222.  
  223.         if (dataHdl^^.gColourQuickDrawPresent) then
  224.             begin
  225.             dataHdl^^.gCloseEnabledHdl := GetCIcon(rCloseEnabledIcon);
  226.             dataHdl^^.gClosePressedHdl := GetCIcon(rClosePressedIcon);
  227.             dataHdl^^.gCheckPatternHdl := GetCIcon(rCheckPatternIcon);
  228.             end;
  229.  
  230.         dataHdl^^.gToggle := false;
  231.     
  232.         theWindowPeek^.dataHandle := Handle(dataHdl);
  233.         end;
  234.     end;
  235.         {of procedure DoInitMessage}
  236.  
  237. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoDrawMessage }
  238.  
  239. procedure DoDrawMessage(theWindowPeek : WindowPeek; param : longint);
  240.  
  241.     var
  242.     tempLong : longint;
  243.     dataHdl : GlobalsHandle;
  244.     
  245.     begin
  246.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  247.     tempLong := BAnd(param, $0000FFFF);
  248.     param := tempLong;
  249.  
  250.     case (param) of
  251.     
  252.         wNoHit: begin
  253.             if (dataHdl^^.gColourQuickDrawPresent and dataHdl^^.gColourDisplay) then 
  254.                 DrawWindowColour(theWindowPeek)
  255.             else 
  256.                 DrawWindowMono(theWindowPeek);
  257.             end;
  258.  
  259.         wInGoAway: begin
  260.             ToggleGoAway(theWindowPeek);
  261.             end;
  262.  
  263.         otherwise begin
  264.             end;
  265.  
  266.         end;
  267.             {of case statement}
  268.     end;
  269.         {of procedure DoDrawMessage}
  270.     
  271. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoHitMessage }
  272.  
  273. function  DoHitMessage(theWindowPeek : WindowPeek; param : longint) : longint;
  274.  
  275.     var
  276.     where : Point;
  277.     goAwayRect : Rect;
  278.  
  279.     begin
  280.     where.v := HiWord(param);
  281.     where.h := LoWord(param);
  282.  
  283.     if (PtInRgn(where, theWindowPeek^.contRgn)) then
  284.         begin
  285.         DoHitMessage := wInContent;
  286.         Exit(DoHitMessage);
  287.         end
  288.     else if (PtInRgn(where, theWindowPeek^.strucRgn)) then
  289.         begin
  290.         if (theWindowPeek^.goAwayFlag) then
  291.             begin
  292.             GetGoAwayRect(theWindowPeek, goAwayRect);
  293.             if (PtInRect(where, goAwayRect)) then
  294.                 begin
  295.                 DoHitMessage := wInGoAway;
  296.                 Exit(DoHitMessage);
  297.                 end;
  298.             end;
  299.  
  300.         DoHitMessage := wInDrag;
  301.         Exit(DoHitMessage);
  302.         end;
  303.  
  304.     DoHitMessage := wNoHit;
  305.     end;
  306.         {of procedure DoHitMessage}
  307.  
  308. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DoCalcRgnsMessage }
  309.  
  310. procedure DoCalcRgnsMessage(theWindowPeek : WindowPeek);
  311.  
  312.     var
  313.     tempRgn : RgnHandle;
  314.     theRect : Rect;
  315.  
  316.     begin
  317.     tempRgn := NewRgn;
  318.  
  319.     GetContentRect(theWindowPeek, theRect);
  320.     RectRgn(theWindowPeek^.contRgn, theRect);
  321.  
  322.     GetStructRect(theWindowPeek, theRect);
  323.     RectRgn(theWindowPeek^.strucRgn, theRect);
  324.     OffsetRect(theRect, 1, 1);
  325.     theRect.left := theRect.left + 1;
  326.     theRect.top := theRect.top + 1;
  327.     RectRgn(tempRgn, theRect);
  328.     UnionRgn(tempRgn, theWindowPeek^.strucRgn, theWindowPeek^.strucRgn);
  329.  
  330.     DisposeRgn(tempRgn);
  331.     end;
  332.         {of procedure DoCalcRgnsMessage}
  333.  
  334. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DrawWindowColour }
  335.  
  336. procedure DrawWindowColour(theWindowPeek : WindowPeek);
  337.  
  338.     var
  339.     oldForeColour : RGBColor;
  340.     oldBackColour : RGBColor;
  341.     contentRect, structRect, theRect : Rect;
  342.     a, b : integer;
  343.     dataHdl : GlobalsHandle;
  344.     
  345.     begin
  346.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  347.     
  348.     GetForeColor(oldForeColour);
  349.     GetBackColor(oldBackColour);
  350.     PenSize(1, 1);
  351.     PenPat(dataHdl^^.gBlackPattern);
  352.     PenMode(patCopy);
  353.     
  354.     if (theWindowPeek^.hilited) then
  355.         begin
  356.         GetContentRect(theWindowPeek, contentRect);
  357.  
  358.         RGBForeColor(dataHdl^^.gBlack);
  359.         InsetRect(contentRect, -1, -1);
  360.         FrameRect(contentRect);
  361.  
  362.         GetStructRect(theWindowPeek, structRect);
  363.         
  364.         RGBForeColor(dataHdl^^.gGray3);
  365.         SetRect(theRect, structRect.left + 2, structRect.top + 2, structRect.right - 2, 
  366.                         structRect.top + 12);
  367.         PaintRect(theRect);
  368.         
  369.         SetRect(theRect, structRect.left + 14, structRect.top + 3, structRect.left + 22, 
  370.                     structRect.top + 11);
  371.         b := (((structRect.right - 4) - (structRect.left + 14)) div 9) + 1;
  372.         a := 0;
  373.         while a < b + 1 do
  374.             begin
  375.             PlotCIcon(theRect, dataHdl^^.gCheckPatternHdl);
  376.             OffsetRect(theRect, 9, 0);
  377.             a := a + 1;
  378.             end;
  379.         
  380.         if (theWindowPeek^.goAwayFlag) then
  381.             DrawGoAwayBox(theWindowPeek);
  382.         
  383.         RGBForeColor(dataHdl^^.gBlack);
  384.         FrameRect(structRect);
  385.         MoveTo(structRect.left + 2, structRect.bottom);
  386.         LineTo(structRect.right, structRect.bottom);
  387.         LineTo(structRect.right, structRect.top + 2);
  388.         
  389.         RGBForeColor(dataHdl^^.gWhite);
  390.         MoveTo(structRect.left + 1, structRect.bottom - 3);
  391.         LineTo(structRect.left + 1, structRect.top + 1);
  392.         LineTo(structRect.right - 3, structRect.top + 1);
  393.         MoveTo(structRect.left + 3, structRect.top + 11);
  394.         LineTo(structRect.left + 11, structRect.top + 11);
  395.         LineTo(structRect.left + 11, structRect.top + 3);
  396.         
  397.         RGBForeColor(dataHdl^^.gGray1);
  398.         MoveTo(structRect.left + 2, structRect.bottom - 3);
  399.         LineTo(structRect.right - 3, structRect.bottom - 3);
  400.         LineTo(structRect.right - 3, structRect.top + 13);
  401.         
  402.         RGBForeColor(dataHdl^^.gGray3);
  403.         MoveTo(structRect.right - 2, structRect.top + 1);
  404.         LineTo(structRect.right - 2, structRect.top + 1);
  405.         RGBForeColor(dataHdl^^.gGray4);
  406.         MoveTo(structRect.left + 1, structRect.bottom - 2);
  407.         LineTo(structRect.left + 1, structRect.bottom - 2);
  408.     
  409.         RGBForeColor(dataHdl^^.gGray6);
  410.         MoveTo(structRect.left + 2, structRect.bottom - 2);
  411.         LineTo(structRect.right - 2, structRect.bottom - 2);
  412.         LineTo(structRect.right - 2, structRect.top + 2);
  413.         MoveTo(structRect.right - 3, structRect.top + 12);
  414.         LineTo(structRect.left + 2, structRect.top + 12);
  415.         LineTo(structRect.left + 2, structRect.bottom - 4);
  416.     
  417.         RGBForeColor(dataHdl^^.gGray7);
  418.         MoveTo(structRect.left + 2, structRect.top + 10);
  419.         LineTo(structRect.left + 2, structRect.top + 2);
  420.         LineTo(structRect.left + 10, structRect.top + 2);
  421.         end    
  422.     else begin
  423.         RGBForeColor(dataHdl^^.gGray10);
  424.         GetContentRect(theWindowPeek, contentRect);
  425.         InsetRect(contentRect, -1, -1);
  426.         FrameRect(contentRect);
  427.  
  428.         GetStructRect(theWindowPeek, structRect);
  429.         FrameRect(structRect);
  430.         MoveTo(structRect.left + 2, structRect.bottom);
  431.         LineTo(structRect.right, structRect.bottom);
  432.         LineTo(structRect.right, structRect.top + 2);
  433.  
  434.         RGBForeColor(dataHdl^^.gGray2);
  435.         InsetRect(structRect, 1, 1);
  436.         PenSize(2, 2);
  437.         FrameRect(structRect);
  438.         structRect.bottom := structRect.top + 12;
  439.         PaintRect(structRect);
  440.         end;
  441.  
  442.     RGBForeColor(oldForeColour);
  443.     RGBBackColor(oldBackColour);
  444.     end;
  445.         {of procedure DrawWindowColour}
  446.  
  447. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DrawWindowMono }
  448.  
  449. procedure DrawWindowMono(theWindowPeek : WindowPeek);
  450.  
  451.     var
  452.     contentRect, structRect, theRect : Rect;
  453.     a, b : integer;
  454.     pattern : UInt8;
  455.     checkPattern : Pattern;
  456.     dataHdl : GlobalsHandle;
  457.     
  458.     begin
  459.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  460.  
  461.     PenSize(1, 1);
  462.     PenPat(dataHdl^^.gBlackPattern);
  463.     PenMode(patCopy);
  464.     
  465.     if (theWindowPeek^.goAwayFlag and theWindowPeek^.hilited) then
  466.         begin
  467.         ForeColor(blackColor);
  468.         BackColor(whiteColor);
  469.  
  470.         GetContentRect(theWindowPeek, contentRect);
  471.  
  472.         InsetRect(contentRect, -1, -1);
  473.         FrameRect(contentRect);
  474.  
  475.         GetStructRect(theWindowPeek, structRect);
  476.  
  477.         FrameRect(structRect);
  478.         MoveTo(structRect.left + 2, structRect.bottom);
  479.         LineTo(structRect.right, structRect.bottom);
  480.         LineTo(structRect.right, structRect.top + 2);
  481.  
  482.         SetRect(theRect, structRect.left + 1, structRect.top + 1, structRect.right - 1, 
  483.                         structRect.top + 10);
  484.         EraseRect(theRect);
  485.  
  486.         for a := 0 to 7 do
  487.             checkPattern.pat[a] := $00;
  488.  
  489.         if (BAnd(structRect.left, 1) <> 0) then
  490.             pattern := $AA
  491.         else
  492.             pattern := $55;
  493.  
  494.         if (BAnd(structRect.top, 1) <> 0) then 
  495.             b := 1
  496.         else 
  497.             b := 0;
  498.             
  499.         a := b;
  500.         
  501.         while(a < 8) do
  502.             begin
  503.             checkPattern.pat[a] := pattern;
  504.             a := a + 2;
  505.             end;
  506.  
  507.         PenPat(checkPattern);
  508.         SetRect(theRect, structRect.left + 11, structRect.top + 2, structRect.right - 2, 
  509.                         structRect.top + 9);
  510.         PaintRect(theRect);
  511.  
  512.         PenPat(dataHdl^^.gBlackPattern);
  513.         
  514.         if (theWindowPeek^.goAwayFlag) then
  515.             DrawGoAwayBox(theWindowPeek);
  516.         end    
  517.     else begin
  518.         SetRect(theRect, structRect.left + 1, structRect.top + 1, structRect.right - 1, 
  519.                         structRect.top + 13);
  520.         EraseRect(theRect);
  521.         end;
  522.     end;
  523.         {of procedure DrawWindowMono}
  524.  
  525. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ ToggleGoAway }
  526.  
  527. procedure ToggleGoAway(theWindowPeek : WindowPeek);
  528.  
  529.     var
  530.     dataHdl : GlobalsHandle;
  531.     
  532.     begin
  533.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  534.  
  535.     dataHdl^^.gToggle := not (dataHdl^^.gToggle);
  536.  
  537.     if (dataHdl^^.gToggle) then
  538.         DrawGoAwayBoxPressed(theWindowPeek)
  539.     else
  540.         DrawGoAwayBox(theWindowPeek);
  541.     end;
  542.         {of procedure ToggleGoAway}
  543.  
  544. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DrawGoAwayBox }
  545.  
  546. procedure DrawGoAwayBox(theWindowPeek : WindowPeek);
  547.  
  548.     var
  549.     theRect : Rect;
  550.     dataHdl : GlobalsHandle;
  551.     
  552.     begin
  553.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  554.  
  555.     GetGoAwayRect(theWindowPeek, theRect);
  556.  
  557.     if (dataHdl^^.gColourQuickDrawPresent and dataHdl^^.gColourDisplay) then
  558.         PlotCIcon(theRect, dataHdl^^.gCloseEnabledHdl)
  559.     else begin
  560.         EraseRect(theRect);
  561.         PenSize(1, 1);
  562.         FrameRect(theRect);
  563.         end;
  564.     end;
  565.         {of procedure DrawGoAwayBox}
  566.  
  567. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ DrawGoAwayBoxPressed }
  568.  
  569. procedure DrawGoAwayBoxPressed(theWindowPeek : WindowPeek);
  570.  
  571.     var
  572.     theRect : Rect;
  573.     dataHdl : GlobalsHandle;
  574.     
  575.     begin
  576.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  577.  
  578.     GetGoAwayRect(theWindowPeek, theRect);
  579.  
  580.     if (dataHdl^^.gColourQuickDrawPresent and dataHdl^^.gColourDisplay) then
  581.         PlotCIcon(theRect, dataHdl^^.gClosePressedHdl)
  582.     else begin
  583.         PenSize(2, 2);
  584.         FrameRect(theRect);
  585.         end;
  586.     end;
  587.         {of procedure DrawGoAwayBox}
  588.         
  589. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ GetGoAwayRect }
  590.  
  591. procedure GetGoAwayRect(theWindowPeek : WindowPeek; var theRect : Rect);
  592.  
  593.     var
  594.     dataHdl : GlobalsHandle;
  595.     
  596.     begin
  597.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  598.  
  599.     GetStructRect(theWindowPeek, theRect);
  600.  
  601.     if (dataHdl^^.gColourQuickDrawPresent and dataHdl^^.gColourDisplay) then
  602.         begin
  603.         theRect.top := theRect.top + 3;
  604.         theRect.left := theRect.left + 3;
  605.         theRect.bottom := theRect.top + 8;
  606.         theRect.right := theRect.left + 8;
  607.         end
  608.     else begin
  609.         theRect.top := theRect.top + 2;
  610.         theRect.left := theRect.left + 2;
  611.         theRect.bottom := theRect.top + 7;
  612.         theRect.right := theRect.left + 7;
  613.         end;
  614.     end;
  615.         {of procedure GetGoAwayRect}
  616.  
  617. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ GetContentRect }        
  618.  
  619. procedure GetContentRect(theWindowPeek : WindowPeek; var theRect : Rect);
  620.  
  621.     var
  622.     oldPort : GrafPtr;
  623.     
  624.     begin
  625.     theRect := theWindowPeek^.port.portRect;
  626.  
  627.     GetPort(oldPort);
  628.     SetPort(GrafPtr(theWindowPeek));
  629.  
  630.     LocalToGlobal(theRect.topLeft);
  631.     LocalToGlobal(theRect.botRight);
  632.  
  633.     SetPort(oldPort);
  634.     end;
  635.         {of procedure GetContentRect}
  636.  
  637. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ GetStructRect }
  638.  
  639. procedure GetStructRect(theWindowPeek : WindowPeek; var theRect : Rect);
  640.  
  641.     var
  642.     dataHdl : GlobalsHandle;
  643.     
  644.     begin
  645.     dataHdl := GlobalsHandle(theWindowPeek^.dataHandle);
  646.  
  647.     GetContentRect(theWindowPeek, theRect);
  648.  
  649.     if (dataHdl^^.gColourQuickDrawPresent and dataHdl^^.gColourDisplay) then
  650.         begin
  651.         InsetRect(theRect, -4, -4);
  652.         theRect.top := theRect.top - 10;
  653.         end
  654.     else begin
  655.         theRect.top := theRect.top - 10;
  656.         InsetRect(theRect, -1, -1);
  657.         end;
  658.     end;
  659.         {of procedure GetStructRect}
  660.         
  661. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ SyncPorts }
  662.  
  663. procedure SyncPorts;
  664.  
  665.     var
  666.     bwPort : GrafPtr;
  667.     colourPort : CGrafPtr;
  668.  
  669.     begin
  670.     GetWMgrPort(bwPort);
  671.     GetCWMgrPort(colourPort);
  672.     SetPort(GrafPtr(colourPort));
  673.  
  674.     BlockMoveData(@bwPort^.pnLoc, @colourPort^.pnLoc, 10);
  675.     BlockMoveData(@bwPort^.pnVis, @colourPort^.pnVis, 14);
  676.  
  677.     PenPat(bwPort^.pnPat);
  678.     BackPat(bwPort^.bkPat);
  679.     end;
  680.         {of procedure SyncPorts}
  681.  
  682. end.
  683.     {of unit WDEFPascal}
  684.     
  685. { ◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊◊ }