moire.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Program Moire;
  2. {
  3. Will now open a default screen (can be any size) with
  4. the new look. The window get it's size depending on
  5. the screen size.
  6. 14 May 1998
  7. Translated to FPC from PCQ Pascal.
  8. 15 Aug 1998.
  9. Changed to use vartags and pas2c.
  10. 18 Jan 2000.
  11. Removed opening of graphics.library.
  12. 21 Mar 2001.
  13. Reworked to use systemvartags.
  14. 28 Nov 2002.
  15. [email protected]
  16. }
  17. uses Exec, Intuition, AGraphics, Utility;
  18. const
  19. pens : array [0..0] of Integer = ( not 0);
  20. var
  21. w : pWindow;
  22. s : pScreen;
  23. m : pMessage;
  24. Procedure DoDrawing(RP : pRastPort);
  25. var
  26. x : word;
  27. Pen : Byte;
  28. Stop : word;
  29. begin
  30. Pen := 1;
  31. while true do begin
  32. with w^ do begin
  33. x := 0;
  34. while x < Pred(Width - BorderRight - BorderLeft) do begin
  35. Stop := Pred(Width - BorderRight);
  36. SetAPen(RP, Pen);
  37. GfxMove(RP, Succ(x + BorderLeft), BorderTop);
  38. Draw(RP, Stop - x, Pred(Height - BorderBottom));
  39. Pen := (Pen + 1) mod 4;
  40. Inc(x);
  41. end;
  42. m := GetMsg(UserPort);
  43. if m <> Nil then
  44. Exit;
  45. x := 0;
  46. while x < Pred(Height - BorderBottom - BorderTop) do begin
  47. Stop := Pred(Height - BorderBottom);
  48. SetAPen(RP, Pen);
  49. GfxMove(RP, Pred(Width - BorderRight), Succ(x + BorderTop));
  50. Draw(RP, Succ(BorderLeft), Stop - x);
  51. Pen := (Pen + 1) mod 4;
  52. Inc(x);
  53. end;
  54. m := GetMsg(UserPort);
  55. if m <> Nil then
  56. Exit;
  57. end;
  58. end;
  59. end;
  60. begin
  61. { Note that the startup code of all FPC programs depends on
  62. Intuition, so if we got to this point Intuition must be
  63. open, so the run time library just uses the pointer that
  64. the startup code created. Same with DOS, although we don't
  65. use that here. }
  66. s := OpenScreenTags(NIL, [
  67. SA_Pens, AsTag(@pens),
  68. SA_Depth, 2,
  69. SA_DisplayID, HIRES_KEY,
  70. SA_Title, AsTag('Close the Window to End This Demonstration'),
  71. TAG_END]);
  72. if s <> NIL then begin
  73. w := OpenWindowTags(NIL, [
  74. WA_IDCMP, IDCMP_CLOSEWINDOW,
  75. WA_Left, 20,
  76. WA_Top, 50,
  77. WA_Width, 336,
  78. WA_Height, 100,
  79. WA_MinWidth, 50,
  80. WA_MinHeight, 20,
  81. WA_MaxWidth, -1,
  82. WA_MaxHeight, -1,
  83. WA_DepthGadget, ltrue,
  84. WA_DragBar, -1,
  85. WA_CloseGadget, -1,
  86. WA_SizeGadget, -1,
  87. WA_SmartRefresh, -1,
  88. WA_Activate, -1,
  89. WA_Title, AsTag('Feel Free to Re-Size the Window'),
  90. WA_CustomScreen, AsTag(s),
  91. TAG_END]);
  92. IF w <> NIL THEN begin
  93. DoDrawing(w^.RPort);
  94. Forbid;
  95. repeat
  96. m := GetMsg(w^.UserPort);
  97. until m = nil;
  98. CloseWindow(w);
  99. Permit;
  100. end else
  101. writeln('Could not open the window');
  102. CloseScreen(s);
  103. end else
  104. writeln('Could not open the screen.');
  105. end.