home *** CD-ROM | disk | FTP | other *** search
/ BUG 1 / BUGCD1996_0708.ISO / pc / util / clysbr / lines.pa_ / lines.pa
Text File  |  1995-02-28  |  5KB  |  205 lines

  1. Library Lines;
  2.  
  3. {define Debug}
  4.  
  5. {$ifndef Debug}
  6. {$R-,I-,D-,L-,S-,V-,W-,G+}
  7. {$endif}
  8.  
  9. {$C MOVEABLE PRELOAD DISCARDABLE}
  10. {$R LINES}
  11.  
  12. Uses
  13.   WinTypes,WinProcs,Strings,WinDOS;
  14.  
  15. {$I ADD-IN.INC}
  16. {$I ..\VER}
  17.  
  18. Const
  19.   LineThick : Integer = 2;
  20.   DiscMode : Boolean = True;
  21.  
  22.   CLBVer : VerString = AddInMasterVer;
  23.  
  24. Var
  25.   GTxInBtn : Boolean;
  26.  
  27. {$D Lines Add-In for Clysbar - clySmic Software}
  28.  
  29. {-----------------------------------------------}
  30.  
  31. { --- Perform Add-In's initialization --- }
  32.  
  33. Function AddInInit(CurVer : PChar; TxInBtn : Boolean) : InitResult; Export;
  34.  
  35. Begin
  36.   Randomize;
  37.  
  38.   { Version check }
  39.   If StrLComp(CurVer,CLBVer,3) <> 0
  40.     Then AddInInit := InitNotOk
  41.     Else AddInInit := InitOk;
  42.  
  43.   { Save text-in-button flag }
  44.   GTxInBtn := TxInBtn;
  45. End {AddInInit};
  46.  
  47. {-----------------------------------------------}
  48.  
  49. { --- Paint on the button (Clysbar does the background) --- }
  50.  
  51. Procedure AddInPaint(Wnd : HWnd; DC : HDC; Pressed : Boolean); Export;
  52.  
  53. Begin
  54. End {AddInPaint};
  55.  
  56. {-----------------------------------------------}
  57.  
  58. { --- Tell Clysbar what kind of timer we need --- }
  59.  
  60. Function AddInTimerNeeded : Integer; Export;
  61.  
  62. Begin
  63.   AddInTimerNeeded := ait_Fast;
  64. End {TimerNeeded};
  65.  
  66. {-----------------------------------------------}
  67.  
  68. { --- Proc called when timer expires, perform timed duties --- }
  69.  
  70. Procedure AddInTimerTick(Wnd : HWnd; DC : HDC); Export;
  71.  
  72. Const
  73.   xSav : Integer = 5;
  74.   ySav : Integer = 5;
  75.  
  76. Var
  77.   Rect : TRect;
  78.   OldPen,ThePen : HPen;
  79.  
  80. Begin
  81.   { If add-in is never uncovered, Wnd will be NULL }
  82.   If Wnd = 0
  83.     Then Exit;
  84.  
  85.   { Don't draw over button "edges" }
  86.   GetClientRect(Wnd,Rect);
  87.   If GTxInBtn
  88.     Then Rect.Right := Rect.Left + GetSystemMetrics(sm_cxIcon) + 18;
  89.   InflateRect(Rect,-6,-6);
  90.  
  91.   { Draw a random line in a random color }
  92.   ThePen := CreatePen(ps_Solid,LineThick,RGB(Random(256),Random(256),Random(256)));
  93.   OldPen := SelectObject(DC,ThePen);
  94.  
  95.   If DiscMode
  96.     Then Begin
  97.            { Disconnected lines }
  98.            MoveTo(Dc,Random(Rect.Right-2) + Rect.Left-2,
  99.                      Random(Rect.Bottom-2) + Rect.Top-2);
  100.            LineTo(Dc,Random(Rect.Right-2) + Rect.Left-2,
  101.                      Random(Rect.Bottom-2) + Rect.Top-2);
  102.          End
  103.     Else Begin
  104.            { Connected lines }
  105.            MoveTo(DC,xSav,ySav);
  106.            xSav := Random(Rect.Right-2) + Rect.Left-2;
  107.            ySav := Random(Rect.Bottom-2) + Rect.Top-2;
  108.            LineTo(DC,xSav,ySav);
  109.          End;
  110.  
  111.   { Clean up }
  112.   SelectObject(DC,OldPen);
  113.   DeleteObject(ThePen);
  114. End {AddInTimerTick};
  115.  
  116. {-----------------------------------------------}
  117.  
  118. { --- Proc called when button pressed --- }
  119.  
  120. Procedure AddInPressed(Wnd : HWnd; DC : HDC); Export;
  121.  
  122. Begin
  123.   LineThick := Random(4) + 1;    {1..4}
  124.  
  125.   DiscMode := Not DiscMode;
  126.  
  127.   AddInPaint(Wnd,DC,False);
  128. End {AddInPressed};
  129.  
  130. {-----------------------------------------------}
  131.  
  132. { --- Exit processing for Add-In --- }
  133.  
  134. Procedure AddInExit; Export;
  135.  
  136. Begin
  137. End {AddInExit};
  138.  
  139. {-----------------------------------------------}
  140.  
  141. { --- Clysbar queries Add-In about itself --- }
  142.  
  143. Procedure AddInAbout(Str1,Str2 : PChar;
  144.                      Var TheIcon : HIcon;
  145.                      Var TitleCol,TxCol,BkCol : TColorRef); Export;
  146.  
  147. Begin
  148.   StrCopy(Str1,'Lines V');
  149.   StrCat(Str1,MasterVer);
  150.   StrCopy(Str2,'A Random Line Drawer'#13'⌐ 1992 - 1995 by clySmic Software.'#13'All Rights Reserved.');
  151.  
  152.   TheIcon := LoadIcon(hInstance,'ABOUT');
  153.  
  154.   TitleCol := RGB(255,255,0);
  155.   TxCol := RGB(0,0,128);
  156.   BkCol := RGB(0,128,0);
  157. End {AddInAbout};
  158.  
  159. {-----------------------------------------------}
  160.  
  161. { --- Clysbar queries Add-In whether it'll accept d'n'd --- }
  162.  
  163. Function AddInAcceptDrops : Boolean; Export;
  164.  
  165. Begin
  166.   AddInAcceptDrops := False;
  167. End {AddInAcceptDrops};
  168.  
  169. {-----------------------------------------------}
  170.  
  171. { --- Clysbar informs Add-In of a d'n'd drop --- }
  172.  
  173. Procedure AddInDrop(hDrop : THandle); Export;
  174.  
  175. Begin
  176. End {AddInDrop};
  177.  
  178. {-----------------------------------------------}
  179.  
  180. { --- Clysbar queries Add-In for Info Window text --- }
  181.  
  182. { Return a zero-length string if you don't want to chg the text }
  183.  
  184. Procedure AddInGetInfoWinTx(Tx : PChar); Export;
  185.  
  186. Begin
  187.   StrCopy(Tx,'');
  188. End {AddInGetInfoWinTx};
  189.  
  190. {-----------------------------------------------}
  191.  
  192. Exports AddInInit         Index 1,
  193.         AddInPaint        Index 2,
  194.         AddInTimerNeeded  Index 3,
  195.         AddInTimerTick    Index 4,
  196.         AddInPressed      Index 5,
  197.         AddInExit         Index 6,
  198.         AddInAbout        Index 7,
  199.         AddInAcceptDrops  Index 8,
  200.         AddInDrop         Index 9,
  201.         AddInGetInfoWinTx Index 10;
  202.  
  203. Begin
  204. End.
  205.