moire.pas 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. [email protected]
  10. }
  11. uses Exec, Intuition, Graphics, Utility;
  12. {$I tagutils.inc}
  13. const
  14. pens : array [0..0] of Integer = ( not 0);
  15. ltrue = 1;
  16. var
  17. w : pWindow;
  18. s : pScreen;
  19. m : pMessage;
  20. thetags : array[0..17] of tTagItem;
  21. Procedure DoDrawing(RP : pRastPort);
  22. var
  23. x : word;
  24. Pen : Byte;
  25. Stop : word;
  26. begin
  27. Pen := 1;
  28. while true do begin
  29. with w^ do begin
  30. x := 0;
  31. while x < Pred(Width - BorderRight - BorderLeft) do begin
  32. Stop := Pred(Width - BorderRight);
  33. SetAPen(RP, Pen);
  34. Move(RP, Succ(x + BorderLeft), BorderTop);
  35. Draw(RP, Stop - x, Pred(Height - BorderBottom));
  36. Pen := (Pen + 1) mod 4;
  37. Inc(x);
  38. end;
  39. m := GetMsg(UserPort);
  40. if m <> Nil then
  41. Exit;
  42. x := 0;
  43. while x < Pred(Height - BorderBottom - BorderTop) do begin
  44. Stop := Pred(Height - BorderBottom);
  45. SetAPen(RP, Pen);
  46. Move(RP, Pred(Width - BorderRight), Succ(x + BorderTop));
  47. Draw(RP, Succ(BorderLeft), Stop - x);
  48. Pen := (Pen + 1) mod 4;
  49. Inc(x);
  50. end;
  51. m := GetMsg(UserPort);
  52. if m <> Nil then
  53. Exit;
  54. end;
  55. end;
  56. end;
  57. begin
  58. { Note that the startup code of all FPC programs depends on
  59. Intuition, so if we got to this point Intuition must be
  60. open, so the run time library just uses the pointer that
  61. the startup code created. Same with DOS, although we don't
  62. use that here. }
  63. GfxBase := OpenLibrary(GRAPHICSNAME,0);
  64. if GfxBase <> nil then begin
  65. thetags[0] := TagItem(SA_Pens, longint(@pens));
  66. thetags[1] := TagItem(SA_Depth, 2);
  67. thetags[2] := TagItem(SA_DisplayID, HIRES_KEY);
  68. thetags[3] := TagItem(SA_Title, Long(PChar('Close the Window to End This Demonstration'#0)));
  69. thetags[4].ti_Tag := TAG_END;
  70. s := OpenScreenTagList(NIL, @thetags);
  71. if s <> NIL then begin
  72. thetags[0] := TagItem(WA_IDCMP, IDCMP_CLOSEWINDOW);
  73. thetags[1] := TagItem(WA_Left, 20);
  74. thetags[2] := TagItem(WA_Top, 50);
  75. thetags[3] := TagItem(WA_Width, 336);
  76. thetags[4] := TagItem(WA_Height, 100);
  77. thetags[5] := TagItem(WA_MinWidth, 50);
  78. thetags[6] := TagItem(WA_MinHeight, 20);
  79. thetags[7] := TagItem(WA_MaxWidth, -1);
  80. thetags[8] := TagItem(WA_MaxHeight, -1);
  81. thetags[9] := TagItem(WA_DepthGadget, ltrue);
  82. thetags[10] := TagItem(WA_DragBar, -1);
  83. thetags[11] := TagItem(WA_CloseGadget, -1);
  84. thetags[12] := TagItem(WA_SizeGadget, -1);
  85. thetags[13] := TagItem(WA_SmartRefresh, -1);
  86. thetags[14] := TagItem(WA_Activate, -1);
  87. thetags[15] := TagItem(WA_Title, Long(PChar('Feel Free to Re-Size the Window'#0)));
  88. thetags[16] := TagItem(WA_CustomScreen, Long(s));
  89. thetags[17].ti_Tag := TAG_END;
  90. w := OpenWindowTagList(NIL, @thetags);
  91. IF w <> NIL THEN begin
  92. DoDrawing(w^.RPort);
  93. Forbid;
  94. repeat
  95. m := GetMsg(w^.UserPort);
  96. until m = nil;
  97. CloseWindow(w);
  98. Permit;
  99. end else
  100. writeln('Could not open the window');
  101. CloseScreen(s);
  102. end else
  103. writeln('Could not open the screen.');
  104. CloseLibrary(GfxBase);
  105. end else writeln('no graphics.library');
  106. end.