home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha 3.02 / source / Code ƒ / A-AboutWndo.p next >
Encoding:
Text File  |  1990-09-08  |  5.2 KB  |  177 lines  |  [TEXT/PJMM]

  1. unit AboutWndo;
  2.  
  3. interface
  4.  
  5.     procedure D_AboutWndo (rightOff, downOff: Integer);
  6.     procedure Init_LogoWindo;
  7.     procedure Close_LogoWindo;
  8.     procedure Open_LogoWindo (rightOff, downOff: Integer);
  9.     procedure Update_LogoWindo;
  10.  
  11. implementation
  12.  
  13.     const                        {These are the item numbers for controls in the Dialog    }
  14.         I_Okay = 1;                {They are all found in the .RSRC file                            }
  15.         I_Static_Text = 2;
  16.         I_Static_Text3 = 3;
  17.         I_Static_Text5 = 4;
  18.         I_Static_Text7 = 5;
  19.         I_Static_Text9 = 6;
  20.         I_Static_Text11 = 7;
  21.         I_Static_Text13 = 8;
  22.         I_Static_Text15 = 9;
  23.         I_Static_Text17 = 10;
  24.         I_Static_Text19 = 11;
  25.         I_Static_Text21 = 12;
  26.         I_Static_Text23 = 13;
  27.         I_Static_Text25 = 14;
  28.         I_Static_Text27 = 15;
  29.         I_Iconx29 = 16;
  30.     var
  31.         ExitDialog: boolean;            {Flag used to exit the Dialog    }
  32.         logoWindo: WindowPtr;        {Ptr to Soft Dorothy logo    }
  33.         tempRect: Rect;
  34.         Pic_Handle: PicHandle;
  35.  
  36. {===========================================================}
  37.  
  38.     function MyFilter (theDialog: DialogPtr; var theEvent: EventRecord; var itemHit: integer): boolean;
  39.         var
  40.             tempRect: Rect;
  41.             thePt: Point;
  42.     begin
  43.         MyFilter := FALSE;
  44.         if (theEvent.what = MouseDown) then    {Only do on a mouse click}
  45.             begin
  46.                 thePt := theEvent.where;            {Get the point where the mouse was clicked}
  47.                 with theDialog^.portBits.bounds do    {Do this way for speed}
  48.                     begin
  49.                         thePt.h := thePt.h + left;
  50.                         thePt.v := thePt.v + top;
  51.                     end;
  52.             end;
  53.     end;
  54.  
  55. {===========================================================}
  56.  
  57.     procedure D_AboutWndo;
  58.         var
  59.             GetSelection: DialogPtr;        {Name of dialog                }
  60.             tempRect: Rect;                {Temporary rectangle            }
  61.             DType: Integer;                {Type of dialog item            }
  62.             Index: Integer;                {For looping                    }
  63.             DItem: Handle;                {Handle to the dialog item        }
  64.             CItem, CTempItem: controlhandle;    {Control handle                }
  65.             sTemp: Str255;                {Get text entered, temp holding    }
  66.             itemHit: Integer;                {Get selection                    }
  67.             temp: Integer;                {Get selection, temp holding        }
  68.             TheDialogPtr: DialogPeek;        {Pointer to Dialogs definition record, contains the TE record}
  69.             ThisEditText: TEHandle;
  70.  
  71.         procedure Refresh_Dialog;        {Refresh the dialogs non-controls    }
  72.             var
  73.                 rTempRect: Rect;                {Temp rectangle used for drawing    }
  74.         begin
  75.             SetRect(tempRect, 172, 140, 252, 172);
  76.             PenSize(3, 3);
  77.             FrameRoundRect(tempRect, 17, 17);
  78.             PenSize(1, 1);
  79.         end;
  80.  
  81.     begin                                {Start of dialog handler        }
  82.         GetSelection := GetNewDialog(2, nil, Pointer(-1));    {Get dialog from rsrc    }
  83.         with GetSelection^.portBits do
  84.             begin
  85.                 rightOff := rightOff - bounds.left;
  86.                 downOff := downOff - bounds.top;
  87.             end;
  88.         MoveWindow(GetSelection, rightOff, downOff, FALSE);
  89.         ShowWindow(GetSelection);            {Open a dialog box    }
  90.         SelectWindow(GetSelection);        {Lets see it                }
  91.         SetPort(GetSelection);                {}
  92.         Refresh_Dialog;
  93.         ExitDialog := FALSE;                    {Do not exit dialog yet        }
  94.         repeat                            {Start of dialog handle loop    }
  95.             ModalDialog(nil, itemHit);    {Wait until an item is hit    }
  96.             GetDItem(GetSelection, itemHit, DType, DItem, tempRect); {Get info    }
  97.             CItem := Pointer(DItem);        {Get the control handle        }
  98.             if (ItemHit = I_Okay) then    {Handle Button being pressed    }
  99.                 begin
  100.                     ExitDialog := TRUE;            {Exit when this is made        }
  101.                     Refresh_Dialog;
  102.                 end;
  103.         until ExitDialog;                    {Do items til OKAY selected    }
  104.         DisposDialog(GetSelection);            {Flush dialog out of memory    }
  105.     end;
  106.  
  107. {=================================}
  108.  
  109.     procedure Init_LogoWindo;
  110.     begin
  111.         logoWindo := nil;
  112.     end;
  113.  
  114. {=================================}
  115.  
  116.     procedure Close_LogoWindo;
  117.     begin
  118.         if (logoWindo <> nil) then
  119.             begin
  120.                 DisposeWindow(logoWindo);
  121.                 logoWindo := nil;
  122.             end;
  123.     end;
  124.  
  125. {=================================}
  126.  
  127.     procedure UpDate_LogoWindo;
  128.         var
  129.             SavePort: WindowPtr;
  130.     begin
  131.         if (logoWindo <> nil) then
  132.             begin
  133.                 GetPort(SavePort);                {Keep track of current port        }
  134.                 SetPort(logoWindo);                {Set the port to logo window        }
  135.                 Pic_Handle := GetPicture(1999);        {Get PICT (ID=1999) from .RSRC fork}
  136.                 SetRect(tempRect, 0, 0, 321, 308);    {Set the size of the bounds of PICT}
  137.                 if (Pic_Handle <> nil) then        {If the PICT (ID=1999) exists then.}
  138.                     begin
  139.                         ClipRect(tempRect);
  140.                         HLock(Handle(Pic_Handle));
  141.                         tempRect.Right := tempRect.Left + (Pic_Handle^^.picFrame.Right - Pic_Handle^^.picFrame.Left);
  142.                         tempRect.Bottom := tempRect.Top + (Pic_Handle^^.picFrame.Bottom - Pic_Handle^^.picFrame.Top);
  143.                         HUnLock(Handle(Pic_Handle));
  144.                         DrawPicture(Pic_Handle, tempRect);    {Draw the PICT into current port    }
  145.                     end;
  146.                 SetRect(tempRect, 0, 0, 1023, 1023);    {Widen the clip area again}
  147.                 ClipRect(tempRect);
  148.                 ReleaseResource(Handle(Pic_Handle));    {Dump PICT from RAM                }
  149.                 SetPort(SavePort);                {Return port to old "current" port    }
  150.             end;
  151.     end;
  152.  
  153. {=================================}
  154.  
  155.     procedure Open_LogoWindo;
  156.     begin
  157.         if (logoWindo = nil) then
  158.             begin
  159.                 logoWindo := GetNewWindow(1999, nil, Pointer(-1));    {Get wind defs    }
  160.                 with logoWindo^.portBits do
  161.                     begin
  162.                         rightOff := rightOff - bounds.left;
  163.                         downOff := downOff - bounds.top;
  164.                     end;
  165.                 MoveWindow(logoWindo, rightOff, downOff, FALSE);
  166.                 SelectWindow(logoWindo);
  167.                 SetPort(logoWindo);
  168.                 ShowWindow(logoWindo);
  169.                 UpDate_LogoWindo;                {Get the logo faerie PICT    }
  170.             end
  171.         else
  172.             SelectWindow(logoWindo);
  173.     end;
  174.  
  175. {=================================}
  176.  
  177. end.                                    {End of unit}