File : test_tasking_graphics_window.adb


with Ada.Text_IO; use Ada.Text_IO;
with Graphics_Windows;
use Graphics_Windows;

procedure Test_Tasking_Graphics_Window is
   Display : Canvas_Type:=Canvas(400,250,"Test Concurrent Graphics");

   Finished : Boolean:=False;
   pragma Atomic(Finished);


   task type Rectangle (Pos : Integer);
   task body Rectangle is
   begin
      -- Outer rectangle

      Set_Fill(Display,False);
      Set_Pen(Display,Blue,4);
      Draw_Rectangle(Display,(Pos,20),50,150);
      -- Inner rectangle

      Set_Fill(Display,Red);
      Set_Pen(Display,Red,1);
      for I in 1..146 loop
         Draw_Rectangle(Display,(Pos+2,22),46,I);
         delay 0.1;
      end loop;
      Finished:=True;
   end Rectangle;

   Rect1 : Rectangle(80);
   Rect2 : Rectangle(200);

begin
   -- main update

   while not Finished loop
      Draw(Display);
      delay 0.5;
   end loop;
   Wait(Display);
   Close(Display);
   Put_Line("Test Completed");
end Test_Tasking_Graphics_Window;